PatchworkOS
Loading...
Searching...
No Matches
PCI Configuration Space

PCI configuration space. More...

Data Structures

struct  pci_config_bar_t
 PCI-e Configuration Space Base Address Allocation Structure. More...
 
struct  mcfg_t
 PCI Express Memory-mapped Configuration. More...
 

Typedefs

typedef uint16_t pci_segment_group_t
 PCI Segment Group Type.
 
typedef uint8_t pci_bus_t
 PCI Bus Type.
 
typedef uint8_t pci_slot_t
 PCI Slot Type.
 
typedef uint8_t pci_function_t
 PCI Function Type.
 

Functions

uint8_t pci_config_read8 (pci_segment_group_t segmentGroup, pci_bus_t bus, pci_slot_t slot, pci_function_t function, uint16_t offset)
 Read a byte from PCI configuration space.
 
uint16_t pci_config_read16 (pci_segment_group_t segmentGroup, pci_bus_t bus, pci_slot_t slot, pci_function_t function, uint16_t offset)
 Read a word from PCI configuration space.
 
uint32_t pci_config_read32 (pci_segment_group_t segmentGroup, pci_bus_t bus, pci_slot_t slot, pci_function_t function, uint16_t offset)
 Read a dword from PCI configuration space.
 
void pci_config_write8 (pci_segment_group_t segmentGroup, pci_bus_t bus, pci_slot_t slot, pci_function_t function, uint16_t offset, uint8_t value)
 Write a byte to PCI configuration space.
 
void pci_config_write16 (pci_segment_group_t segmentGroup, pci_bus_t bus, pci_slot_t slot, pci_function_t function, uint16_t offset, uint16_t value)
 Write a word to PCI configuration space.
 
void pci_config_write32 (pci_segment_group_t segmentGroup, pci_bus_t bus, pci_slot_t slot, pci_function_t function, uint16_t offset, uint32_t value)
 Write a dword to PCI configuration space.
 

Detailed Description

PCI configuration space.

Id like to use the PCI Firmware Specification as a reference for this, but unfortunately, its not freely available. So we use the OSDev Wiki instead.

See also
OSDev PCI
OSDev PCI Express

Typedef Documentation

◆ pci_bus_t

typedef uint8_t pci_bus_t

PCI Bus Type.

Definition at line 29 of file pci_config.h.

◆ pci_function_t

PCI Function Type.

Definition at line 39 of file pci_config.h.

◆ pci_segment_group_t

PCI Segment Group Type.

Definition at line 24 of file pci_config.h.

◆ pci_slot_t

PCI Slot Type.

Definition at line 34 of file pci_config.h.

Function Documentation

◆ pci_config_read16()

uint16_t pci_config_read16 ( pci_segment_group_t  segmentGroup,
pci_bus_t  bus,
pci_slot_t  slot,
pci_function_t  function,
uint16_t  offset 
)

Read a word from PCI configuration space.

Parameters
segmentGroupSegment group number
busBus number
slotSlot number
functionFunction number
offsetOffset within the configuration space
Returns
Word read from the configuration space

Definition at line 91 of file pci_config.c.

References NULL, and pci_config_get_address().

Referenced by aml_pci_config_read().

◆ pci_config_read32()

uint32_t pci_config_read32 ( pci_segment_group_t  segmentGroup,
pci_bus_t  bus,
pci_slot_t  slot,
pci_function_t  function,
uint16_t  offset 
)

Read a dword from PCI configuration space.

Parameters
segmentGroupSegment group number
busBus number
slotSlot number
functionFunction number
offsetOffset within the configuration space
Returns
DWord read from the configuration space

Definition at line 102 of file pci_config.c.

References NULL, and pci_config_get_address().

Referenced by aml_pci_config_read().

◆ pci_config_read8()

uint8_t pci_config_read8 ( pci_segment_group_t  segmentGroup,
pci_bus_t  bus,
pci_slot_t  slot,
pci_function_t  function,
uint16_t  offset 
)

Read a byte from PCI configuration space.

Parameters
segmentGroupSegment group number
busBus number
slotSlot number
functionFunction number
offsetOffset within the configuration space
Returns
Byte read from the configuration space

Definition at line 80 of file pci_config.c.

References NULL, and pci_config_get_address().

Referenced by aml_pci_config_read().

◆ pci_config_write16()

void pci_config_write16 ( pci_segment_group_t  segmentGroup,
pci_bus_t  bus,
pci_slot_t  slot,
pci_function_t  function,
uint16_t  offset,
uint16_t  value 
)

Write a word to PCI configuration space.

Parameters
segmentGroupSegment group number
busBus number
slotSlot number
functionFunction number
offsetOffset within the configuration space
valueWord value to write

Definition at line 123 of file pci_config.c.

References NULL, and pci_config_get_address().

Referenced by aml_pci_config_write().

◆ pci_config_write32()

void pci_config_write32 ( pci_segment_group_t  segmentGroup,
pci_bus_t  bus,
pci_slot_t  slot,
pci_function_t  function,
uint16_t  offset,
uint32_t  value 
)

Write a dword to PCI configuration space.

Parameters
segmentGroupSegment group number
busBus number
slotSlot number
functionFunction number
offsetOffset within the configuration space
valueDWord value to write

Definition at line 133 of file pci_config.c.

References NULL, and pci_config_get_address().

Referenced by aml_pci_config_write().

◆ pci_config_write8()

void pci_config_write8 ( pci_segment_group_t  segmentGroup,
pci_bus_t  bus,
pci_slot_t  slot,
pci_function_t  function,
uint16_t  offset,
uint8_t  value 
)

Write a byte to PCI configuration space.

Parameters
segmentGroupSegment group number
busBus number
slotSlot number
functionFunction number
offsetOffset within the configuration space
valueByte value to write

Definition at line 113 of file pci_config.c.

References NULL, and pci_config_get_address().

Referenced by aml_pci_config_write().