From 6b3047828bc2254ed5edb535e5316cf684e993b4 Mon Sep 17 00:00:00 2001 From: John Hodge Date: Fri, 3 May 2013 11:12:49 +0800 Subject: [PATCH] Kernel/acpica - Fiddling --- KernelLand/Kernel/arch/x86/acpica.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/KernelLand/Kernel/arch/x86/acpica.c b/KernelLand/Kernel/arch/x86/acpica.c index 15347892..a4a0bbc2 100644 --- a/KernelLand/Kernel/arch/x86/acpica.c +++ b/KernelLand/Kernel/arch/x86/acpica.c @@ -6,7 +6,7 @@ * - ACPICA Interface */ #define ACPI_DEBUG_OUTPUT 0 -#define DEBUG 0 +#define DEBUG 1 #define _AcpiModuleName "Shim" #define _COMPONENT "Acess" #include @@ -49,7 +49,6 @@ int ACPICA_Initialise(void) return -1; } - // AcpiInitializeTables? rv = AcpiLoadTables(); if( ACPI_FAILURE(rv) ) { @@ -134,6 +133,10 @@ 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); + if( ReturnCache == NULL || ObjectSize < 16) { + return AE_BAD_PARAMETER; + } + namelen = (namelen + 3) & ~3; ret = malloc(sizeof(*ret) + MaxDepth*sizeof(char) + namelen + MaxDepth*ObjectSize); @@ -151,7 +154,7 @@ ACPI_STATUS AcpiOsCreateCache(char *CacheName, UINT16 ObjectSize, UINT16 MaxDept else ret->Name[0] = 0; memset(ret->ObjectStates, 0, sizeof(char)*MaxDepth); - + LOG("Allocated cache %p '%s' (%i x 0x%x)", ret, CacheName, MaxDepth, ObjectSize); *ReturnCache = ret; @@ -185,11 +188,16 @@ ACPI_STATUS AcpiOsPurgeCache(ACPI_CACHE_T *Cache) void *AcpiOsAcquireObject(ACPI_CACHE_T *Cache) { ENTER("pCache", Cache); + LOG("Called by %p", __builtin_return_address(0)); for(int i = 0; i < Cache->nObj; i ++ ) { if( !Cache->ObjectStates[i] ) { Cache->ObjectStates[i] = 1; void *rv = (char*)Cache->First + i*Cache->ObjectSize; + if(!rv) { + LEAVE('n'); + return NULL; + } memset(rv, 0, Cache->ObjectSize); LEAVE('p', rv); return rv; @@ -213,8 +221,10 @@ ACPI_STATUS AcpiOsReleaseObject(ACPI_CACHE_T *Cache, void *Object) delta /= Cache->ObjectSize; LOG("Cache=%p, delta = %i, (limit %i)", Cache, delta, Cache->nObj); - if( delta >= Cache->nObj ) + if( delta >= Cache->nObj ) { + LEAVE('i', AE_BAD_PARAMETER); return AE_BAD_PARAMETER; + } Cache->ObjectStates[delta] = 0; @@ -339,6 +349,7 @@ ACPI_STATUS AcpiOsCreateMutex(ACPI_MUTEX *OutHandle) void AcpiOsDeleteMutex(ACPI_MUTEX Handle) { + // TODO: Need `Mutex_Destroy` Mutex_Acquire(Handle); free(Handle); } -- 2.20.1