mirror of
https://github.com/genodelabs/genode.git
synced 2024-12-23 23:42:32 +00:00
hw_x86_64: Add x86-specific I/O mem allocator init
Enable a platform to specify how the MMIO memory allocator is to be initialized. On ARM the existing behavior is kept while on x86 the I/O memory is defined as the entire address space excluding the core only RAM regions. This aligns the hw_x86_64 I/O memory allocator initialization with how it is done for other x86 kernels such as NOVA or Fiasco.
This commit is contained in:
parent
36b2cf932b
commit
f99fab544a
@ -31,6 +31,12 @@
|
|||||||
|
|
||||||
namespace Genode {
|
namespace Genode {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function pointer that provides accessor to a pool of address regions.
|
||||||
|
*/
|
||||||
|
typedef Native_region * (*Region_pool)(unsigned const);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manages all platform ressources
|
* Manages all platform ressources
|
||||||
*/
|
*/
|
||||||
@ -59,6 +65,16 @@ namespace Genode {
|
|||||||
*/
|
*/
|
||||||
void _init_io_port_alloc();
|
void _init_io_port_alloc();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize IO memory allocator
|
||||||
|
*
|
||||||
|
* Use byte granularity for MMIO regions because on some platforms,
|
||||||
|
* devices driven by core share a physical page with devices
|
||||||
|
* driven outside of core. Using byte granularity allows handing
|
||||||
|
* out the MMIO page to trusted user-level device drivers.
|
||||||
|
*/
|
||||||
|
void _init_io_mem_alloc();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -71,7 +87,6 @@ namespace Genode {
|
|||||||
* on the current platform.
|
* on the current platform.
|
||||||
*/
|
*/
|
||||||
static Native_region * _ram_regions(unsigned i);
|
static Native_region * _ram_regions(unsigned i);
|
||||||
static Native_region * _mmio_regions(unsigned i);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get one of the consecutively numbered core regions
|
* Get one of the consecutively numbered core regions
|
||||||
|
@ -51,11 +51,6 @@ extern Bm_header _boot_modules_headers_end;
|
|||||||
extern int _boot_modules_binaries_begin;
|
extern int _boot_modules_binaries_begin;
|
||||||
extern int _boot_modules_binaries_end;
|
extern int _boot_modules_binaries_end;
|
||||||
|
|
||||||
/**
|
|
||||||
* Functionpointer that provides accessor to a pool of address regions
|
|
||||||
*/
|
|
||||||
typedef Native_region * (*Region_pool)(unsigned const);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper to initialise allocators through include/exclude region lists
|
* Helper to initialise allocators through include/exclude region lists
|
||||||
@ -87,19 +82,6 @@ static void init_alloc(Range_allocator * const alloc,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Helper to initialise allocators through include region lists
|
|
||||||
*/
|
|
||||||
static void init_alloc_core_mmio(Range_allocator * const alloc,
|
|
||||||
Region_pool incl_regions)
|
|
||||||
{
|
|
||||||
/* make all include regions available */
|
|
||||||
Native_region * r = incl_regions(0);
|
|
||||||
for (unsigned i = 0; r; r = incl_regions(++i))
|
|
||||||
alloc->add_range(r->base, r->size);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**************
|
/**************
|
||||||
** Platform **
|
** Platform **
|
||||||
**************/
|
**************/
|
||||||
@ -157,13 +139,7 @@ Platform::Platform()
|
|||||||
_irq_alloc.add_range(i, 1);
|
_irq_alloc.add_range(i, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
_init_io_mem_alloc();
|
||||||
* Use byte granuarity for MMIO regions because on some platforms, devices
|
|
||||||
* driven by core share a physical page with devices driven outside of
|
|
||||||
* core. Using byte granuarlity allows handing out the MMIO page to trusted
|
|
||||||
* user-level device drivers.
|
|
||||||
*/
|
|
||||||
init_alloc_core_mmio(&_io_mem_alloc, _mmio_regions);
|
|
||||||
|
|
||||||
/* add boot modules to ROM FS */
|
/* add boot modules to ROM FS */
|
||||||
Bm_header * header = &_boot_modules_headers_begin;
|
Bm_header * header = &_boot_modules_headers_begin;
|
||||||
|
@ -18,5 +18,15 @@ using namespace Genode;
|
|||||||
|
|
||||||
void Platform::_init_io_port_alloc() { };
|
void Platform::_init_io_port_alloc() { };
|
||||||
|
|
||||||
|
Native_region * mmio_regions(unsigned);
|
||||||
|
|
||||||
long Platform::irq(long const user_irq) { return user_irq; }
|
|
||||||
|
void Platform::_init_io_mem_alloc()
|
||||||
|
{
|
||||||
|
Native_region * r = mmio_regions(0);
|
||||||
|
for (unsigned i = 0; r; r = mmio_regions(++i))
|
||||||
|
_io_mem_alloc.add_range(r->base, r->size);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
long Platform::irq(long const user_irq) { return user_irq; }
|
||||||
|
@ -31,7 +31,7 @@ Native_region * Platform::_ram_regions(unsigned const i)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Native_region * Platform::_mmio_regions(unsigned const i)
|
Native_region * mmio_regions(unsigned const i)
|
||||||
{
|
{
|
||||||
static Native_region _regions[] =
|
static Native_region _regions[] =
|
||||||
{
|
{
|
||||||
|
@ -30,7 +30,7 @@ Native_region * Platform::_ram_regions(unsigned const i)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Native_region * Platform::_mmio_regions(unsigned const i)
|
Native_region * mmio_regions(unsigned const i)
|
||||||
{
|
{
|
||||||
static Native_region _regions[] =
|
static Native_region _regions[] =
|
||||||
{
|
{
|
||||||
|
@ -71,7 +71,7 @@ Native_region * Platform::_ram_regions(unsigned const i)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Native_region * Platform::_mmio_regions(unsigned const i)
|
Native_region * mmio_regions(unsigned const i)
|
||||||
{
|
{
|
||||||
static Native_region _regions[] =
|
static Native_region _regions[] =
|
||||||
{
|
{
|
||||||
|
@ -29,7 +29,7 @@ Native_region * Platform::_ram_regions(unsigned const i)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Native_region * Platform::_mmio_regions(unsigned const i)
|
Native_region * mmio_regions(unsigned const i)
|
||||||
{
|
{
|
||||||
static Native_region _regions[] =
|
static Native_region _regions[] =
|
||||||
{
|
{
|
||||||
|
@ -30,7 +30,7 @@ Native_region * Platform::_ram_regions(unsigned const i)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Native_region * Platform::_mmio_regions(unsigned const i)
|
Native_region * mmio_regions(unsigned const i)
|
||||||
{
|
{
|
||||||
static Native_region _regions[] =
|
static Native_region _regions[] =
|
||||||
{
|
{
|
||||||
|
@ -31,7 +31,7 @@ Native_region * Platform::_ram_regions(unsigned const i)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Native_region * Platform::_mmio_regions(unsigned const i)
|
Native_region * mmio_regions(unsigned const i)
|
||||||
{
|
{
|
||||||
static Native_region _regions[] =
|
static Native_region _regions[] =
|
||||||
{
|
{
|
||||||
|
@ -28,7 +28,7 @@ Native_region * Platform::_ram_regions(unsigned const i)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Native_region * Platform::_mmio_regions(unsigned const i)
|
Native_region * mmio_regions(unsigned const i)
|
||||||
{
|
{
|
||||||
static Native_region _regions[] =
|
static Native_region _regions[] =
|
||||||
{
|
{
|
||||||
|
@ -32,7 +32,7 @@ Native_region * Platform::_ram_regions(unsigned const i)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Native_region * Platform::_mmio_regions(unsigned const i)
|
Native_region * mmio_regions(unsigned const i)
|
||||||
{
|
{
|
||||||
static Native_region _regions[] =
|
static Native_region _regions[] =
|
||||||
{
|
{
|
||||||
|
@ -31,19 +31,6 @@ Native_region * Platform::_ram_regions(unsigned const i)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Native_region * Platform::_mmio_regions(unsigned const i)
|
|
||||||
{
|
|
||||||
static Native_region _regions[] =
|
|
||||||
{
|
|
||||||
{ 0x00000000, 0x0001000 },
|
|
||||||
{ 0x000a0000, 0x0060000 },
|
|
||||||
{ 0xc0000000, 0x1000000 },
|
|
||||||
{ 0xfc000000, 0x1000000 },
|
|
||||||
};
|
|
||||||
return i < sizeof(_regions)/sizeof(_regions[0]) ? &_regions[i] : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Native_region * Platform::_core_only_mmio_regions(unsigned const i)
|
Native_region * Platform::_core_only_mmio_regions(unsigned const i)
|
||||||
{
|
{
|
||||||
static Native_region _regions[] =
|
static Native_region _regions[] =
|
||||||
@ -61,6 +48,27 @@ void Platform::_init_io_port_alloc()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove given exclude memory regions from specified allocator.
|
||||||
|
*/
|
||||||
|
static void alloc_exclude_regions(Range_allocator * const alloc,
|
||||||
|
Region_pool excl_regions)
|
||||||
|
{
|
||||||
|
Native_region * r = excl_regions(0);
|
||||||
|
for (unsigned i = 0; r; r = excl_regions(++i))
|
||||||
|
alloc->remove_range(r->base, r->size);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Platform::_init_io_mem_alloc()
|
||||||
|
{
|
||||||
|
/* add entire adress space minus the RAM memory regions */
|
||||||
|
_io_mem_alloc.add_range(0, ~0x0UL);
|
||||||
|
alloc_exclude_regions(&_io_mem_alloc, _ram_regions);
|
||||||
|
alloc_exclude_regions(&_io_mem_alloc, _core_only_ram_regions);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
long Platform::irq(long const user_irq)
|
long Platform::irq(long const user_irq)
|
||||||
{
|
{
|
||||||
/* remap IRQ requests to fit I/O APIC configuration */
|
/* remap IRQ requests to fit I/O APIC configuration */
|
||||||
|
Loading…
Reference in New Issue
Block a user