From a4287f02e53f0c32d1d3c5a51e534f4c08c756dc Mon Sep 17 00:00:00 2001 From: Adrien Bourmault Date: Thu, 13 Feb 2020 13:06:18 +0100 Subject: [PATCH] Some cosmetics, add panic when necessary --- kaleid/kernel/init/init.c | 10 +--------- kaleid/kernel/io/acpi.c | 12 ++++-------- kaleid/kernel/io/pci.c | 18 +++++++++--------- 3 files changed, 14 insertions(+), 26 deletions(-) diff --git a/kaleid/kernel/init/init.c b/kaleid/kernel/init/init.c index a3a0a4e..981dd65 100644 --- a/kaleid/kernel/init/init.c +++ b/kaleid/kernel/init/init.c @@ -86,16 +86,8 @@ noreturn void BtStartKern(multiboot_info_t *mbInfo, uint mbMagic, void *codeSeg) // ACPI IoInitAcpi(); - // PCI + // PCI express IoInitPCI(); - - // Test RTL8139 - PciDev_t *rtl8139_pciDev = IoPciGetDevice(0x10EC, 0x8139); - if(rtl8139_pciDev != NULL) - { - DebugLog("Network card RTL8139 found ! PCI config addr = %p\n", - rtl8139_pciDev->configAddr); - } // Scheduler PsInitSched(); diff --git a/kaleid/kernel/io/acpi.c b/kaleid/kernel/io/acpi.c index 6448fe0..bae24da 100644 --- a/kaleid/kernel/io/acpi.c +++ b/kaleid/kernel/io/acpi.c @@ -169,16 +169,14 @@ static inline void IoInitRXSDT(void) KeStartPanic("Invalid RSDT checksum : %d vs 0", checksum); if (IoACPIVersion == 1) { - DebugLog("ACPI Root System Table %s (%s) length %d [%p]\n", + DebugLog("ACPI Root System Table %s length %d [%p]\n", rxsdt->signature, - rxsdt->OEMID, rxsdt->length, rxsdt ); } else { - DebugLog("ACPI Extended System Table %s (%s) length %d [%p]\n", + DebugLog("ACPI Extended System Table %s length %d [%p]\n", rxsdt->signature, - rxsdt->OEMID, rxsdt->length, rxsdt ); @@ -222,9 +220,8 @@ static inline void IoSearchAcpiTables(void) if (!checksum) { for (ulong i=0; i < N_SDT_TYPES; i++) { if (!strncmp(table->signature, SDTChar[i], 4)) { - DebugLog("ACPI System Table %s (OEM %s) length %d [%p]\n", + DebugLog("ACPI System Table %s length %d [%p]\n", SDTChar[i], - table->OEMID, table->length, table ); @@ -248,9 +245,8 @@ static inline void IoSearchAcpiTables(void) checksum = DoChecksum(dsdt, (size_t)dsdt->length, 0, 0); if (!checksum) { if (!strncmp(dsdt->signature, SDTChar[SDT_DSDT], 4)) { - DebugLog("ACPI System Table %s (OEM %s) length %d [%p]\n", + DebugLog("ACPI System Table %s length %d [%p]\n", SDTChar[SDT_DSDT], - dsdt->OEMID, dsdt->length, dsdt ); diff --git a/kaleid/kernel/io/pci.c b/kaleid/kernel/io/pci.c index 6e05afd..94adb3c 100644 --- a/kaleid/kernel/io/pci.c +++ b/kaleid/kernel/io/pci.c @@ -34,15 +34,15 @@ static inline void* pciGetConfigAddr(uchar bus, uchar device, uchar function, ushort offset) { if(device > 32) { - KernLog("pciGetConfigAddr(): bad device ID\n"); + DebugLog("pciGetConfigAddr(): bad device ID\n"); return 0; } if(function > 8) { - KernLog("pciGetConfigAddr(): bad function ID\n"); + DebugLog("pciGetConfigAddr(): bad function ID\n"); return 0; } if(offset > 4096) { - KernLog("pciGetConfigAddr(): bad register offset\n"); + DebugLog("pciGetConfigAddr(): bad register offset\n"); return 0; } @@ -109,7 +109,7 @@ void IoPciWriteConfigDWord(PciDev_t *device, ushort offset, uint data) void IoPciEnumerate() { if(pciConfigBaseAddress == NULL) { - KernLog("Unable to access PCI configuration : MCFG table not reachable\n"); + KeStartPanic("Unable to access PCI configuration : MCFG table not reachable\n"); return; } @@ -130,7 +130,7 @@ void IoPciEnumerate() PciDev_t *IoPciGetDevice(ushort vendorID, ushort deviceID) { if(pciConfigBaseAddress == NULL) { - KernLog("Unable to access PCI configuration : MCFG table not reachable\n"); + KeStartPanic("Unable to access PCI configuration : MCFG table not reachable\n"); return NULL; } @@ -155,7 +155,7 @@ void IoInitPCI() { struct MCFG_t *MCFG_table = (struct MCFG_t*)IoGetAcpiTable(SDT_MCFG); if(MCFG_table == NULL) { - KernLog("Unable to access PCI configuration : MCFG table not reachable\n"); + KeStartPanic("Unable to access PCI configuration : MCFG table not reachable\n"); } pciConfigBaseAddress = MCFG_table->pciConfigBaseAddress; DebugLog("PCI Config Base address = 0x%p\n", pciConfigBaseAddress); @@ -165,9 +165,9 @@ void IoInitPCI() // Give R/W access to the configuration space for(int i=0; i < 65536; i++) // 65536 = 256 * 32 * 8 { - // 4096 for page size TODO: use of KPAGESIZE - MmMapPage((void *)((ulong)pciConfigBaseAddress + i * 4096), - (void *)((ulong)pciConfigBaseAddress + i * 4096), PRESENT | READWRITE); + MmMapPage((void *)((ulong)pciConfigBaseAddress + i * KPAGESIZE), + (void *)((ulong)pciConfigBaseAddress + i * KPAGESIZE), + PRESENT | READWRITE); } }