From 802193677c6d85b31030bba5950cb667ff064415 Mon Sep 17 00:00:00 2001 From: "John Hodge (sonata)" Date: Sun, 9 Dec 2012 13:02:34 +0800 Subject: [PATCH] Kernel/x86 - Added USE_ACPICA makefile variable to easily enable/disable --- KernelLand/Kernel/arch/x86/Makefile | 9 ++++++--- KernelLand/Kernel/arch/x86/acpica.c | 14 +++++++++++--- KernelLand/Kernel/arch/x86/desctab.asm | 2 +- KernelLand/Kernel/arch/x86/main.c | 6 ++++-- 4 files changed, 22 insertions(+), 9 deletions(-) diff --git a/KernelLand/Kernel/arch/x86/Makefile b/KernelLand/Kernel/arch/x86/Makefile index 9e5a883c..a9368f4b 100644 --- a/KernelLand/Kernel/arch/x86/Makefile +++ b/KernelLand/Kernel/arch/x86/Makefile @@ -9,6 +9,7 @@ CPPFLAGS = CFLAGS = ASFLAGS = -f elf +USE_ACPICA ?= 1 USE_MP=0 ifeq ($(PLATFORM),default) @@ -18,13 +19,15 @@ else ifeq ($(PLATFORM),smp) endif ASFLAGS += -D USE_MP=$(USE_MP) -CPPFLAGS += -DUSE_MP=$(USE_MP) +CPPFLAGS += -DUSE_MP=$(USE_MP) -DUSE_ACPICA=$(USE_ACPICA) A_OBJ = start.ao main.o mboot.o lib.o desctab.ao errors.o irq.o A_OBJ += mm_phys.o mm_virt.o A_OBJ += proc.o proc.ao time.o vm8086.o A_OBJ += kpanic.o pci.o vpci.o -#A_OBJ += acpica.o -#EXTERNS += ACPICA +ifeq ($(USE_ACPICA),1) +A_OBJ += acpica.o +EXTERNS += ACPICA +endif diff --git a/KernelLand/Kernel/arch/x86/acpica.c b/KernelLand/Kernel/arch/x86/acpica.c index f310fc5b..7bbe1cd5 100644 --- a/KernelLand/Kernel/arch/x86/acpica.c +++ b/KernelLand/Kernel/arch/x86/acpica.c @@ -5,6 +5,7 @@ * acpica.c * - ACPICA Interface */ +#define ACPI_DEBUG_OUTPUT 1 #define DEBUG 1 #define _AcpiModuleName "Shim" #define _COMPONENT "Acess" @@ -133,6 +134,8 @@ ACPI_STATUS AcpiOsCreateCache(char *CacheName, UINT16 ObjectSize, UINT16 MaxDept int namelen = (CacheName ? strlen(CacheName) : 0) + 1; LOG("CacheName=%s, ObjSize=%x, MaxDepth=%x", CacheName, ObjectSize, MaxDepth); + namelen = (namelen + 3) & ~3; + ret = malloc(sizeof(*ret) + MaxDepth*sizeof(char) + namelen + MaxDepth*ObjectSize); if( !ret ) return AE_NO_MEMORY; @@ -174,15 +177,18 @@ ACPI_STATUS AcpiOsPurgeCache(ACPI_CACHE_T *Cache) void *AcpiOsAcquireObject(ACPI_CACHE_T *Cache) { - LOG("(Cache=%p)", Cache); + ENTER("pCache", Cache); for(int i = 0; i < Cache->nObj; i ++ ) { if( !Cache->ObjectStates[i] ) { Cache->ObjectStates[i] = 1; - return (char*)Cache->First + i*Cache->ObjectSize; + void *rv = (char*)Cache->First + i*Cache->ObjectSize; + LEAVE('p', rv); + return rv; } } - // TODO + + LEAVE('n'); return NULL; } @@ -193,6 +199,7 @@ ACPI_STATUS AcpiOsReleaseObject(ACPI_CACHE_T *Cache, void *Object) tVAddr delta = (tVAddr)Object - (tVAddr)Cache->First; delta /= Cache->ObjectSize; + LOG("delta = %i, (limit %i)", delta, Cache->nObj); if( delta > Cache->nObj ) return AE_BAD_PARAMETER; @@ -210,6 +217,7 @@ void *AcpiOsMapMemory(ACPI_PHYSICAL_ADDRESS PhysicalAddress, ACPI_SIZE Length) Uint ofs = PhysicalAddress & (PAGE_SIZE-1); int npages = (ofs + Length + (PAGE_SIZE-1)) / PAGE_SIZE; void *rv = ((char*)MM_MapHWPages(PhysicalAddress, npages)) + ofs; +// MM_DumpTables(0, -1); LOG("Map (%P+%i pg) to %p", PhysicalAddress, npages, rv); return rv; } diff --git a/KernelLand/Kernel/arch/x86/desctab.asm b/KernelLand/Kernel/arch/x86/desctab.asm index 6eaa651a..18ed10d3 100644 --- a/KernelLand/Kernel/arch/x86/desctab.asm +++ b/KernelLand/Kernel/arch/x86/desctab.asm @@ -215,7 +215,7 @@ Isr240.jmp: %endif ; - Assignable %assign i 0xF1 -%rep 16 +%rep 15 DEF_IRQ i %assign i i+1 %endrep diff --git a/KernelLand/Kernel/arch/x86/main.c b/KernelLand/Kernel/arch/x86/main.c index 8f36f47c..3abf5482 100644 --- a/KernelLand/Kernel/arch/x86/main.c +++ b/KernelLand/Kernel/arch/x86/main.c @@ -24,7 +24,7 @@ extern void MM_PreinitVirtual(void); extern void MM_Install(int NPMemRanges, tPMemMapEnt *PMemRanges); extern void MM_InstallVirtual(void); extern int Time_Setup(void); -//extern int ACPICA_Initialise(void); +extern int ACPICA_Initialise(void); // === PROTOTYPES === int kmain(Uint MbMagic, void *MbInfoPtr); @@ -85,8 +85,10 @@ int kmain(Uint MbMagic, void *MbInfoPtr) // Start Multitasking Threads_Init(); + #if USE_ACPICA // Poke ACPICA -// ACPICA_Initialise(); + ACPICA_Initialise(); + #endif Log_Log("Arch", "Starting VFS..."); // Load Virtual Filesystem -- 2.20.1