summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--acpi/acpi.c25
1 files changed, 8 insertions, 17 deletions
diff --git a/acpi/acpi.c b/acpi/acpi.c
index 63066aaf..ad0c55ca 100644
--- a/acpi/acpi.c
+++ b/acpi/acpi.c
@@ -30,7 +30,7 @@
#include "acpi.h"
-int
+static int
mmap_phys_acpi_header(uintptr_t base_addr, struct acpi_header **ptr_to_header,
void **virt_addr, int fd)
{
@@ -263,28 +263,19 @@ acpi_get_tables(struct acpi_table **tables)
munmap(virt_addr2, ESCD_SIZE);
continue;
}
- uint32_t datalen = next->length - sizeof(*next);
- void *data = (void *)((uintptr_t)next + sizeof(*next));
+ size_t datalen = next->length - sizeof(*next);
+ void *data = (void *)next + sizeof(*next);
+ struct acpi_table *t = *tables + cur_tab;
- /* We now have a pointer to the data,
- * its length and header.
+ /* We now have a special pointer in data to the table,
+ * its length and header, which will only disappear
+ * when this process dies.
*/
- struct acpi_table *t = *tables + cur_tab;
memcpy(&t->h, next, sizeof(*next));
- t->datalen = 0;
- t->data = malloc(datalen);
- if (!t->data) {
- munmap(virt_addr2, ESCD_SIZE);
- munmap(virt_addr, ESCD_SIZE);
- return ENOMEM;
- }
t->datalen = datalen;
- memcpy(t->data, data, datalen);
+ t->data = data;
cur_tab++;
- munmap(virt_addr2, ESCD_SIZE);
}
- munmap(virt_addr, ESCD_SIZE);
-
return 0;
}