Imported Genode release 11.11

This commit is contained in:
Genode Labs
2011-12-22 16:19:25 +01:00
committed by Christian Helmuth
parent 6bcc9aef0e
commit da4e1feaa5
2462 changed files with 320115 additions and 3 deletions

View File

@@ -0,0 +1,52 @@
/*
* \brief Core-local region manager session
* \author Norman Feske
* \date 2009-10-02
*/
/*
* Copyright (C) 2009-2011 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.
*/
#ifndef _CORE__INCLUDE__CORE_RM_SESSION_H_
#define _CORE__INCLUDE__CORE_RM_SESSION_H_
/* Genode includes */
#include <rm_session/rm_session.h>
/* core includes */
#include <dataspace_component.h>
namespace Genode {
class Core_rm_session : public Rm_session
{
private:
Rpc_entrypoint *_ds_ep;
public:
Core_rm_session(Rpc_entrypoint *ds_ep) : _ds_ep(ds_ep) { }
Local_addr attach(Dataspace_capability ds_cap, size_t size = 0,
off_t offset = 0, bool use_local_addr = false,
Local_addr local_addr = 0);
void detach(Local_addr) { }
Pager_capability add_client(Thread_capability) {
return Pager_capability(); }
void fault_handler(Signal_context_capability) { }
State state() { return State(); }
Dataspace_capability dataspace() { return Dataspace_capability(); }
};
}
#endif /* _CORE__INCLUDE__CORE_RM_SESSION_H_ */

View File

@@ -0,0 +1,71 @@
/*
* \brief IRQ session interface for NOVA
* \author Norman Feske
* \date 2010-01-30
*/
/*
* Copyright (C) 2010-2011 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.
*/
#ifndef _CORE__INCLUDE__IRQ_SESSION_COMPONENT_H_
#define _CORE__INCLUDE__IRQ_SESSION_COMPONENT_H_
#include <base/lock.h>
#include <util/list.h>
#include <irq_session/capability.h>
namespace Genode {
class Irq_session_component : public Rpc_object<Irq_session>,
public List<Irq_session_component>::Element
{
private:
enum { STACK_SIZE = 4096 };
unsigned _irq_number;
Range_allocator *_irq_alloc;
Rpc_entrypoint _entrypoint;
Irq_session_capability _cap;
bool _attached;
public:
/**
* Constructor
*
* \param cap_session capability session to use
* \param irq_alloc platform-dependent IRQ allocator
* \param args session construction arguments
*/
Irq_session_component(Cap_session *cap_session,
Range_allocator *irq_alloc,
const char *args);
/**
* Destructor
*/
~Irq_session_component();
/**
* Return capability to this session
*
* If an initialization error occurs, returned capability is invalid.
*/
Irq_session_capability cap() const { return _cap; }
/***************************
** Irq session interface **
***************************/
void wait_for_irq();
};
}
#endif /* _CORE__INCLUDE__IRQ_SESSION_COMPONENT_H_ */

View File

@@ -0,0 +1,66 @@
/*
* \brief Core-local mapping
* \author Norman Feske
* \date 2010-02-15
*/
/*
* Copyright (C) 2010-2011 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.
*/
#ifndef _CORE__INCLUDE__MAP_LOCAL_H_
#define _CORE__INCLUDE__MAP_LOCAL_H_
/* Genode includes */
#include <base/printf.h>
/* core includes */
#include <util.h>
namespace Genode {
/**
* Map physical pages to core-local virtual address range
*
* On Codezero, mappings originate from the physical address space.
*
* \param from_phys physical source address
* \param to_virt core-local destination address
* \param num_pages number of pages to map
*
* \return true on success
*/
inline bool map_local(addr_t from_phys, addr_t to_virt, size_t num_pages)
{
using namespace Codezero;
int res = l4_map((void *)from_phys, (void *)to_virt,
num_pages, MAP_USR_RW, thread_myself());
if (res < 0) {
PERR("l4_map phys 0x%lx -> 0x%lx returned %d", from_phys, to_virt, res);
return false;
}
return true;
}
inline bool unmap_local(addr_t virt_addr, size_t num_pages)
{
using namespace Codezero;
int res = l4_unmap((void *)virt_addr, num_pages, thread_myself());
if (res < 0) {
PERR("l4_unmap returned %d", res);
return false;
}
return true;
}
}
#endif /* _CORE__INCLUDE__MAP_LOCAL_H_ */

