AquilaOS documentation
How it works, and its code
Toggle main menu visibility
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
20
struct
ioaddr
{
21
char
type
;
/* IOADDR_* */
22
uintptr_t
addr
;
/* the first port, or the kernel address of the first register */
23
};
24
26
static
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 */
ioaddr_type_str
static char * ioaddr_type_str(struct ioaddr *io)
Definition
io.h:101
IOADDR_PORT
#define IOADDR_PORT
Definition
io.h:89
IOADDR_MMIO16
#define IOADDR_MMIO16
Definition
io.h:91
IOADDR_MMIO8
#define IOADDR_MMIO8
Definition
io.h:90
IOADDR_MMIO32
#define IOADDR_MMIO32
Definition
io.h:92
NULL
#define NULL
Definition
stddef.h:27
uintptr_t
__SIZE_TYPE__ uintptr_t
Definition
stddef.h:12
stdint.h
ioaddr
Where a device's registers are.
Definition
io.h:95
ioaddr::addr
uintptr_t addr
Definition
io.h:97
ioaddr::type
char type
Definition
io.h:96
kernel
include
cpu
io.h
Generated by
1.18.0