AquilaOS documentation
How it works, and its code
Loading...
Searching...
No Matches
ecam.c File Reference

PCI configuration space through ECAM, the Enhanced Configuration Access Mechanism of PCI Express. More...

#include <core/system.h>
#include <dev/pci.h>
#include <cpu/io.h>

Go to the source code of this file.

Functions

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 down to 4 bytes).
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.
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.

Detailed Description

PCI configuration space through ECAM, the Enhanced Configuration Access Mechanism of PCI Express.

Every function's 4 KiB of configuration space is in memory, one after the other, ordered by bus, device and function, from the host bridge's config address (which pci_host_set() mapped). Reading or writing a register is a plain memory access.

Definition in file ecam.c.

Function Documentation

◆ offset()

uintptr_t offset ( struct pci_dev * dev,
uint16_t reg )
static

Returns where register reg of dev is, from the start of the configuration space (the register rounded down to 4 bytes).

Definition at line 17 of file ecam.c.

Referenced by pci_ecam_read(), and pci_ecam_write().

◆ 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.

Parameters
hostthe host bridge
devthe function
regthe register's offset (rounded down to 4 bytes)
Returns
the register's value, or all ones if it is past what the host mapped

Definition at line 32 of file ecam.c.

References pci_host::config, io_in32(), offset(), pci_ecam_read(), and pci_host::size.

Referenced by pci_ecam_read().

◆ 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.

A register past what the host mapped is left alone.

Parameters
hostthe host bridge
devthe function
regthe register's offset (rounded down to 4 bytes)
valthe value to write

Definition at line 51 of file ecam.c.

References pci_host::config, io_out32(), offset(), and pci_ecam_write().

Referenced by pci_ecam_write().