X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=KernelLand%2FKernel%2Farch%2Fx86%2Facpica.c;h=43a185498d06fb2fe5ea37d67dd0097575bb5932;hb=df224fad82532507b2801670dbb83666b69539dc;hp=f310fc5b88f208264eb48dd33e4d22128e1ae09b;hpb=fd61b8c2f5e94da0265b3885525beff8e86317f6;p=tpg%2Facess2.git diff --git a/KernelLand/Kernel/arch/x86/acpica.c b/KernelLand/Kernel/arch/x86/acpica.c index f310fc5b..43a18549 100644 --- a/KernelLand/Kernel/arch/x86/acpica.c +++ b/KernelLand/Kernel/arch/x86/acpica.c @@ -5,7 +5,8 @@ * acpica.c * - ACPICA Interface */ -#define DEBUG 1 +#define ACPI_DEBUG_OUTPUT 1 +#define DEBUG 0 #define _AcpiModuleName "Shim" #define _COMPONENT "Acess" #include @@ -133,8 +134,13 @@ 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; + if( !ret ) { + Log_Notice("ACPICA", "%s: malloc() fail", __func__); + return AE_NO_MEMORY; + } ret->nObj = MaxDepth; ret->ObjectSize = ObjectSize; @@ -146,7 +152,7 @@ ACPI_STATUS AcpiOsCreateCache(char *CacheName, UINT16 ObjectSize, UINT16 MaxDept ret->Name[0] = 0; memset(ret->ObjectStates, 0, sizeof(char)*MaxDepth); - LOG("Allocated cache '%s' (%i x 0x%x)", CacheName, MaxDepth, ObjectSize); + LOG("Allocated cache %p '%s' (%i x 0x%x)", ret, CacheName, MaxDepth, ObjectSize); *ReturnCache = ret; @@ -174,15 +180,21 @@ 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; + memset(rv, 0, Cache->ObjectSize); + LEAVE('p', rv); + return rv; } } - // TODO + + Log_Debug("ACPICA", "AcpiOsAcquireObject: %i objects used", Cache->nObj); + + LEAVE('n'); return NULL; } @@ -193,8 +205,9 @@ ACPI_STATUS AcpiOsReleaseObject(ACPI_CACHE_T *Cache, void *Object) tVAddr delta = (tVAddr)Object - (tVAddr)Cache->First; delta /= Cache->ObjectSize; + LOG("Cache=%p, delta = %i, (limit %i)", Cache, delta, Cache->nObj); - if( delta > Cache->nObj ) + if( delta >= Cache->nObj ) return AE_BAD_PARAMETER; Cache->ObjectStates[delta] = 0; @@ -210,6 +223,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; } @@ -301,8 +315,10 @@ ACPI_STATUS AcpiOsCreateMutex(ACPI_MUTEX *OutHandle) if( !OutHandle ) return AE_BAD_PARAMETER; tMutex *ret = calloc( sizeof(tMutex), 1 ); - if( !ret ) + if( !ret ) { + Log_Notice("ACPICA", "%s: malloc() fail", __func__); return AE_NO_MEMORY; + } ret->Name = "AcpiOsCreateMutex"; *OutHandle = ret; @@ -336,8 +352,10 @@ ACPI_STATUS AcpiOsCreateSemaphore(UINT32 MaxUnits, UINT32 InitialUnits, ACPI_SEM if( !OutHandle ) return AE_BAD_PARAMETER; tSemaphore *ret = calloc( sizeof(tSemaphore), 1 ); - if( !ret ) + if( !ret ) { + Log_Notice("ACPICA", "%s: malloc() fail", __func__); return AE_NO_MEMORY; + } Semaphore_Init(ret, InitialUnits, MaxUnits, "AcpiOsCreateSemaphore", ""); *OutHandle = ret;