5#include <sys/kassert.h>
29 kprintf(
"PCI: Initializing ...\n");
31 kprintf(
"PCI: Initialization Done!\n");
148 kprintf(
"PCI: (%d,%d,%d) Host Bridge (%04x:%04x)\n",
149 bus, device, func, vendorId, deviceId);
151 kprintf(
"PCI: (%d,%d,%d) ISA Bridge (%04x:%04x)\n",
152 bus, device, func, vendorId, deviceId);
154 kprintf(
"PCI: (%d,%d,%d) PCI-PCI Bridge (%04x:%04x)\n",
155 bus, device, func, vendorId, deviceId);
158 kprintf(
"PCI: (%d,%d,%d) Other Bridge (%04x:%04x)\n",
159 bus, device, func, vendorId, deviceId);
163 kprintf(
"PCI: (%d,%d,%d) SATA Controller (%04x:%04x)\n",
164 bus, device, func, vendorId, deviceId);
168 kprintf(
"PCI: (%d,%d,%d) IDE Controller (%04x:%04x)\n",
169 bus, device, func, vendorId, deviceId);
172 kprintf(
"PCI: (%d,%d,%d) Ethernet (%04x:%04x)\n",
173 bus, device, func, vendorId, deviceId);
176 kprintf(
"PCI: (%d,%d,%d) VGA (%04x:%04x)\n",
177 bus, device, func, vendorId, deviceId);
179 kprintf(
"PCI: (%d,%d,%d) SMBUS (%04x:%04x)\n",
180 bus, device, func, vendorId, deviceId);
182 kprintf(
"PCI: (%d,%d,%d) Unsupported (%04x:%04x %02x:%02x)\n",
183 bus, device, func, vendorId, deviceId, baseClass, subClass);
194 if (vendorId == 0xFFFF)
200 if ((headerType & 0x80) != 0) {
202 for (func = 0; func < 8; func++) {
215 for (device = 0; device < 32; device++) {
230 if ((headerType & 0x80) == 0) {
235 for (busNo = 0; busNo < 8; busNo++) {
281 base = origValue & 0xFFFFFFFC;
286 base = origValue & 0xFFFFFFF0;
290 ASSERT((origValue & 0x06) == 0x00);
311 kprintf(
"PCI: (%d,%d,%d) Host Bridge (%04x:%04x)\n",
312 bus, device, func, vendorId, deviceId);
314 kprintf(
"PCI: (%d,%d,%d) ISA Bridge (%04x:%04x)\n",
315 bus, device, func, vendorId, deviceId);
317 kprintf(
"PCI: (%d,%d,%d) PCI-PCI Bridge (%04x:%04x)\n",
318 bus, device, func, vendorId, deviceId);
321 kprintf(
"PCI: (%d,%d,%d) Other Bridge (%04x:%04x)\n",
322 bus, device, func, vendorId, deviceId);
326 kprintf(
"PCI: (%d,%d,%d) SATA Controller (%04x:%04x)\n",
327 bus, device, func, vendorId, deviceId);
329 kprintf(
"PCI: (%d,%d,%d) IDE Controller (%04x:%04x)\n",
330 bus, device, func, vendorId, deviceId);
333 kprintf(
"PCI: (%d,%d,%d) Ethernet (%04x:%04x)\n",
334 bus, device, func, vendorId, deviceId);
336 kprintf(
"PCI: (%d,%d,%d) VGA (%04x:%04x)\n",
337 bus, device, func, vendorId, deviceId);
339 kprintf(
"PCI: (%d,%d,%d) SMBUS (%04x:%04x)\n",
340 bus, device, func, vendorId, deviceId);
342 kprintf(
"PCI: (%d,%d,%d) Unsupported (%04x:%04x %02x:%02x)\n",
343 bus, device, func, vendorId, deviceId, baseClass, subClass);
354 for (device = 0; device < 32; device++) {
356 if (vendorId == 0xFFFF)
362 if ((headerType & 0x80) != 0) {
364 for (func = 0; func < 8; func++) {
378 if ((headerType & 0x80) == 0) {
383 for (busNo = 0; busNo < 8; busNo++) {
400 kprintf(
"Requires 3 arguments!\n");
uint32_t PCICfgRead32(uint32_t bus, uint32_t slot, uint32_t func, uint32_t reg)
uint8_t PCICfgRead8(uint32_t bus, uint32_t slot, uint32_t func, uint32_t reg)
void PCICfgWrite8(uint32_t bus, uint32_t slot, uint32_t func, uint32_t reg, uint8_t data)
void PCICfgWrite32(uint32_t bus, uint32_t slot, uint32_t func, uint32_t reg, uint32_t data)
void PCICfgWrite16(uint32_t bus, uint32_t slot, uint32_t func, uint32_t reg, uint16_t data)
uint16_t PCICfgRead16(uint32_t bus, uint32_t slot, uint32_t func, uint32_t reg)
void PCI_CfgWrite32(PCIDevice *dev, uint32_t reg, uint32_t data)
uint8_t PCI_GetHeaderType(PCIDevice *dev)
static void PCIScanDevice(uint32_t bus, uint32_t device)
void PCI_CfgWrite8(PCIDevice *dev, uint32_t reg, uint8_t data)
static void PCICheckFunction(uint32_t bus, uint32_t device, uint32_t func)
void Debug_PCIList(int argc, const char *argv[])
void Debug_PCIDump(int argc, const char *argv[])
uint16_t PCI_GetVendorID(PCIDevice *dev)
uint8_t PCI_GetBaseClass(PCIDevice *dev)
static void DebugPCICheckFunction(uint32_t bus, uint32_t device, uint32_t func)
uint16_t PCI_GetDeviceID(PCIDevice *dev)
uint16_t PCIGetVendorID(uint32_t bus, uint32_t device, uint32_t func)
void PCI_CfgWrite16(PCIDevice *dev, uint32_t reg, uint16_t data)
void AHCI_Init(uint32_t bus, uint32_t device, uint32_t func)
static void DebugPCIScanBus(uint8_t bus)
uint8_t PCIGetSubClass(uint32_t bus, uint32_t device, uint32_t func)
void E1000_Init(uint32_t bus, uint32_t device, uint32_t func)
uint32_t PCI_CfgRead32(PCIDevice *dev, uint32_t reg)
uint16_t PCIGetDeviceID(uint32_t bus, uint32_t device, uint32_t func)
void PCI_Configure(PCIDevice *dev)
uint8_t PCIGetHeaderType(uint32_t bus, uint32_t device, uint32_t func)
uint8_t PCIGetBaseClass(uint32_t bus, uint32_t device, uint32_t func)
uint16_t PCI_CfgRead16(PCIDevice *dev, uint32_t reg)
uint8_t PCI_CfgRead8(PCIDevice *dev, uint32_t reg)
uint8_t PCI_GetSubClass(PCIDevice *dev)
static void PCIScanBus(uint8_t bus)
int kprintf(const char *fmt,...)
uint64_t Debug_StrToInt(const char *s)
#define REGISTER_DBGCMD(_NAME, _DESC, _FUNC)
#define PCI_SCLASS_BUS_SMBUS
#define PCI_SCLASS_BRIDGE_PCI
#define PCI_COMMAND_MEMENABLE
#define PCI_OFFSET_BARFIRST
#define PCI_SCLASS_BRIDGE_ISA
#define PCI_OFFSET_IRQLINE
#define PCI_OFFSET_VENDORID
#define PCI_CLASS_NETWORK
#define PCI_COMMAND_BUSMASTER
#define PCI_OFFSET_SUBCLASS
#define PCI_SCLASS_BRIDGE_MISC
#define PCI_SCLASS_STORAGE_SATA
PCIBAR bars[PCI_MAX_BARS]
#define PCI_CLASS_STORAGE
#define PCI_OFFSET_COMMAND
#define PCI_SCLASS_STORAGE_IDE
#define PCI_OFFSET_HEADERTYPE
#define PCI_COMMAND_IOENABLE
#define PCI_CLASS_GRAPHICS
#define PCI_OFFSET_DEVICEID
#define PCI_SCLASS_BRIDGE_HOST