92 lines
1.7 KiB
C
92 lines
1.7 KiB
C
//
|
|
// Created by rick on 02-02-21.
|
|
//
|
|
|
|
#ifndef NEW_KERNEL_PCI_H
|
|
#define NEW_KERNEL_PCI_H
|
|
|
|
#include <types.h>
|
|
|
|
#define PCI_CLASS_MASS_STORAGE 0x01
|
|
|
|
// class MASS STORAGE 1
|
|
#define PCI_SUB_CLASS_IDE 0x01
|
|
|
|
#define PCI_REGISTER_OK 0
|
|
#define PCI_REGISTER_ERR_FULL (-1)
|
|
|
|
#define PCI_VALIDATE_OK 0
|
|
#define PCI_VALIDATE_FAIL 1
|
|
|
|
#define PCI_INIT_OK 0
|
|
#define PCI_INIT_FAIL 1
|
|
|
|
typedef struct pci_driver pci_driver;
|
|
typedef struct pci_device pci_device;
|
|
|
|
typedef u8 (*pci_driver_validate)(const pci_device *);
|
|
typedef u8 (*pci_driver_initialize)(const pci_device *);
|
|
|
|
typedef struct pci_driver {
|
|
const char *name;
|
|
const char *description;
|
|
u8 order;
|
|
u8 pci_class;
|
|
u8 pci_subclass;
|
|
struct {
|
|
u8 pci_use_subclass: 1;
|
|
};
|
|
pci_driver_validate validate;
|
|
pci_driver_initialize initialize;
|
|
} pci_driver;
|
|
|
|
typedef struct pci_device {
|
|
u8 bus;
|
|
u8 slot;
|
|
u8 func;
|
|
union {
|
|
struct {
|
|
u16 vendorId;
|
|
u16 deviceId;
|
|
};
|
|
u32 config_line_0;
|
|
};
|
|
union {
|
|
struct {
|
|
u8 revisionId;
|
|
u8 programInterface;
|
|
u8 subclass;
|
|
u8 class;
|
|
};
|
|
u32 config_line_2;
|
|
};
|
|
union {
|
|
struct {
|
|
u8 cacheLineSize;
|
|
u8 latencyTimer;
|
|
u8 headerType;
|
|
u8 bist;
|
|
};
|
|
u32 config_line_3;
|
|
};
|
|
const pci_driver *pci_driver;
|
|
struct {
|
|
u8 present: 1;
|
|
} device_state;
|
|
struct {
|
|
u8 initialized: 1;
|
|
} driver_state;
|
|
} pci_device;
|
|
|
|
void pci_print_info();
|
|
|
|
u32 pci_register_driver(const pci_driver *pci_driver);
|
|
|
|
void pci_sort_drivers();
|
|
|
|
void pci_init_drivers();
|
|
|
|
void pci_scan();
|
|
|
|
#endif //NEW_KERNEL_PCI_H
|