AquilaOS documentation
How it works, and its code
Toggle main menu visibility
Loading...
Searching...
No Matches
ecam.c
Go to the documentation of this file.
1
10
11
#include <
core/system.h
>
12
#include <
dev/pci.h
>
13
#include <
cpu/io.h
>
14
17
static
uintptr_t
offset
(
struct
pci_dev
*
dev
,
uint16_t
reg)
18
{
19
return
(
uintptr_t
)
dev
->bus << 20 | (
uintptr_t
)
dev
->dev << 15 |
20
(
uintptr_t
)
dev
->func << 12 | (reg & 0xFFC);
21
}
22
32
uint32_t
pci_ecam_read
(
struct
pci_host
*host,
struct
pci_dev
*
dev
,
uint16_t
reg)
33
{
34
uintptr_t
off =
offset
(
dev
, reg);
35
36
if
(off >= host->
size
)
37
return
0xFFFFFFFF;
38
39
return
io_in32
(&host->
config
, off);
40
}
41
51
void
pci_ecam_write
(
struct
pci_host
*host,
struct
pci_dev
*
dev
,
uint16_t
reg,
uint32_t
val)
52
{
53
uintptr_t
off =
offset
(
dev
, reg);
54
55
if
(off < host->size)
56
io_out32
(&host->
config
, off, val);
57
}
io_in32
static uint32_t io_in32(struct ioaddr *io, uintptr_t off)
Definition
io.h:38
io_out32
static void io_out32(struct ioaddr *io, uintptr_t off, uint32_t val)
Definition
io.h:54
pci_ecam_write
void pci_ecam_write(struct pci_host *host, struct pci_dev *dev, uint16_t reg, uint32_t val)
Writes a 32-bit register of a function's configuration space.
Definition
ecam.c:51
pci_ecam_read
uint32_t pci_ecam_read(struct pci_host *host, struct pci_dev *dev, uint16_t reg)
Reads a 32-bit register of a function's configuration space.
Definition
ecam.c:32
offset
static uintptr_t offset(struct pci_dev *dev, uint16_t reg)
Returns where register reg of dev is, from the start of the configuration space (the register rounded...
Definition
ecam.c:17
system.h
io.h
pci.h
uintptr_t
__SIZE_TYPE__ uintptr_t
Definition
stddef.h:12
uint32_t
unsigned int uint32_t
Definition
stddef.h:22
uint16_t
unsigned short int uint16_t
Definition
stddef.h:21
dev
A device driver: its operations, any of which may be NULL.
Definition
dev.h:28
pci_dev
A PCI function: its bus, device (slot) and function numbers.
Definition
pci.h:18
pci_host
The host bridge, which the platform describes (platform_init() sets it): how its configuration space ...
Definition
pci.h:32
pci_host::config
struct ioaddr config
Definition
pci.h:38
pci_host::size
size_t size
Definition
pci.h:39
kernel
dev
pci
ecam.c
Generated by
1.18.0