diff options
author | Damien Zammit <damien@zamaudio.com> | 2020-04-25 19:21:41 +1000 |
---|---|---|
committer | Damien Zammit <damien@zamaudio.com> | 2020-04-25 19:21:41 +1000 |
commit | af0233e39fc31defb07caa9caf5e8a2486bfc3ea (patch) | |
tree | 7c25cb2917c5e27abe01b7d5d5b2edbf1214dde1 | |
parent | 15ebb5a3e4ea5fd4d7f320c2c7399e38160feb15 (diff) |
acpica: Add debug && fix memory mapping of tables
-rw-r--r-- | acpica/acpi_init.c | 42 | ||||
-rw-r--r-- | acpica/src/include/acpi/platform/acgnu.h | 2 |
2 files changed, 19 insertions, 25 deletions
diff --git a/acpica/acpi_init.c b/acpica/acpi_init.c index b25832bd..669d306d 100644 --- a/acpica/acpi_init.c +++ b/acpica/acpi_init.c @@ -1,13 +1,12 @@ #include "acpi_init.h" #include <kern/timer.h> // clock #include <kern/printf.h> // *printf -#include <vm/pmap.h> // vremap hack #include <vm/vm_kern.h> // kmem_alloc_wired #include <mach/vm_param.h> // kmem_cache #include <i386/pio.h> #define MACH_INCLUDE #include <linux/delay.h> // udelay -#include <linux/kernel.h> // printk +#include <linux/kernel.h> // printk && vremap/vfree #define ACPI_MAX_TABLES 128 @@ -68,22 +67,6 @@ isprint(char c) return ((c <= 126) && (c >= 32)); } -static void * -pmap_hack (unsigned long offset, unsigned long size) -{ - vm_offset_t addr; - kern_return_t ret; - - ret = kmem_alloc_wired (kernel_map, &addr, round_page (size)); - if (ret != KERN_SUCCESS) - return NULL; - - (void) pmap_map_bd (addr, offset, offset + round_page (size), - VM_PROT_READ | VM_PROT_WRITE); - - return (void *) addr; -} - void acpi_ds_dump_method_stack(acpi_status status, ...) // struct acpi_walk_state *walk_state, @@ -195,7 +178,13 @@ acpi_os_get_timer(void) void * acpi_os_map_memory(acpi_physical_address phys, acpi_size size) { - return pmap_hack (phys, size); + ptrdiff_t into_page = phys % PAGE_SIZE; + uintptr_t nearest_page = (uintptr_t)trunc_page(phys); + void *ret = vremap (nearest_page, size + into_page); + if (!ret) { + acpi_os_printf("Can't map memory 0x%llx\n", phys); + } + return ret + into_page; } acpi_status @@ -267,7 +256,12 @@ acpi_os_table_override(struct acpi_table_header *existing_table, void acpi_os_unmap_memory(void *virt, acpi_size size) { - return; + void *freeme = (void *)trunc_page(virt); + if (!freeme) { + acpi_os_printf("Nothing to unmap\n"); + return; + } + //FIXME crashes: vfree (freeme); } static int @@ -301,7 +295,7 @@ acpi_os_read_memory(acpi_physical_address phys_addr, u64 *value, u32 width) u64 dummy; acpi_status err = AE_BAD_ADDRESS; - virt_addr = vremap (phys_addr, size); + virt_addr = acpi_os_map_memory (phys_addr, size); if (!virt_addr) return err; @@ -311,7 +305,7 @@ acpi_os_read_memory(acpi_physical_address phys_addr, u64 *value, u32 width) if (!acpi_os_read_iomem (virt_addr, value, width)) err = AE_OK; - //munmap (virt_addr, size); + acpi_os_unmap_memory (virt_addr, size); return err; } @@ -353,7 +347,7 @@ acpi_os_write_memory(acpi_physical_address phys_addr, u64 value, u32 width) unsigned int size = width / 8; acpi_status err = AE_OK; - virt_addr = vremap (phys_addr, size); + virt_addr = acpi_os_map_memory (phys_addr, size); if (!virt_addr) return AE_BAD_ADDRESS; @@ -376,7 +370,7 @@ acpi_os_write_memory(acpi_physical_address phys_addr, u64 value, u32 width) break; } - //munmap (virt_addr, size); + acpi_os_unmap_memory (virt_addr, size); return err; } diff --git a/acpica/src/include/acpi/platform/acgnu.h b/acpica/src/include/acpi/platform/acgnu.h index cf53e634..5cd65d0d 100644 --- a/acpica/src/include/acpi/platform/acgnu.h +++ b/acpica/src/include/acpi/platform/acgnu.h @@ -36,7 +36,7 @@ #undef ACPI_NO_MEM_ALLOCATIONS #undef ACPI_NO_ERROR_MESSAGES -#undef ACPI_DEBUG_OUTPUT +#define ACPI_DEBUG_OUTPUT #endif /* CONFIG_ACPI */ |