Move repositories to 'repos/' subdirectory

This patch changes the top-level directory layout as a preparatory
step for improving the tools for managing 3rd-party source codes.
The rationale is described in the issue referenced below.

Issue #1082
This commit is contained in:
Norman Feske
2014-05-07 11:48:19 +02:00
parent 1f9890d635
commit ca971bbfd8
3943 changed files with 454 additions and 430 deletions

View File

@ -0,0 +1,68 @@
/*
* \brief Core-local RM session
* \author Norman Feske
* \date 2009-10-02
*/
/*
* Copyright (C) 2009-2013 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.
*/
/* Genode includes */
#include <base/printf.h>
/* core includes */
#include <core_rm_session.h>
#include <platform.h>
#include <map_local.h>
using namespace Genode;
Rm_session::Local_addr
Core_rm_session::attach(Dataspace_capability ds_cap, size_t size,
off_t offset, bool use_local_addr,
Rm_session::Local_addr local_addr,
bool executable)
{
using namespace Codezero;
Object_pool<Dataspace_component>::Guard ds(_ds_ep->lookup_and_lock(ds_cap));
if (!ds)
throw Invalid_dataspace();
if (size == 0)
size = ds->size();
size_t page_rounded_size = (size + get_page_size() - 1) & get_page_mask();
size_t num_pages = page_rounded_size >> get_page_size_log2();
if (use_local_addr) {
PERR("Parameter 'use_local_addr' not supported within core");
return 0;
}
if (offset) {
PERR("Parameter 'offset' not supported within core");
return 0;
}
/* allocate range in core's virtual address space */
void *virt_addr;
if (!platform()->region_alloc()->alloc(page_rounded_size, &virt_addr)) {
PERR("Could not allocate virtual address range in core of size %zd\n",
page_rounded_size);
return false;
}
if (!map_local(ds->phys_addr(), (addr_t)virt_addr, num_pages)) {
PERR("core-local memory mapping failed virt=%lx, phys=%lx\n",
(addr_t)virt_addr, ds->phys_addr());
return 0;
}
return virt_addr;
}

View File

@ -0,0 +1,28 @@
/*
* \brief Platform-specific parts of cores CPU-service
* \author Martin Stein
* \date 2012-04-17
*/
/*
* Copyright (C) 2009-2013 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.
*/
/* Genode includes */
#include <base/printf.h>
/* Core includes */
#include <cpu_session_component.h>
using namespace Genode;
Ram_dataspace_capability Cpu_session_component::utcb(Thread_capability thread_cap)
{
PERR("%s: Not implemented", __PRETTY_FUNCTION__);
return Ram_dataspace_capability();
}

View File

@ -0,0 +1,55 @@
/*
* \brief Core-local region manager session
* \author Norman Feske
* \date 2009-10-02
*/
/*
* Copyright (C) 2009-2013 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,
bool executable = false);
void detach(Local_addr) { }
Pager_capability add_client(Thread_capability) {
return Pager_capability(); }
void remove_client(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-2013 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-2013 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-2013 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(); }
Range_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,81 @@
/*
* \brief Protection-domain facility
* \author Norman Feske
* \date 2009-10-02
*/
/*
* Copyright (C) 2009-2013 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>
#include <address_space.h>
/* Codezero includes */
#include <codezero/syscalls.h>
namespace Genode {
class Platform_thread;
class Platform_pd : public Address_space
{
private:
enum { MAX_THREADS_PER_PD = 32 };
enum { UTCB_VIRT_BASE = 0x30000000 };
enum { UTCB_AREA_SIZE = MAX_THREADS_PER_PD*sizeof(struct Codezero::utcb) };
unsigned _space_id;
bool utcb_in_use[MAX_THREADS_PER_PD];
public:
/**
* Constructors
*/
Platform_pd(bool core);
Platform_pd(char const *, 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; }
/*****************************
** Address-space interface **
*****************************/
void flush(addr_t, size_t) { PDBG("not implemented"); }
};
}
#endif /* _CORE__INCLUDE__PLATFORM_PD_H_ */

View File

