AquilaOS documentation
How it works, and its code
Toggle main menu visibility
Loading...
Searching...
No Matches
platform.c
Go to the documentation of this file.
1
8
9
#include <
core/system.h
>
10
#include <
core/string.h
>
11
#include <
core/arch.h
>
12
#include <
dev/platform.h
>
13
21
const
struct
platform_device
*
platform_device_get
(
const
char
*
name
,
int
index)
22
{
23
for
(
const
struct
platform_device
*pd =
platform_devices
; pd->
name
; ++pd)
24
if
(!strcmp(pd->name,
name
) && !index--)
25
return
pd;
26
27
return
NULL
;
28
}
29
38
int
platform_device_io
(
const
struct
platform_device
*pd,
struct
ioaddr
*
io
)
39
{
40
*
io
= pd->
io
;
41
42
if
(
io
->
type
==
IOADDR_PORT
)
43
return
0;
44
45
void
*regs =
arch_mmio_map
(pd->
io
.
addr
, pd->
size
);
46
47
if
(!regs)
48
return
-ENOMEM;
49
50
io
->
addr
= (
uintptr_t
) regs;
51
return
0;
52
}
platform_devices
const struct platform_device platform_devices[]
Definition
devices.c:11
IOADDR_PORT
#define IOADDR_PORT
Definition
io.h:89
arch.h
system.h
platform.h
platform_device_io
int platform_device_io(const struct platform_device *pd, struct ioaddr *io)
Gets a device's registers, ready for io_in8() and the others.
Definition
platform.c:38
platform_device_get
const struct platform_device * platform_device_get(const char *name, int index)
Finds one of the platform's devices by its driver's name.
Definition
platform.c:21
arch_mmio_map
void * arch_mmio_map(uintptr_t paddr, size_t size)
Maps a device's registers into the kernel's address space, uncached (memory-mapped I/O).
Definition
pmap.c:508
NULL
#define NULL
Definition
stddef.h:27
uintptr_t
__SIZE_TYPE__ uintptr_t
Definition
stddef.h:12
string.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
platform_device
A device of the platform's table.
Definition
platform.h:20
platform_device::name
const char * name
Definition
platform.h:21
platform_device::size
size_t size
Definition
platform.h:23
platform_device::io
struct ioaddr io
Definition
platform.h:22
kernel
dev
platform.c
Generated by
1.18.0