Remove mmu allocation and free
EFI should have ACPI regions mapped, and kernel does its own mapping Change-Id: I12a1ce625740dfe9751f2907ac462ef112b22645 Reviewed-on: https://review.haiku-os.org/c/haiku/+/3402 Reviewed-by: waddlesplash <waddlesplash@gmail.com> Reviewed-by: Rene Gollent <rene@gollent.com>
This commit is contained in:
parent
cb5156f081
commit
7b9ad03e70
@ -1,4 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
|
* Copyright 2020 Haiku, Inc. All rights reserved.
|
||||||
* Copyright 2014, Jessica Hamilton, jessica.l.hamilton@gmail.com.
|
* Copyright 2014, Jessica Hamilton, jessica.l.hamilton@gmail.com.
|
||||||
* Copyright 2011, Rene Gollent, rene@gollent.com.
|
* Copyright 2011, Rene Gollent, rene@gollent.com.
|
||||||
* Copyright 2008, Dustin Howett, dustin.howett@gmail.com. All rights reserved.
|
* Copyright 2008, Dustin Howett, dustin.howett@gmail.com. All rights reserved.
|
||||||
@ -69,7 +70,6 @@ acpi_validate_rsdp(acpi_rsdp* rsdp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static status_t
|
static status_t
|
||||||
acpi_validate_rsdt(acpi_descriptor_header* rsdt)
|
acpi_validate_rsdt(acpi_descriptor_header* rsdt)
|
||||||
{
|
{
|
||||||
@ -94,15 +94,11 @@ acpi_check_rsdt(acpi_rsdp* rsdp)
|
|||||||
rsdp, rsdp->oem_id, rsdp->revision));
|
rsdp, rsdp->oem_id, rsdp->revision));
|
||||||
TRACE(("acpi: rsdp points to rsdt at 0x%x\n", rsdp->rsdt_address));
|
TRACE(("acpi: rsdp points to rsdt at 0x%x\n", rsdp->rsdt_address));
|
||||||
|
|
||||||
uint32 length = 0;
|
|
||||||
acpi_descriptor_header* rsdt = NULL;
|
acpi_descriptor_header* rsdt = NULL;
|
||||||
if (rsdp->revision > 0) {
|
if (rsdp->revision > 0) {
|
||||||
length = rsdp->xsdt_length;
|
rsdt = (acpi_descriptor_header*)(addr_t)rsdp->xsdt_address;
|
||||||
rsdt = (acpi_descriptor_header*)mmu_map_physical_memory(
|
|
||||||
(uint32)rsdp->xsdt_address, rsdp->xsdt_length, kDefaultPageFlags);
|
|
||||||
if (rsdt != NULL
|
if (rsdt != NULL
|
||||||
&& strncmp(rsdt->signature, ACPI_XSDT_SIGNATURE, 4) != 0) {
|
&& strncmp(rsdt->signature, ACPI_XSDT_SIGNATURE, 4) != 0) {
|
||||||
mmu_free(rsdt, rsdp->xsdt_length);
|
|
||||||
rsdt = NULL;
|
rsdt = NULL;
|
||||||
TRACE(("acpi: invalid extended system description table\n"));
|
TRACE(("acpi: invalid extended system description table\n"));
|
||||||
} else
|
} else
|
||||||
@ -112,33 +108,24 @@ acpi_check_rsdt(acpi_rsdp* rsdp)
|
|||||||
// if we're ACPI v1 or we fail to map the XSDT for some reason,
|
// if we're ACPI v1 or we fail to map the XSDT for some reason,
|
||||||
// attempt to use the RSDT instead.
|
// attempt to use the RSDT instead.
|
||||||
if (rsdt == NULL) {
|
if (rsdt == NULL) {
|
||||||
// map and validate the root system description table
|
// validate the root system description table
|
||||||
rsdt = (acpi_descriptor_header*)mmu_map_physical_memory(
|
rsdt = (acpi_descriptor_header*)(addr_t)rsdp->rsdt_address;
|
||||||
rsdp->rsdt_address, sizeof(acpi_descriptor_header),
|
|
||||||
kDefaultPageFlags);
|
|
||||||
if (rsdt == NULL) {
|
if (rsdt == NULL) {
|
||||||
TRACE(("acpi: couldn't map rsdt header\n"));
|
TRACE(("acpi: couldn't map rsdt header\n"));
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
if (strncmp(rsdt->signature, ACPI_RSDT_SIGNATURE, 4) != 0) {
|
if (strncmp(rsdt->signature, ACPI_RSDT_SIGNATURE, 4) != 0) {
|
||||||
mmu_free(rsdt, sizeof(acpi_descriptor_header));
|
|
||||||
rsdt = NULL;
|
rsdt = NULL;
|
||||||
TRACE(("acpi: invalid root system description table\n"));
|
TRACE(("acpi: invalid root system description table\n"));
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
length = rsdt->length;
|
TRACE(("acpi: rsdt length: %u\n", 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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rsdt != NULL) {
|
if (rsdt != NULL) {
|
||||||
if (acpi_validate_rsdt(rsdt) != B_OK) {
|
if (acpi_validate_rsdt(rsdt) != B_OK) {
|
||||||
TRACE(("acpi: rsdt failed checksum validation\n"));
|
TRACE(("acpi: rsdt failed checksum validation\n"));
|
||||||
mmu_free(rsdt, length);
|
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
} else {
|
} else {
|
||||||
if (usingXsdt)
|
if (usingXsdt)
|
||||||
@ -164,9 +151,8 @@ acpi_find_table_generic(const char* signature, acpi_descriptor_header* acpiSdt)
|
|||||||
|
|
||||||
if (sNumEntries == -1) {
|
if (sNumEntries == -1) {
|
||||||
// if using the xsdt, our entries are 64 bits wide.
|
// if using the xsdt, our entries are 64 bits wide.
|
||||||
sNumEntries = (acpiSdt->length
|
sNumEntries = (acpiSdt->length - sizeof(acpi_descriptor_header))
|
||||||
- sizeof(acpi_descriptor_header))
|
/ sizeof(PointerType);
|
||||||
/ sizeof(PointerType);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sNumEntries <= 0) {
|
if (sNumEntries <= 0) {
|
||||||
@ -182,38 +168,19 @@ acpi_find_table_generic(const char* signature, acpi_descriptor_header* acpiSdt)
|
|||||||
|
|
||||||
acpi_descriptor_header* header = NULL;
|
acpi_descriptor_header* header = NULL;
|
||||||
for (int32 j = 0; j < sNumEntries; j++, pointer++) {
|
for (int32 j = 0; j < sNumEntries; j++, pointer++) {
|
||||||
header = (acpi_descriptor_header*)
|
header = (acpi_descriptor_header*)(addr_t)*pointer;
|
||||||
mmu_map_physical_memory((uint32)*pointer,
|
if (header != NULL && strncmp(header->signature, signature, 4) == 0) {
|
||||||
sizeof(acpi_descriptor_header), kDefaultPageFlags);
|
TRACE(("acpi: Found '%.4s' @ %p\n", signature, pointer));
|
||||||
|
return header;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TRACE(("acpi: Found '%.4s' @ %p\n", signature, pointer));
|
TRACE(("acpi: Looking for '%.4s'. Skipping '%.4s'\n",
|
||||||
break;
|
signature, header != NULL ? header->signature : "null"));
|
||||||
|
header = NULL;
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user