Usermode/libc - Fix strchr and strrchr behavior
[tpg/acess2.git] / KernelLand / Kernel / arch / x86 / acpica.c
index 726feb7..5603add 100644 (file)
@@ -118,6 +118,7 @@ ACPI_STATUS AcpiOsPhysicalTableOverride(ACPI_TABLE_HEADER *ExisitingTable, ACPI_
 }
 
 // -- Memory Management ---
+#if USE_ACESS_ACPI_CACHE
 struct sACPICache
 {
        Uint16  nObj;
@@ -231,15 +232,18 @@ ACPI_STATUS AcpiOsReleaseObject(ACPI_CACHE_T *Cache, void *Object)
        LEAVE('i', AE_OK);
        return AE_OK;
 }
+#endif
 
 void *AcpiOsMapMemory(ACPI_PHYSICAL_ADDRESS PhysicalAddress, ACPI_SIZE Length)
 {
-       if( PhysicalAddress < ONEMEG )
+       if( PhysicalAddress < ONEMEG ) {
+               ASSERTCR(Length, <=, ONEMEG-PhysicalAddress, NULL);
                return (void*)(KERNEL_BASE | PhysicalAddress);
+       }
        
        Uint    ofs = PhysicalAddress & (PAGE_SIZE-1);
        int npages = (ofs + Length + (PAGE_SIZE-1)) / PAGE_SIZE;
-       char *maploc = (void*)MM_MapHWPages(PhysicalAddress, npages);
+       char *maploc = MM_MapHWPages(PhysicalAddress, npages);
        if(!maploc) {
                LOG("Mapping %P+0x%x failed", PhysicalAddress, Length);
                return NULL;
@@ -252,15 +256,16 @@ void *AcpiOsMapMemory(ACPI_PHYSICAL_ADDRESS PhysicalAddress, ACPI_SIZE Length)
 
 void AcpiOsUnmapMemory(void *LogicalAddress, ACPI_SIZE Length)
 {
-       if( (tVAddr)LogicalAddress - KERNEL_BASE < ONEMEG )
+       if( (tVAddr)LogicalAddress - KERNEL_BASE < ONEMEG ) {
                return ;
+       }
 
        LOG("%p", LogicalAddress);
 
        Uint    ofs = (tVAddr)LogicalAddress & (PAGE_SIZE-1);
        int npages = (ofs + Length + (PAGE_SIZE-1)) / PAGE_SIZE;
        // TODO: Validate `Length` is the same as was passed to AcpiOsMapMemory
-       MM_UnmapHWPages( (tVAddr)LogicalAddress, npages);
+       MM_UnmapHWPages( LogicalAddress, npages);
 }
 
 ACPI_STATUS AcpiOsGetPhysicalAddress(void *LogicalAddress, ACPI_PHYSICAL_ADDRESS *PhysicalAddress)
@@ -531,6 +536,8 @@ ACPI_STATUS AcpiOsReadMemory(ACPI_PHYSICAL_ADDRESS Address, UINT64 *Value, UINT3
                MM_FreeTemp(ptr);
        }
 
+       LOG("*%P = [%i]%X", Address, Width, *Value);
+
        return AE_OK;
 }
 
@@ -554,7 +561,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);
        }
        

UCC git Repository :: git.ucc.asn.au