Spaces:
Runtime error
Runtime error
| /* | |
| * asm-generic/io.h | |
| * adapted from the Linux kernel's include/asm-generic/io.h | |
| * and arch/arm/include/asm/io.h | |
| * | |
| * Copyright (C) 2017, Red Hat Inc, Andrew Jones <drjones@redhat.com> | |
| * | |
| * This work is licensed under the terms of the GNU GPL, version 2. | |
| */ | |
| static inline u8 __raw_readb(const volatile void *addr) | |
| { | |
| return *(const volatile u8 *)addr; | |
| } | |
| static inline u16 __raw_readw(const volatile void *addr) | |
| { | |
| return *(const volatile u16 *)addr; | |
| } | |
| static inline u32 __raw_readl(const volatile void *addr) | |
| { | |
| return *(const volatile u32 *)addr; | |
| } | |
| static inline u64 __raw_readq(const volatile void *addr) | |
| { | |
| assert(sizeof(unsigned long) == sizeof(u64)); | |
| return *(const volatile u64 *)addr; | |
| } | |
| static inline void __raw_writeb(u8 b, volatile void *addr) | |
| { | |
| *(volatile u8 *)addr = b; | |
| } | |
| static inline void __raw_writew(u16 b, volatile void *addr) | |
| { | |
| *(volatile u16 *)addr = b; | |
| } | |
| static inline void __raw_writel(u32 b, volatile void *addr) | |
| { | |
| *(volatile u32 *)addr = b; | |
| } | |
| static inline void __raw_writeq(u64 b, volatile void *addr) | |
| { | |
| assert(sizeof(unsigned long) == sizeof(u64)); | |
| *(volatile u64 *)addr = b; | |
| } | |
| static inline u16 __bswap16(u16 x) | |
| { | |
| return ((x >> 8) & 0xff) | ((x & 0xff) << 8); | |
| } | |
| static inline u32 __bswap32(u32 x) | |
| { | |
| return ((x & 0xff000000) >> 24) | ((x & 0x00ff0000) >> 8) | | |
| ((x & 0x0000ff00) << 8) | ((x & 0x000000ff) << 24); | |
| } | |
| static inline u64 __bswap64(u64 x) | |
| { | |
| return ((x & 0x00000000000000ffULL) << 56) | | |
| ((x & 0x000000000000ff00ULL) << 40) | | |
| ((x & 0x0000000000ff0000ULL) << 24) | | |
| ((x & 0x00000000ff000000ULL) << 8) | | |
| ((x & 0x000000ff00000000ULL) >> 8) | | |
| ((x & 0x0000ff0000000000ULL) >> 24) | | |
| ((x & 0x00ff000000000000ULL) >> 40) | | |
| ((x & 0xff00000000000000ULL) >> 56); | |
| } | |
| static inline uint8_t inb(unsigned long port) | |
| { | |
| return readb((const volatile void __iomem *)port); | |
| } | |
| static inline uint16_t inw(unsigned long port) | |
| { | |
| return readw((const volatile void __iomem *)port); | |
| } | |
| static inline uint32_t inl(unsigned long port) | |
| { | |
| return readl((const volatile void __iomem *)port); | |
| } | |
| static inline void outb(uint8_t value, unsigned long port) | |
| { | |
| writeb(value, (volatile void __iomem *)port); | |
| } | |
| static inline void outw(uint16_t value, unsigned long port) | |
| { | |
| writew(value, (volatile void __iomem *)port); | |
| } | |
| static inline void outl(uint32_t value, unsigned long port) | |
| { | |
| writel(value, (volatile void __iomem *)port); | |
| } | |
| static inline void __iomem *ioremap(phys_addr_t phys_addr, size_t size __unused) | |
| { | |
| assert(sizeof(long) == 8 || !(phys_addr >> 32)); | |
| return (void __iomem *)(unsigned long)phys_addr; | |
| } | |
| static inline unsigned long virt_to_phys(volatile void *address) | |
| { | |
| return __pa((unsigned long)address); | |
| } | |
| static inline void *phys_to_virt(unsigned long address) | |
| { | |
| return __va(address); | |
| } | |