XenevaOS
Loading...
Searching...
No Matches
io.h
Go to the documentation of this file.
1#ifndef __LINUX_IO_H__
2#define __LINUX_IO_H__
3
4/*
5 * DCL <linux/io.h> -- physical memory windowing for /dev/mem.
6 *
7 * Xeneva keeps a linear physical->virtual map (P2V), so xlate_dev_mem_ptr()
8 * is a plain P2V and unxlate is a no-op: there is no ioremap-style temporary
9 * window to tear down. Bodies in DCL/linux_mm_shim.c.
10 *
11 * arch_has_dev_port() is read unguarded by mem.c's chr_dev_init even when
12 * CONFIG_DEVPORT is off (it decides whether /dev/port is created at all);
13 * ARM64 boards have no x86 I/O port space, so it answers no.
14 */
15
16#include <linux/kernel.h> /* phys_addr_t */
17
18/*
19 * ioremap()/iounmap() live here rather than in <asm/io.h> because on ARM64
20 * there is no window to carve: the linear physical->virtual map (P2V) already
21 * covers RAM and the device ranges Xeneva maps, so ioremap is a P2V and
22 * iounmap is a no-op -- there is no temporary mapping to tear down. Mainline
23 * gets the same result from these calls on a system with a linear map, so the
24 * 8250 and PCI code can use them unchanged. Bodies in DCL/linux_irq_shim.c.
25 */
26void* ioremap(unsigned long phys_addr, unsigned long size);
27void iounmap(void* addr);
28#define ioremap_nocache(phys, size) ioremap((phys), (size))
29#define ioremap_wc(phys, size) ioremap((phys), (size))
30#define ioremap_cache(phys, size) ioremap((phys), (size))
31
35
36/*
37 * Mainline's <linux/io.h> includes <asm/io.h> so that inb/outb and friends
38 * arrive with it; DCL does the same so a ported file that includes only
39 * <linux/io.h> still sees the accessors.
40 */
41#include <asm/io.h>
42
43
44/*
45 * ioread32be()/iowrite32be() -- 32-bit big-endian MMIO.
46 *
47 * Only mem32be_serial_in/out() use them (8250_port.c:386-396), the register
48 * access mode for SoCs whose UART register block sits on a big-endian bus.
49 * On this little-endian aarch64 target a big-endian device word is a byte
50 * swap of the natural load, which is exactly what mainline's
51 * be32_to_cpu/cpu_to_be32 pair reduces to -- so the swap is spelled out with
52 * __builtin_bswap32 rather than pulling in <linux/byteorder> for two calls.
53 *
54 * Worth knowing: the *absence* of the swap would still compile and would
55 * still produce a UART that never answers, because every 8250 register read
56 * would come back byte-reversed. That failure mode -- transmits, never
57 * receives -- is the same one the comment at the top of <linux/termios.h>
58 * warns about for flag tables.
59 */
60static inline u32 ioread32be(const volatile void* addr)
61{
62 return (u32)__builtin_bswap32(readl(addr));
63}
64
65static inline void iowrite32be(u32 v, volatile void* addr)
66{
67 writel(__builtin_bswap32(v), addr);
68}
69
70/*
71 * memcpy_fromio() / memcpy_toio() -- copies across the I/O-memory wall.
72 *
73 * mainline defines these as extern functions in <asm-generic/io.h>, backed
74 * by lib/iomap.c's byte loop or an arch override, and <linux/iosys-map.h>
75 * calls them from iosys_map_memcpy_to/_from and its 64-bit _rd_io/_wr_io
76 * arms -- so a vendored file can reach them through iosys-map.h alone. On
77 * this target there is no separate I/O mapping to be careful about: ioremap()
78 * above is the linear P2V map and an MMIO pointer is an ordinary pointer, so
79 * the correct body is a plain memcpy and the inlines *are* the definition
80 * rather than declarations waiting on a lib/iomap.c DCL does not vendor.
81 *
82 * Call sites: drm_cache.c:220/:232/:239 (drm_memcpy_from_wc) and
83 * drm_format_helper.c:216 (drm_fb_memcpy/swab destinations).
84 *
85 * The __iomem spelling is mainline's; it is empty on this target
86 * (<linux/compiler.h>), and the volatile qualifier on the pair is what keeps
87 * a caller from handing the source where the destination belongs -- dropping
88 * it would compile the two swapped in either direction.
89 */
90static inline void memcpy_fromio(void* dst, const volatile void __iomem* src,
91 size_t count)
92{
93 memcpy(dst, (const void*)src, count);
94}
95
96static inline void memcpy_toio(volatile void __iomem* dst, const void* src,
97 size_t count)
98{
99 memcpy((void*)dst, src, count);
100}
101#endif /* __LINUX_IO_H__ */
#define __iomem
Definition aclinux.h:312
size_t size
Definition drm_bridge.h:1299
void memcpy(void)
int arch_has_dev_port(void)
void iounmap(void *addr)
void unxlate_dev_mem_ptr(phys_addr_t phys, void *addr)
void * xlate_dev_mem_ptr(phys_addr_t phys)
void * ioremap(unsigned long phys_addr, unsigned long size)
uintptr_t phys_addr_t
Definition kernel.h:40
#define writel(v, addr)
Definition kernel.h:357
#define readl(addr)
Definition kernel.h:354
uint32_t u32
Definition kernel.h:16
char phys[]