View File

@@ -0,0 +1,72 @@
/*
* \brief Platform interface
* \author Norman Feske
* \date 2009-10-02
*/
/*
* Copyright (C) 2009-2011 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.
*/
#ifndef _CORE__INCLUDE__PLATFORM_H_
#define _CORE__INCLUDE__PLATFORM_H_
/* Genode includes */
#include <base/printf.h>
/* local includes */
#include <platform_generic.h>
#include <core_mem_alloc.h>
namespace Genode {
class Platform : public Platform_generic
{
private:
typedef Core_mem_allocator::Phys_allocator Phys_allocator;
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 */
/**
* Virtual address range usable by non-core processes
*/
addr_t _vm_base;
size_t _vm_size;
int _init_rom_fs();
public:
/**
* Constructor
*/
Platform();
/********************************
** Generic platform interface **
********************************/
Range_allocator *ram_alloc() { return _core_mem_alloc.phys_alloc(); }
Range_allocator *io_mem_alloc() { return &_io_mem_alloc; }
Range_allocator *io_port_alloc() { return &_io_port_alloc; }
Range_allocator *irq_alloc() { return &_irq_alloc; }
Range_allocator *region_alloc() { return _core_mem_alloc.virt_alloc(); }
Allocator *core_mem_alloc() { return &_core_mem_alloc; }
addr_t vm_start() const { return _vm_base; }
size_t vm_size() const { return _vm_size; }
Rom_fs *rom_fs() { return &_rom_fs; }
void wait_for_exit();
};
}
#endif /* _CORE__INCLUDE__PLATFORM_H_ */

View File

@@ -0,0 +1,74 @@
/*
* \brief Protection-domain facility
* \author Norman Feske
* \date 2009-10-02
*/
/*
* Copyright (C) 2009-2011 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.
*/
#ifndef _CORE__INCLUDE__PLATFORM_PD_H_
#define _CORE__INCLUDE__PLATFORM_PD_H_
/* core includes */
#include <platform_thread.h>
/* Codezero includes */
#include <codezero/syscalls.h>
namespace Genode {
class Platform_thread;
class Platform_pd
{
private:
enum { MAX_THREADS_PER_PD = 32 };
enum { UTCB_VIRT_BASE = 0x30000000 };
enum { UTCB_AREA_SIZE = MAX_THREADS_PER_PD*sizeof(struct Codezero::utcb) };
int _space_id;
bool utcb_in_use[MAX_THREADS_PER_PD];
public:
/**
* Constructors
*/
Platform_pd(bool core);
Platform_pd(signed pd_id = -1, bool create = true);
/**
* Destructor
*/
~Platform_pd();
/**
* Bind thread to protection domain
*
* \return 0 on success or
* -1 if thread ID allocation failed.
*/
int bind_thread(Platform_thread *thread);
/**
* Unbind thread from protection domain
*
* Free the thread's slot and update thread object.
*/
void unbind_thread(Platform_thread *thread);
/**
* Assign parent interface to protection domain
*/
int assign_parent(Native_capability parent) { return 0; }
};
}
#endif /* _CORE__INCLUDE__PLATFORM_PD_H_ */

View File

