From 6ef5f0ef3518b19cca649d46b5eb3ceab3eadaf1 Mon Sep 17 00:00:00 2001 From: Adrien Bourmault Date: Thu, 13 Feb 2020 13:40:07 +0100 Subject: [PATCH] Cleanup things --- include/io/acpi.h | 6 +++--- include/kernel.h | 1 + kaleid/kernel/init/init.c | 3 +-- kaleid/kernel/io/pci.c | 16 +++++----------- 4 files changed, 10 insertions(+), 16 deletions(-) diff --git a/include/io/acpi.h b/include/io/acpi.h index 3363a8a..7421859 100644 --- a/include/io/acpi.h +++ b/include/io/acpi.h @@ -70,7 +70,7 @@ struct SDTHeader_t { uint creatorID; uint creatorRevision; uint sdtEntry; -}; +} __attribute__ ((packed)); // // GAS type, used by ACPI tables to inform about registers @@ -82,7 +82,7 @@ struct GenericAddressStructure uchar offset; uchar accessSize; ulong address; -}; +} __attribute__ ((packed)); // // ACPI table types id @@ -192,7 +192,7 @@ struct FADT_t struct GenericAddressStructure xPMTimerBlock; struct GenericAddressStructure xGPE0Block; struct GenericAddressStructure xGPE1Block; -}; +} __attribute__ ((packed)); //----------------------------------------------------------------------------// diff --git a/include/kernel.h b/include/kernel.h index 09084d9..a8430ae 100644 --- a/include/kernel.h +++ b/include/kernel.h @@ -59,6 +59,7 @@ typedef struct ISRFrame_t ISRFrame_t; typedef struct RSDPDescriptor_t RSDPDescriptor_t; typedef struct SDTHeader_t SDTHeader_t; typedef struct FADT_t FADT_t; +typedef struct MCFG_t MCFG_t; typedef struct MemoryMap_t MemoryMap_t; typedef struct MapEntry_t MapEntry_t; diff --git a/kaleid/kernel/init/init.c b/kaleid/kernel/init/init.c index 981dd65..92cda93 100644 --- a/kaleid/kernel/init/init.c +++ b/kaleid/kernel/init/init.c @@ -35,11 +35,10 @@ #include #include #include +#include #include #include -#include - // // Entry point of the Kaleid kernel // diff --git a/kaleid/kernel/io/pci.c b/kaleid/kernel/io/pci.c index 94adb3c..7f5c66a 100644 --- a/kaleid/kernel/io/pci.c +++ b/kaleid/kernel/io/pci.c @@ -22,15 +22,15 @@ // along with OS/K. If not, see . // //----------------------------------------------------------------------------// - #include #include #include -void* pciConfigBaseAddress = NULL; +static void *pciConfigBaseAddress = NULL; +// -------------------------------------------------------------------------- // -static inline void* pciGetConfigAddr(uchar bus, uchar device, +static inline void* pciGetConfigAddr(uchar bus, uchar device, uchar function, ushort offset) { if(device > 32) { @@ -68,7 +68,6 @@ static inline uint pciReadConfigDWord(uchar bus, uchar device, return *((uint*)(pciGetConfigAddr(bus, device, function, offset))); } - //----------------------------------------------------------------------------// uchar IoPciReadConfigByte(PciDev_t *device, ushort offset) @@ -104,8 +103,6 @@ void IoPciWriteConfigDWord(PciDev_t *device, ushort offset, uint data) memmove((void *)((ulong)device->configAddr + offset), &data, 4); } - - void IoPciEnumerate() { if(pciConfigBaseAddress == NULL) { @@ -118,7 +115,7 @@ void IoPciEnumerate() for(uchar function = 0; function < 8; function++) { ushort vendor = pciReadConfigWord((uchar)bus, device, function, PCI_REG_VENDOR); if(vendor == 0xffff) continue; - DebugLog("PCI device found ! vendor: %x, device: %x\n", + DebugLog("PCI device vendor: %x, device: %x\n", vendor, pciReadConfigWord((uchar)bus, device, function, PCI_REG_DEVICE) ); @@ -153,7 +150,7 @@ PciDev_t *IoPciGetDevice(ushort vendorID, ushort deviceID) void IoInitPCI() { - struct MCFG_t *MCFG_table = (struct MCFG_t*)IoGetAcpiTable(SDT_MCFG); + MCFG_t *MCFG_table = (MCFG_t*)IoGetAcpiTable(SDT_MCFG); if(MCFG_table == NULL) { KeStartPanic("Unable to access PCI configuration : MCFG table not reachable\n"); } @@ -170,6 +167,3 @@ void IoInitPCI() PRESENT | READWRITE); } } - - -