X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=KernelLand%2FKernel%2Farch%2Fx86%2Facpica.c;h=433feaac97dec9574b185c4b8837943afef6663b;hb=2462d860630674d10d554f86aa669163f6f2db6b;hp=153478923e2964ced7d674c68a3d4e67e4c61cd6;hpb=faad72a08c4bbd6b3b536c6c9b5201a203d45889;p=tpg%2Facess2.git diff --git a/KernelLand/Kernel/arch/x86/acpica.c b/KernelLand/Kernel/arch/x86/acpica.c index 15347892..433feaac 100644 --- a/KernelLand/Kernel/arch/x86/acpica.c +++ b/KernelLand/Kernel/arch/x86/acpica.c @@ -49,7 +49,6 @@ int ACPICA_Initialise(void) return -1; } - // AcpiInitializeTables? rv = AcpiLoadTables(); if( ACPI_FAILURE(rv) ) { @@ -119,6 +118,7 @@ ACPI_STATUS AcpiOsPhysicalTableOverride(ACPI_TABLE_HEADER *ExisitingTable, ACPI_ } // -- Memory Management --- +#if USE_ACESS_ACPI_CACHE struct sACPICache { Uint16 nObj; @@ -134,6 +134,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 +155,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 +189,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,14 +222,17 @@ 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; LEAVE('i', AE_OK); return AE_OK; } +#endif void *AcpiOsMapMemory(ACPI_PHYSICAL_ADDRESS PhysicalAddress, ACPI_SIZE Length) { @@ -339,6 +351,7 @@ ACPI_STATUS AcpiOsCreateMutex(ACPI_MUTEX *OutHandle) void AcpiOsDeleteMutex(ACPI_MUTEX Handle) { + // TODO: Need `Mutex_Destroy` Mutex_Acquire(Handle); free(Handle); } @@ -520,6 +533,8 @@ ACPI_STATUS AcpiOsReadMemory(ACPI_PHYSICAL_ADDRESS Address, UINT64 *Value, UINT3 MM_FreeTemp(ptr); } + LOG("*%P = [%i]%X", Address, Width, *Value); + return AE_OK; } @@ -543,7 +558,7 @@ ACPI_STATUS AcpiOsWriteMemory(ACPI_PHYSICAL_ADDRESS Address, UINT64 Value, UINT3 return AE_BAD_PARAMETER; } - if( Address >= 1024*1024 ) { + if( Address >= ONEMEG ) { MM_FreeTemp(ptr); }