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