AquilaOS documentation
How it works, and its code
Toggle main menu visibility
Loading...
Searching...
No Matches
platform.h
Go to the documentation of this file.
1
#ifndef _DEV_PLATFORM_H
2
#define _DEV_PLATFORM_H
3
4
#include <
core/types.h
>
5
#include <
cpu/io.h
>
6
7
/*
8
* The devices that no bus finds (PCI's devices are found by scanning the
9
* bus). The platform lists where its devices are in a table
10
* (arch/ARCH/platform/PLATFORM/devices.c). A driver asks for its devices
11
* by name, the first one, the second one..., and attaches to each. So
12
* which drivers there are is the build's choice (Build.mk), and which
13
* devices the machine has, and where, is the platform's.
14
*/
15
16
/* The most interrupts a platform device can have. */
17
#define PLATFORM_IRQS 2
18
20
struct
platform_device
{
21
const
char
*
name
;
/* its driver's name: "8250", "pl011", "i8042" */
22
struct
ioaddr
io
;
/* its registers: ports, or physical memory */
23
size_t
size
;
/* their size (memory registers are mapped) */
24
int
nirq
;
/* how many interrupts it has */
25
unsigned
irq
[
PLATFORM_IRQS
];
26
};
27
28
/* The platform's table, ended by an entry without a name. */
29
extern
const
struct
platform_device
platform_devices
[];
30
31
/* Returns the platform's `index`th device named `name`. */
32
const
struct
platform_device
*
platform_device_get
(
const
char
*
name
,
int
index);
33
34
/* Gets a device's registers ready for io_in*() and io_out*(). */
35
int
platform_device_io
(
const
struct
platform_device
*pd,
struct
ioaddr
*
io
);
36
37
#endif
/* ! _DEV_PLATFORM_H */
platform_devices
const struct platform_device platform_devices[]
Definition
devices.c:11
io.h
PLATFORM_IRQS
#define PLATFORM_IRQS
Definition
platform.h:17
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
ioaddr
Where a device's registers are.
Definition
io.h:95
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::irq
unsigned irq[PLATFORM_IRQS]
Definition
platform.h:25
platform_device::size
size_t size
Definition
platform.h:23
platform_device::nirq
int nirq
Definition
platform.h:24
platform_device::io
struct ioaddr io
Definition
platform.h:22
types.h
kernel
include
dev
platform.h
Generated by
1.18.0