XenevaOS
Loading...
Searching...
No Matches
io.h
Go to the documentation of this file.
1#ifndef __ASM_IO_H__
2#define __ASM_IO_H__
3
4/*
5 * DCL <asm/io.h> -- port I/O accessors.
6 *
7 * ARM64 has no x86 I/O port space, but 8250's probe and PIO paths carry
8 * inb/outb/inl/outl calls that must still *compile* even though every port we
9 * intend to bind is MMIO (QEMU's pci-serial BAR, iMX8MP's UART -- both
10 * reach registers through readb/writeb, already in <linux/kernel.h>). The
11 * 16-bit pair (inw/outw) is here for the same reason: bochs.c hands the
12 * VBE dispi registers that way when it has no MMIO BAR, and that whole arm
13 * is dead on this target because bochs_uses_mmio() folds to true (see
14 * <linux/kconfig.h>: CONFIG_HAS_IOPORT is undefined), but the call sites
15 * still have to name the functions.
16 *
17 * So these are honest failures, not silent ones: a read answers 0 and a write
18 * drops, and the first of either logs once. 0 rather than 0xff on purpose --
19 * an all-ones answer makes LSR look like "transmitter always empty", which
20 * would let the driver believe it is talking to a live UART, while 0 says
21 * "no line is ready" and drives every polling loop into its timeout and out
22 * again. Failing toward the timeout is what keeps a misconfigured port from
23 * becoming a boot hang.
24 *
25 * When a board that genuinely needs PIO shows up, the body becomes a window
26 * (PCI I/O space is a mapping on ARM64, not an x86 instruction) and this
27 * comment is the thing to delete.
28 */
29
30#include <linux/kernel.h> /* u8/u32 */
31
32unsigned char inb(unsigned long addr);
33void outb(unsigned char v, unsigned long addr);
34unsigned short inw(unsigned long addr);
35void outw(unsigned short v, unsigned long addr);
36unsigned int inl(unsigned long addr);
37void outl(unsigned int v, unsigned long addr);
38
39
40/*
41 * ioremap()/iounmap() and the be32 accessors, reached the way a mainline
42 * driver reaches them: through <asm/io.h>.
43 *
44 * DCL deliberately houses ioremap in <linux/io.h> rather than here (see the
45 * note at the top of that header: on arm64 ioremap is a plain P2V, and it
46 * belongs with the other map/unmap declarations). The consequence was that
47 * nothing included it -- every mainline source says <asm/io.h> and calls
48 * ioremap, so 8250_port.c:2908 compiled as an implicit `int ioremap()` and
49 * assigned the result to `void *port->membase`. On this LLP64 target that is
50 * not a warning to tolerate: the int is 32 bits, membase is 8, and the pointer
51 * would have its top half zeroed before a single register was read through it.
52 * Re-exporting the header here is what makes the declaration reach the
53 * call sites that were always going to ask for it.
54 */
55#include <linux/io.h>
56
57/* The `_p` ("slow, with a pause") variants: same honest-failure answers as
58 * inb/outb above -- 0 on read, drop on write -- because the pause exists to
59 * slow down an x86 ISA access that has no counterpart here. */
60static inline unsigned char inb_p(unsigned long addr)
61{
62 return inb(addr);
63}
64
65static inline void outb_p(unsigned char v, unsigned long addr)
66{
67 outb(v, addr);
68}
69#endif /* __ASM_IO_H__ */
void outw(unsigned short v, unsigned long addr)
void outb(unsigned char v, unsigned long addr)
unsigned short inw(unsigned long addr)
unsigned char inb(unsigned long addr)
unsigned int inl(unsigned long addr)
void outl(unsigned int v, unsigned long addr)