feat(kernel/pci): add device initialization method for PCI devices

Signed-off-by: EnderIce2 <enderice2@protonmail.com>
This commit is contained in:
EnderIce2 2025-03-01 23:32:14 +00:00
parent 65ab83b42b
commit aea8a7bb08
No known key found for this signature in database
GPG Key ID: 2EE20AF089811A5A
2 changed files with 13 additions and 0 deletions

View File

@ -982,6 +982,18 @@ namespace PCI
} }
} }
void Manager::InitializeDevice(PCIDevice Device, Memory::PageTable *Table)
{
this->MapPCIAddresses(Device, Table);
PCI::PCIDeviceHeader *Header = Device.Header;
Header->Command |= PCI_COMMAND_MASTER |
PCI_COMMAND_IO |
PCI_COMMAND_MEMORY;
Header->Command &= ~PCI_COMMAND_INTX_DISABLE;
}
void Manager::EnumerateFunction(uint64_t DeviceAddress, uint32_t Function, PCIDevice dev) void Manager::EnumerateFunction(uint64_t DeviceAddress, uint32_t Function, PCIDevice dev)
{ {
dev.Function = Function; dev.Function = Function;

View File

@ -232,6 +232,7 @@ namespace PCI
public: public:
std::list<PCIDevice> GetDevices() { return Devices; } std::list<PCIDevice> GetDevices() { return Devices; }
void MapPCIAddresses(PCIDevice Device, Memory::PageTable *Table); void MapPCIAddresses(PCIDevice Device, Memory::PageTable *Table);
void InitializeDevice(PCIDevice Device, Memory::PageTable *Table);
void EnumerateFunction(uint64_t DeviceAddress, uint32_t Function, PCIDevice dev); void EnumerateFunction(uint64_t DeviceAddress, uint32_t Function, PCIDevice dev);
void EnumerateDevice(uint64_t BusAddress, uint32_t Device, PCIDevice dev); void EnumerateDevice(uint64_t BusAddress, uint32_t Device, PCIDevice dev);
void EnumerateBus(uint64_t BaseAddress, uint32_t Bus, PCIDevice dev); void EnumerateBus(uint64_t BaseAddress, uint32_t Bus, PCIDevice dev);