mirror of
https://github.com/Fennix-Project/Kernel.git
synced 2025-05-25 22:14:37 +00:00
Added PCI support
This commit is contained in:
parent
32a17c5e63
commit
19e810653a
@ -1,6 +1,14 @@
|
||||
#include <pci.hpp>
|
||||
|
||||
#include <memory.hpp>
|
||||
#include <power.hpp>
|
||||
#if defined(__amd64__)
|
||||
#include "../Architecture/amd64/acpi.hpp"
|
||||
#elif defined(__i386__)
|
||||
#elif defined(__aarch64__)
|
||||
#endif
|
||||
|
||||
#include "../kernel.h"
|
||||
|
||||
namespace PCI
|
||||
{
|
||||
@ -703,6 +711,7 @@ namespace PCI
|
||||
switch (SubclassCode)
|
||||
{
|
||||
case 0x00:
|
||||
{
|
||||
switch (ProgIF)
|
||||
{
|
||||
case 0x00:
|
||||
@ -712,7 +721,10 @@ namespace PCI
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 0x03:
|
||||
{
|
||||
switch (ProgIF)
|
||||
{
|
||||
case 0x00:
|
||||
@ -730,6 +742,8 @@ namespace PCI
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -826,16 +840,22 @@ namespace PCI
|
||||
|
||||
PCI::PCI()
|
||||
{
|
||||
// int Entries = ((MCFG->Header.Length) - sizeof(ACPI::ACPI::MCFGHeader)) / sizeof(DeviceConfig);
|
||||
// for (int t = 0; t < Entries; t++)
|
||||
// {
|
||||
// DeviceConfig *NewDeviceConfig = (DeviceConfig *)((uint64_t)MCFG + sizeof(ACPI::ACPI::MCFGHeader) + (sizeof(DeviceConfig) * t));
|
||||
// Memory::Virtual().Map((void *)NewDeviceConfig->BaseAddress, (void *)NewDeviceConfig->BaseAddress, Memory::PTFlag::RW);
|
||||
// trace("PCI Entry %d Address:%#llx BUS:%#llx-%#llx", t, NewDeviceConfig->BaseAddress,
|
||||
// NewDeviceConfig->StartBus, NewDeviceConfig->EndBus);
|
||||
// for (uint64_t Bus = NewDeviceConfig->StartBus; Bus < NewDeviceConfig->EndBus; Bus++)
|
||||
// EnumerateBus(NewDeviceConfig->BaseAddress, Bus);
|
||||
// }
|
||||
#if defined(__amd64__)
|
||||
int Entries = ((((ACPI::ACPI *)PowerManager->GetACPI())->MCFG->Header.Length) - sizeof(ACPI::ACPI::MCFGHeader)) / sizeof(DeviceConfig);
|
||||
for (int t = 0; t < Entries; t++)
|
||||
{
|
||||
DeviceConfig *NewDeviceConfig = (DeviceConfig *)((uint64_t)((ACPI::ACPI *)PowerManager->GetACPI())->MCFG + sizeof(ACPI::ACPI::MCFGHeader) + (sizeof(DeviceConfig) * t));
|
||||
Memory::Virtual().Map((void *)NewDeviceConfig->BaseAddress, (void *)NewDeviceConfig->BaseAddress, Memory::PTFlag::RW);
|
||||
trace("PCI Entry %d Address:%#llx BUS:%#llx-%#llx", t, NewDeviceConfig->BaseAddress,
|
||||
NewDeviceConfig->StartBus, NewDeviceConfig->EndBus);
|
||||
for (uint64_t Bus = NewDeviceConfig->StartBus; Bus < NewDeviceConfig->EndBus; Bus++)
|
||||
EnumerateBus(NewDeviceConfig->BaseAddress, Bus);
|
||||
}
|
||||
#elif defined(__i386__)
|
||||
error("PCI not implemented on i386");
|
||||
#elif defined(__aarch64__)
|
||||
error("PCI not implemented on aarch64");
|
||||
#endif
|
||||
}
|
||||
|
||||
PCI::~PCI()
|
||||
|
@ -1,10 +1,7 @@
|
||||
#include "kernel.h"
|
||||
|
||||
#include <interrupts.hpp>
|
||||
#include <display.hpp>
|
||||
#include <symbols.hpp>
|
||||
#include <memory.hpp>
|
||||
#include <power.hpp>
|
||||
#include <string.h>
|
||||
#include <printf.h>
|
||||
#include <time.hpp>
|
||||
@ -14,6 +11,7 @@ BootInfo *bInfo = nullptr;
|
||||
Video::Display *Display = nullptr;
|
||||
SymbolResolver::Symbols *KernelSymbolTable = nullptr;
|
||||
Power::Power *PowerManager = nullptr;
|
||||
PCI::PCI *PCIManager = nullptr;
|
||||
|
||||
// For the Display class. Printing on first buffer.
|
||||
extern "C" void putchar(char c) { Display->Print(c, 0); }
|
||||
@ -58,6 +56,8 @@ EXTERNC void Entry(BootInfo *Info)
|
||||
KernelSymbolTable = new SymbolResolver::Symbols((uint64_t)Info->Kernel.FileBase);
|
||||
KPrint("Initializing Power Manager");
|
||||
PowerManager = new Power::Power;
|
||||
KPrint("Initializing PCI Manager");
|
||||
PCIManager = new PCI::PCI;
|
||||
while (1)
|
||||
CPU::Halt();
|
||||
}
|
||||
|
@ -14,6 +14,9 @@ namespace Power
|
||||
void *madt;
|
||||
|
||||
public:
|
||||
void *GetACPI() { return this->acpi; }
|
||||
void *GetDSDT() { return this->dsdt; }
|
||||
void *GetMADT() { return this->madt; }
|
||||
void Reboot();
|
||||
void Shutdown();
|
||||
Power();
|
||||
|
13
kernel.h
13
kernel.h
@ -2,9 +2,22 @@
|
||||
#define __FENNIX_KERNEL_KERNEL_H__
|
||||
|
||||
#include <types.h>
|
||||
|
||||
#include <boot/binfo.h>
|
||||
#ifdef __cplusplus
|
||||
#include <display.hpp>
|
||||
#include <symbols.hpp>
|
||||
#include <power.hpp>
|
||||
#include <pci.hpp>
|
||||
#endif
|
||||
|
||||
extern struct BootInfo *bInfo;
|
||||
#ifdef __cplusplus
|
||||
extern Video::Display *Display;
|
||||
extern SymbolResolver::Symbols *KernelSymbolTable;
|
||||
extern Power::Power *PowerManager;
|
||||
extern PCI::PCI *PCIManager;
|
||||
#endif
|
||||
|
||||
EXTERNC void Entry(struct BootInfo *Info);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user