AquilaOS documentation
How it works, and its code
Loading...
Searching...
No Matches
io.h
Go to the documentation of this file.
1#ifndef _CPU_IO_H
2#define _CPU_IO_H
3
4#include <stdint.h>
5
6/*
7 * A device's registers, wherever they are: I/O ports (on x86), or memory.
8 * Each architecture's cpu/io.h adds io_in8() and the others, which read
9 * and write them. A memory-mapped device's registers may be a byte, two
10 * or four bytes apart (IOADDR_MMIO8, MMIO16, MMIO32).
11 */
12
13/* What kind of registers an ioaddr has. */
14#define IOADDR_PORT 1
15#define IOADDR_MMIO8 2
16#define IOADDR_MMIO16 3
17#define IOADDR_MMIO32 4
18
20struct ioaddr {
21 char type; /* IOADDR_* */
22 uintptr_t addr; /* the first port, or the kernel address of the first register */
23};
24
26static inline char *ioaddr_type_str(struct ioaddr *io)
27{
28 switch (io->type) {
29 case IOADDR_PORT:
30 return "pio";
31 case IOADDR_MMIO8:
32 return "mmio8";
33 case IOADDR_MMIO16:
34 return "mmio16";
35 case IOADDR_MMIO32:
36 return "mmio32";
37 }
38
39 return NULL;
40}
41
42#endif /* ! _CPU_IO_H */
static char * ioaddr_type_str(struct ioaddr *io)
Definition io.h:101
#define IOADDR_PORT
Definition io.h:89
#define IOADDR_MMIO16
Definition io.h:91
#define IOADDR_MMIO8
Definition io.h:90
#define IOADDR_MMIO32
Definition io.h:92
#define NULL
Definition stddef.h:27
__SIZE_TYPE__ uintptr_t
Definition stddef.h:12
Where a device's registers are.
Definition io.h:95
uintptr_t addr
Definition io.h:97
char type
Definition io.h:96