2012-05-30 20:13:09 +02:00
|
|
|
/*
|
|
|
|
* \brief Platform interface
|
|
|
|
* \author Martin Stein
|
2014-04-28 21:31:57 +02:00
|
|
|
* \author Stefan Kalkowski
|
2012-05-30 20:13:09 +02:00
|
|
|
* \date 2011-12-21
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2017-02-20 13:23:52 +01:00
|
|
|
* Copyright (C) 2011-2017 Genode Labs GmbH
|
2012-05-30 20:13:09 +02:00
|
|
|
*
|
|
|
|
* This file is part of the Genode OS framework, which is distributed
|
2017-02-20 13:23:52 +01:00
|
|
|
* under the terms of the GNU Affero General Public License version 3.
|
2012-05-30 20:13:09 +02:00
|
|
|
*/
|
|
|
|
|
2017-04-12 10:06:29 +02:00
|
|
|
#ifndef _CORE__PLATFORM_H_
|
|
|
|
#define _CORE__PLATFORM_H_
|
2012-05-30 20:13:09 +02:00
|
|
|
|
|
|
|
/* Genode includes */
|
2015-09-17 14:16:59 +02:00
|
|
|
#include <base/synced_allocator.h>
|
2012-05-30 20:13:09 +02:00
|
|
|
#include <base/allocator_avl.h>
|
2013-10-30 13:56:57 +01:00
|
|
|
#include <irq_session/irq_session.h>
|
2013-11-14 17:29:34 +01:00
|
|
|
|
|
|
|
/* base-hw includes */
|
2017-02-21 13:46:59 +01:00
|
|
|
#include <hw/boot_info.h>
|
|
|
|
#include <hw/memory_region.h>
|
2015-06-25 15:53:39 +02:00
|
|
|
#include <kernel/configuration.h>
|
2014-03-15 01:26:53 +01:00
|
|
|
#include <kernel/core_interface.h>
|
2012-05-30 20:13:09 +02:00
|
|
|
|
|
|
|
/* core includes */
|
|
|
|
#include <platform_generic.h>
|
2016-04-15 15:19:22 +02:00
|
|
|
#include <core_region_map.h>
|
2014-04-28 21:31:57 +02:00
|
|
|
#include <core_mem_alloc.h>
|
2017-02-21 13:46:59 +01:00
|
|
|
#include <translation_table.h>
|
2012-05-30 20:13:09 +02:00
|
|
|
|
2017-02-21 13:46:59 +01:00
|
|
|
namespace Genode { class Platform; };
|
2012-05-30 20:13:09 +02:00
|
|
|
|
2017-02-21 13:46:59 +01:00
|
|
|
class Genode::Platform : public Genode::Platform_generic
|
|
|
|
{
|
|
|
|
private:
|
2012-05-30 20:13:09 +02:00
|
|
|
|
2017-02-21 13:46:59 +01:00
|
|
|
Core_mem_allocator _core_mem_alloc; /* core-accessible memory */
|
|
|
|
Phys_allocator _io_mem_alloc; /* MMIO allocator */
|
|
|
|
Phys_allocator _io_port_alloc; /* I/O port allocator */
|
|
|
|
Phys_allocator _irq_alloc; /* IRQ allocator */
|
|
|
|
Rom_fs _rom_fs; /* ROM file system */
|
2014-10-10 16:13:52 +02:00
|
|
|
|
2017-02-21 13:46:59 +01:00
|
|
|
static Hw::Boot_info const & _boot_info();
|
|
|
|
static Hw::Memory_region_array const & _core_virt_regions();
|
2016-11-07 18:00:24 +01:00
|
|
|
|
2017-02-21 13:46:59 +01:00
|
|
|
/**
|
|
|
|
* Initialize I/O port allocator
|
|
|
|
*/
|
|
|
|
void _init_io_port_alloc();
|
2014-04-28 21:31:57 +02:00
|
|
|
|
2017-02-21 13:46:59 +01:00
|
|
|
/**
|
|
|
|
* 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();
|
2015-04-28 14:56:00 +02:00
|
|
|
|
2017-02-21 13:46:59 +01:00
|
|
|
/**
|
|
|
|
* Perform additional platform-specific initialization.
|
|
|
|
*/
|
|
|
|
void _init_additional();
|
2015-07-02 16:25:51 +02:00
|
|
|
|
2017-02-21 13:46:59 +01:00
|
|
|
public:
|
2012-05-30 20:13:09 +02:00
|
|
|
|
2017-02-21 13:46:59 +01:00
|
|
|
Platform();
|
2012-05-30 20:13:09 +02:00
|
|
|
|
2017-02-21 13:46:59 +01:00
|
|
|
static addr_t mmio_to_virt(addr_t mmio);
|
2016-11-07 18:00:24 +01:00
|
|
|
|
2017-02-21 13:46:59 +01:00
|
|
|
/**
|
|
|
|
* Return platform IRQ-number for user IRQ-number 'user_irq'
|
|
|
|
*/
|
|
|
|
static long irq(long const user_irq);
|
2012-05-30 20:13:09 +02:00
|
|
|
|
2017-02-21 13:46:59 +01:00
|
|
|
/**
|
|
|
|
* Setup mode of an IRQ to specified trigger mode and polarity
|
|
|
|
*
|
|
|
|
* \param irq_number ID of targeted interrupt
|
|
|
|
* \param trigger new interrupt trigger mode
|
|
|
|
* \param polarity new interrupt polarity setting
|
|
|
|
*/
|
|
|
|
static void setup_irq_mode(unsigned irq_number, unsigned trigger,
|
|
|
|
unsigned polarity);
|
2015-05-16 02:34:45 +02:00
|
|
|
|
2017-02-21 13:46:59 +01:00
|
|
|
/**
|
|
|
|
* Get MSI-related parameters from device PCI config space
|
|
|
|
*
|
|
|
|
* \param mmconf PCI config space address of device
|
|
|
|
* \param address MSI address register value to use
|
|
|
|
* \param data MSI data register value to use
|
|
|
|
* \param irq_number IRQ to use
|
|
|
|
*
|
|
|
|
* \return true if the device is MSI-capable, false if not
|
|
|
|
*/
|
|
|
|
static bool get_msi_params(const addr_t mmconf,
|
|
|
|
addr_t &address, addr_t &data,
|
|
|
|
unsigned &irq_number);
|
2015-06-25 15:53:39 +02:00
|
|
|
|
2017-02-21 13:46:59 +01:00
|
|
|
static addr_t core_phys_addr(addr_t virt);
|
2016-11-07 18:00:24 +01:00
|
|
|
|
2017-02-21 13:46:59 +01:00
|
|
|
static Hw::Page_table & core_page_table();
|
|
|
|
static Hw::Page_table::Allocator & core_page_table_allocator();
|
2016-11-07 18:00:24 +01:00
|
|
|
|
2016-10-06 20:07:16 +02:00
|
|
|
|
2017-02-21 13:46:59 +01:00
|
|
|
/********************************
|
|
|
|
** Platform_generic interface **
|
|
|
|
********************************/
|
2016-10-06 20:07:16 +02:00
|
|
|
|
2017-02-21 13:46:59 +01:00
|
|
|
Range_allocator * core_mem_alloc() {
|
|
|
|
return &_core_mem_alloc; }
|
2012-05-30 20:13:09 +02:00
|
|
|
|
2017-02-21 13:46:59 +01:00
|
|
|
Range_allocator * ram_alloc() {
|
|
|
|
return _core_mem_alloc.phys_alloc(); }
|
2014-04-28 21:31:57 +02:00
|
|
|
|
2017-02-21 13:46:59 +01:00
|
|
|
Range_allocator * region_alloc() {
|
|
|
|
return _core_mem_alloc.virt_alloc(); }
|
2012-05-30 20:13:09 +02:00
|
|
|
|
2017-02-21 13:46:59 +01:00
|
|
|
Range_allocator * io_mem_alloc() { return &_io_mem_alloc; }
|
2012-05-30 20:13:09 +02:00
|
|
|
|
2017-02-21 13:46:59 +01:00
|
|
|
Range_allocator * io_port_alloc() { return &_io_port_alloc; }
|
2012-05-30 20:13:09 +02:00
|
|
|
|
2017-02-21 13:46:59 +01:00
|
|
|
Range_allocator * irq_alloc() { return &_irq_alloc; }
|
2012-05-30 20:13:09 +02:00
|
|
|
|
2017-02-21 13:46:59 +01:00
|
|
|
addr_t vm_start() const { return VIRT_ADDR_SPACE_START; }
|
2012-05-30 20:13:09 +02:00
|
|
|
|
2017-02-21 13:46:59 +01:00
|
|
|
size_t vm_size() const { return VIRT_ADDR_SPACE_SIZE; }
|
2012-05-30 20:13:09 +02:00
|
|
|
|
2017-02-21 13:46:59 +01:00
|
|
|
Rom_fs *rom_fs() { return &_rom_fs; }
|
2012-05-30 20:13:09 +02:00
|
|
|
|
2017-02-21 13:46:59 +01:00
|
|
|
inline void wait_for_exit() {
|
|
|
|
while (1) { Kernel::stop_thread(); } };
|
2012-05-30 20:13:09 +02:00
|
|
|
|
2017-02-21 13:46:59 +01:00
|
|
|
bool supports_direct_unmap() const { return 1; }
|
2012-05-30 20:13:09 +02:00
|
|
|
|
2017-02-21 13:46:59 +01:00
|
|
|
Affinity::Space affinity_space() const {
|
|
|
|
return Affinity::Space(NR_OF_CPUS); }
|
|
|
|
};
|
2012-05-30 20:13:09 +02:00
|
|
|
|
2017-04-12 10:06:29 +02:00
|
|
|
#endif /* _CORE__PLATFORM_H_ */
|