From de5d5c2a1e87c1bff8ff6384b6b68d89f437f188 Mon Sep 17 00:00:00 2001 From: Sebastian Sumpf Date: Fri, 17 Aug 2012 15:19:01 +0200 Subject: [PATCH] ACPI: Fix offsets when mapping I/O mem Fixes #309 --- os/src/drivers/acpi/acpi.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/os/src/drivers/acpi/acpi.cc b/os/src/drivers/acpi/acpi.cc index 6f4970ee9..5e785f0dc 100644 --- a/os/src/drivers/acpi/acpi.cc +++ b/os/src/drivers/acpi/acpi.cc @@ -127,7 +127,7 @@ class Table_wrapper */ void _map(size_t size) { - _io_mem = new (env()->heap()) Io_mem_connection(_base, size + _offset()); + _io_mem = new (env()->heap()) Io_mem_connection(_base - _offset(), size + _offset()); Io_mem_dataspace_capability io_ds = _io_mem->dataspace(); if (!io_ds.valid()) throw -1; @@ -206,7 +206,11 @@ class Table_wrapper Table_wrapper(addr_t base) : _base(base), _io_mem(0), _table(0) { - _map(0x1000); + /* + * Try to map one page only, if table is on page boundary, map two pages + */ + size_t map_size = 0x1000 - _offset(); + _map(map_size < 8 ? 0x1000 : map_size); /* remap if table size is larger than current size */ if (_offset() + _table->size > 0x1000) {