AquilaOS documentation
How it works, and its code
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
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. */
29extern const struct platform_device platform_devices[];
30
31/* Returns the platform's `index`th device named `name`. */
32const 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*(). */
35int platform_device_io(const struct platform_device *pd, struct ioaddr *io);
36
37#endif /* ! _DEV_PLATFORM_H */
const struct platform_device platform_devices[]
Definition devices.c:11
#define PLATFORM_IRQS
Definition platform.h:17
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
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
Where a device's registers are.
Definition io.h:95
A device of the platform's table.
Definition platform.h:20
const char * name
Definition platform.h:21
unsigned irq[PLATFORM_IRQS]
Definition platform.h:25
struct ioaddr io
Definition platform.h:22