mirror of
https://github.com/genodelabs/genode.git
synced 2025-02-21 02:01:38 +00:00
parent
5f25718e8c
commit
1cfeb41f14
@ -11,7 +11,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2009-2016 Genode Labs GmbH
|
||||
* Copyright (C) 2009-2017 Genode Labs GmbH
|
||||
*
|
||||
* This file is part of the Genode OS framework, which is distributed
|
||||
* under the terms of the GNU General Public License version 2.
|
||||
@ -24,7 +24,6 @@
|
||||
|
||||
/* os includes */
|
||||
#include <os/reporter.h>
|
||||
#include <os/attached_rom_dataspace.h>
|
||||
|
||||
#include "acpi.h"
|
||||
#include "memory.h"
|
||||
@ -291,12 +290,6 @@ class Pci_config_space : public List<Pci_config_space>::Element
|
||||
};
|
||||
|
||||
|
||||
static Acpi::Memory & acpi_memory()
|
||||
{
|
||||
static Acpi::Memory _memory;
|
||||
return _memory;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* ACPI table wrapper that for mapping tables to this address space
|
||||
@ -422,17 +415,18 @@ class Table_wrapper
|
||||
Dmar_entry::list()->insert(new (&alloc) Dmar_entry(head->clone(alloc)));
|
||||
}
|
||||
|
||||
Table_wrapper(addr_t base) : _base(base), _table(0)
|
||||
Table_wrapper(Acpi::Memory &memory, addr_t base)
|
||||
: _base(base), _table(0)
|
||||
{
|
||||
/* if table is on page boundary, map two pages, otherwise one page */
|
||||
size_t const map_size = 0x1000UL - _offset() < 8 ? 0x1000UL : 1UL;
|
||||
|
||||
/* make table header accessible */
|
||||
_table = reinterpret_cast<Generic *>(acpi_memory().phys_to_virt(base, map_size));
|
||||
_table = reinterpret_cast<Generic *>(memory.phys_to_virt(base, map_size));
|
||||
|
||||
/* table size is known now - make it complete accessible */
|
||||
if (_offset() + _table->size > 0x1000UL)
|
||||
acpi_memory().phys_to_virt(base, _table->size);
|
||||
memory.phys_to_virt(base, _table->size);
|
||||
|
||||
memset(_name, 0, 5);
|
||||
memcpy(_name, _table->signature, 4);
|
||||
@ -1118,6 +1112,7 @@ class Acpi_table
|
||||
|
||||
Genode::Env &_env;
|
||||
Genode::Allocator &_alloc;
|
||||
Acpi::Memory _memory;
|
||||
|
||||
/* BIOS range to scan for RSDP */
|
||||
enum { BIOS_BASE = 0xe0000, BIOS_SIZE = 0x20000 };
|
||||
@ -1130,7 +1125,8 @@ class Acpi_table
|
||||
uint8_t *_search_rsdp(uint8_t *area)
|
||||
{
|
||||
for (addr_t addr = 0; area && addr < BIOS_SIZE; addr += 16)
|
||||
if (!memcmp(area + addr, "RSD PTR ", 8) && !Table_wrapper::checksum(area + addr, 20))
|
||||
if (!memcmp(area + addr, "RSD PTR ", 8) &&
|
||||
!Table_wrapper::checksum(area + addr, 20))
|
||||
return area + addr;
|
||||
|
||||
throw -2;
|
||||
@ -1174,7 +1170,7 @@ class Acpi_table
|
||||
for (uint32_t i = 0; i < count; i++) {
|
||||
uint32_t dsdt = 0;
|
||||
{
|
||||
Table_wrapper table(entries[i]);
|
||||
Table_wrapper table(_memory, entries[i]);
|
||||
if (table.is_facp()) {
|
||||
Fadt fadt(reinterpret_cast<Genode::addr_t>(table->signature));
|
||||
dsdt = fadt.read<Fadt::Dsdt>();
|
||||
@ -1206,7 +1202,7 @@ class Acpi_table
|
||||
}
|
||||
|
||||
if (dsdt) {
|
||||
Table_wrapper table(dsdt);
|
||||
Table_wrapper table(_memory, dsdt);
|
||||
if (table.is_searched()) {
|
||||
if (verbose)
|
||||
Genode::log("Found dsdt ", table.name());
|
||||
@ -1221,7 +1217,7 @@ class Acpi_table
|
||||
public:
|
||||
|
||||
Acpi_table(Genode::Env &env, Genode::Allocator &alloc)
|
||||
: _env(env), _alloc(alloc)
|
||||
: _env(env), _alloc(alloc), _memory(_env, _alloc)
|
||||
{
|
||||
uint8_t * ptr_rsdp = _rsdp();
|
||||
|
||||
@ -1264,12 +1260,12 @@ class Acpi_table
|
||||
|
||||
if (acpi_revision != 0 && xsdt && sizeof(addr_t) != sizeof(uint32_t)) {
|
||||
/* running 64bit and xsdt is valid */
|
||||
Table_wrapper table(xsdt);
|
||||
Table_wrapper table(_memory, xsdt);
|
||||
uint64_t * entries = reinterpret_cast<uint64_t *>(table.table() + 1);
|
||||
_parse_tables(alloc, entries, table.entry_count(entries));
|
||||
} else {
|
||||
/* running (32bit) or (64bit and xsdt isn't valid) */
|
||||
Table_wrapper table(rsdt);
|
||||
Table_wrapper table(_memory, rsdt);
|
||||
uint32_t * entries = reinterpret_cast<uint32_t *>(table.table() + 1);
|
||||
_parse_tables(alloc, entries, table.entry_count(entries));
|
||||
}
|
||||
@ -1278,7 +1274,7 @@ class Acpi_table
|
||||
Element::clean_list(alloc);
|
||||
|
||||
/* free up io memory */
|
||||
acpi_memory().free_io_memory();
|
||||
_memory.free_io_memory();
|
||||
}
|
||||
};
|
||||
|
||||
@ -1298,7 +1294,7 @@ void Acpi::generate_report(Genode::Env &env, Genode::Allocator &alloc)
|
||||
Acpi_table acpi_table(env, alloc);
|
||||
|
||||
enum { REPORT_SIZE = 4 * 4096 };
|
||||
static Reporter acpi("acpi", "acpi", REPORT_SIZE);
|
||||
static Reporter acpi(env, "acpi", "acpi", REPORT_SIZE);
|
||||
acpi.enabled(true);
|
||||
|
||||
Genode::Reporter::Xml_generator xml(acpi, [&] () {
|
||||
|
@ -14,7 +14,9 @@
|
||||
#ifndef _MEMORY_H_
|
||||
#define _MEMORY_H_
|
||||
|
||||
#include <base/allocator.h>
|
||||
#include <base/allocator_avl.h>
|
||||
#include <base/env.h>
|
||||
#include <rm_session/connection.h>
|
||||
#include <region_map/client.h>
|
||||
|
||||
@ -30,7 +32,8 @@ class Acpi::Memory
|
||||
Genode::Io_mem_connection _io_mem;
|
||||
|
||||
public:
|
||||
Io_mem(Genode::addr_t phys) : _io_mem(phys, 0x1000UL) { }
|
||||
Io_mem(Genode::Env &env, Genode::addr_t phys)
|
||||
: _io_mem(env, phys, 0x1000UL) { }
|
||||
|
||||
Genode::Io_mem_dataspace_capability dataspace()
|
||||
{
|
||||
@ -38,22 +41,27 @@ class Acpi::Memory
|
||||
}
|
||||
};
|
||||
|
||||
Genode::Env &_env;
|
||||
Genode::addr_t const ACPI_REGION_SIZE_LOG2;
|
||||
Genode::Rm_connection _rm;
|
||||
Genode::Region_map_client _rm_acpi;
|
||||
Genode::addr_t const _acpi_base;
|
||||
Genode::Allocator &_heap;
|
||||
Genode::Allocator_avl _range;
|
||||
Genode::List<Io_mem> _io_mem_list;
|
||||
|
||||
public:
|
||||
|
||||
Memory()
|
||||
Memory(Genode::Env &env, Genode::Allocator &heap)
|
||||
:
|
||||
_env(env),
|
||||
/* 1 GB range */
|
||||
ACPI_REGION_SIZE_LOG2(30),
|
||||
_rm(env),
|
||||
_rm_acpi(_rm.create(1UL << ACPI_REGION_SIZE_LOG2)),
|
||||
_acpi_base(Genode::env()->rm_session()->attach(_rm_acpi.dataspace())),
|
||||
_range(Genode::env()->heap())
|
||||
_acpi_base(env.rm().attach(_rm_acpi.dataspace())),
|
||||
_heap(heap),
|
||||
_range(&_heap)
|
||||
{
|
||||
_range.add_range(0, 1UL << ACPI_REGION_SIZE_LOG2);
|
||||
}
|
||||
@ -83,7 +91,7 @@ class Acpi::Memory
|
||||
continue;
|
||||
|
||||
/* allocate acpi page as io memory */
|
||||
Io_mem *mem = new (Genode::env()->heap()) Io_mem(phys_aligned + size);
|
||||
Io_mem *mem = new (_heap) Io_mem(_env, phys_aligned + size);
|
||||
/* attach acpi page to this process */
|
||||
_rm_acpi.attach_at(mem->dataspace(), low, 0x1000UL);
|
||||
/* add to list to free when parsing acpi table is done */
|
||||
@ -97,7 +105,7 @@ class Acpi::Memory
|
||||
{
|
||||
while (Io_mem * io_mem = _io_mem_list.first()) {
|
||||
_io_mem_list.remove(io_mem);
|
||||
destroy(Genode::env()->heap(), io_mem);
|
||||
destroy(_heap, io_mem);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user