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

PCI configuration space through configuration mechanism #1, the PC's. More...

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

Go to the source code of this file.

Data Structures

union  pci_address
 What is written to CONFIG_ADDRESS: the register to reach. More...

Macros

#define PCI_CONFIG_ADDRESS   0x00
#define PCI_CONFIG_DATA   0x04

Functions

static void conf1_select (struct pci_host *host, struct pci_dev *dev, uint16_t reg)
 Selects register reg of dev (rounded down to 4 bytes), for the next access to CONFIG_DATA.
uint32_t pci_conf1_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_conf1_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 configuration mechanism #1, the PC's.

The address of a register (its bus, device, function and offset) is written to one port, CONFIG_ADDRESS (the host bridge's config, 0xCF8 on the PC), and the register's value is then read from or written to the next one, CONFIG_DATA, 4 bytes on. Only the first 256 bytes of a function's configuration space can be reached this way.

Definition in file conf1.c.

Macro Definition Documentation

◆ PCI_CONFIG_ADDRESS

#define PCI_CONFIG_ADDRESS   0x00

Definition at line 15 of file conf1.c.

Referenced by conf1_select().

◆ PCI_CONFIG_DATA

#define PCI_CONFIG_DATA   0x04

Definition at line 16 of file conf1.c.

Referenced by pci_conf1_read(), and pci_conf1_write().

Function Documentation

◆ conf1_select()

void conf1_select ( struct pci_host * host,
struct pci_dev * dev,
uint16_t reg )
static

Selects register reg of dev (rounded down to 4 bytes), for the next access to CONFIG_DATA.

Definition at line 33 of file conf1.c.

References conf1_select(), pci_host::config, io_out32(), PCI_CONFIG_ADDRESS, pci_address::raw, and pci_address::structure.

Referenced by conf1_select(), pci_conf1_read(), and pci_conf1_write().

◆ pci_conf1_read()

uint32_t pci_conf1_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 for an offset past 255

Definition at line 55 of file conf1.c.

References conf1_select(), pci_host::config, io_in32(), pci_conf1_read(), and PCI_CONFIG_DATA.

Referenced by pci_conf1_read().

◆ pci_conf1_write()

void pci_conf1_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.

An offset past 255 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 73 of file conf1.c.

References conf1_select(), pci_host::config, io_out32(), pci_conf1_write(), and PCI_CONFIG_DATA.

Referenced by pci_conf1_write().