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
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2013-01-10 21:44:47 +01:00
|
|
|
* Copyright (C) 2011-2013 Genode Labs GmbH
|
2012-05-30 20:13:09 +02:00
|
|
|
*
|
|
|
|
* This file is part of the Genode OS framework, which is distributed
|
|
|
|
* under the terms of the GNU General Public License version 2.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _CORE__INCLUDE__PLATFORM_H_
|
|
|
|
#define _CORE__INCLUDE__PLATFORM_H_
|
|
|
|
|
|
|
|
/* Genode includes */
|
|
|
|
#include <base/sync_allocator.h>
|
|
|
|
#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 */
|
2012-05-30 20:13:09 +02:00
|
|
|
#include <kernel/log.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>
|
2014-04-28 21:31:57 +02:00
|
|
|
#include <core_rm_session.h>
|
|
|
|
#include <core_mem_alloc.h>
|
2012-05-30 20:13:09 +02:00
|
|
|
|
|
|
|
namespace Genode {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Manages all platform ressources
|
|
|
|
*/
|
|
|
|
class Platform : public Platform_generic
|
|
|
|
{
|
2014-10-10 16:13:52 +02:00
|
|
|
private:
|
2012-05-30 20:13:09 +02:00
|
|
|
|
2014-10-10 16:13:52 +02:00
|
|
|
typedef Core_mem_allocator::Phys_allocator Phys_allocator;
|
2014-04-28 21:31:57 +02:00
|
|
|
|
2014-10-10 16:13:52 +02:00
|
|
|
Core_mem_allocator _core_mem_alloc; /* core-accessible memory */
|
|
|
|
Phys_allocator _io_mem_alloc; /* MMIO allocator */
|
2015-03-18 23:40:58 +01:00
|
|
|
Phys_allocator _io_port_alloc; /* I/O port allocator */
|
2014-10-10 16:13:52 +02:00
|
|
|
Phys_allocator _irq_alloc; /* IRQ allocator */
|
|
|
|
Rom_fs _rom_fs; /* ROM file system */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Virtual-memory range for non-core address spaces.
|
|
|
|
* The virtual memory layout of core is maintained in
|
|
|
|
* '_core_mem_alloc.virt_alloc()'.
|
|
|
|
*/
|
|
|
|
addr_t _vm_start;
|
|
|
|
size_t _vm_size;
|
2012-05-30 20:13:09 +02:00
|
|
|
|
2015-03-18 23:40:58 +01:00
|
|
|
/**
|
|
|
|
* Initialize I/O port allocator
|
|
|
|
*/
|
|
|
|
void _init_io_port_alloc();
|
2014-04-28 21:31:57 +02:00
|
|
|
|
|
|
|
public:
|
2012-05-30 20:13:09 +02:00
|
|
|
|
2014-10-10 16:13:52 +02:00
|
|
|
/**
|
|
|
|
* Get one of the consecutively numbered available resource regions
|
|
|
|
*
|
|
|
|
* \return >0 region pointer if region with index 'i' exists
|
|
|
|
* 0 if region with index 'i' doesn't exist
|
|
|
|
*
|
|
|
|
* These functions should provide all ressources that are available
|
|
|
|
* on the current platform.
|
|
|
|
*/
|
|
|
|
static Native_region * _ram_regions(unsigned i);
|
|
|
|
static Native_region * _mmio_regions(unsigned i);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get one of the consecutively numbered core regions
|
|
|
|
*
|
|
|
|
* \return >0 Region pointer if region with index 'i' exists
|
|
|
|
* 0 If region with index 'i' doesn't exist
|
|
|
|
*
|
|
|
|
* Core regions are address regions that must be permitted to
|
|
|
|
* core only, such as the core image ROM. These regions are
|
|
|
|
* normally a subset of the ressource regions provided above.
|
|
|
|
*/
|
|
|
|
static Native_region * _core_only_ram_regions(unsigned i);
|
|
|
|
static Native_region * _core_only_mmio_regions(unsigned i);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get one of the consecutively numbered user interrupts
|
|
|
|
*
|
|
|
|
* \param i index of interrupt
|
|
|
|
*
|
|
|
|
* \return >0 pointer to the name of the requested interrupt
|
|
|
|
* 0 no interrupt for that index
|
|
|
|
*/
|
|
|
|
static unsigned * _irq(unsigned const i);
|
2012-05-30 20:13:09 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Constructor
|
|
|
|
*/
|
|
|
|
Platform();
|
|
|
|
|
2015-03-19 16:55:21 +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
|
|
|
|
|
|
|
/********************************
|
|
|
|
** Platform_generic interface **
|
|
|
|
********************************/
|
|
|
|
|
2014-04-28 21:31:57 +02:00
|
|
|
inline Range_allocator * core_mem_alloc() {
|
|
|
|
return &_core_mem_alloc; }
|
|
|
|
|
|
|
|
inline Range_allocator * ram_alloc() {
|
|
|
|
return _core_mem_alloc.phys_alloc(); }
|
2012-05-30 20:13:09 +02:00
|
|
|
|
2014-04-28 21:31:57 +02:00
|
|
|
inline Range_allocator * region_alloc() {
|
|
|
|
return _core_mem_alloc.virt_alloc(); }
|
2012-05-30 20:13:09 +02:00
|
|
|
|
|
|
|
inline Range_allocator * io_mem_alloc() { return &_io_mem_alloc; }
|
|
|
|
|
2015-03-18 23:40:58 +01:00
|
|
|
inline Range_allocator * io_port_alloc() { return &_io_port_alloc; }
|
2012-05-30 20:13:09 +02:00
|
|
|
|
|
|
|
inline Range_allocator * irq_alloc() { return &_irq_alloc; }
|
|
|
|
|
2013-11-23 02:30:24 +01:00
|
|
|
inline addr_t vm_start() const { return _vm_start; }
|
2012-05-30 20:13:09 +02:00
|
|
|
|
|
|
|
inline size_t vm_size() const { return _vm_size; }
|
|
|
|
|
|
|
|
inline Rom_fs *rom_fs() { return &_rom_fs; }
|
|
|
|
|
2014-10-10 16:13:52 +02:00
|
|
|
inline void wait_for_exit() {
|
|
|
|
while (1) { Kernel::pause_current_thread(); } };
|
2012-05-30 20:13:09 +02:00
|
|
|
|
2013-09-18 13:11:27 +02:00
|
|
|
bool supports_direct_unmap() const { return 1; }
|
|
|
|
|
2014-10-10 16:13:52 +02:00
|
|
|
Affinity::Space affinity_space() const {
|
|
|
|
return Affinity::Space(NR_OF_CPUS); }
|
2012-05-30 20:13:09 +02:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* _CORE__INCLUDE__PLATFORM_H_ */
|
|
|
|
|