Newer
Older
tree-os / src / include / pci.h
#ifndef PCI_H
#define PCI_H

#include <list.h>
#include <stdint.h>

typedef struct {
    uint8_t bus, device, function;
    uint8_t class, subclass;
    uint16_t deviceId, vendorId, programmingInterface;
    uint32_t bar0, bar1, bar2, bar3, bar4, bar5;
} PciDevice;

extern void scanPCIDevices();
extern ListElement **getPciDevices();
extern void pciConfigWriteByte(uint32_t bus, uint32_t device, uint32_t function,
                               uint8_t offset, uint8_t data);

extern uint8_t pciConfigReadByte(uint32_t bus, uint32_t device,
                                 uint32_t function, uint8_t offset);
extern void pciConfigWriteByte(uint32_t bus, uint32_t device, uint32_t function,
                               uint8_t offset, uint8_t data);
extern uint16_t pciConfigReadWord(uint8_t bus, uint8_t device, uint8_t function,
                                  uint8_t offset);
extern uint32_t pciConfigReadInt(uint8_t bus, uint8_t device, uint8_t function,
                                 uint8_t offset);
#endif