@ -0,0 +1,158 @@
/*
* \brief Thread facility
* \author Norman Feske
* \date 2009-10-02
*/
/*
* Copyright (C) 2009-2013 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>
/* core includes */
#include <address_space.h>
namespace Genode {
class Platform_pd;
class Platform_thread
{
private:
friend class Platform_pd;
enum { PD_NAME_MAX_LEN = 64 };
unsigned _tid; /* global codezero thread ID */
unsigned _space_id;
Weak_ptr<Address_space> _address_space;
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(unsigned tid, unsigned space_id,
addr_t utcb,
Weak_ptr<Address_space> address_space)
{
_tid = tid; _space_id = space_id; _utcb = utcb;
_address_space = address_space;
}
public:
enum { THREAD_INVALID = -1 }; /* invalid thread number */
/**
* Constructor
*/
Platform_thread(const char *name = 0, unsigned priority = 0,
addr_t utcb = 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();
/**
* Override thread state with 's'
*
* \throw Cpu_session::State_access_failed
*/
void state(Thread_state s);
/**
* Read thread state
*
* \throw Cpu_session::State_access_failed
*/
Thread_state state();
/**
* Return the address space to which the thread is bound
*/
Weak_ptr<Address_space> address_space();
/************************
** 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 affinity(Affinity::Location) { }
/**
* Get the executing CPU for this thread
*/
Affinity::Location affinity() { return Affinity::Location(); }
/**
* 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-2013 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 {
constexpr size_t get_page_size_log2() { return 12; }
constexpr size_t get_page_size() { return 1 << get_page_size_log2(); }
constexpr 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_ */

View File

@ -0,0 +1,27 @@
/*
* \brief Implementation of the IO_MEM session interface
* \author Norman Feske
* \date 2009-03-29
*
*/
/*
* Copyright (C) 2009-2013 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.
*/
/* core includes */
#include <io_mem_session_component.h>
using namespace Genode;
void Io_mem_session_component::_unmap_local(addr_t base, size_t size)
{ }
addr_t Io_mem_session_component::_map_local(addr_t base, size_t size)
{ return 0; }

View File

@ -0,0 +1,72 @@
/*
* \brief Implementation of IRQ session component
* \author Norman Feske
* \date 2009-10-02
*/
/*
* Copyright (C) 2009-2013 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.
*/
/* Genode includes */
#include <base/printf.h>
#include <base/sleep.h>
/* core includes */
#include <irq_root.h>
/* Codezero includes */
#include <codezero/syscalls.h>
using namespace Genode;
void Irq_session_component::wait_for_irq()
{
using namespace Codezero;
/* attach thread to IRQ when first called */
if (!_attached) {
int ret = l4_irq_control(IRQ_CONTROL_REGISTER, 0, _irq_number);
if (ret < 0) {
PERR("l4_irq_control(IRQ_CONTROL_REGISTER) returned %d", ret);
sleep_forever();
}
_attached = true;
}
/* block for IRQ */
int ret = l4_irq_control(IRQ_CONTROL_WAIT, 0, _irq_number);
if (ret < 0)
PWRN("l4_irq_control(IRQ_CONTROL_WAIT) returned %d", ret);
}
Irq_session_component::Irq_session_component(Cap_session *cap_session,
Range_allocator *irq_alloc,
const char *args)
:
_irq_alloc(irq_alloc),
_entrypoint(cap_session, STACK_SIZE, "irq"),
_attached(false)
{
long irq_number = Arg_string::find_arg(args, "irq_number").long_value(-1);
if (!irq_alloc || (irq_number == -1)||
irq_alloc->alloc_addr(1, irq_number).is_error()) {
PERR("unavailable IRQ %lx requested", irq_number);
return;
}
_irq_number = irq_number;
_cap = Irq_session_capability(_entrypoint.manage(this));
}
Irq_session_component::~Irq_session_component()
{
PERR("not yet implemented");
}

View File

@ -0,0 +1,302 @@
/*
* \brief Platform interface implementation
* \author Norman Feske
* \date 2009-10-02
*/
/*
* Copyright (C) 2009-2013 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.
*/
/* Genode includes */
#include <base/printf.h>
#include <base/sleep.h>
#include <base/thread.h>
/* core includes */
#include <core_parent.h>
#include <platform.h>
#include <map_local.h>
/* Codezero includes */
#include <codezero/syscalls.h>
using namespace Genode;
enum { verbose_boot_info = true };
/*
* Memory-layout information provided by the linker script
*/
/* virtual address range consumed by core's program image */
extern unsigned _prog_img_beg, _prog_img_end;
/* physical address range occupied by core */
extern addr_t _vma_start, _lma_start;
/**************************
** Boot-module handling **
**************************/
/**
* Scan ROM module image for boot modules
*
* By convention, the boot modules start at the page after core's BSS segment.
*/
int Platform::_init_rom_fs()
{
/**
* Format of module meta-data as found in the ROM module image
*/
struct Module
{
long name; /* physical address of null-terminated string */
long base; /* physical address of module data */
long size; /* size of module data in bytes */
};
/* find base address of ROM module image */
addr_t phys_base = round_page((addr_t)&_prog_img_end);
/* map the first page of the image containing the module meta data */
class Out_of_virtual_memory_during_rom_fs_init { };
void *virt_base = 0;
if (!_core_mem_alloc.virt_alloc()->alloc(get_page_size(), &virt_base))
throw Out_of_virtual_memory_during_rom_fs_init();
if (!map_local(phys_base, (addr_t)virt_base, 1)) {
PERR("map_local failed");
return -1;
}
/* remove page containing module infos from physical memory allocator */
_core_mem_alloc.phys_alloc()->remove_range(phys_base, get_page_size());
/* validate the presence of a ROM image by checking the magic cookie */
const char cookie[4] = {'G', 'R', 'O', 'M'};
for (size_t i = 0; i < sizeof(cookie); i++)
if (cookie[i] != ((char *)virt_base)[i]) {
PERR("could not detect ROM modules");
return -2;
}
printf("detected ROM module image at 0x%p\n", (void *)phys_base);
/* detect overly large meta data, we only support 4K */
addr_t end_of_header = ((long *)virt_base)[1];
size_t header_size = end_of_header - (long)phys_base;
if (header_size > get_page_size()) {
PERR("ROM fs module header exceeds %d bytes", get_page_size());
return -3;
}
/* start of module list */
Module *module = (Module *)((addr_t)virt_base + 2*sizeof(long));
/*
* Interate over module list and populate core's ROM file system with
* 'Rom_module' objects.
*/
for (; module->name; module++) {
/* convert physical address of module name to core-local address */
char *name = (char *)(module->name - phys_base + (addr_t)virt_base);
printf("ROM module \"%s\" at physical address 0x%p, size=%zd\n",
name, (void *)module->base, (size_t)module->size);
Rom_module *rom_module = new (core_mem_alloc())
Rom_module(module->base, module->size, name);
_rom_fs.insert(rom_module);
/* remove module from physical memory allocator */
_core_mem_alloc.phys_alloc()->remove_range(module->base, round_page(module->size));
}
return 0;
}
/****************************************
** Support for core memory management **
****************************************/
bool Core_mem_allocator::Mapped_mem_allocator::_map_local(addr_t virt_addr,
addr_t phys_addr,
unsigned size)
{
return map_local(phys_addr, virt_addr, size / get_page_size());
}
bool Core_mem_allocator::Mapped_mem_allocator::_unmap_local(addr_t virt_addr,
unsigned size)
{
return unmap_local(virt_addr, size / get_page_size());
}
/************************
** Platform interface **
************************/
Platform::Platform() :
_io_mem_alloc(core_mem_alloc()), _io_port_alloc(core_mem_alloc()),
_irq_alloc(core_mem_alloc()), _vm_base(0), _vm_size(0)
{
using namespace Codezero;
/* init core UTCB */
static char main_utcb[PAGE_SIZE] __attribute__((aligned(PAGE_SIZE)));
static struct exregs_data exregs;
exregs_set_utcb(&exregs, (unsigned long)&main_utcb[0]);
l4_exchange_registers(&exregs, thread_myself());
/* error handling is futile at this point */
/* read number of capabilities */
int num_caps;
int ret;
if ((ret = l4_capability_control(CAP_CONTROL_NCAPS,
0, &num_caps)) < 0) {
PERR("l4_capability_control(CAP_CONTROL_NCAPS) returned %d", ret);
class Could_not_obtain_num_of_capabilities { };
throw Could_not_obtain_num_of_capabilities();
}
struct capability cap_array[num_caps];
if (verbose_boot_info)
printf("allocated cap array[%d] of size %d on stack\n",
num_caps, sizeof(cap_array));
/* read all capabilities */
if ((ret = l4_capability_control(CAP_CONTROL_READ,
0, cap_array)) < 0) {
PERR("l4_capability_control(CAP_CONTROL_READ) returned %d", ret);
class Read_caps_failed { };
throw Read_caps_failed();
}
/* initialize core allocators */
bool phys_mem_defined = false;
addr_t dev_mem_base = 0;
for (int i = 0; i < num_caps; i++) {
struct capability *cap = &cap_array[i];
addr_t base = cap->start << get_page_size_log2(),
size = cap->size << get_page_size_log2();
if (verbose_boot_info)
printf("cap type=%x, rtype=%x, base=%lx, size=%lx\n",
cap_type(cap), cap_rtype(cap), base, size);
switch (cap_type(cap)) {
case CAP_TYPE_MAP_VIRTMEM:
/*
* Use first non-UTCB virtual address range as default
* virtual memory range usable for all processes.
*/
if (_vm_size == 0) {
/* exclude page at virtual address 0 */
if (base == 0 && size >= get_page_size()) {
base += get_page_size();
size -= get_page_size();
}
_vm_base = base;
_vm_size = size;
/* add range as free range to core's virtual address allocator */
_core_mem_alloc.virt_alloc()->add_range(base, size);
break;
}
PWRN("ignoring additional virtual address range [%lx,%lx)",
base, base + size);
break;
case CAP_TYPE_MAP_PHYSMEM:
/*
* We interpret the first physical memory resource that is bigger
* than typical device resources as RAM.
*/
enum { RAM_SIZE_MIN = 16*1024*1024 };
if (!phys_mem_defined && size > RAM_SIZE_MIN) {
_core_mem_alloc.phys_alloc()->add_range(base, size);
phys_mem_defined = true;
dev_mem_base = base + size;
}
break;
case CAP_TYPE_IPC:
case CAP_TYPE_UMUTEX:
case CAP_TYPE_IRQCTRL:
case CAP_TYPE_QUANTITY:
break;
}
}
addr_t core_virt_beg = trunc_page((addr_t)&_prog_img_beg),
core_virt_end = round_page((addr_t)&_prog_img_end);
size_t core_size = core_virt_end - core_virt_beg;
printf("core image:\n");
printf(" virtual address range [%08lx,%08lx) size=0x%zx\n",
core_virt_beg, core_virt_end, core_size);
printf(" physically located at 0x%08lx\n", _lma_start);
/* remove core image from core's virtual address allocator */
_core_mem_alloc.virt_alloc()->remove_range(core_virt_beg, core_size);
/* preserve context area in core's virtual address space */
_core_mem_alloc.virt_alloc()->raw()->remove_range(Native_config::context_area_virtual_base(),
Native_config::context_area_virtual_size());
/* remove used core memory from physical memory allocator */
_core_mem_alloc.phys_alloc()->remove_range(_lma_start, core_size);
/* remove magically mapped UART from core virtual memory */
_core_mem_alloc.virt_alloc()->remove_range(USERSPACE_CONSOLE_VBASE, get_page_size());
/* add boot modules to ROM fs */
if (_init_rom_fs() < 0) {
PERR("initialization of romfs failed - halt.");
while(1);
}
/* initialize interrupt allocator */
_irq_alloc.add_range(0, 255);
/* regard physical addresses higher than memory area as MMIO */
_io_mem_alloc.add_range(dev_mem_base, 0x80000000 - dev_mem_base);
/*
* Print statistics about allocator initialization
*/
printf("VM area at [%08lx,%08lx)\n", _vm_base, _vm_base + _vm_size);
if (verbose_boot_info) {
printf(":phys_alloc: "); _core_mem_alloc.phys_alloc()->raw()->dump_addr_tree();
printf(":virt_alloc: "); _core_mem_alloc.virt_alloc()->raw()->dump_addr_tree();
printf(":io_mem_alloc: "); _io_mem_alloc.raw()->dump_addr_tree();
}
}
void Platform::wait_for_exit()
{
sleep_forever();
}
void Core_parent::exit(int exit_value) { }

View File

@ -0,0 +1,126 @@
/*
* \brief Protection-domain facility
* \author Norman Feske
* \date 2009-10-02
*/
/*
* Copyright (C) 2009-2013 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.
*/
/* Genode includes */
#include <base/printf.h>
/* core includes */
#include <platform_pd.h>
#include <platform.h>
#include <util.h>
using namespace Genode;
using namespace Codezero;
/***************************
** Public object members **
***************************/
int Platform_pd::bind_thread(Platform_thread *thread)
{
/* allocate new thread at the kernel */
struct task_ids ids = { 1, _space_id, TASK_ID_INVALID };
int ret = l4_thread_control(THREAD_CREATE | TC_SHARE_SPACE, &ids);
if (ret < 0) {
PERR("l4_thread_control returned %d, tid=%d\n", ret, ids.tid);
return -1;
}
/* allocate UTCB for new thread */
int utcb_idx;
for (utcb_idx = 0; utcb_idx < MAX_THREADS_PER_PD; utcb_idx++)
if (!utcb_in_use[utcb_idx]) break;
if (utcb_idx == MAX_THREADS_PER_PD) {
PERR("UTCB allocation failed");
return -2;
}
/* mark UTCB as being in use */
utcb_in_use[utcb_idx] = true;
/* map UTCB area for the first thread of a new PD */
if (utcb_idx == 0) {
void *utcb_phys = 0;
if (!platform()->ram_alloc()->alloc(UTCB_AREA_SIZE, &utcb_phys)) {
PERR("could not allocate physical pages for UTCB");
return -3;
}
ret = l4_map(utcb_phys, (void *)UTCB_VIRT_BASE,
UTCB_AREA_SIZE/get_page_size(), MAP_USR_RW, ids.tid);
if (ret < 0) {
PERR("UTCB mapping into new PD failed, ret=%d", ret);
return -4;
}
}
addr_t utcb_addr = UTCB_VIRT_BASE + utcb_idx*sizeof(struct utcb);
thread->_assign_physical_thread(ids.tid, _space_id, utcb_addr,
this->Address_space::weak_ptr());
return 0;
}
void Platform_pd::unbind_thread(Platform_thread *thread)
{
/* find UTCB index of thread */
unsigned utcb_idx;
for (utcb_idx = 0; utcb_idx < MAX_THREADS_PER_PD; utcb_idx++)
if (thread->utcb() == UTCB_VIRT_BASE + utcb_idx*sizeof(struct utcb))
break;
if (utcb_idx == MAX_THREADS_PER_PD) {
PWRN("could not find UTCB index of thread");
return;
}
utcb_in_use[utcb_idx] = false;
PWRN("not fully implemented");
}
Platform_pd::Platform_pd(bool core)
{
PWRN("not yet implemented");
}
Platform_pd::Platform_pd(char const *, signed pd_id, bool create)
: _space_id(TASK_ID_INVALID)
{
_space_id = TASK_ID_INVALID;
/* mark all UTCBs of the new PD as free */
for (int i = 0; i < MAX_THREADS_PER_PD; i++)
utcb_in_use[i] = false;
struct task_ids ids = { TASK_ID_INVALID, TASK_ID_INVALID, TASK_ID_INVALID };
int ret = l4_thread_control(THREAD_CREATE | TC_NEW_SPACE, &ids);
if (ret < 0) {
PERR("l4_thread_control(THREAD_CREATE | TC_NEW_SPACE) returned %d", ret);
return;
}
/* set space ID to valid value to indicate success */
_space_id = ids.spid;
}
Platform_pd::~Platform_pd()
{
PWRN("not yet implemented");
}

View File

@ -0,0 +1,112 @@
/*
* \brief Thread facility
* \author Norman Feske
* \date 2009-10-02
*/
/*
* Copyright (C) 2009-2013 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.
*/
/* Genode includes */
#include <base/printf.h>
#include <util/string.h>
/* core includes */
#include <platform_thread.h>
/* Codezero includes */
#include <codezero/syscalls.h>
enum { verbose_thread_start = true };
using namespace Genode;
using namespace Codezero;
int Platform_thread::start(void *ip, void *sp, unsigned int cpu_no)
{
Native_thread_id pager = _pager ? _pager->cap().dst() : THREAD_INVALID;
/* setup thread context */
struct exregs_data exregs;
memset(&exregs, 0, sizeof(exregs));
exregs_set_stack(&exregs, (unsigned long)sp);
exregs_set_pc (&exregs, (unsigned long)ip);
exregs_set_pager(&exregs, pager);
exregs_set_utcb (&exregs, _utcb);
int ret = l4_exchange_registers(&exregs, _tid);
if (ret < 0) {
printf("l4_exchange_registers returned ret=%d\n", ret);
return -2;
}
/* start execution */
struct task_ids ids = { _tid, _space_id, _tid };
ret = l4_thread_control(THREAD_RUN, &ids);
if (ret < 0) {
printf("Error: l4_thread_control(THREAD_RUN) returned %d\n", ret);
return -3;
}
if (verbose_thread_start)
printf("core started thread \"%s\" with ID %d inside space ID %d\n",
_name, _tid, _space_id);
return 0;
}
void Platform_thread::pause()
{
PDBG("not implemented");
}
void Platform_thread::resume()
{
PDBG("not implemented");
}
void Platform_thread::state(Thread_state s)
{
PDBG("Not implemented");
throw Cpu_session::State_access_failed();
}
Thread_state Platform_thread::state()
{
PDBG("Not implemented");
throw Cpu_session::State_access_failed();
}
void Platform_thread::cancel_blocking()
{
PDBG("not implemented");
}
Weak_ptr<Address_space> Platform_thread::address_space()
{
return _address_space;
}
Platform_thread::Platform_thread(const char *name, unsigned, addr_t,
int thread_id)
: _tid(THREAD_INVALID)
{
strncpy(_name, name, sizeof(_name));
}
Platform_thread::~Platform_thread()
{
PDBG("not implemented");
}

View File

@ -0,0 +1,65 @@
/*
* \brief Export RAM dataspace as shared memory object (dummy)
* \author Norman Feske
* \date 2009-10-02
*/
/*
* Copyright (C) 2009-2013 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.
*/
/* Genode includes */
#include <base/printf.h>
#include <util/misc_math.h>
/* core includes */
#include <ram_session_component.h>
#include <platform.h>
#include <map_local.h>
using namespace Genode;
void Ram_session_component::_export_ram_ds(Dataspace_component *ds) { }
void Ram_session_component::_revoke_ram_ds(Dataspace_component *ds) { }
void Ram_session_component::_clear_ds (Dataspace_component *ds)
{
using namespace Codezero;
/*
* Map dataspace core-locally, memset, unmap dataspace
*/
size_t page_rounded_size = (ds->size() + get_page_size() - 1) & get_page_mask();
size_t num_pages = page_rounded_size >> get_page_size_log2();
/* allocate range in core's virtual address space */
void *virt_addr;
if (!platform()->region_alloc()->alloc(page_rounded_size, &virt_addr)) {
PERR("Could not allocate virtual address range in core of size %zd\n",
page_rounded_size);
return;
}
/* map the dataspace's physical pages to corresponding virtual addresses */
if (!map_local(ds->phys_addr(), (addr_t)virt_addr, num_pages)) {
PERR("core-local memory mapping failed\n");
return;
}
memset(virt_addr, 0, ds->size());
/* unmap dataspace from core */
if (!unmap_local((addr_t)virt_addr, num_pages)) {
PERR("could not unmap %zd pages from virtual address range at %p",
num_pages, virt_addr);
return;
}
/* free core's virtual address space */
platform()->region_alloc()->free(virt_addr, page_rounded_size);
}

View File

@ -0,0 +1,28 @@
/*
* \brief RM-session implementation
* \author Norman Feske
* \date 2009-10-02
*/
/*
* Copyright (C) 2009-2013 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.
*/
/* core includes */
#include <rm_session_component.h>
#include <util.h>
/* Codezero includes */
#include <codezero/syscalls.h>
using namespace Genode;
using namespace Codezero;
void Rm_client::unmap(addr_t core_local_base, addr_t virt_base, size_t size)
{
l4_unmap((void *)virt_base, size >> get_page_size_log2(), badge());
}

View File

@ -0,0 +1,57 @@
TARGET = core
GEN_CORE_DIR = $(BASE_DIR)/src/core
SRC_CC += \
main.cc \
ram_session_component.cc \
ram_session_support.cc \
rom_session_component.cc \
cpu_session_component.cc \
cpu_session_support.cc \
pd_session_component.cc \
io_mem_session_component.cc \
io_mem_session_support.cc \
thread_start.cc \
platform_thread.cc \
platform_pd.cc \
platform_services.cc \
platform.cc \
dataspace_component.cc \
rm_session_component.cc \
rm_session_support.cc \
irq_session_component.cc \
signal_session_component.cc \
signal_source_component.cc \
trace_session_component.cc \
core_rm_session.cc \
core_mem_alloc.cc \
dump_alloc.cc \
context_area.cc
LIBS += core_printf base-common
INC_DIR += $(REP_DIR)/src/core/include \
$(GEN_CORE_DIR)/include \
$(REP_DIR)/include/codezero/dummies \
$(BASE_DIR)/src/base/thread
include $(GEN_CORE_DIR)/version.inc
vpath main.cc $(GEN_CORE_DIR)
vpath ram_session_component.cc $(GEN_CORE_DIR)
vpath rom_session_component.cc $(GEN_CORE_DIR)
vpath cpu_session_component.cc $(GEN_CORE_DIR)
vpath pd_session_component.cc $(GEN_CORE_DIR)
vpath rm_session_component.cc $(GEN_CORE_DIR)
vpath io_mem_session_component.cc $(GEN_CORE_DIR)
vpath io_mem_session_support.cc $(GEN_CORE_DIR)
vpath platform_services.cc $(GEN_CORE_DIR)
vpath signal_session_component.cc $(GEN_CORE_DIR)
vpath signal_source_component.cc $(GEN_CORE_DIR)
vpath trace_session_component.cc $(GEN_CORE_DIR)
vpath dataspace_component.cc $(GEN_CORE_DIR)
vpath core_mem_alloc.cc $(GEN_CORE_DIR)
vpath dump_alloc.cc $(GEN_CORE_DIR)
vpath context_area.cc $(GEN_CORE_DIR)
vpath %.cc $(REP_DIR)/src/core

View File

@ -0,0 +1,4 @@
include $(PRG_DIR)/target.inc
LD_TEXT_ADDR = 0x100000

View File

@ -0,0 +1,120 @@
/*
* \brief Implementation of Thread API interface for core
* \author Norman Feske
* \date 2006-05-03
*/
/*
* Copyright (C) 2006-2013 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.
*/
/* Codezero includes */
#include <codezero/syscalls.h>
/* Genode includes */
#include <base/thread.h>
#include <base/printf.h>
#include <base/sleep.h>
/* core includes */
#include <platform.h>
#include <platform_thread.h>
enum { verbose_thread_start = true };
using namespace Genode;
void Thread_base::_deinit_platform_thread() { }
/**
* Create and start new thread
*
* \param space_no space ID in which the new thread will be executed
* \param sp initial stack pointer
* \param ip initial instruction pointer
* \return new thread ID, or
* negative error code
*/
inline int create_thread(unsigned space_no,
void *sp, void *ip,
int pager_tid = 1)
{
using namespace Codezero;
struct task_ids ids = { 1U, space_no, TASK_ID_INVALID };
/* allocate new thread at the kernel */
unsigned long flags = THREAD_CREATE | TC_SHARE_SPACE | TC_SHARE_GROUP;
int ret = l4_thread_control(flags, &ids);
if (ret < 0) {
PERR("l4_thread_control returned %d, spid=%d\n",
ret, ids.spid);
return -1;
}
unsigned long utcb_base_addr = (unsigned long)l4_get_utcb();
/* calculate utcb address of new thread */
unsigned long new_utcb = utcb_base_addr + ids.tid*sizeof(struct utcb);
/* setup thread context */
struct exregs_data exregs;
memset(&exregs, 0, sizeof(exregs));
exregs_set_stack(&exregs, (unsigned long)sp);
exregs_set_pc (&exregs, (unsigned long)ip);
exregs_set_pager(&exregs, pager_tid);
exregs_set_utcb (&exregs, new_utcb);
ret = l4_exchange_registers(&exregs, ids.tid);
if (ret < 0) {
printf("l4_exchange_registers returned ret=%d\n", ret);
return -2;
}
/* start execution */
ret = l4_thread_control(THREAD_RUN, &ids);
if (ret < 0) {
printf("Error: l4_thread_control(THREAD_RUN) returned %d\n", ret);
return -3;
}
/* return new thread ID allocated by the kernel */
return ids.tid;
}
void Thread_base::_thread_start()
{
Thread_base::myself()->_thread_bootstrap();
Thread_base::myself()->entry();
sleep_forever();
}
void Thread_base::start()
{
/* create and start platform thread */
_tid.pt = new(platform()->core_mem_alloc()) Platform_thread(_context->name);
_tid.l4id = create_thread(1, stack_top(), (void *)&_thread_start);
if (_tid.l4id < 0)
PERR("create_thread returned %d", _tid.l4id);
if (verbose_thread_start)
printf("core started local thread \"%s\" with ID %d\n",
_context->name, _tid.l4id);
}
void Thread_base::cancel_blocking()
{
PWRN("not implemented");
}