@@ -0,0 +1,135 @@
/*
* \brief Thread facility
* \author Norman Feske
* \date 2009-10-02
*/
/*
* Copyright (C) 2009-2011 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.
*/
#ifndef _CORE__INCLUDE__PLATFORM_THREAD_H_
#define _CORE__INCLUDE__PLATFORM_THREAD_H_
/* Genode includes */
#include <base/pager.h>
#include <base/thread_state.h>
#include <base/native_types.h>
namespace Genode {
class Platform_pd;
class Platform_thread
{
private:
friend class Platform_pd;
enum { PD_NAME_MAX_LEN = 64 };
int _tid; /* global codezero thread ID */
int _space_id;
addr_t _utcb;
char _name[PD_NAME_MAX_LEN];
Pager_object *_pager;
/**
* Assign physical thread ID and UTCB address to thread
*
* This function is called from 'Platform_pd::bind_thread'.
*/
void _assign_physical_thread(int tid, int space_id, addr_t utcb) {
_tid = tid; _space_id = space_id; _utcb = utcb; }
public:
enum { THREAD_INVALID = -1 }; /* invalid thread number */
/**
* Constructor
*/
Platform_thread(const char *name = 0, unsigned priority = 0,
int thread_id = THREAD_INVALID);
/**
* Destructor
*/
~Platform_thread();
/**
* Start thread
*
* \param ip instruction pointer to start at
* \param sp stack pointer to use
* \param cpu_no target cpu
*
* \retval 0 successful
* \retval -1 thread could not be started
*/
int start(void *ip, void *sp, unsigned int cpu_no = 0);
/**
* Pause this thread
*/
void pause();
/**
* Resume this thread
*/
void resume();
/**
* Cancel currently blocking operation
*/
void cancel_blocking();
/**
* Request thread state
*
* \param state_dst destination state buffer
*
* \retval 0 successful
* \retval -1 thread state not accessible
*/
int state(Genode::Thread_state *state_dst);
/************************
** Accessor functions **
************************/
/**
* Set pager capability
*/
Pager_object *pager(Pager_object *pager) const { return _pager; }
void pager(Pager_object *pager) { _pager = pager; }
Pager_object *pager() { return _pager; }
/**
* Return identification of thread when faulting
*/
unsigned long pager_object_badge() const { return _tid; }
/**
* Set the executing CPU for this thread.
*/
void set_cpu(unsigned int cpu_no);
/**
* Get thread name
*/
const char *name() const { return "noname"; }
/***********************
** Codezero specific **
***********************/
addr_t utcb() const { return _utcb; }
};
}
#endif /* _CORE__INCLUDE__PLATFORM_THREAD_H_ */

View File

@@ -0,0 +1,46 @@
/*
* \brief Core-internal utilities
* \author Norman Feske
* \date 2009-10-02
*/
/*
* Copyright (C) 2009-2011 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.
*/
#ifndef _CORE__INCLUDE__UTIL_H_
#define _CORE__INCLUDE__UTIL_H_
/* Genode includes */
#include <rm_session/rm_session.h>
#include <base/printf.h>
/* Codezero includes */
#include <codezero/syscalls.h>
namespace Genode {
inline size_t get_page_size_log2() { return 12; }
inline size_t get_page_size() { return 1 << get_page_size_log2(); }
inline addr_t get_page_mask() { return ~(get_page_size() - 1); }
inline addr_t trunc_page(addr_t addr) { return addr & get_page_mask(); }
inline addr_t round_page(addr_t addr) { return trunc_page(addr + get_page_size() - 1); }
inline addr_t map_src_addr(addr_t core_local, addr_t phys) { return phys; }
inline size_t constrain_map_size_log2(size_t size_log2) { return get_page_size_log2(); }
inline void print_page_fault(const char *msg, addr_t pf_addr, addr_t pf_ip,
Rm_session::Fault_type pf_type,
unsigned long faulter_badge)
{
printf("%s (%s pf_addr=%p pf_ip=%p from %02lx)\n", msg,
pf_type == Rm_session::WRITE_FAULT ? "WRITE" : "READ",
(void *)pf_addr, (void *)pf_ip,
faulter_badge);
}
}
#endif /* _CORE__INCLUDE__UTIL_H_ */