Functions for accessing PCI devices.
More...
#include <Library/UefiLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <UEFIStarter/pci.h>
#include <UEFIStarter/core/memory.h>
#include <UEFIStarter/core/files.h>
#include <UEFIStarter/core/string.h>
#include <UEFIStarter/core/logger.h>
|
#define | MAX_PCI_DEVICES 100 |
| the highest number of PCI device entries supported
|
|
Functions for accessing PCI devices.
- Author
- Richard Nusser
- Copyright
- 2017-2018 Richard Nusser
- License
- GPLv3 (see http://www.gnu.org/licenses/)
- See also
- https://github.com/rinusser/UEFIStarter
- Todo:
- read classes and subclasses from pci.ids
◆ hexdigita()
static CHAR8 hexdigita |
( |
UINT8 |
value | ) |
|
|
static |
internal: converts a hexadecimal value into a printable hex character.
- Parameters
-
value | the hex value (0-15) to format |
- Returns
- the lowercase hexadecimal character, or '?' if the input was invalid
◆ ui16tohexa()
static void ui16tohexa |
( |
char * |
buffer, |
|
|
UINT16 |
value |
|
) |
| |
|
static |
internal: converts a UINT16 value to a printable lowercase hex string.
5 bytes of output will be written, starting where buffer
points to. The last bytes is a binary zero for string termination.
- Parameters
-
buffer | where to write the string to (as ascii) |
value | the value to format |
◆ find_pci_device_name()
CHAR16* find_pci_device_name |
( |
UINT16 |
vendor_id, |
|
|
UINT16 |
device_id, |
|
|
UINT16 |
subvendor_id, |
|
|
UINT16 |
subdevice_id |
|
) |
| |
Looks up a PCI device's name by vendor ID and device ID.
Subvendor and subdevice IDs are not implemented yet, they will be ignored.
- Parameters
-
vendor_id | the device's vendor ID |
device_id | the device's device ID |
subvendor_id | ignored |
subdevice_id | ignored |
- Returns
- the device's name, as UTF-16; returns "(unknown)" if the requested device wasn't found
- Todo:
- later: implement sub IDs.
◆ find_pci_class_name()
CHAR16* find_pci_class_name |
( |
UINT8 |
class_code[3] | ) |
|
Finds a PCI class and subclass name by 3-byte class code.
- Parameters
-
class_code | the PCI class code to look up |
- Returns
- the class name; uses "unknown" to replace unhandled classes or subclasses
◆ describe_pci_device()
void describe_pci_device |
( |
PCI_TYPE00 * |
config | ) |
|
Prints basic information about a PCI device.
- Parameters
-
config | the PCI's TYPE00 header |
◆ enumerate_pci_devices()
int enumerate_pci_devices |
( |
| ) |
|
Assembles the internal list of PCI devices.
- Returns
- 0 on success, -1 on failure.
◆ find_pci_device()
EFI_PCI_IO_PROTOCOL* find_pci_device |
( |
UINT16 |
vendor_id, |
|
|
UINT16 |
device_id |
|
) |
| |
Fetches a PCI device's protocol handle.
This is currently the easiest way to access a specific PCI device.
- Parameters
-
vendor_id | the device's vendor ID |
device_id | the device's device ID |
- Returns
- the protocol handle if the device was found, NULL otherwise
◆ print_known_pci_classes()
void print_known_pci_classes |
( |
| ) |
|
Prints a list of known PCI classes and subclasses.
This is mostly for debugging.
◆ init_pci_lib()
Initializes the PCI library.
Call this before using the other library functions.
◆ shutdown_pci_lib()
void shutdown_pci_lib |
( |
| ) |
|
Shuts down the PCI library.
Call this when you're done with PCI functions.
◆ PCI_CLASS01_SUBCLASSES
Initial value:={
{0,L"SCSI Controller"},
{1,L"IDE Controller"},
{2,L"Floppy Disk Controller"},
{4,L"RAID Controller"},
{5,L"ATA Controller"},
{6,L"SATA Controller"},
{7,L"SAS Controller"},
{0x80,L"Other"},
{0,NULL}
}
PCI subclasses for Mass Storage Controllers.
◆ PCI_CLASS02_SUBCLASSES
Initial value:={
{0,L"Ethernet"},
{0,NULL}
}
PCI subclasses for Network Controllers.
◆ PCI_CLASS03_SUBCLASSES
Initial value:={
{0,L"VGA"},
{1,L"XGA"},
{0x80,L"Other"},
{0,NULL}
}
PCI subclasses for Display Controllers.
◆ PCI_CLASS04_SUBCLASSES
Initial value:={
{0,L"Video Device"},
{1,L"Audio Device"},
{0,NULL}
}
PCI subclasses for Multimedia devices.
◆ PCI_CLASS06_SUBCLASSES
Initial value:={
{0,L"Host/PCI"},
{1,L"PCI/ISA"},
{2,L"PCI/EISA"},
{3,L"PCI/Micro Channel"},
{4,L"PCI/PCI"},
{5,L"PCI/PCMCIA"},
{6,L"PCI/NuBus"},
{7,L"PCI/CardBus"},
{0x80,L"Other"},
{0,NULL}
}
PCI subclasses for Bridge Devices.
◆ PCI_CLASS08_SUBCLASSES
Initial value:={
{0x80,L"Other"},
{0,NULL}
}
PCI subclasses for Base System Peripherals.
◆ PCI_CLASS0C_SUBCLASSES
Initial value:={
{0,L"IEEE 1394 Controller (FireWire)"},
{3,L"USB Controller"},
{0,NULL}
}
PCI subclasses for Serial Bus Controllers.
◆ PCI_CLASSES
Initial value:={
{0,NULL,NULL}
}
static pci_subclass_name_t PCI_CLASS04_SUBCLASSES[]
PCI subclasses for Multimedia devices.
Definition: pci.c:61
static pci_subclass_name_t PCI_CLASS06_SUBCLASSES[]
PCI subclasses for Bridge Devices.
Definition: pci.c:68
static pci_subclass_name_t PCI_CLASS01_SUBCLASSES[]
PCI subclasses for Mass Storage Controllers.
Definition: pci.c:34
static pci_subclass_name_t PCI_CLASS08_SUBCLASSES[]
PCI subclasses for Base System Peripherals.
Definition: pci.c:82
static pci_subclass_name_t PCI_CLASS03_SUBCLASSES[]
PCI subclasses for Display Controllers.
Definition: pci.c:53
static pci_subclass_name_t PCI_CLASS0C_SUBCLASSES[]
PCI subclasses for Serial Bus Controllers.
Definition: pci.c:88
static pci_subclass_name_t PCI_CLASS02_SUBCLASSES[]
PCI subclasses for Network Controllers.
Definition: pci.c:47
PCI classes.