[haiku-commits] Change in haiku[master]: Remove mmu allocation and free

  • From: Gerrit <review@xxxxxxxxxxxxxxxxxxx>
  • To: waddlesplash <waddlesplash@xxxxxxxxx>, haiku-commits@xxxxxxxxxxxxx
  • Date: Thu, 19 Nov 2020 18:01:41 +0000

From Fredrik Holmqvist <fredrik.holmqvist@xxxxxxxxx>:

Fredrik Holmqvist has uploaded this change for review. ( 
https://review.haiku-os.org/c/haiku/+/3402 ;)


Change subject: Remove mmu allocation and free
......................................................................

Remove mmu allocation and free

EFI should have ACPI regions mapped, and kernel does its own mapping
---
M src/system/boot/platform/efi/acpi.cpp
1 file changed, 16 insertions(+), 49 deletions(-)



  git pull ssh://git.haiku-os.org:22/haiku refs/changes/02/3402/1

diff --git a/src/system/boot/platform/efi/acpi.cpp 
b/src/system/boot/platform/efi/acpi.cpp
index 8056149..3b5a45f 100644
--- a/src/system/boot/platform/efi/acpi.cpp
+++ b/src/system/boot/platform/efi/acpi.cpp
@@ -1,4 +1,5 @@
 /*
+ * Copyright 2020 Haiku, Inc. All rights reserved.
  * Copyright 2014, Jessica Hamilton, jessica.l.hamilton@xxxxxxxxx.
  * Copyright 2011, Rene Gollent, rene@xxxxxxxxxxx.
  * Copyright 2008, Dustin Howett, dustin.howett@xxxxxxxxx. All rights reserved.
@@ -69,7 +70,6 @@
 }


-
 static status_t
 acpi_validate_rsdt(acpi_descriptor_header* rsdt)
 {
@@ -94,15 +94,11 @@
                rsdp, rsdp->oem_id, rsdp->revision));
        TRACE(("acpi: rsdp points to rsdt at 0x%x\n", rsdp->rsdt_address));

-       uint32 length = 0;
        acpi_descriptor_header* rsdt = NULL;
        if (rsdp->revision > 0) {
-               length = rsdp->xsdt_length;
-               rsdt = (acpi_descriptor_header*)mmu_map_physical_memory(
-                       (uint32)rsdp->xsdt_address, rsdp->xsdt_length, 
kDefaultPageFlags);
+               rsdt = (acpi_descriptor_header*)(addr_t)rsdp->xsdt_address;
                if (rsdt != NULL
                        && strncmp(rsdt->signature, ACPI_XSDT_SIGNATURE, 4) != 
0) {
-                       mmu_free(rsdt, rsdp->xsdt_length);
                        rsdt = NULL;
                        TRACE(("acpi: invalid extended system description 
table\n"));
                } else
@@ -112,33 +108,24 @@
        // if we're ACPI v1 or we fail to map the XSDT for some reason,
        // attempt to use the RSDT instead.
        if (rsdt == NULL) {
-               // map and validate the root system description table
-               rsdt = (acpi_descriptor_header*)mmu_map_physical_memory(
-                       rsdp->rsdt_address, sizeof(acpi_descriptor_header),
-                       kDefaultPageFlags);
+               // validate the root system description table
+               rsdt = (acpi_descriptor_header*)(addr_t)rsdp->rsdt_address;
                if (rsdt == NULL) {
                        TRACE(("acpi: couldn't map rsdt header\n"));
                        return B_ERROR;
                }
                if (strncmp(rsdt->signature, ACPI_RSDT_SIGNATURE, 4) != 0) {
-                       mmu_free(rsdt, sizeof(acpi_descriptor_header));
                        rsdt = NULL;
                        TRACE(("acpi: invalid root system description 
table\n"));
                        return B_ERROR;
                }

-               length = rsdt->length;
-               // Map the whole table, not just the header
-               TRACE(("acpi: rsdt length: %u\n", length));
-               mmu_free(rsdt, sizeof(acpi_descriptor_header));
-               rsdt = (acpi_descriptor_header*)mmu_map_physical_memory(
-                       rsdp->rsdt_address, length, kDefaultPageFlags);
+               TRACE(("acpi: rsdt length: %u\n", rsdt->length));
        }

        if (rsdt != NULL) {
                if (acpi_validate_rsdt(rsdt) != B_OK) {
                        TRACE(("acpi: rsdt failed checksum validation\n"));
-                       mmu_free(rsdt, length);
                        return B_ERROR;
                } else {
                        if (usingXsdt)
@@ -164,9 +151,8 @@

        if (sNumEntries == -1) {
                // if using the xsdt, our entries are 64 bits wide.
-               sNumEntries = (acpiSdt->length
-                       - sizeof(acpi_descriptor_header))
-                               / sizeof(PointerType);
+               sNumEntries = (acpiSdt->length - sizeof(acpi_descriptor_header))
+                       / sizeof(PointerType);
        }

        if (sNumEntries <= 0) {
@@ -182,38 +168,19 @@

        acpi_descriptor_header* header = NULL;
        for (int32 j = 0; j < sNumEntries; j++, pointer++) {
-               header = (acpi_descriptor_header*)
-                       mmu_map_physical_memory((uint32)*pointer,
-                               sizeof(acpi_descriptor_header), 
kDefaultPageFlags);
-
-               if (header == NULL
-                       || strncmp(header->signature, signature, 4) != 0) {
-                       // not interesting for us
-                       TRACE(("acpi: Looking for '%.4s'. Skipping '%.4s'\n",
-                               signature, header != NULL ? header->signature : 
"null"));
-
-                       if (header != NULL) {
-                               mmu_free(header, 
sizeof(acpi_descriptor_header));
-                               header = NULL;
-                       }
-
-                       continue;
+               header = (acpi_descriptor_header*)(addr_t)*pointer;
+               if (header != NULL && strncmp(header->signature, signature, 4) 
== 0) {
+                       TRACE(("acpi: Found '%.4s' @ %p\n", signature, 
pointer));
+                       return header;
                }

-               TRACE(("acpi: Found '%.4s' @ %p\n", signature, pointer));
-               break;
+               TRACE(("acpi: Looking for '%.4s'. Skipping '%.4s'\n",
+                       signature, header != NULL ? header->signature : 
"null"));
+               header = NULL;
+               continue;
        }

-
-       if (header == NULL)
-               return NULL;
-
-       // Map the whole table, not just the header
-       uint32 length = header->length;
-       mmu_free(header, sizeof(acpi_descriptor_header));
-
-       return (acpi_descriptor_header*)mmu_map_physical_memory(
-               (uint32)*pointer, length, kDefaultPageFlags);
+       return NULL;
 }

 

--
To view, visit https://review.haiku-os.org/c/haiku/+/3402
To unsubscribe, or for help writing mail filters, visit 
https://review.haiku-os.org/settings

Gerrit-Project: haiku
Gerrit-Branch: master
Gerrit-Change-Id: I12a1ce625740dfe9751f2907ac462ef112b22645
Gerrit-Change-Number: 3402
Gerrit-PatchSet: 1
Gerrit-Owner: Fredrik Holmqvist <fredrik.holmqvist@xxxxxxxxx>
Gerrit-MessageType: newchange

Other related posts:

  • » [haiku-commits] Change in haiku[master]: Remove mmu allocation and free - Gerrit