Use appropriate logging functions
This commit is contained in:
parent
1ab0f7291b
commit
fe672e6a18
@ -13,29 +13,29 @@ ACPI::SDTHeader* ACPI::GetRSDTOrXSDT()
|
||||
{
|
||||
static void* cache = nullptr;
|
||||
if (cache) return (SDTHeader*)cache;
|
||||
kinfoln("First time accessing the RSDT/XSDT, mapping it into memory");
|
||||
kdbgln("First time accessing the RSDT/XSDT, mapping it into memory");
|
||||
void* physical = (void*)bootboot.arch.x86_64.acpi_ptr;
|
||||
uint64_t offset = (uint64_t)physical % 4096;
|
||||
kinfoln("RSDT/XSDT physical address: %lx", (uint64_t)physical);
|
||||
kdbgln("RSDT/XSDT physical address: %lx", (uint64_t)physical);
|
||||
cache = KernelMemoryManager::get_unaligned_mapping(physical);
|
||||
uint64_t numPages = 1;
|
||||
while ((offset + ((SDTHeader*)cache)->Length) > (numPages * 4096))
|
||||
{
|
||||
kinfoln("RSDT/XSDT extends beyond the mapped page, mapping one more page");
|
||||
kwarnln("RSDT/XSDT extends beyond the mapped page, mapping one more page");
|
||||
KernelMemoryManager::release_unaligned_mappings(cache, numPages);
|
||||
numPages++;
|
||||
cache = KernelMemoryManager::get_unaligned_mappings(cache, numPages);
|
||||
}
|
||||
kinfoln("Mapped RSDT/XSDT to virtual address %lx, uses %ld pages", (uint64_t)cache, numPages);
|
||||
kdbgln("Mapped RSDT/XSDT to virtual address %lx, uses %ld pages", (uint64_t)cache, numPages);
|
||||
SDTHeader* result = (SDTHeader*)cache;
|
||||
char OEMID[7];
|
||||
memcpy(OEMID, result->OEMID, 6);
|
||||
OEMID[6] = 0;
|
||||
kinfoln("OEMID: %s", OEMID);
|
||||
kdbgln("OEMID: %s", OEMID);
|
||||
char OEMTableID[9];
|
||||
memcpy(OEMTableID, result->OEMTableID, 8);
|
||||
OEMTableID[8] = 0;
|
||||
kinfoln("OEMTableID: %s", OEMTableID);
|
||||
kdbgln("OEMTableID: %s", OEMTableID);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -56,12 +56,12 @@ void* ACPI::FindTable(ACPI::SDTHeader* rootSDT, const char* signature)
|
||||
{
|
||||
bool isXSDT = (strncmp(rootSDT->Signature, "XSDT", 4) == 0);
|
||||
int entries = (rootSDT->Length - sizeof(SDTHeader)) / (isXSDT ? 8 : 4);
|
||||
kinfoln("Searching for table %s in the %s at %lx (table contains %d entries)", signature, isXSDT ? "XSDT" : "RSDT",
|
||||
kdbgln("Searching for table %s in the %s at %lx (table contains %d entries)", signature, isXSDT ? "XSDT" : "RSDT",
|
||||
(uint64_t)rootSDT, entries);
|
||||
|
||||
for (int i = 0; i < entries; i++)
|
||||
{
|
||||
kinfoln("Testing for table %s in entry %d", signature, i);
|
||||
kdbgln("Testing for table %s in entry %d", signature, i);
|
||||
SDTHeader* h;
|
||||
if (isXSDT)
|
||||
{
|
||||
@ -76,28 +76,28 @@ void* ACPI::FindTable(ACPI::SDTHeader* rootSDT, const char* signature)
|
||||
}
|
||||
if (!h)
|
||||
{
|
||||
kinfoln("Entry points to null");
|
||||
kwarnln("Entry %d in the %s points to null", i, isXSDT ? "XSDT" : "RSDT");
|
||||
continue;
|
||||
}
|
||||
kinfoln("Physical address of entry: %lx", (uint64_t)h);
|
||||
kdbgln("Physical address of entry: %lx", (uint64_t)h);
|
||||
SDTHeader* realHeader = (SDTHeader*)KernelMemoryManager::get_unaligned_mapping(h);
|
||||
kinfoln("Mapped entry to virtual address %lx", (uint64_t)realHeader);
|
||||
kdbgln("Mapped entry to virtual address %lx", (uint64_t)realHeader);
|
||||
if (!ValidateSDTHeader(realHeader))
|
||||
{
|
||||
kinfoln("Header is not valid, skipping this entry");
|
||||
kwarnln("Header of entry %d is not valid, skipping this entry", i);
|
||||
KernelMemoryManager::release_unaligned_mapping(realHeader);
|
||||
continue;
|
||||
}
|
||||
char tableSignature[5];
|
||||
memcpy(tableSignature, h->Signature, 4);
|
||||
tableSignature[4] = 0;
|
||||
kinfoln("Comparing target signature (%s) to signature of entry (%s)", signature, tableSignature);
|
||||
kdbgln("Comparing target signature (%s) to signature of entry (%s)", signature, tableSignature);
|
||||
if (strncmp(h->Signature, signature, 4) == 0)
|
||||
{
|
||||
kinfoln("Found table %s", signature);
|
||||
kdbgln("Found table %s", signature);
|
||||
return (void*)realHeader;
|
||||
}
|
||||
kinfoln("Signatures do not match, unmapping entry and continuing");
|
||||
kdbgln("Signatures do not match, unmapping entry and continuing");
|
||||
KernelMemoryManager::release_unaligned_mapping(realHeader);
|
||||
}
|
||||
|
||||
|
@ -42,6 +42,6 @@ void GDT::load()
|
||||
static GDTR gdtr;
|
||||
gdtr.offset = (uint64_t)&internal_gdt;
|
||||
gdtr.size = sizeof(InternalGDT);
|
||||
kinfoln("Loading GDT at offset %lx, size %d", gdtr.offset, gdtr.size);
|
||||
kdbgln("Loading GDT at offset %lx, size %d", gdtr.offset, gdtr.size);
|
||||
load_gdt(&gdtr);
|
||||
}
|
@ -50,6 +50,6 @@ void IDT::load()
|
||||
{
|
||||
idtr.limit = 0x0FFF;
|
||||
idtr.offset = (uint64_t)entries;
|
||||
kinfoln("Loading IDT at offset %lx, limit %d", idtr.offset, idtr.limit);
|
||||
kdbgln("Loading IDT at offset %lx, limit %d", idtr.offset, idtr.limit);
|
||||
asm("lidt %0" : : "m"(idtr));
|
||||
}
|
@ -54,7 +54,7 @@ extern "C"
|
||||
|
||||
void Interrupts::install()
|
||||
{
|
||||
kinfoln("Installing handler stubs for exceptions (ISRs 0-31)");
|
||||
kdbgln("Installing handler stubs for exceptions (ISRs 0-31)");
|
||||
INSTALL_TRAP(0);
|
||||
INSTALL_TRAP(1);
|
||||
INSTALL_TRAP(2);
|
||||
@ -87,7 +87,7 @@ void Interrupts::install()
|
||||
INSTALL_TRAP(29);
|
||||
INSTALL_TRAP(30);
|
||||
INSTALL_UNUSED(31);
|
||||
kinfoln("Installing handler stubs for IRQs (ISRs 32-47)");
|
||||
kdbgln("Installing handler stubs for IRQs (ISRs 32-47)");
|
||||
INSTALL_ISR(32);
|
||||
INSTALL_ISR(33);
|
||||
INSTALL_ISR(34);
|
||||
@ -104,8 +104,8 @@ void Interrupts::install()
|
||||
INSTALL_ISR(45);
|
||||
INSTALL_ISR(46);
|
||||
INSTALL_ISR(47);
|
||||
kinfoln("Installing handler stub for software interrupt 48");
|
||||
kdbgln("Installing handler stub for software interrupt 48");
|
||||
INSTALL_ISR(48);
|
||||
kinfoln("Installing unused handler stubs for the rest of the IDT");
|
||||
kdbgln("Installing unused handler stubs for the rest of the IDT");
|
||||
for (int i = 49; i < 256; i++) { INSTALL_UNUSED(i); }
|
||||
}
|
@ -16,7 +16,7 @@
|
||||
|
||||
void PIC::remap()
|
||||
{
|
||||
kinfoln("Remapping PIC");
|
||||
kdbgln("Remapping PIC");
|
||||
uint8_t a1, a2;
|
||||
|
||||
a1 = IO::inb(PIC1_DATA);
|
||||
@ -29,10 +29,10 @@ void PIC::remap()
|
||||
IO::outb(PIC2_COMMAND, ICW1_INIT | ICW1_ICW4);
|
||||
IO::delay();
|
||||
|
||||
kinfoln("Remapping master PIC to ISRs 32-39");
|
||||
kdbgln("Remapping master PIC to ISRs 32-39");
|
||||
IO::outb(PIC1_DATA, 0x20);
|
||||
IO::delay();
|
||||
kinfoln("Remapping slave PIC to ISRs 40-47");
|
||||
kdbgln("Remapping slave PIC to ISRs 40-47");
|
||||
IO::outb(PIC2_DATA, 0x28);
|
||||
IO::delay();
|
||||
|
||||
@ -53,13 +53,13 @@ void PIC::remap()
|
||||
|
||||
void PIC::enable_master(uint8_t mask)
|
||||
{
|
||||
kinfoln("Setting mask of master PIC to 0x%x", mask);
|
||||
kdbgln("Setting mask of master PIC to 0x%x", mask);
|
||||
IO::outb(PIC1_DATA, mask);
|
||||
}
|
||||
|
||||
void PIC::enable_slave(uint8_t mask)
|
||||
{
|
||||
kinfoln("Setting mask of slave PIC to 0x%x", mask);
|
||||
kdbgln("Setting mask of slave PIC to 0x%x", mask);
|
||||
IO::outb(PIC2_DATA, mask);
|
||||
}
|
||||
|
||||
|
@ -33,10 +33,10 @@ extern "C" void _start()
|
||||
|
||||
Memory::walk_memory_map();
|
||||
|
||||
kinfoln("System memory: %ld KB", Memory::get_system() / 1024);
|
||||
kinfoln(" Free memory : %ld KB", kernelPMM.get_free() / 1024);
|
||||
kinfoln(" Used memory : %ld KB", kernelPMM.get_used() / 1024);
|
||||
kinfoln(" Reserved memory : %ld KB", kernelPMM.get_reserved() / 1024);
|
||||
kdbgln("System memory: %ld KB", Memory::get_system() / 1024);
|
||||
kdbgln(" Free memory : %ld KB", kernelPMM.get_free() / 1024);
|
||||
kdbgln(" Used memory : %ld KB", kernelPMM.get_used() / 1024);
|
||||
kdbgln(" Reserved memory : %ld KB", kernelPMM.get_reserved() / 1024);
|
||||
|
||||
GDT::load();
|
||||
|
||||
|
@ -13,7 +13,7 @@
|
||||
|
||||
static void try_acpi_reboot()
|
||||
{
|
||||
kinfoln("Fetching pointer to RSDT/XSDT");
|
||||
kdbgln("Fetching pointer to RSDT/XSDT");
|
||||
ACPI::SDTHeader* rootSDT = ACPI::GetRSDTOrXSDT();
|
||||
if (!rootSDT)
|
||||
{
|
||||
@ -30,7 +30,7 @@ static void try_acpi_reboot()
|
||||
kwarnln("The RSDT/XSDT's signature is not RSDT or XSDT");
|
||||
return;
|
||||
}
|
||||
kinfoln("Searching for the FADT");
|
||||
kdbgln("Searching for the FADT");
|
||||
ACPI::FADT* fadt = (ACPI::FADT*)ACPI::FindTable(rootSDT, "FACP");
|
||||
if (!fadt)
|
||||
{
|
||||
@ -50,12 +50,12 @@ static void try_acpi_reboot()
|
||||
switch (fadt->ResetReg.AddressSpace)
|
||||
{
|
||||
case ACPI::SystemIO:
|
||||
kinfoln("Attempting ACPI Reset via SystemIO: sending byte %d to port %lx", fadt->ResetValue,
|
||||
kdbgln("Attempting ACPI Reset via SystemIO: sending byte %d to port %lx", fadt->ResetValue,
|
||||
fadt->ResetReg.Address);
|
||||
IO::outb(fadt->ResetReg.Address, fadt->ResetValue);
|
||||
break;
|
||||
case ACPI::GeneralPurposeIO:
|
||||
kinfoln("Attempting ACPI Reset via GeneralPurposeIO: sending byte %d to port %lx", fadt->ResetValue,
|
||||
kdbgln("Attempting ACPI Reset via GeneralPurposeIO: sending byte %d to port %lx", fadt->ResetValue,
|
||||
fadt->ResetReg.Address);
|
||||
IO::outb(fadt->ResetReg.Address, fadt->ResetValue);
|
||||
break;
|
||||
|
@ -12,7 +12,7 @@ uint16_t divisor = 65535;
|
||||
void PIT::initialize(uint64_t frequency)
|
||||
{
|
||||
divisor = base_frequency / frequency;
|
||||
kinfoln("Configuring PIT to use divisor %d (will tick %lu times per second)", divisor, frequency);
|
||||
kdbgln("Configuring PIT to use divisor %d (will tick %lu times per second)", divisor, frequency);
|
||||
if (divisor < 100) divisor = 100;
|
||||
IO::outb(PIT_CHANNEL_0_PORT, (uint8_t)(divisor & 0xFF));
|
||||
IO::delay();
|
||||
|
Loading…
Reference in New Issue
Block a user