18#define PCI_CONFIG_ADDRESS 0xCF8
19#define PCI_CONFIG_DATA 0xCFC
20#define VIRTIO_REG(offset) (iob + (offset))
50 (1U << 31) | (bus << 16) | (slot << 11) | (func << 8) | (offset & 0xFC);
60 for (
u8 bus = 0; bus < 255; bus++) {
61 for (
u8 slot = 0; slot < 32; slot++) {
62 for (
u8 func = 0; func < 8; func++) {
64 if (vendor == 0xFFFF) {
72 if (vendor == 0x1AF4 && dev == 0x1000 && revid == 0x00) {
76 Kprintf(
"VirtIO at %x:%x.%x BAR0=%x IO=%x Rev=%x\n", bus,
void Outb(u16 port, u8 val)
Write a byte to the specified I/O port.
u32 Inl(u16 port)
Read a 32-bit value from the specified I/O port.
void Outl(u16 port, u32 val)
Write a 32-bit value to the specified I/O port.
void Kprintf(const char *fmt,...)
Formatted output to the screen.
unsigned int u32
32-Bit Unsigned Int
unsigned short u16
16-Bit Unsigned Int
unsigned long uptr
Long Unsigned Int.
unsigned char u8
8-Bit Unsigned Int
#define VIRTIO_REG(offset)
u32 FindVirtionetDev()
Search for VirtNet Device.
#define PCI_CONFIG_ADDRESS
u32 PciConfigRead(u8 bus, u8 slot, u8 func, u8 offset)
Reads a 32-bit value from PCI configuration space.