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:
57
repos/base-fiasco/Makefile
Normal file
57
repos/base-fiasco/Makefile
Normal file
@@ -0,0 +1,57 @@
|
||||
#
|
||||
# \brief Download, and unpack Fiasco and addtional needed tools (sigma0, bootstrap)
|
||||
# \author Stefan Kalkowski
|
||||
# \date 2011-07-18
|
||||
#
|
||||
|
||||
VERBOSE ?= @
|
||||
ECHO = @echo
|
||||
DOWNLOAD_DIR = download
|
||||
CONTRIB_DIR = contrib
|
||||
FIASCO_ARCHIVE = 3rd_fiasco.tar.bz2
|
||||
FIASCO_URI = http://downloads.sourceforge.net/project/genode/3rd/$(FIASCO_ARCHIVE)
|
||||
PATCHES = $(shell find patches -name *.patch)
|
||||
|
||||
#
|
||||
# Utility to check if a tool is installed
|
||||
#
|
||||
check_tool = $(if $(shell which $(1)),,$(error Need to have '$(1)' installed.))
|
||||
|
||||
$(call check_tool,wget)
|
||||
$(call check_tool,patch)
|
||||
$(call check_tool,tar)
|
||||
$(call check_tool,byacc)
|
||||
|
||||
#
|
||||
# Print help information by default
|
||||
#
|
||||
help:
|
||||
$(ECHO)
|
||||
$(ECHO) "Prepare the Fiasco base repository"
|
||||
$(ECHO)
|
||||
$(ECHO) "--- available commands ---"
|
||||
$(ECHO) "prepare - download and extract the Fiasco source code"
|
||||
$(ECHO) "clean - clean everything except downloaded archives"
|
||||
$(ECHO) "cleanall - clean everything including downloaded archives"
|
||||
$(ECHO)
|
||||
|
||||
$(DOWNLOAD_DIR)/$(FIASCO_ARCHIVE):
|
||||
$(ECHO) "downloading source code to '$(DOWNLOAD_DIR)/'"
|
||||
$(VERBOSE)mkdir -p $(DOWNLOAD_DIR)
|
||||
$(VERBOSE)wget -c $(FIASCO_URI) -O $@
|
||||
|
||||
$(CONTRIB_DIR): $(DOWNLOAD_DIR)/$(FIASCO_ARCHIVE)
|
||||
$(ECHO) "unpacking source code to '$(CONTRIB_DIR)/'"
|
||||
$(VERBOSE)tar xjf $<
|
||||
$(VERBOSE)mv 3rd $@
|
||||
$(ECHO) "applying patches to '$@/'"
|
||||
$(VERBOSE)for i in $(PATCHES); do patch -d $@ -p0 < $$i; done
|
||||
$(VERBOSE)touch $@
|
||||
|
||||
prepare: $(CONTRIB_DIR)
|
||||
|
||||
clean:
|
||||
$(VERBOSE)rm -rf $(CONTRIB_DIR)
|
||||
|
||||
cleanall: clean
|
||||
$(VERBOSE)rm -rf $(DOWNLOAD_DIR)
|
||||
4
repos/base-fiasco/README
Normal file
4
repos/base-fiasco/README
Normal file
@@ -0,0 +1,4 @@
|
||||
This repository contains the L4/Fiasco-specific implementation of Genode.
|
||||
|
||||
For instructions to build and start the Fiasco version of Genode, please
|
||||
consult the documentation located at 'base-fiasco/doc/fiasco.txt'.
|
||||
95
repos/base-fiasco/config/kernel-config.x86
Normal file
95
repos/base-fiasco/config/kernel-config.x86
Normal file
@@ -0,0 +1,95 @@
|
||||
#
|
||||
# Automatically generated make config: don't edit
|
||||
# Fiasco kernel version: SVN
|
||||
# Thu Jul 21 16:51:09 2011
|
||||
#
|
||||
|
||||
#
|
||||
# Target configuration
|
||||
#
|
||||
CONFIG_IA32=y
|
||||
# CONFIG_AMD64 is not set
|
||||
# CONFIG_ARM is not set
|
||||
CONFIG_PF_PC=y
|
||||
# CONFIG_PF_UX is not set
|
||||
# CONFIG_PF_REALVIEW is not set
|
||||
# CONFIG_PF_INTEGRATOR is not set
|
||||
# CONFIG_PF_XSCALE is not set
|
||||
# CONFIG_PF_SA1100 is not set
|
||||
CONFIG_ABI_V2=y
|
||||
# CONFIG_ARM_PXA is not set
|
||||
# CONFIG_ARM_SA is not set
|
||||
# CONFIG_ARM_920T is not set
|
||||
# CONFIG_ARM_926 is not set
|
||||
# CONFIG_ARM_1176 is not set
|
||||
# CONFIG_ARM_MPCORE is not set
|
||||
# CONFIG_ARM_CORTEX_A8 is not set
|
||||
# CONFIG_IA32_486 is not set
|
||||
CONFIG_IA32_586=y
|
||||
# CONFIG_IA32_686 is not set
|
||||
# CONFIG_IA32_P2 is not set
|
||||
# CONFIG_IA32_P3 is not set
|
||||
# CONFIG_IA32_P4 is not set
|
||||
# CONFIG_IA32_PM is not set
|
||||
# CONFIG_IA32_K6 is not set
|
||||
# CONFIG_IA32_K7 is not set
|
||||
# CONFIG_IA32_K8 is not set
|
||||
# CONFIG_AMD64_K8 is not set
|
||||
CONFIG_SCHED_PIT=y
|
||||
# CONFIG_SCHED_RTC is not set
|
||||
# CONFIG_SCHED_APIC is not set
|
||||
# CONFIG_WORKAROUND_AMD_FPU_LEAK is not set
|
||||
CONFIG_REGPARM3=y
|
||||
|
||||
#
|
||||
# Kernel options
|
||||
#
|
||||
CONFIG_HANDLE_SEGMENTS=y
|
||||
# CONFIG_PL0_HACK is not set
|
||||
CONFIG_TASK_CAPS=y
|
||||
# CONFIG_USER_LOCKS is not set
|
||||
CONFIG_CONTEXT_4K=y
|
||||
CONFIG_IO_PROT=y
|
||||
# CONFIG_IO_PROT_IOPL_3 is not set
|
||||
CONFIG_SYNC_TSC=y
|
||||
CONFIG_FINE_GRAINED_CPUTIME=y
|
||||
|
||||
#
|
||||
# Debugging
|
||||
#
|
||||
CONFIG_INLINE=y
|
||||
# CONFIG_NDEBUG is not set
|
||||
# CONFIG_NO_FRAME_PTR is not set
|
||||
# CONFIG_STACK_DEPTH is not set
|
||||
# CONFIG_LIST_ALLOC_SANITY is not set
|
||||
# CONFIG_BEFORE_IRET_SANITY is not set
|
||||
CONFIG_GSTABS=y
|
||||
# CONFIG_WATCHDOG is not set
|
||||
CONFIG_SERIAL=y
|
||||
CONFIG_JDB=y
|
||||
# CONFIG_JDB_LOGGING is not set
|
||||
# CONFIG_JDB_ACCOUNTING is not set
|
||||
# CONFIG_JDB_MISC is not set
|
||||
CONFIG_POWERSAVE_GETCHAR=y
|
||||
# CONFIG_WARN_NONE is not set
|
||||
# CONFIG_WARN_WARNING is not set
|
||||
CONFIG_WARN_ANY=y
|
||||
|
||||
#
|
||||
# Compiling
|
||||
#
|
||||
CONFIG_CC="gcc"
|
||||
CONFIG_CXX="g++"
|
||||
CONFIG_HOST_CC="gcc"
|
||||
CONFIG_HOST_CXX="g++"
|
||||
# CONFIG_VERBOSE is not set
|
||||
# CONFIG_MAINTAINER_MODE is not set
|
||||
CONFIG_LABEL=""
|
||||
CONFIG_EXPERIMENTAL=y
|
||||
CONFIG_PERF_CNT=y
|
||||
CONFIG_BIT32=y
|
||||
CONFIG_WARN_LEVEL=2
|
||||
CONFIG_XARCH="ia32"
|
||||
CONFIG_IA32_TARGET="Intel Pentium"
|
||||
CONFIG_ABI="v2"
|
||||
CONFIG_DECEIT_BIT_DISABLES_SWITCH=y
|
||||
83
repos/base-fiasco/config/l4env-config.x86
Normal file
83
repos/base-fiasco/config/l4env-config.x86
Normal file
@@ -0,0 +1,83 @@
|
||||
#
|
||||
# Automatically generated by configuration tool: don't edit
|
||||
#
|
||||
|
||||
#
|
||||
# Target Architecture
|
||||
#
|
||||
BUILD_ARCH_x86=y
|
||||
BUILD_ARCH_arm=n
|
||||
BUILD_ARCH_amd64=n
|
||||
BUILD_ARCH='x86'
|
||||
CPU='586'
|
||||
BUILD_ABI_l4v2=y
|
||||
BUILD_ABI_linux=n
|
||||
BUILD_ABI='l4v2'
|
||||
|
||||
#
|
||||
# Paths and Directories
|
||||
#
|
||||
DROPS_INSTDIR='$(DROPS_STDDIR)'
|
||||
|
||||
#
|
||||
# Verboseness and Messages
|
||||
#
|
||||
DEPEND_VERBOSE_SWITCH=n
|
||||
DEPEND_VERBOSE='@'
|
||||
VERBOSE_SWITCH=n
|
||||
SHOWMESSAGES=y
|
||||
BID_COLORED_PHASES=y
|
||||
|
||||
#
|
||||
# Compilers and Tools
|
||||
#
|
||||
BIDc_USE_SPECIAL_CC=y
|
||||
HOST_CC="gcc"
|
||||
HOST_CXX="g++"
|
||||
CC="${SYSTEM_TARGET}gcc -m32"
|
||||
CXX="${SYSTEM_TARGET}g++ -m32"
|
||||
|
||||
#
|
||||
# Tools
|
||||
#
|
||||
YACC='byacc'
|
||||
LEX='flex'
|
||||
CTAGS='ctags'
|
||||
ETAGS='etags'
|
||||
|
||||
#
|
||||
# Options
|
||||
#
|
||||
HAVE_LDSO=n
|
||||
INT_CPP_NAME_SWITCH=y
|
||||
INT_LD_NAME_SWITCH=y
|
||||
BID_STRIP_PROGS=n
|
||||
BID_GSTAB_SW=y
|
||||
BID_CFLAGS_GSTAB='-gstabs+'
|
||||
BID_GCC_OMIT_FP=n
|
||||
BID_GENERATE_MAPFILE=n
|
||||
BID_BUILD_DOC=y
|
||||
|
||||
#
|
||||
# Advanced
|
||||
#
|
||||
USE_UCLIBC=y
|
||||
USE_DIETLIBC=n
|
||||
BUILD_LOADER=n
|
||||
BUILD_LOADER_PICS='libl4util.a libl4util_root.a libsigma0.a libnames.a libloaderif.a libcon.a libl4rm.a libbootmod.a libcon.a libconstream-server.a libdm_generic.a libdm_mem.a libgeneric_ts.a liblogserver.a liblogserver_capsule.a libsemaphore.a libthread.a libslab.a libgeneric_fprov.a libl4env_err.a libl4env.a libroot.a libc_be_l4env_start_stop.a libc_be_minimal_log_io.a libc_be_simple_mem.a libc_be_mmap.a libc_be_mmap_util.a libuclibc_support.a librtc.a libl4env-l4lx.a'
|
||||
L4_CALL_SYSCALLS=y
|
||||
L4_ABS_SYSCALLS=y
|
||||
BID_CPPFLAGS_SYSCALLS='-DCONFIG_L4_CALL_SYSCALLS -DCONFIG_L4_ABS_SYSCALLS'
|
||||
USE_TASKLIB=n
|
||||
RELEASE_MODE=n
|
||||
BID_BUILD_L4DIR_ONLY=n
|
||||
CONFIG_LABEL='__none__'
|
||||
|
||||
#
|
||||
# Paths
|
||||
#
|
||||
LINUX24_INCDIR='$(OBJ_BASE)/include/linux-24 $(DROPS_STDDIR)/include/linux-24'
|
||||
LINUX26_INCDIR='$(OBJ_BASE)/include/$(ARCH)/l4/linux-26-headers $(DROPS_STDDIR)/include/$(ARCH)/l4/linux-26-headers $(OBJ_BASE)/include/l4/linux-26-headers $(DROPS_STDDIR)/include/l4/linux-26-headers'
|
||||
DDE_INCDIR='$(OBJ_BASE)/include/$(ARCH)/l4/dde_linux $(DROPS_STDDIR)/include/$(ARCH)/l4/dde_linux'
|
||||
DDE26_INCDIR='$(OBJ_BASE)/include/$(ARCH)/l4/dde_linux26 $(DROPS_STDDIR)/include/$(ARCH)/l4/dde_linux26 $(OBJ_BASE)/include/l4/dde_linux26 $(DROPS_STDDIR)/include/l4/dde_linux26'
|
||||
SDL_INCDIR='$(OBJ_BASE)/include/l4/sdl $(DROPS_STDDIR)/include/l4/sdl'
|
||||
137
repos/base-fiasco/doc/fiasco.txt
Normal file
137
repos/base-fiasco/doc/fiasco.txt
Normal file
@@ -0,0 +1,137 @@
|
||||
|
||||
=============================================
|
||||
How to use Genode with the Fiasco microkernel
|
||||
=============================================
|
||||
|
||||
|
||||
Norman Feske, Christian Helmuth
|
||||
|
||||
Abstract
|
||||
########
|
||||
|
||||
This documentation describes the process of building and booting the L4/Fiasco
|
||||
version of Genode. It assumes that you are familiar with basic concepts
|
||||
described in the introductory documentation of Genode, namely the "How to start
|
||||
exploring Genode" document.
|
||||
|
||||
|
||||
Preconditions
|
||||
#############
|
||||
|
||||
The Fiasco version of Genode relies on the following components from
|
||||
the source tree of the Fiasco microkernel and the L4 environment (which also
|
||||
need additional tools).
|
||||
|
||||
|
||||
Tools
|
||||
=====
|
||||
|
||||
* Gawk
|
||||
* Bison
|
||||
* Byacc
|
||||
* Python
|
||||
|
||||
|
||||
The Fiasco microkernel
|
||||
======================
|
||||
|
||||
Information about Fiasco are provided at its official website:
|
||||
|
||||
! http://os.inf.tu-dresden.de/fiasco/prev/
|
||||
|
||||
To download the kernel and integrate it with Genode, issue the following
|
||||
command from within the 'base-fiasco' directory:
|
||||
|
||||
! make prepare
|
||||
|
||||
For the vesa driver on x86 the x86emu library is required and can be downloaded
|
||||
and prepared by invoking the following command from within the 'libports'
|
||||
directory:
|
||||
|
||||
! make prepare PKG=x86emu
|
||||
|
||||
This command will download a prepackaged version of the kernel tested
|
||||
with Genode. The build process of the kernel is integrated with Genode's
|
||||
build system. After creating a build directory using 'create_builddir'
|
||||
with 'fiasco_x86' as argument:
|
||||
|
||||
! <genode-dir>/tool/create_builddir fiasco_x86 \
|
||||
! BUILD_DIR=<build-dir>
|
||||
|
||||
From within the new <build-dir>, the kernel can be compiled via
|
||||
|
||||
! make kernel
|
||||
|
||||
When using Genode's run mechanism, there is no need to explicitly
|
||||
build the kernel. The run environment (see 'base-fiasco/run/env')
|
||||
takes care of it. So you can simple execute run scripts from within
|
||||
the build directory, for example:
|
||||
|
||||
! make run/demo
|
||||
|
||||
|
||||
Behind the scenes
|
||||
=================
|
||||
|
||||
For using the L4/Fiasco kernel, some basic user-level components and libraries
|
||||
are needed. These are subsumed under the name L4 environment an are organized
|
||||
as a number of packages. These packages provide two types of components. There
|
||||
are low-level components for booting up and interfacing to Fiasco and there are
|
||||
higher-level components that compose a basic OS infrastructure. For Genode, we
|
||||
only rely on the low-level packages.
|
||||
|
||||
Previous versions of Genode included all necessary sources from the L4
|
||||
environment in the '3rd/fiasco/snapshot' subdirectory. From release 10.02, the
|
||||
'3rd' directory is no longer part of the release archive and also removed from
|
||||
the subversion repository. Please download the '3rd_fiasco.tar.bz2' archive.
|
||||
The source are organized as follows
|
||||
|
||||
:'tool': contains the tools that are used by the build processes of
|
||||
the L4 environment and Fiasco. For example, the build process of Fiasco
|
||||
relies on the 'preprocess' tool.
|
||||
|
||||
:'kernel': contains the Fiasco microkernel.
|
||||
|
||||
:'l4': contains the L4-environment source tree. The single packages
|
||||
are located at 'l4/pkg'.
|
||||
|
||||
From all the packages of the L4 environment, the following three are of
|
||||
interest for using Genode:
|
||||
|
||||
:'pkg/l4sys': contains the Fiasco system-call bindings.
|
||||
|
||||
The system-call bindings are a set of C-header files that define the
|
||||
application-programming interface for invoking the system calls of
|
||||
Fiasco.
|
||||
|
||||
:'pkg/sigma0':
|
||||
|
||||
Sigma0 is the initial memory manager required to use Fiasco.
|
||||
|
||||
:'pkg/bootstrap':
|
||||
|
||||
Bootstrap is the program that is started by the boot loader.
|
||||
After being started, Bootstrap prepares the bare machine to
|
||||
accommodate Fiasco. On many embedded architectures, bootstrap
|
||||
is used to create a single binary image containing all boot-time
|
||||
OS components.
|
||||
|
||||
To build all components under '3rd/fiasco' after extracting the
|
||||
archive, issue the following commands:
|
||||
|
||||
! mkdir <build-dir>
|
||||
! make -C 3rd/fiasco BUILD_DIR=<build-dir>/3rd build
|
||||
|
||||
The specified '<build-dir>' must be the absolute path to the
|
||||
directory, which will contain the build directories for the third party
|
||||
software and the Genode build directory. After the build, your compound
|
||||
build directory contains the following subdirectories:
|
||||
|
||||
:'fiasco_x86':
|
||||
|
||||
All generated files and the final binary of Fiasco reside here.
|
||||
|
||||
:'l4env':
|
||||
|
||||
L4 environment binaries and header files.
|
||||
|
||||
11
repos/base-fiasco/etc/fiasco.conf
Normal file
11
repos/base-fiasco/etc/fiasco.conf
Normal file
@@ -0,0 +1,11 @@
|
||||
#
|
||||
# Fiasco-specific default configuration options
|
||||
#
|
||||
|
||||
#
|
||||
# Directory, where to search for L4 headers
|
||||
#
|
||||
# When using this file as template for a customized
|
||||
# '<builddir>/etc/fiasco.conf'.
|
||||
#
|
||||
#L4_DIR = $(HOME)/src/l4build.x86
|
||||
15
repos/base-fiasco/etc/specs.conf
Normal file
15
repos/base-fiasco/etc/specs.conf
Normal file
@@ -0,0 +1,15 @@
|
||||
#
|
||||
# Description of build platform
|
||||
#
|
||||
|
||||
#
|
||||
# To build the Fiasco-specific Genode binaries,
|
||||
# use one of the the following config options.
|
||||
#
|
||||
SPECS = genode fiasco_x86
|
||||
|
||||
#
|
||||
# To build for the ARM integrator platform,
|
||||
# use the following SPECS value.
|
||||
#
|
||||
#SPECS = genode platform_integrator fiasco_arm
|
||||
8
repos/base-fiasco/etc/tools.conf
Normal file
8
repos/base-fiasco/etc/tools.conf
Normal file
@@ -0,0 +1,8 @@
|
||||
#
|
||||
# The following options let you define your cross-compile tool chain
|
||||
#
|
||||
|
||||
include $(BASE_DIR)/etc/tools.conf
|
||||
|
||||
#CROSS_DEV_PREFIX = arm-softfloat-linux-gnu-
|
||||
|
||||
56
repos/base-fiasco/include/base/cancelable_lock.h
Normal file
56
repos/base-fiasco/include/base/cancelable_lock.h
Normal file
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* \brief Basic locking primitive
|
||||
* \author Norman Feske
|
||||
* \date 2006-07-26
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef _INCLUDE__BASE__CANCELABLE_LOCK_H_
|
||||
#define _INCLUDE__BASE__CANCELABLE_LOCK_H_
|
||||
|
||||
#include <base/lock_guard.h>
|
||||
#include <base/blocking.h>
|
||||
|
||||
namespace Genode {
|
||||
|
||||
class Cancelable_lock
|
||||
{
|
||||
private:
|
||||
|
||||
int volatile _lock;
|
||||
|
||||
public:
|
||||
|
||||
enum State { LOCKED, UNLOCKED };
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
explicit Cancelable_lock(State initial = UNLOCKED);
|
||||
|
||||
/**
|
||||
* Try to aquire lock an block while lock is not free
|
||||
*
|
||||
* This function may throw a Genode::Blocking_canceled exception.
|
||||
*/
|
||||
void lock();
|
||||
|
||||
/**
|
||||
* Release lock
|
||||
*/
|
||||
void unlock();
|
||||
|
||||
/**
|
||||
* Lock guard
|
||||
*/
|
||||
typedef Genode::Lock_guard<Cancelable_lock> Guard;
|
||||
};
|
||||
}
|
||||
|
||||
#endif /* _INCLUDE__BASE__CANCELABLE_LOCK_H_ */
|
||||
65
repos/base-fiasco/include/base/ipc_msgbuf.h
Normal file
65
repos/base-fiasco/include/base/ipc_msgbuf.h
Normal file
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* \brief Fiasco-specific layout of IPC message buffer
|
||||
* \author Norman Feske
|
||||
* \date 2006-06-14
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef _INCLUDE__BASE__IPC_MSGBUF_H_
|
||||
#define _INCLUDE__BASE__IPC_MSGBUF_H_
|
||||
|
||||
namespace Genode {
|
||||
|
||||
/**
|
||||
* IPC message buffer layout
|
||||
*/
|
||||
class Msgbuf_base
|
||||
{
|
||||
protected:
|
||||
|
||||
Genode::size_t _size;
|
||||
|
||||
public:
|
||||
|
||||
/*
|
||||
* Begin of message buffer layout
|
||||
*/
|
||||
|
||||
Fiasco::l4_fpage_t rcv_fpage;
|
||||
Fiasco::l4_msgdope_t size_dope;
|
||||
Fiasco::l4_msgdope_t send_dope;
|
||||
char buf[];
|
||||
|
||||
/**
|
||||
* Return size of message buffer
|
||||
*/
|
||||
inline size_t size() const { return _size; };
|
||||
|
||||
/**
|
||||
* Return address of message buffer
|
||||
*/
|
||||
inline void *addr() { return &rcv_fpage; };
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Instance of IPC message buffer with specified buffer size
|
||||
*/
|
||||
template <unsigned BUF_SIZE>
|
||||
class Msgbuf : public Msgbuf_base
|
||||
{
|
||||
public:
|
||||
|
||||
char buf[BUF_SIZE];
|
||||
|
||||
Msgbuf() { _size = BUF_SIZE; }
|
||||
};
|
||||
}
|
||||
|
||||
#endif /* _INCLUDE__BASE__IPC_MSGBUF_H_ */
|
||||
174
repos/base-fiasco/include/base/ipc_pager.h
Normal file
174
repos/base-fiasco/include/base/ipc_pager.h
Normal file
@@ -0,0 +1,174 @@
|
||||
/*
|
||||
* \brief Fiasco pager support
|
||||
* \author Christian Helmuth
|
||||
* \date 2006-06-14
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef _INCLUDE__BASE__IPC_PAGER_H_
|
||||
#define _INCLUDE__BASE__IPC_PAGER_H_
|
||||
|
||||
/* Genode includes */
|
||||
#include <base/ipc.h>
|
||||
#include <base/stdint.h>
|
||||
#include <base/native_types.h>
|
||||
#include <fiasco/thread_helper.h>
|
||||
#include <util/touch.h>
|
||||
|
||||
/* Fiasco includes */
|
||||
namespace Fiasco {
|
||||
#include <l4/sys/types.h>
|
||||
}
|
||||
|
||||
namespace Genode {
|
||||
|
||||
class Mapping
|
||||
{
|
||||
private:
|
||||
|
||||
addr_t _dst_addr;
|
||||
Fiasco::l4_fpage_t _fpage;
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
Mapping(addr_t dst_addr, addr_t src_addr,
|
||||
bool write_combined, bool io_mem,
|
||||
unsigned l2size = L4_LOG2_PAGESIZE,
|
||||
bool rw = true, bool grant = false)
|
||||
:
|
||||
_dst_addr(dst_addr),
|
||||
_fpage(Fiasco::l4_fpage(src_addr, l2size, rw, grant))
|
||||
{
|
||||
if (write_combined)
|
||||
_fpage.fp.cache = Fiasco::L4_FPAGE_BUFFERABLE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct invalid flexpage
|
||||
*/
|
||||
Mapping() : _dst_addr(0), _fpage(Fiasco::l4_fpage(0, 0, 0, 0)) { }
|
||||
|
||||
Fiasco::l4_umword_t dst_addr() const { return _dst_addr; }
|
||||
Fiasco::l4_fpage_t fpage() const { return _fpage; }
|
||||
|
||||
/**
|
||||
* Prepare map operation
|
||||
*
|
||||
* On Fiasco, we need to map a page locally to be able to map it to
|
||||
* another address space.
|
||||
*/
|
||||
void prepare_map_operation()
|
||||
{
|
||||
addr_t core_local_addr = _fpage.fp.page << 12;
|
||||
size_t mapping_size = 1 << _fpage.fp.size;
|
||||
|
||||
for (addr_t i = 0; i < mapping_size; i += L4_PAGESIZE) {
|
||||
if (_fpage.fp.write)
|
||||
touch_read_write((unsigned char volatile *)(core_local_addr + i));
|
||||
else
|
||||
touch_read((unsigned char const volatile *)(core_local_addr + i));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Special paging server class
|
||||
*/
|
||||
class Ipc_pager : public Native_capability
|
||||
{
|
||||
private:
|
||||
|
||||
Native_thread_id _last; /* origin of last fault message */
|
||||
addr_t _pf_addr; /* page-fault address */
|
||||
addr_t _pf_ip; /* instruction pointer of faulter */
|
||||
Mapping _reply_mapping; /* page-fault answer */
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
Ipc_pager();
|
||||
|
||||
/**
|
||||
* Wait for a new page fault received as short message IPC
|
||||
*/
|
||||
void wait_for_fault();
|
||||
|
||||
/**
|
||||
* Reply current page-fault and wait for a new one
|
||||
*
|
||||
* Send short flex page and wait for next short-message (register)
|
||||
* IPC -- pagefault
|
||||
*/
|
||||
void reply_and_wait_for_fault();
|
||||
|
||||
/**
|
||||
* Request instruction pointer of current page fault
|
||||
*/
|
||||
addr_t fault_ip() { return _pf_ip; }
|
||||
|
||||
/**
|
||||
* Request fault address of current page fault
|
||||
*/
|
||||
addr_t fault_addr() { return _pf_addr & ~3; }
|
||||
|
||||
/**
|
||||
* Set parameters for next reply
|
||||
*/
|
||||
void set_reply_mapping(Mapping m) { _reply_mapping = m; }
|
||||
|
||||
/**
|
||||
* Set destination for next reply
|
||||
*/
|
||||
void set_reply_dst(Native_capability pager_object) {
|
||||
_last.raw = pager_object.local_name(); }
|
||||
|
||||
/**
|
||||
* Answer call without sending a flex-page mapping
|
||||
*
|
||||
* This function is used to acknowledge local calls from one of
|
||||
* core's region-manager sessions.
|
||||
*/
|
||||
void acknowledge_wakeup();
|
||||
|
||||
/**
|
||||
* Return thread ID of last faulter
|
||||
*/
|
||||
Native_thread_id last() const { return _last; }
|
||||
|
||||
/**
|
||||
* Return badge for faulting thread
|
||||
*
|
||||
* As Fiasco has no server-defined badges for page-fault messages, we
|
||||
* interpret the sender ID as badge.
|
||||
*/
|
||||
unsigned long badge() const {
|
||||
return convert_native_thread_id_to_badge(_last); }
|
||||
|
||||
bool is_write_fault() const { return (_pf_addr & 2); }
|
||||
|
||||
/**
|
||||
* Return true if last fault was an exception
|
||||
*/
|
||||
bool is_exception() const
|
||||
{
|
||||
/*
|
||||
* Reflection of exceptions is not supported on this platform.
|
||||
*/
|
||||
return false;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif /* _INCLUDE__BASE__IPC_PAGER_H_ */
|
||||
95
repos/base-fiasco/include/base/native_types.h
Normal file
95
repos/base-fiasco/include/base/native_types.h
Normal file
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
* \brief Native types on L4/Fiasco
|
||||
* \author Norman Feske
|
||||
* \date 2008-07-26
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2008-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 _INCLUDE__BASE__NATIVE_TYPES_H_
|
||||
#define _INCLUDE__BASE__NATIVE_TYPES_H_
|
||||
|
||||
#include <base/native_capability.h>
|
||||
#include <base/stdint.h>
|
||||
|
||||
namespace Fiasco {
|
||||
#include <l4/sys/types.h>
|
||||
}
|
||||
|
||||
namespace Genode {
|
||||
|
||||
class Platform_thread;
|
||||
|
||||
typedef Fiasco::l4_threadid_t Native_thread_id;
|
||||
|
||||
struct Cap_dst_policy
|
||||
{
|
||||
typedef Fiasco::l4_threadid_t Dst;
|
||||
static bool valid(Dst id) { return !Fiasco::l4_is_invalid_id(id); }
|
||||
static Dst invalid()
|
||||
{
|
||||
using namespace Fiasco;
|
||||
return L4_INVALID_ID;
|
||||
}
|
||||
static void copy(void* dst, Native_capability_tpl<Cap_dst_policy>* src);
|
||||
};
|
||||
|
||||
struct Native_thread
|
||||
{
|
||||
Native_thread_id l4id;
|
||||
|
||||
/**
|
||||
* Only used in core
|
||||
*
|
||||
* For 'Thread' objects created within core, 'pt' points to
|
||||
* the physical thread object, which is going to be destroyed
|
||||
* on destruction of the 'Thread'.
|
||||
*/
|
||||
Platform_thread *pt;
|
||||
};
|
||||
|
||||
inline unsigned long convert_native_thread_id_to_badge(Native_thread_id tid)
|
||||
{
|
||||
/*
|
||||
* Fiasco has no server-defined badges for page-fault messages.
|
||||
* Therefore, we have to interpret the sender ID as badge.
|
||||
*/
|
||||
return tid.raw;
|
||||
}
|
||||
|
||||
/**
|
||||
* Empty UTCB type expected by the thread library
|
||||
*
|
||||
* On this kernel, UTCBs are not placed within the the context area. Each
|
||||
* thread can request its own UTCB pointer using the kernel interface.
|
||||
*/
|
||||
typedef struct { } Native_utcb;
|
||||
|
||||
typedef Native_capability_tpl<Cap_dst_policy> Native_capability;
|
||||
typedef Fiasco::l4_threadid_t Native_connection_state;
|
||||
|
||||
struct Native_config
|
||||
{
|
||||
/**
|
||||
* Thread-context area configuration.
|
||||
*/
|
||||
static constexpr addr_t context_area_virtual_base() {
|
||||
return 0x40000000UL; }
|
||||
static constexpr addr_t context_area_virtual_size() {
|
||||
return 0x10000000UL; }
|
||||
|
||||
/**
|
||||
* Size of virtual address region holding the context of one thread
|
||||
*/
|
||||
static constexpr addr_t context_virtual_size() { return 0x00100000UL; }
|
||||
};
|
||||
|
||||
struct Native_pd_args { };
|
||||
}
|
||||
|
||||
#endif /* _INCLUDE__BASE__NATIVE_TYPES_H_ */
|
||||
31
repos/base-fiasco/include/base/sleep.h
Normal file
31
repos/base-fiasco/include/base/sleep.h
Normal file
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* \brief Lay back and relax
|
||||
* \author Norman Feske
|
||||
* \author Christian Helmuth
|
||||
* \date 2006-07-19
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2006-2014 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 _INCLUDE__BASE__SLEEP_H_
|
||||
#define _INCLUDE__BASE__SLEEP_H_
|
||||
|
||||
/* L4/Fiasco includes */
|
||||
namespace Fiasco {
|
||||
#include <l4/sys/ipc.h>
|
||||
}
|
||||
|
||||
namespace Genode {
|
||||
|
||||
__attribute__((noreturn)) inline void sleep_forever()
|
||||
{
|
||||
while (true) Fiasco::l4_ipc_sleep((Fiasco::l4_timeout_t){0});
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* _INCLUDE__BASE__SLEEP_H_ */
|
||||
40
repos/base-fiasco/include/fiasco/thread_helper.h
Normal file
40
repos/base-fiasco/include/fiasco/thread_helper.h
Normal file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* \brief Fiasco-specific thread helper functions
|
||||
* \author Norman Feske
|
||||
* \date 2007-05-03
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2007-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 _INCLUDE__FIASCO__THREAD_HELPER_H_
|
||||
#define _INCLUDE__FIASCO__THREAD_HELPER_H_
|
||||
|
||||
#include <base/printf.h>
|
||||
|
||||
namespace Fiasco {
|
||||
#include <l4/sys/types.h>
|
||||
|
||||
inline void print_l4_threadid(l4_threadid_t t)
|
||||
{
|
||||
Genode::printf("THREAD %x.%02x\n", t.id.task, t.id.lthread);
|
||||
Genode::printf(" unsigned version_low:10 = %x\n", t.id.version_low);
|
||||
Genode::printf(" unsigned lthread:7 = %x\n", t.id.lthread);
|
||||
Genode::printf(" unsigned task:11 = %x\n", t.id.task);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sigma0 thread ID
|
||||
*
|
||||
* We must use a raw hex value initializer since we're using C++ and
|
||||
* l4_threadid_t is an union.
|
||||
*/
|
||||
const l4_threadid_t sigma0_threadid = { 0x00040000 };
|
||||
}
|
||||
|
||||
#endif /* _INCLUDE__FIASCO__THREAD_HELPER_H_ */
|
||||
31
repos/base-fiasco/lib/mk/base-common.mk
Normal file
31
repos/base-fiasco/lib/mk/base-common.mk
Normal file
@@ -0,0 +1,31 @@
|
||||
#
|
||||
# \brief Portions of base library shared by core and non-core processes
|
||||
# \author Norman Feske
|
||||
# \date 2013-02-14
|
||||
#
|
||||
|
||||
LIBS += cxx startup
|
||||
|
||||
SRC_CC += cap_copy.cc
|
||||
SRC_CC += ipc/ipc.cc ipc/pager.cc ipc/ipc_marshal_cap.cc
|
||||
SRC_CC += pager/pager.cc pager/common.cc
|
||||
SRC_CC += avl_tree/avl_tree.cc
|
||||
SRC_CC += allocator/slab.cc
|
||||
SRC_CC += allocator/allocator_avl.cc
|
||||
SRC_CC += heap/heap.cc heap/sliced_heap.cc
|
||||
SRC_CC += console/console.cc
|
||||
SRC_CC += child/child.cc
|
||||
SRC_CC += process/process.cc
|
||||
SRC_CC += elf/elf_binary.cc
|
||||
SRC_CC += lock/lock.cc
|
||||
SRC_CC += signal/signal.cc signal/common.cc
|
||||
SRC_CC += server/server.cc server/common.cc
|
||||
SRC_CC += thread/thread.cc thread/thread_bootstrap.cc thread/trace.cc
|
||||
SRC_CC += thread/context_allocator.cc
|
||||
|
||||
INC_DIR += $(REP_DIR)/src/base/lock
|
||||
INC_DIR += $(BASE_DIR)/src/base/thread
|
||||
|
||||
vpath cap_copy.cc $(BASE_DIR)/src/platform
|
||||
vpath %.cc $(REP_DIR)/src/base
|
||||
vpath %.cc $(BASE_DIR)/src/base
|
||||
16
repos/base-fiasco/lib/mk/base.mk
Normal file
16
repos/base-fiasco/lib/mk/base.mk
Normal file
@@ -0,0 +1,16 @@
|
||||
#
|
||||
# \brief Portions of base library that are exclusive to non-core processes
|
||||
# \author Norman Feske
|
||||
# \date 2013-02-14
|
||||
#
|
||||
|
||||
LIBS += base-common
|
||||
|
||||
SRC_CC += console/log_console.cc
|
||||
SRC_CC += env/env.cc env/context_area.cc env/reinitialize.cc
|
||||
SRC_CC += thread/thread_start.cc
|
||||
|
||||
INC_DIR += $(BASE_DIR)/src/base/env
|
||||
|
||||
vpath %.cc $(REP_DIR)/src/base
|
||||
vpath %.cc $(BASE_DIR)/src/base
|
||||
19
repos/base-fiasco/lib/mk/l4v2_support.mk
Normal file
19
repos/base-fiasco/lib/mk/l4v2_support.mk
Normal file
@@ -0,0 +1,19 @@
|
||||
#
|
||||
# Build L4env base libraries, needed by sigma0 and bootstrap
|
||||
|
||||
|
||||
# ignore stage one, visit the L4 build system at second build stage
|
||||
ifeq ($(called_from_lib_mk),yes)
|
||||
|
||||
# packages in 'l4/pkg/'
|
||||
PKGS = l4sys/lib \
|
||||
uclibc/lib/uclibc \
|
||||
uclibc/lib/include \
|
||||
crtx \
|
||||
l4util/lib \
|
||||
cxx
|
||||
|
||||
include $(REP_DIR)/mk/l4_pkg.mk
|
||||
all: $(PKG_TAGS)
|
||||
|
||||
endif
|
||||
56
repos/base-fiasco/lib/mk/platform.inc
Normal file
56
repos/base-fiasco/lib/mk/platform.inc
Normal file
@@ -0,0 +1,56 @@
|
||||
#
|
||||
# Create prerequisites for building Genode for Fiasco
|
||||
#
|
||||
# Prior building Genode programs for Fiasco, the kernel bindings must be
|
||||
# generated. This is done by building a minimalistic subset of the original
|
||||
# userland that comes with Fiasco.
|
||||
#
|
||||
|
||||
#
|
||||
# Execute the rules in this file only at the second build stage when we know
|
||||
# about the complete build settings, e.g., the 'CROSS_DEV_PREFIX'.
|
||||
#
|
||||
ifeq ($(called_from_lib_mk),yes)
|
||||
|
||||
#
|
||||
# Sanity checks
|
||||
#
|
||||
ifeq ($(L4_BUILD_DIR),$(BUILD_BASE_DIR)/l4)
|
||||
all: $(L4_SRC_DIR)
|
||||
|
||||
$(L4_SRC_DIR):
|
||||
$(VERBOSE)$(ECHO) "--> Please, execute 'make prepare' in $(REP_DIR)"
|
||||
$(VERBOSE)$(ECHO) "--> before compiling Genode apps for Fiasco."
|
||||
$(VERBOSE)exit 1
|
||||
endif
|
||||
|
||||
#
|
||||
# Create L4 build directory
|
||||
#
|
||||
$(BUILD_BASE_DIR)/l4/.Makeconf.bid.old:
|
||||
$(VERBOSE)mkdir -p $(dir $@)
|
||||
$(VERBOSE)cp $(L4_CONFIG) $(@:.old=)
|
||||
$(VERBOSE_MK) MAKEFLAGS= make $(VERBOSE_DIR) -C $(L4_SRC_DIR)/l4 \
|
||||
O=$(BUILD_BASE_DIR)/l4 SYSTEM_TARGET="$(CROSS_DEV_PREFIX)" oldconfig
|
||||
|
||||
$(BUILD_BASE_DIR)/l4/pkg/uclibc/lib/uclibc:
|
||||
$(VERBOSE)mkdir -p $(BUILD_BASE_DIR)/l4/pkg/uclibc/lib/uclibc
|
||||
$(VERBOSE)tar cf - --exclude .svn -C $(L4_SRC_DIR)/../uclibc ARCH-all ARCH-x86 \
|
||||
| tar xf - -C $(BUILD_BASE_DIR)/l4/pkg/uclibc/lib/uclibc
|
||||
|
||||
PKGS = input/include \
|
||||
drivers/uart/include \
|
||||
l4sys/include \
|
||||
l4util/include \
|
||||
libc_support/include \
|
||||
libsigma0/include
|
||||
|
||||
include $(REP_DIR)/mk/l4_pkg.mk
|
||||
|
||||
all: $(PKG_TAGS)
|
||||
|
||||
$(PKG_TAGS): $(BUILD_BASE_DIR)/l4/.Makeconf.bid.old
|
||||
$(PKG_TAGS): $(BUILD_BASE_DIR)/l4/pkg/uclibc/lib/uclibc
|
||||
|
||||
endif
|
||||
|
||||
6
repos/base-fiasco/lib/mk/x86/platform.mk
Normal file
6
repos/base-fiasco/lib/mk/x86/platform.mk
Normal file
@@ -0,0 +1,6 @@
|
||||
#
|
||||
# Configuration for L4 build system (for kernel-bindings, sigma0, bootstrap).
|
||||
#
|
||||
L4_CONFIG = $(REP_DIR)/config/l4env-config.x86
|
||||
|
||||
include $(REP_DIR)/lib/mk/platform.inc
|
||||
69
repos/base-fiasco/mk/l4_pkg.mk
Normal file
69
repos/base-fiasco/mk/l4_pkg.mk
Normal file
@@ -0,0 +1,69 @@
|
||||
#
|
||||
# Utility for building L4 contrib packages
|
||||
#
|
||||
# Variables that steer the behaviour of this makefile:
|
||||
#
|
||||
# TARGET - name of target
|
||||
# PKGS - list of L4 packages to visit in order to create
|
||||
# the target
|
||||
#
|
||||
|
||||
LIBS += platform
|
||||
|
||||
ifeq ($(filter-out $(SPECS),x86_32),)
|
||||
L4_BUILD_ARCH := x86
|
||||
endif
|
||||
|
||||
ifeq ($(filter-out $(SPECS),arm),)
|
||||
L4_BUILD_ARCH := arm
|
||||
endif
|
||||
|
||||
ifeq ($(L4_BUILD_ARCH),)
|
||||
all: l4_build_arch_undefined
|
||||
$(VERBOSE)$(ECHO) "Error: L4_BUILD_ARCH undefined, architecture not supported"
|
||||
$(VERBOSE)false
|
||||
endif
|
||||
|
||||
L4_PKG_DIR = $(L4_SRC_DIR)/l4/pkg
|
||||
STARTUP_LIB =
|
||||
PKG_TAGS = $(addsuffix .tag,$(PKGS))
|
||||
|
||||
ifeq ($(VERBOSE),)
|
||||
L4_VERBOSE = V=1
|
||||
endif
|
||||
|
||||
$(TARGET): $(PKG_TAGS)
|
||||
|
||||
#
|
||||
# We preserve the order of processing 'l4/pkg/' directories because of
|
||||
# inter-package dependencies. However, within each directory, make is working
|
||||
# in parallel.
|
||||
#
|
||||
.NOTPARALLEL: $(PKG_TAGS)
|
||||
|
||||
#
|
||||
# The '_GNU_SOURCE' definition is needed to convince uClibc to define the
|
||||
# 'off64_t' type, which is used by bootstrap.
|
||||
#
|
||||
%.tag:
|
||||
$(VERBOSE_MK) MAKEFLAGS= CPPFLAGS="$(CC_MARCH)" \
|
||||
CFLAGS="$(CC_MARCH)" CXXFLAGS="$(CC_MARCH) -D_GNU_SOURCE" \
|
||||
ASFLAGS="$(CC_MARCH)" LDFLAGS="$(LD_MARCH)" \
|
||||
$(MAKE) $(VERBOSE_DIR) O=$(L4_BUILD_DIR) $(L4_VERBOSE) \
|
||||
-C $(L4_PKG_DIR)/$* \
|
||||
CC="$(CROSS_DEV_PREFIX)gcc" \
|
||||
CXX="$(CROSS_DEV_PREFIX)g++" \
|
||||
LD="$(CROSS_DEV_PREFIX)ld"
|
||||
$(VERBOSE)mkdir -p $(dir $@) && touch $@
|
||||
|
||||
clean cleanall: clean_tags
|
||||
|
||||
# if (pseudo) target is named after a directory, remove the whole subtree
|
||||
clean_prg_objects: clean_dir_named_as_target
|
||||
|
||||
clean_dir_named_as_target:
|
||||
$(VERBOSE)(test -d $(TARGET) && rm -rf $(TARGET)) || true
|
||||
|
||||
clean_tags:
|
||||
$(VERBOSE)rm -f $(PKG_TAGS)
|
||||
|
||||
25
repos/base-fiasco/mk/spec-fiasco.mk
Normal file
25
repos/base-fiasco/mk/spec-fiasco.mk
Normal file
@@ -0,0 +1,25 @@
|
||||
#
|
||||
# Specifics for the l4v2 kernel API
|
||||
#
|
||||
|
||||
#
|
||||
# Read default and builddir-specific config files
|
||||
#
|
||||
# In these config files, we find the definition of L4_DIR
|
||||
#
|
||||
-include $(call select_from_repositories,etc/fiasco.conf)
|
||||
-include $(BUILD_BASE_DIR)/etc/fiasco.conf
|
||||
|
||||
L4_BUILD_DIR ?= $(BUILD_BASE_DIR)/l4
|
||||
L4_SRC_DIR ?= $(REP_DIR)/contrib/fiasco/snapshot
|
||||
|
||||
#
|
||||
# L4/sys headers
|
||||
#
|
||||
L4_INC_DIR += $(L4_BUILD_DIR)/include \
|
||||
$(L4_BUILD_DIR)/include/l4v2
|
||||
|
||||
clean_contrib:
|
||||
$(VERBOSE)rm -rf $(BUILD_BASE_DIR)/l4
|
||||
|
||||
cleanall: clean_contrib
|
||||
25
repos/base-fiasco/mk/spec-fiasco_x86.mk
Normal file
25
repos/base-fiasco/mk/spec-fiasco_x86.mk
Normal file
@@ -0,0 +1,25 @@
|
||||
#
|
||||
# Specifics for Fiasco L4v2 on x86
|
||||
#
|
||||
|
||||
SPECS += x86_32 fiasco
|
||||
SPECS += pci ps2 vesa framebuffer
|
||||
|
||||
#
|
||||
# x86-specific L4v2/sys headers
|
||||
#
|
||||
L4_INC_DIR += $(L4_BUILD_DIR)/include/x86/l4v2 \
|
||||
$(L4_BUILD_DIR)/include/x86
|
||||
|
||||
#
|
||||
# Linker options that are specific for x86
|
||||
#
|
||||
LD_TEXT_ADDR ?= 0x01000000
|
||||
|
||||
#
|
||||
# Also include less-specific configuration last
|
||||
#
|
||||
include $(call select_from_repositories,mk/spec-x86_32.mk)
|
||||
include $(call select_from_repositories,mk/spec-fiasco.mk)
|
||||
|
||||
INC_DIR += $(L4_INC_DIR)
|
||||
16
repos/base-fiasco/mk/spec-platform_imx.mk
Normal file
16
repos/base-fiasco/mk/spec-platform_imx.mk
Normal file
@@ -0,0 +1,16 @@
|
||||
#
|
||||
# Specifics for Freescale i.MX21 platform
|
||||
#
|
||||
|
||||
RAM_BASE = 0xc0000000
|
||||
|
||||
#
|
||||
# Configure target CPU for gcc
|
||||
#
|
||||
CC_OPT += -march=armv5
|
||||
|
||||
#
|
||||
# Defines for L4/sys headers
|
||||
#
|
||||
CC_OPT += -DCPUTYPE_imx
|
||||
L4SYS_ARM_CPU = arm_imx
|
||||
14
repos/base-fiasco/mk/spec-platform_integrator.mk
Normal file
14
repos/base-fiasco/mk/spec-platform_integrator.mk
Normal file
@@ -0,0 +1,14 @@
|
||||
#
|
||||
# Specifics for ARM integrator platform
|
||||
#
|
||||
|
||||
#
|
||||
# Configure target CPU for gcc
|
||||
#
|
||||
CC_OPT += -march=armv5
|
||||
|
||||
#
|
||||
# Defines for L4/sys headers
|
||||
#
|
||||
CC_OPT += -DCPUTYPE_int
|
||||
L4SYS_ARM_CPU = arm_int
|
||||
14
repos/base-fiasco/mk/spec-platform_mmsp2.mk
Normal file
14
repos/base-fiasco/mk/spec-platform_mmsp2.mk
Normal file
@@ -0,0 +1,14 @@
|
||||
#
|
||||
# Specifics for MagicEyes Digital’s Multimedia Signal Processor
|
||||
#
|
||||
|
||||
#
|
||||
# Configure target CPU for gcc
|
||||
#
|
||||
CC_OPT += -march=armv4t
|
||||
|
||||
#
|
||||
# Defines for L4/sys headers
|
||||
#
|
||||
CC_OPT += -DCPUTYPE_mmsp2
|
||||
L4SYS_ARM_CPU = arm_mmsp2
|
||||
40
repos/base-fiasco/patches/bda.patch
Normal file
40
repos/base-fiasco/patches/bda.patch
Normal file
@@ -0,0 +1,40 @@
|
||||
--- fiasco/snapshot/kernel/fiasco/src/kern/kernel_uart.cpp 2008-07-30 13:19:01.000000000 +0200
|
||||
+++ fiasco/snapshot/kernel/fiasco/src/kern/kernel_uart.cpp 2013-06-10 14:21:54.183996620 +0200
|
||||
@@ -72,6 +72,12 @@
|
||||
if ( (s = strstr(cmdline, " -comport "))
|
||||
||(s = strstr(cmdline, " -comport=")))
|
||||
p = strtoul(s + 10, 0, 0);
|
||||
+ else
|
||||
+ {
|
||||
+ unsigned short bda_comports = (*((unsigned short *)0x410) >> 9) & 0x7;
|
||||
+ if (bda_comports)
|
||||
+ p = *((unsigned short *)0x400);
|
||||
+ }
|
||||
|
||||
if ((s = strstr(cmdline, " -comirq=")))
|
||||
i = strtoul(s + 9, 0, 0);
|
||||
--- fiasco/snapshot/l4/pkg/bootstrap/server/src/startup.cc 2008-07-30 13:19:01.000000000 +0200
|
||||
--- fiasco/snapshot/l4/pkg/bootstrap/server/src/startup.cc 2014-04-07 11:09:34.483037907 +0200
|
||||
@@ -709,11 +709,21 @@
|
||||
if (mbi->flags & L4UTIL_MB_CMDLINE)
|
||||
{
|
||||
const char *s;
|
||||
- int comport = 1;
|
||||
+ int comport = -1;
|
||||
|
||||
if ((s = check_arg(L4_CHAR_PTR(mbi->cmdline), "-comport")))
|
||||
comport = strtoul(s + 9, 0, 0);
|
||||
|
||||
+ if (comport == -1) {
|
||||
+ /* try to read Bios Data Area (BDA) to get comport information */
|
||||
+ unsigned short comport_count = (*((unsigned short *)0x410) >> 9) & 0x7;
|
||||
+ if (comport_count)
|
||||
+ comport = *((unsigned short *)0x400);
|
||||
+ else
|
||||
+ /* give up and try default values */
|
||||
+ comport = 1;
|
||||
+ }
|
||||
+
|
||||
if (check_arg(L4_CHAR_PTR(mbi->cmdline), "-serial"))
|
||||
com_cons_init(comport);
|
||||
}
|
||||
11
repos/base-fiasco/patches/bootstrap.patch
Normal file
11
repos/base-fiasco/patches/bootstrap.patch
Normal file
@@ -0,0 +1,11 @@
|
||||
--- fiasco/snapshot/l4/pkg/bootstrap/server/src/startup.cc 2014-04-07 11:55:10.811087853 +0200
|
||||
--- fiasco/snapshot/l4/pkg/bootstrap/server/src/startup.cc 2014-04-07 11:56:24.891089205 +0200
|
||||
@@ -289,7 +289,7 @@
|
||||
|
||||
printf(" move modules to %lx with offset %lx\n", modaddr, offset);
|
||||
|
||||
- for (i = dir; i != mbi->mods_count - dir ; offset > 0 ? i-- : i++)
|
||||
+ for (i = dir; offset > 0 ? i != 0 : i <= mbi->mods_count ; offset > 0 ? i-- : i++)
|
||||
{
|
||||
unsigned long start = (L4_MB_MOD_PTR(mbi->mods_addr))[i-1].mod_start;
|
||||
unsigned long end = (L4_MB_MOD_PTR(mbi->mods_addr))[i-1].mod_end;
|
||||
30
repos/base-fiasco/patches/c++11.patch
Normal file
30
repos/base-fiasco/patches/c++11.patch
Normal file
@@ -0,0 +1,30 @@
|
||||
diff -ur contrib.bak/fiasco/snapshot/l4/pkg/l4sys/include/ARCH-x86/kdebug.h contrib/fiasco/snapshot/l4/pkg/l4sys/include/ARCH-x86/kdebug.h
|
||||
--- fiasco/snapshot/l4/pkg/l4sys/include/ARCH-x86/kdebug.h 2008-07-30 13:19:01.000000000 +0200
|
||||
+++ fiasco/snapshot/l4/pkg/l4sys/include/ARCH-x86/kdebug.h 2013-09-23 09:02:29.875532260 +0200
|
||||
@@ -21,7 +21,7 @@
|
||||
asm(\
|
||||
"int $3 \n\t"\
|
||||
"jmp 1f \n\t"\
|
||||
- ".ascii \""text "\"\n\t"\
|
||||
+ ".ascii \"" text "\"\n\t"\
|
||||
"1: \n\t"\
|
||||
)
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
#define asm_enter_kdebug(text) \
|
||||
"int $3 \n\t"\
|
||||
"jmp 1f \n\t"\
|
||||
- ".ascii \""text "\"\n\t"\
|
||||
+ ".ascii \"" text "\"\n\t"\
|
||||
"1: \n\t"
|
||||
|
||||
/**
|
||||
@@ -50,7 +50,7 @@
|
||||
"int $3 \n\t"\
|
||||
"nop \n\t"\
|
||||
"jmp 1f \n\t"\
|
||||
- ".ascii \""text "\"\n\t"\
|
||||
+ ".ascii \"" text "\"\n\t"\
|
||||
"1: \n\t"\
|
||||
)
|
||||
|
||||
199
repos/base-fiasco/run/env
Normal file
199
repos/base-fiasco/run/env
Normal file
@@ -0,0 +1,199 @@
|
||||
#
|
||||
# \brief Fiasco-specific test-environment supplements
|
||||
# \author Norman Feske
|
||||
# \author Christian Helmuth
|
||||
# \date 2010-08-26
|
||||
#
|
||||
# This file is meant to be used as '--include' argument for 'tool/run'.
|
||||
#
|
||||
|
||||
|
||||
##
|
||||
# Install files needed to boot via PXE
|
||||
#
|
||||
proc install_pxe_bootloader_to_run_dir { } {
|
||||
exec cp [genode_dir]/tool/boot/pulsar [run_dir]/boot/pulsar
|
||||
exec cp [genode_dir]/tool/boot/bender [run_dir]/boot/bender
|
||||
}
|
||||
|
||||
|
||||
##
|
||||
# Read the location of the Fiasco user directory from 'etc/fiasco.conf'
|
||||
#
|
||||
proc l4_dir { } {
|
||||
global _l4_dir
|
||||
|
||||
if {![info exists _l4_dir]} {
|
||||
if {[file exists etc/fiasco.conf]} {
|
||||
set _l4_dir [exec sed -n "/^L4_BUILD_DIR/s/^.*=\\s*//p" etc/fiasco.conf]
|
||||
if {[file exists $_l4_dir]} { return $_l4_dir }
|
||||
}
|
||||
|
||||
set _l4_dir "[pwd]/l4"
|
||||
if {![file exists $_l4_dir]} {
|
||||
puts -nonewline stderr "Error: Could neither find the L4 build directory "
|
||||
puts -nonewline stderr "within '<genode-build-dir>/l4' nor at a location "
|
||||
puts -nonewline stderr "specified via 'L4_BUILD_DIR = <l4v2-build-dir>' "
|
||||
puts stderr "in <genode-build-dir>/etc/fiasco.conf'."
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
return $_l4_dir
|
||||
}
|
||||
|
||||
|
||||
##
|
||||
# Return whether the l4-buid-directory is provided from the outside
|
||||
#
|
||||
proc l4_dir_external { } {
|
||||
if {[l4_dir] == "[pwd]/l4"} { return 0 }
|
||||
return 1
|
||||
}
|
||||
|
||||
|
||||
##
|
||||
# Return the location of the Fiasco kernel
|
||||
#
|
||||
proc fiasco { } {
|
||||
return [kernel_location_from_config_file etc/fiasco.conf [pwd]/kernel/fiasco/fiasco]
|
||||
}
|
||||
|
||||
|
||||
##
|
||||
# Return whether fiasco kernel is provided from the outside
|
||||
#
|
||||
proc fiasco_external { } {
|
||||
if {[fiasco] == "[pwd]/kernel/fiasco/fiasco"} { return 0 }
|
||||
return 1
|
||||
}
|
||||
|
||||
|
||||
##################################
|
||||
## Test framework API functions ##
|
||||
##################################
|
||||
|
||||
proc create_boot_directory { } {
|
||||
exec rm -rf [run_dir]
|
||||
exec mkdir -p [run_dir]/genode
|
||||
exec mkdir -p [run_dir]/fiasco
|
||||
}
|
||||
|
||||
proc bin_dir { } {
|
||||
if {[have_spec x86_32]} { return "[l4_dir]/bin/x86_586" }
|
||||
|
||||
puts stderr "Error: Cannot determine bin directory"
|
||||
exit 1
|
||||
}
|
||||
|
||||
set fiasco_serial_esc_arg "-serial_esc "
|
||||
|
||||
proc build_boot_image {binaries} {
|
||||
|
||||
global fiasco_serial_esc_arg
|
||||
|
||||
#
|
||||
# Collect contents of the ISO image
|
||||
#
|
||||
copy_and_strip_genode_binaries_to_run_dir $binaries
|
||||
|
||||
if {![fiasco_external]} { build { kernel } }
|
||||
if {![l4_dir_external]} { build { bootstrap sigma0 } }
|
||||
|
||||
# assert existence of the L4 build directory
|
||||
l4_dir
|
||||
|
||||
puts "using fiasco kernel [fiasco]"
|
||||
exec cp [fiasco] [run_dir]/fiasco/fiasco
|
||||
puts "using sigma0/bootstrap at [l4_dir]"
|
||||
exec cp [bin_dir]/l4v2/sigma0 [run_dir]/fiasco
|
||||
exec cp [bin_dir]/bootstrap [run_dir]/fiasco
|
||||
|
||||
install_iso_bootloader_to_run_dir
|
||||
|
||||
#
|
||||
# Generate grub config file
|
||||
#
|
||||
# The core binary is part of the 'binaries' list but it must
|
||||
# appear right after 'sigma0' as boot module. Hence the special case.
|
||||
#
|
||||
set fh [open "[run_dir]/boot/grub/menu.lst" "WRONLY CREAT TRUNC"]
|
||||
puts $fh "timeout 0"
|
||||
puts $fh "default 0"
|
||||
puts $fh "\ntitle Genode on L4/Fiasco"
|
||||
puts $fh " kernel /fiasco/bootstrap -serial -modaddr=0x02000000"
|
||||
puts $fh " module /fiasco/fiasco -serial -jdb_cmd=JH $fiasco_serial_esc_arg"
|
||||
puts $fh " module /fiasco/sigma0"
|
||||
puts $fh " module /genode/core"
|
||||
puts $fh " module /genode/config"
|
||||
foreach binary $binaries {
|
||||
if {$binary != "core"} {
|
||||
puts $fh " module /genode/$binary" } }
|
||||
puts $fh " vbeset 0x117 506070"
|
||||
close $fh
|
||||
|
||||
#
|
||||
# Install PXE bootloader pulsar
|
||||
#
|
||||
install_pxe_bootloader_to_run_dir
|
||||
|
||||
create_iso_image_from_run_dir
|
||||
|
||||
#
|
||||
# Generate pulsar config file
|
||||
#
|
||||
set fh [open "[run_dir]/config-52-54-00-12-34-56" "WRONLY CREAT TRUNC"]
|
||||
puts $fh " exec /boot/bender"
|
||||
puts $fh " load /fiasco/bootstrap -serial -modaddr=0x02000000"
|
||||
puts $fh " load /fiasco/fiasco -serial -serial_esc -jdb_cmd=JH"
|
||||
puts $fh " load /fiasco/sigma0"
|
||||
puts $fh " load /genode/core"
|
||||
puts $fh " load /genode/config"
|
||||
foreach binary $binaries {
|
||||
if {$binary != "core"} {
|
||||
puts $fh " load /genode/$binary" } }
|
||||
close $fh
|
||||
|
||||
#
|
||||
# Generate pulsar config file pointing to the config file above.
|
||||
#
|
||||
if {[info exists ::env(PXE_TFTP_DIR_BASE)] && [info exists ::env(PXE_TFTP_DIR_OFFSET)]} {
|
||||
exec ln -nfs "[pwd]" "$::env(PXE_TFTP_DIR_BASE)$::env(PXE_TFTP_DIR_OFFSET)"
|
||||
|
||||
set tftp_base ""
|
||||
if {[get_cmd_switch --tftp-absolute]} {
|
||||
set tftp_base $::env(PXE_TFTP_DIR_BASE)
|
||||
}
|
||||
|
||||
set fh [open "$::env(PXE_TFTP_DIR_BASE)$::env(PXE_TFTP_DIR_OFFSET)/config-00-00-00-00-00-00" "WRONLY CREAT TRUNC"]
|
||||
puts $fh " root $tftp_base$::env(PXE_TFTP_DIR_OFFSET)/[run_dir]"
|
||||
puts $fh " config config-52-54-00-12-34-56"
|
||||
close $fh
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
proc run_genode_until {{wait_for_re forever} {timeout_value 0} {running_spawn_id -1}} {
|
||||
#
|
||||
# If a running_spawn_id is specified, wait for the expected output
|
||||
#
|
||||
if {$running_spawn_id != -1} {
|
||||
wait_for_output $wait_for_re $timeout_value $running_spawn_id
|
||||
return
|
||||
}
|
||||
|
||||
#
|
||||
# Try to use one of the supported backends for running the scripts
|
||||
#
|
||||
if {[is_amt_available]} {
|
||||
spawn_amt $wait_for_re $timeout_value
|
||||
return
|
||||
}
|
||||
if {[is_qemu_available]} {
|
||||
spawn_qemu $wait_for_re $timeout_value
|
||||
return
|
||||
}
|
||||
|
||||
global run_target
|
||||
puts stderr "Error: Can't execute automatically on target '$run_target'"
|
||||
exit -1
|
||||
}
|
||||
30
repos/base-fiasco/src/base/console/core_console.h
Normal file
30
repos/base-fiasco/src/base/console/core_console.h
Normal file
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* \brief Console backend using the Fiasco kernel debugger
|
||||
* \author Norman Feske
|
||||
* \date 2006-04-08
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/* Fiasco includes */
|
||||
namespace Fiasco {
|
||||
#include <l4/sys/kdebug.h>
|
||||
}
|
||||
|
||||
/* Genode includes */
|
||||
#include <base/console.h>
|
||||
|
||||
namespace Genode {
|
||||
|
||||
class Core_console : public Console
|
||||
{
|
||||
protected:
|
||||
|
||||
void _out_char(char c) { Fiasco::outchar(c); }
|
||||
};
|
||||
}
|
||||
260
repos/base-fiasco/src/base/ipc/ipc.cc
Normal file
260
repos/base-fiasco/src/base/ipc/ipc.cc
Normal file
@@ -0,0 +1,260 @@
|
||||
/*
|
||||
* \brief IPC implementation for Fiasco
|
||||
* \author Norman Feske
|
||||
* \date 2006-06-13
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <base/printf.h>
|
||||
#include <base/ipc.h>
|
||||
#include <base/blocking.h>
|
||||
|
||||
namespace Fiasco {
|
||||
#include <l4/sys/ipc.h>
|
||||
#include <l4/sys/syscalls.h>
|
||||
#include <l4/sys/kdebug.h>
|
||||
}
|
||||
|
||||
using namespace Genode;
|
||||
|
||||
|
||||
/*****************
|
||||
** Ipc_ostream **
|
||||
*****************/
|
||||
|
||||
void Ipc_ostream::_send()
|
||||
{
|
||||
using namespace Fiasco;
|
||||
|
||||
_snd_msg->send_dope = L4_IPC_DOPE((_write_offset + sizeof(umword_t) - 1)>>2, 0);
|
||||
|
||||
l4_msgdope_t result;
|
||||
l4_ipc_send(_dst.dst(), _snd_msg->addr(), _dst.local_name(),
|
||||
*reinterpret_cast<l4_umword_t *>(&_snd_msg->buf[sizeof(umword_t)]),
|
||||
L4_IPC_NEVER, &result);
|
||||
|
||||
if (L4_IPC_IS_ERROR(result)) {
|
||||
PERR("Ipc error %lx", L4_IPC_ERROR(result));
|
||||
throw Genode::Ipc_error();
|
||||
}
|
||||
|
||||
_write_offset = sizeof(umword_t);
|
||||
}
|
||||
|
||||
|
||||
Ipc_ostream::Ipc_ostream(Native_capability dst, Msgbuf_base *snd_msg) :
|
||||
Ipc_marshaller(&snd_msg->buf[0], snd_msg->size()),
|
||||
_snd_msg(snd_msg), _dst(dst)
|
||||
{
|
||||
_write_offset = sizeof(umword_t);
|
||||
}
|
||||
|
||||
|
||||
/*****************
|
||||
** Ipc_istream **
|
||||
*****************/
|
||||
|
||||
void Ipc_istream::_wait()
|
||||
{
|
||||
using namespace Fiasco;
|
||||
|
||||
l4_msgdope_t result;
|
||||
|
||||
/*
|
||||
* Wait until we get a proper message and thereby
|
||||
* ignore receive message cuts on the server-side.
|
||||
* This error condition should be handled by the
|
||||
* client. The server does not bother.
|
||||
*/
|
||||
do {
|
||||
_rcv_msg->size_dope = L4_IPC_DOPE(_rcv_msg->size()>>2, 0);
|
||||
|
||||
l4_ipc_wait(&_rcv_cs, _rcv_msg->addr(),
|
||||
reinterpret_cast<l4_umword_t *>(&_rcv_msg->buf[0]),
|
||||
reinterpret_cast<l4_umword_t *>(&_rcv_msg->buf[sizeof(umword_t)]),
|
||||
L4_IPC_NEVER, &result);
|
||||
|
||||
if (L4_IPC_IS_ERROR(result))
|
||||
PERR("Ipc error %lx", L4_IPC_ERROR(result));
|
||||
|
||||
} while (L4_IPC_IS_ERROR(result));
|
||||
|
||||
/* reset buffer read offset */
|
||||
_read_offset = sizeof(umword_t);
|
||||
}
|
||||
|
||||
|
||||
Ipc_istream::Ipc_istream(Msgbuf_base *rcv_msg):
|
||||
Ipc_unmarshaller(&rcv_msg->buf[0], rcv_msg->size()),
|
||||
Native_capability(Fiasco::l4_myself(), 0),
|
||||
_rcv_msg(rcv_msg)
|
||||
{
|
||||
using namespace Fiasco;
|
||||
|
||||
_rcv_cs = L4_INVALID_ID;
|
||||
|
||||
_read_offset = sizeof(umword_t);
|
||||
}
|
||||
|
||||
|
||||
Ipc_istream::~Ipc_istream() { }
|
||||
|
||||
|
||||
/****************
|
||||
** Ipc_client **
|
||||
****************/
|
||||
|
||||
void Ipc_client::_call()
|
||||
{
|
||||
using namespace Fiasco;
|
||||
|
||||
l4_msgdope_t ipc_result;
|
||||
long rec_badge;
|
||||
|
||||
_snd_msg->send_dope = L4_IPC_DOPE((_write_offset + 2*sizeof(umword_t) - 1)>>2, 0);
|
||||
_rcv_msg->size_dope = L4_IPC_DOPE(_rcv_msg->size()>>2, 0);
|
||||
|
||||
l4_ipc_call(Ipc_ostream::_dst.dst(),
|
||||
_write_offset <= 2*sizeof(umword_t) ? L4_IPC_SHORT_MSG : _snd_msg->addr(),
|
||||
Ipc_ostream::_dst.local_name(),
|
||||
*reinterpret_cast<l4_umword_t *>(&_snd_msg->buf[sizeof(umword_t)]),
|
||||
_rcv_msg->addr(),
|
||||
reinterpret_cast<l4_umword_t *>(&rec_badge),
|
||||
reinterpret_cast<l4_umword_t *>(&_rcv_msg->buf[sizeof(umword_t)]),
|
||||
L4_IPC_NEVER, &ipc_result);
|
||||
|
||||
if (L4_IPC_IS_ERROR(ipc_result)) {
|
||||
|
||||
if (L4_IPC_ERROR(ipc_result) == L4_IPC_RECANCELED)
|
||||
throw Genode::Blocking_canceled();
|
||||
|
||||
PERR("Ipc error %lx", L4_IPC_ERROR(ipc_result));
|
||||
throw Genode::Ipc_error();
|
||||
}
|
||||
|
||||
/*
|
||||
* Reset buffer read and write offsets. We shadow the first mword of the
|
||||
* send message buffer (filled via '_write_offset') with the local name of
|
||||
* the invoked remote object. We shadow the first mword of the receive
|
||||
* buffer (retrieved via '_read_offset') with the local name of the reply
|
||||
* capability ('rec_badge'), which is bogus in the L4/Fiasco case. In both
|
||||
* cases, we skip the shadowed message mword when reading/writing the
|
||||
* message payload.
|
||||
*/
|
||||
_write_offset = _read_offset = sizeof(umword_t);
|
||||
}
|
||||
|
||||
|
||||
Ipc_client::Ipc_client(Native_capability const &srv, Msgbuf_base *snd_msg,
|
||||
Msgbuf_base *rcv_msg, unsigned short):
|
||||
Ipc_istream(rcv_msg), Ipc_ostream(srv, snd_msg), _result(0)
|
||||
{ }
|
||||
|
||||
|
||||
/****************
|
||||
** Ipc_server **
|
||||
****************/
|
||||
|
||||
void Ipc_server::_prepare_next_reply_wait()
|
||||
{
|
||||
/* now we have a request to reply */
|
||||
_reply_needed = true;
|
||||
|
||||
/* leave space for return value at the beginning of the msgbuf */
|
||||
_write_offset = 2*sizeof(umword_t);
|
||||
|
||||
/* receive buffer offset */
|
||||
_read_offset = sizeof(umword_t);
|
||||
}
|
||||
|
||||
|
||||
void Ipc_server::_wait()
|
||||
{
|
||||
/* wait for new server request */
|
||||
try { Ipc_istream::_wait(); } catch (Blocking_canceled) { }
|
||||
|
||||
/* define destination of next reply */
|
||||
Ipc_ostream::_dst = Native_capability(_rcv_cs, badge());
|
||||
|
||||
_prepare_next_reply_wait();
|
||||
}
|
||||
|
||||
|
||||
void Ipc_server::_reply()
|
||||
{
|
||||
using namespace Fiasco;
|
||||
|
||||
_snd_msg->send_dope = L4_IPC_DOPE((_write_offset + sizeof(umword_t) - 1)>>2, 0);
|
||||
|
||||
l4_msgdope_t result;
|
||||
l4_ipc_send(Ipc_ostream::_dst.dst(), _snd_msg->addr(),
|
||||
Ipc_ostream::_dst.local_name(),
|
||||
*reinterpret_cast<l4_umword_t *>(&_snd_msg->buf[sizeof(umword_t)]),
|
||||
L4_IPC_SEND_TIMEOUT_0, &result);
|
||||
|
||||
if (L4_IPC_IS_ERROR(result))
|
||||
PERR("Ipc error %lx, ignored", L4_IPC_ERROR(result));
|
||||
|
||||
_prepare_next_reply_wait();
|
||||
}
|
||||
|
||||
|
||||
void Ipc_server::_reply_wait()
|
||||
{
|
||||
using namespace Fiasco;
|
||||
|
||||
if (_reply_needed) {
|
||||
|
||||
l4_msgdope_t ipc_result;
|
||||
|
||||
_snd_msg->send_dope = L4_IPC_DOPE((_write_offset + sizeof(umword_t) - 1)>>2, 0);
|
||||
_rcv_msg->size_dope = L4_IPC_DOPE(_rcv_msg->size()>>2, 0);
|
||||
|
||||
/*
|
||||
* Use short IPC for reply if possible.
|
||||
* This is the common case of returning
|
||||
* an integer as RPC result.
|
||||
*/
|
||||
l4_ipc_reply_and_wait(
|
||||
Ipc_ostream::_dst.dst(),
|
||||
_write_offset <= 2*sizeof(umword_t) ? L4_IPC_SHORT_MSG : _snd_msg->addr(),
|
||||
Ipc_ostream::_dst.local_name(),
|
||||
*reinterpret_cast<l4_umword_t *>(&_snd_msg->buf[sizeof(umword_t)]),
|
||||
&_rcv_cs, _rcv_msg->addr(),
|
||||
reinterpret_cast<l4_umword_t *>(&_rcv_msg->buf[0]),
|
||||
reinterpret_cast<l4_umword_t *>(&_rcv_msg->buf[sizeof(umword_t)]),
|
||||
L4_IPC_SEND_TIMEOUT_0, &ipc_result);
|
||||
|
||||
if (L4_IPC_IS_ERROR(ipc_result)) {
|
||||
PERR("Ipc error %lx", L4_IPC_ERROR(ipc_result));
|
||||
|
||||
/*
|
||||
* The error conditions could be a message cut (which
|
||||
* we want to ignore on the server side) or a reply failure
|
||||
* (for example, if the caller went dead during the call.
|
||||
* In both cases, we do not reflect the error condition to
|
||||
* the user but want to wait for the next proper incoming
|
||||
* message. So let's just wait now.
|
||||
*/
|
||||
_wait();
|
||||
}
|
||||
|
||||
} else _wait();
|
||||
|
||||
/* define destination of next reply */
|
||||
Ipc_ostream::_dst = Native_capability(_rcv_cs, badge());
|
||||
|
||||
_prepare_next_reply_wait();
|
||||
}
|
||||
|
||||
|
||||
Ipc_server::Ipc_server(Msgbuf_base *snd_msg, Msgbuf_base *rcv_msg):
|
||||
Ipc_istream(rcv_msg),
|
||||
Ipc_ostream(Native_capability(), snd_msg), _reply_needed(false)
|
||||
{ }
|
||||
69
repos/base-fiasco/src/base/ipc/pager.cc
Normal file
69
repos/base-fiasco/src/base/ipc/pager.cc
Normal file
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* \brief Pager support for Fiasco
|
||||
* \author Christian Helmuth
|
||||
* \date 2006-06-14
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <base/ipc_pager.h>
|
||||
#include <base/printf.h>
|
||||
|
||||
namespace Fiasco {
|
||||
#include <l4/sys/ipc.h>
|
||||
#include <l4/sys/syscalls.h>
|
||||
}
|
||||
|
||||
using namespace Genode;
|
||||
using namespace Fiasco;
|
||||
|
||||
|
||||
void Ipc_pager::wait_for_fault()
|
||||
{
|
||||
l4_msgdope_t result;
|
||||
|
||||
do {
|
||||
l4_ipc_wait(&_last,
|
||||
L4_IPC_SHORT_MSG, &_pf_addr, &_pf_ip,
|
||||
L4_IPC_NEVER, &result);
|
||||
|
||||
if (L4_IPC_IS_ERROR(result))
|
||||
PERR("Ipc error %lx", L4_IPC_ERROR(result));
|
||||
|
||||
} while (L4_IPC_IS_ERROR(result));
|
||||
}
|
||||
|
||||
|
||||
void Ipc_pager::reply_and_wait_for_fault()
|
||||
{
|
||||
l4_msgdope_t result;
|
||||
|
||||
l4_ipc_reply_and_wait(_last,
|
||||
L4_IPC_SHORT_FPAGE, _reply_mapping.dst_addr(),
|
||||
_reply_mapping.fpage().fpage, &_last,
|
||||
L4_IPC_SHORT_MSG, &_pf_addr, &_pf_ip,
|
||||
L4_IPC_SEND_TIMEOUT_0, &result);
|
||||
|
||||
if (L4_IPC_IS_ERROR(result)) {
|
||||
PERR("Ipc error %lx", L4_IPC_ERROR(result));
|
||||
|
||||
/* ignore all errors and wait for next proper message */
|
||||
wait_for_fault();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Ipc_pager::acknowledge_wakeup()
|
||||
{
|
||||
/* answer wakeup call from one of core's region-manager sessions */
|
||||
l4_msgdope_t result;
|
||||
l4_ipc_send(_last, L4_IPC_SHORT_MSG, 0, 0, L4_IPC_SEND_TIMEOUT_0, &result);
|
||||
}
|
||||
|
||||
|
||||
Ipc_pager::Ipc_pager() : Native_capability(Fiasco::l4_myself(), 0) { }
|
||||
50
repos/base-fiasco/src/base/lock/lock.cc
Normal file
50
repos/base-fiasco/src/base/lock/lock.cc
Normal file
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* \brief Lock implementation
|
||||
* \author Norman Feske
|
||||
* \date 2007-10-15
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2007-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/cancelable_lock.h>
|
||||
#include <cpu/atomic.h>
|
||||
#include <base/printf.h>
|
||||
|
||||
/* L4/Fiasco includes */
|
||||
namespace Fiasco {
|
||||
#include <l4/sys/ipc.h>
|
||||
}
|
||||
|
||||
using namespace Genode;
|
||||
|
||||
|
||||
Cancelable_lock::Cancelable_lock(Cancelable_lock::State initial)
|
||||
: _lock(UNLOCKED)
|
||||
{
|
||||
if (initial == LOCKED)
|
||||
lock();
|
||||
}
|
||||
|
||||
|
||||
void Cancelable_lock::lock()
|
||||
{
|
||||
/*
|
||||
* XXX: How to notice cancel-blocking signals issued when being outside the
|
||||
* 'l4_ipc_sleep' system call?
|
||||
*/
|
||||
while (!Genode::cmpxchg(&_lock, UNLOCKED, LOCKED))
|
||||
if (Fiasco::l4_ipc_sleep(Fiasco::l4_ipc_timeout(0, 0, 500, 0)) != L4_IPC_RETIMEOUT)
|
||||
throw Genode::Blocking_canceled();
|
||||
}
|
||||
|
||||
|
||||
void Cancelable_lock::unlock()
|
||||
{
|
||||
_lock = UNLOCKED;
|
||||
}
|
||||
34
repos/base-fiasco/src/base/lock/lock_helper.h
Normal file
34
repos/base-fiasco/src/base/lock/lock_helper.h
Normal file
@@ -0,0 +1,34 @@
|
||||
|
||||
/*
|
||||
* \brief L4/Fiasco-specific helper functions for the Lock implementation
|
||||
* \author Norman Feske
|
||||
* \date 2012-03-01
|
||||
*
|
||||
* L4/Fiasco is the only kernel that does not rely on Genode's generic lock
|
||||
* implementation. The custom implementation contained in 'lock.cc' does not
|
||||
* need 'lock_helper.h'. This file exists for the sole reason to make the
|
||||
* L4/Fiasco version of 'lock_helper' usable from the DDE Kit's spin lock.
|
||||
* Otherwise, we would need to add a special case for L4/Fiasco to the DDE Kit
|
||||
* library.
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/* L4/Fiasco includes */
|
||||
namespace Fiasco {
|
||||
#include <l4/sys/ipc.h>
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Yield CPU time
|
||||
*/
|
||||
static inline void thread_yield()
|
||||
{
|
||||
Fiasco::l4_ipc_sleep(Fiasco::l4_ipc_timeout(0, 0, 500, 0));
|
||||
}
|
||||
122
repos/base-fiasco/src/base/pager/pager.cc
Normal file
122
repos/base-fiasco/src/base/pager/pager.cc
Normal file
@@ -0,0 +1,122 @@
|
||||
/*
|
||||
* \brief Fiasco pager framework
|
||||
* \author Norman Feske
|
||||
* \author Christian Helmuth
|
||||
* \date 2006-07-14
|
||||
*
|
||||
* FIXME Isn't this file generic?
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <base/pager.h>
|
||||
|
||||
namespace Fiasco {
|
||||
#include <l4/sys/ipc.h>
|
||||
#include <l4/sys/syscalls.h>
|
||||
}
|
||||
|
||||
using namespace Genode;
|
||||
|
||||
|
||||
/**********************
|
||||
** Pager activation **
|
||||
**********************/
|
||||
|
||||
void Pager_activation_base::entry()
|
||||
{
|
||||
Ipc_pager pager;
|
||||
_cap = pager;
|
||||
_cap_valid.unlock();
|
||||
|
||||
Pager_object * obj;
|
||||
bool reply = false;
|
||||
|
||||
while (1) {
|
||||
|
||||
if (reply)
|
||||
pager.reply_and_wait_for_fault();
|
||||
else
|
||||
pager.wait_for_fault();
|
||||
|
||||
/* lookup referenced object */
|
||||
Object_pool<Pager_object>::Guard _obj(_ep ? _ep->lookup_and_lock(pager.badge()) : 0);
|
||||
obj = _obj;
|
||||
reply = false;
|
||||
|
||||
/* handle request */
|
||||
if (obj) {
|
||||
reply = !obj->pager(pager);
|
||||
/* something strange occurred - leave thread in pagefault */
|
||||
continue;
|
||||
} else {
|
||||
|
||||
/* prevent threads outside of core to mess with our wake-up interface */
|
||||
enum { CORE_TASK_ID = 4 };
|
||||
if (pager.last().id.task != CORE_TASK_ID) {
|
||||
|
||||
PWRN("page fault from unknown partner %x.%02x",
|
||||
(int)pager.last().id.task, (int)pager.last().id.lthread);
|
||||
|
||||
} else {
|
||||
|
||||
/*
|
||||
* We got a request from one of cores region-manager sessions
|
||||
* to answer the pending page fault of a resolved region-manager
|
||||
* client. Hence, we have to send the page-fault reply to the
|
||||
* specified thread and answer the call of the region-manager
|
||||
* session.
|
||||
*
|
||||
* When called from a region-manager session, we receive the
|
||||
* core-local address of the targeted pager object via the
|
||||
* first message word, which corresponds to the 'fault_ip'
|
||||
* argument of normal page-fault messages.
|
||||
*/
|
||||
obj = reinterpret_cast<Pager_object *>(pager.fault_ip());
|
||||
|
||||
/* send reply to the calling region-manager session */
|
||||
pager.acknowledge_wakeup();
|
||||
|
||||
/* answer page fault of resolved pager object */
|
||||
pager.set_reply_dst(obj->cap());
|
||||
pager.acknowledge_wakeup();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/**********************
|
||||
** Pager entrypoint **
|
||||
**********************/
|
||||
|
||||
Pager_entrypoint::Pager_entrypoint(Cap_session *, Pager_activation_base *a)
|
||||
: _activation(a)
|
||||
{ _activation->ep(this); }
|
||||
|
||||
|
||||
void Pager_entrypoint::dissolve(Pager_object *obj)
|
||||
{
|
||||
remove_locked(obj);
|
||||
}
|
||||
|
||||
|
||||
Pager_capability Pager_entrypoint::manage(Pager_object *obj)
|
||||
{
|
||||
/* return invalid capability if no activation is present */
|
||||
if (!_activation) return Pager_capability();
|
||||
|
||||
Native_capability cap(_activation->cap().dst(), obj->badge());
|
||||
|
||||
/* add server object to object pool */
|
||||
obj->cap(cap);
|
||||
insert(obj);
|
||||
|
||||
/* return capability that uses the object id as badge */
|
||||
return reinterpret_cap_cast<Pager_object>(cap);
|
||||
}
|
||||
41
repos/base-fiasco/src/base/thread/thread_bootstrap.cc
Normal file
41
repos/base-fiasco/src/base/thread/thread_bootstrap.cc
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* \brief Platform specific thread initialization
|
||||
* \author Martin Stein
|
||||
* \date 2014-01-06
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2014 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/thread.h>
|
||||
#include <base/env.h>
|
||||
|
||||
using namespace Genode;
|
||||
|
||||
|
||||
/*****************************
|
||||
** Startup library support **
|
||||
*****************************/
|
||||
|
||||
void prepare_init_main_thread() { }
|
||||
|
||||
void prepare_reinit_main_thread() { }
|
||||
|
||||
|
||||
/*****************
|
||||
** Thread_base **
|
||||
*****************/
|
||||
|
||||
void Thread_base::_thread_bootstrap() { }
|
||||
|
||||
|
||||
void Thread_base::_init_platform_thread(Type type)
|
||||
{
|
||||
if (type == NORMAL) { return; }
|
||||
_thread_cap = Genode::env()->parent()->main_thread_cap();
|
||||
}
|
||||
5
repos/base-fiasco/src/bootstrap/target.mk
Normal file
5
repos/base-fiasco/src/bootstrap/target.mk
Normal file
@@ -0,0 +1,5 @@
|
||||
TARGET = bootstrap
|
||||
PKGS = bootstrap
|
||||
LIBS = l4v2_support
|
||||
|
||||
include $(REP_DIR)/mk/l4_pkg.mk
|
||||
28
repos/base-fiasco/src/core/cpu_session_support.cc
Normal file
28
repos/base-fiasco/src/core/cpu_session_support.cc
Normal 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();
|
||||
}
|
||||
|
||||
87
repos/base-fiasco/src/core/include/map_local.h
Normal file
87
repos/base-fiasco/src/core/include/map_local.h
Normal file
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* \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_
|
||||
|
||||
/* core includes */
|
||||
#include <platform.h>
|
||||
#include <util.h>
|
||||
|
||||
/* Fiasco includes */
|
||||
namespace Fiasco {
|
||||
#include <l4/sys/ipc.h>
|
||||
#include <l4/sys/syscalls.h>
|
||||
#include <l4/sys/kdebug.h>
|
||||
}
|
||||
|
||||
namespace Genode {
|
||||
|
||||
/**
|
||||
* Map page locally within core
|
||||
*
|
||||
* On Fiasco, all mapping originate from virtual addresses. At startup,
|
||||
* core obtains the whole memory sigma0 in a one-to-one fashion. Hence,
|
||||
* core-local addresses normally correspond to physical addresses.
|
||||
*
|
||||
* \param from_addr core-virtual source address
|
||||
* \param to_addr core-virtual destination address
|
||||
* \param num_pages number of pages to remap
|
||||
*/
|
||||
inline bool map_local(addr_t from_addr, addr_t to_addr, size_t num_pages)
|
||||
{
|
||||
Native_thread_id core_pager = platform_specific()->core_pager()->native_thread_id();
|
||||
|
||||
addr_t offset = 0;
|
||||
size_t page_size = get_page_size();
|
||||
size_t page_size_log2 = get_page_size_log2();
|
||||
for (unsigned i = 0; i < num_pages; i++, offset += page_size) {
|
||||
|
||||
using namespace Fiasco;
|
||||
|
||||
/* perform echo request to the core pager */
|
||||
l4_umword_t dummy = 0;
|
||||
l4_msgdope_t ipc_result;
|
||||
l4_fpage_t from_fpage = l4_fpage(from_addr + offset,
|
||||
page_size_log2, true, false);
|
||||
enum { ECHO_LOCAL_MAP_REQUEST = 0 };
|
||||
l4_ipc_call(core_pager, L4_IPC_SHORT_MSG,
|
||||
from_fpage.raw, /* normally page-fault addr */
|
||||
ECHO_LOCAL_MAP_REQUEST, /* normally page-fault IP */
|
||||
L4_IPC_MAPMSG(to_addr + offset, page_size_log2),
|
||||
&dummy, &dummy,
|
||||
L4_IPC_NEVER, &ipc_result);
|
||||
|
||||
if (L4_IPC_IS_ERROR(ipc_result)) {
|
||||
PWRN("could not locally remap 0x%lx to 0x%lx, error code is %ld",
|
||||
from_addr, to_addr, L4_IPC_ERROR(ipc_result));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unmap pages locally within core
|
||||
*
|
||||
* \param virt core-local address
|
||||
* \param num_pages number of pages to unmap
|
||||
*/
|
||||
inline void unmap_local(addr_t virt, size_t num_pages)
|
||||
{
|
||||
PERR("unmap_local() called - not implemented yet");
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* _CORE__INCLUDE__MAP_LOCAL_H_ */
|
||||
|
||||
158
repos/base-fiasco/src/core/include/platform.h
Normal file
158
repos/base-fiasco/src/core/include/platform.h
Normal file
@@ -0,0 +1,158 @@
|
||||
/*
|
||||
* \brief Fiasco platform
|
||||
* \author Christian Helmuth
|
||||
* \author Norman Feske
|
||||
* \date 2007-09-10
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2007-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_
|
||||
|
||||
#include <base/sync_allocator.h>
|
||||
#include <base/allocator_avl.h>
|
||||
|
||||
#include "platform_generic.h"
|
||||
#include "platform_thread.h"
|
||||
#include "platform_pd.h"
|
||||
#include "multiboot.h"
|
||||
|
||||
|
||||
namespace Genode {
|
||||
|
||||
class Platform : public Platform_generic
|
||||
{
|
||||
private:
|
||||
|
||||
/*
|
||||
* Shortcut for the type of allocator instances for physical resources
|
||||
*/
|
||||
typedef Synchronized_range_allocator<Allocator_avl> Phys_allocator;
|
||||
|
||||
char _core_label[1]; /* to satisfy _core_pd */
|
||||
Platform_pd *_core_pd; /* core protection domain object */
|
||||
Phys_allocator _ram_alloc; /* RAM allocator */
|
||||
Phys_allocator _io_mem_alloc; /* MMIO allocator */
|
||||
Phys_allocator _io_port_alloc; /* I/O port allocator */
|
||||
Phys_allocator _irq_alloc; /* IRQ allocator */
|
||||
Phys_allocator _region_alloc; /* virtual memory allocator for core */
|
||||
Multiboot_info _mb_info; /* multiboot information */
|
||||
Rom_fs _rom_fs; /* ROM file system */
|
||||
Rom_module _kip_rom; /* ROM module for Fiasco KIP */
|
||||
|
||||
addr_t _vm_start; /* begin of virtual memory */
|
||||
size_t _vm_size; /* size of virtual memory */
|
||||
|
||||
/*
|
||||
* We do not export any boot module loaded before FIRST_ROM.
|
||||
*/
|
||||
enum { FIRST_ROM = 3 };
|
||||
|
||||
/**
|
||||
* Setup base resources
|
||||
*
|
||||
* - Map and provide KIP as ROM module
|
||||
* - Initializes region allocator
|
||||
* - Initializes multiboot info structure
|
||||
*/
|
||||
void _setup_basics();
|
||||
|
||||
/**
|
||||
* Setup RAM, IO_MEM, and region allocators
|
||||
*/
|
||||
void _setup_mem_alloc();
|
||||
|
||||
/**
|
||||
* Setup I/O port space allocator
|
||||
*/
|
||||
void _setup_io_port_alloc();
|
||||
|
||||
/**
|
||||
* Setup IRQ allocator
|
||||
*/
|
||||
void _setup_irq_alloc();
|
||||
|
||||
/**
|
||||
* Parse multi-boot information and update ROM database
|
||||
*/
|
||||
void _setup_rom();
|
||||
|
||||
/**
|
||||
* Setup pager for core-internal threads
|
||||
*/
|
||||
void _setup_core_pager();
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Pager object representing the pager of core namely sigma0
|
||||
*/
|
||||
struct Sigma0 : public Pager_object
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
Sigma0();
|
||||
|
||||
int pager(Ipc_pager &ps) { /* never called */ return -1; }
|
||||
};
|
||||
|
||||
/**
|
||||
* Return singleton instance of Sigma0 pager object
|
||||
*/
|
||||
static Sigma0 *sigma0();
|
||||
|
||||
/**
|
||||
* Core pager thread that handles core-internal page-faults
|
||||
*/
|
||||
struct Core_pager : public Platform_thread, public Pager_object
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
Core_pager(Platform_pd *core_pd);
|
||||
|
||||
int pager(Ipc_pager &ps) { /* never called */ return -1; }
|
||||
};
|
||||
|
||||
/**
|
||||
* Return singleton instance of core pager object
|
||||
*/
|
||||
Core_pager *core_pager();
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
Platform();
|
||||
|
||||
/**
|
||||
* Accessor for core pd object
|
||||
*/
|
||||
Platform_pd *core_pd() { return _core_pd; }
|
||||
|
||||
|
||||
/********************************
|
||||
** Generic platform interface **
|
||||
********************************/
|
||||
|
||||
Range_allocator *core_mem_alloc() { return &_ram_alloc; }
|
||||
Range_allocator *ram_alloc() { return &_ram_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 &_region_alloc; }
|
||||
addr_t vm_start() const { return _vm_start; }
|
||||
size_t vm_size() const { return _vm_size; }
|
||||
Rom_fs *rom_fs() { return &_rom_fs; }
|
||||
|
||||
void wait_for_exit();
|
||||
};
|
||||
}
|
||||
|
||||
#endif /* _CORE__INCLUDE__PLATFORM_H_ */
|
||||
195
repos/base-fiasco/src/core/include/platform_pd.h
Normal file
195
repos/base-fiasco/src/core/include/platform_pd.h
Normal file
@@ -0,0 +1,195 @@
|
||||
/*
|
||||
* \brief L4/Fiasco protection domain facility
|
||||
* \author Christian Helmuth
|
||||
* \date 2006-04-11
|
||||
*
|
||||
* Protection domains are L4 tasks under Fiasco and serve as base
|
||||
* container for the platform.
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef _CORE__INCLUDE__PLATFORM_PD_H_
|
||||
#define _CORE__INCLUDE__PLATFORM_PD_H_
|
||||
|
||||
#include <platform_thread.h>
|
||||
#include <address_space.h>
|
||||
|
||||
namespace Fiasco {
|
||||
#include <l4/sys/types.h>
|
||||
}
|
||||
|
||||
namespace Genode {
|
||||
|
||||
class Platform_thread;
|
||||
class Platform_pd : public Address_space
|
||||
{
|
||||
private:
|
||||
|
||||
enum {
|
||||
VERSION_BITS = 10,
|
||||
PD_FIRST = 0x10,
|
||||
PD_MAX = (1 << 11) - 1, /* leave 0x7ff free for L4_INVALID_ID */
|
||||
PD_VERSION_MAX = (1 << 10) - 1,
|
||||
PD_INVALID = -1,
|
||||
THREAD_MAX = (1 << 7),
|
||||
};
|
||||
|
||||
unsigned _pd_id; /* plain pd number */
|
||||
unsigned _version; /* version number */
|
||||
|
||||
Fiasco::l4_taskid_t _l4_task_id; /* L4 task ID */
|
||||
|
||||
|
||||
/**********************************************
|
||||
** Threads of this protection domain object **
|
||||
**********************************************/
|
||||
|
||||
Platform_thread *_threads[THREAD_MAX];
|
||||
|
||||
/**
|
||||
* Initialize thread allocator
|
||||
*/
|
||||
void _init_threads();
|
||||
|
||||
/**
|
||||
* Thread iteration for one task
|
||||
*/
|
||||
Platform_thread *_next_thread();
|
||||
|
||||
/**
|
||||
* Thread allocation
|
||||
*
|
||||
* Again a special case for Core thread0.
|
||||
*/
|
||||
int _alloc_thread(int thread_id, Platform_thread *thread);
|
||||
|
||||
/**
|
||||
* Thread deallocation
|
||||
*
|
||||
* No special case for Core thread0 here - we just never call it.
|
||||
*/
|
||||
void _free_thread(int thread_id);
|
||||
|
||||
|
||||
/******************
|
||||
** PD allocator **
|
||||
******************/
|
||||
|
||||
struct Pd_alloc
|
||||
{
|
||||
unsigned reserved : 1;
|
||||
unsigned free : 1;
|
||||
unsigned version : VERSION_BITS;
|
||||
|
||||
Pd_alloc(bool r, bool f, unsigned v)
|
||||
: reserved(r), free(f), version(v) { }
|
||||
|
||||
Pd_alloc() : reserved(0), free(0), version(0) { }
|
||||
};
|
||||
|
||||
static Pd_alloc *_pds()
|
||||
{
|
||||
static Pd_alloc static_pds[PD_MAX];
|
||||
return static_pds;
|
||||
}
|
||||
|
||||
/**
|
||||
* Protection-domain creation
|
||||
*
|
||||
* The syscall parameter propagates if any L4 kernel function
|
||||
* should be used. We need the special case for the Core startup.
|
||||
*/
|
||||
void _create_pd(bool syscall);
|
||||
|
||||
/**
|
||||
* Protection domain destruction
|
||||
*
|
||||
* No special case for Core here - we just never call it.
|
||||
*/
|
||||
void _destroy_pd();
|
||||
|
||||
/**
|
||||
* Protection domain allocation
|
||||
*
|
||||
* Find free L4 task and use it. We need the special case for Core
|
||||
* startup.
|
||||
*/
|
||||
int _alloc_pd(signed pd_id);
|
||||
|
||||
/**
|
||||
* Protection domain deallocation
|
||||
*
|
||||
* No special case for Core here - we just never call it.
|
||||
*/
|
||||
void _free_pd();
|
||||
|
||||
|
||||
/***************
|
||||
** Debugging **
|
||||
***************/
|
||||
|
||||
void _debug_log_pds(void);
|
||||
void _debug_log_threads(void);
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
Platform_pd(char const *, signed pd_id = PD_INVALID,
|
||||
bool create = true);
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
~Platform_pd();
|
||||
|
||||
/**
|
||||
* Initialize L4 task facility
|
||||
*/
|
||||
static void init();
|
||||
|
||||
/**
|
||||
* Bind thread to protection domain
|
||||
*
|
||||
* \return 0 on success or
|
||||
* -1 if thread ID allocation failed.
|
||||
*
|
||||
* This function allocates the physical L4 thread ID.
|
||||
*/
|
||||
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; }
|
||||
|
||||
int pd_id() const { return _pd_id; }
|
||||
|
||||
|
||||
/*****************************
|
||||
** Address-space interface **
|
||||
*****************************/
|
||||
|
||||
/*
|
||||
* On L4/Fiasco, we don't use directed unmap but rely on the
|
||||
* in-kernel mapping database. See 'rm_session_support.cc'.
|
||||
*/
|
||||
void flush(addr_t, size_t) { PDBG("not implemented"); }
|
||||
};
|
||||
}
|
||||
|
||||
#endif /* _CORE__INCLUDE__PLATFORM_PD_H_ */
|
||||
164
repos/base-fiasco/src/core/include/platform_thread.h
Normal file
164
repos/base-fiasco/src/core/include/platform_thread.h
Normal file
@@ -0,0 +1,164 @@
|
||||
/*
|
||||
* \brief Fiasco thread facility
|
||||
* \author Christian Helmuth
|
||||
* \date 2006-04-11
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef _CORE__INCLUDE__PLATFORM_THREAD_H_
|
||||
#define _CORE__INCLUDE__PLATFORM_THREAD_H_
|
||||
|
||||
/* Genode includes */
|
||||
#include <base/native_types.h>
|
||||
#include <base/thread_state.h>
|
||||
#include <base/pager.h>
|
||||
|
||||
/* core includes */
|
||||
#include <platform_pd.h>
|
||||
#include <address_space.h>
|
||||
|
||||
/* Fiasco includes */
|
||||
namespace Fiasco {
|
||||
#include <l4/sys/types.h>
|
||||
}
|
||||
|
||||
namespace Genode {
|
||||
|
||||
class Platform_pd;
|
||||
class Platform_thread
|
||||
{
|
||||
private:
|
||||
|
||||
int _thread_id; /* plain thread number */
|
||||
Native_thread_id _l4_thread_id; /* L4 thread ID */
|
||||
char _name[32]; /* thread name that will be
|
||||
registered at the kernel
|
||||
debugger */
|
||||
Platform_pd *_platform_pd; /* protection domain thread
|
||||
is bound to */
|
||||
Pager_object *_pager;
|
||||
|
||||
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
|
||||
*
|
||||
* \retval 0 successful
|
||||
* \retval -1 thread could not be started
|
||||
*/
|
||||
int start(void *ip, void *sp);
|
||||
|
||||
/**
|
||||
* Pause this thread
|
||||
*/
|
||||
void pause();
|
||||
|
||||
/**
|
||||
* Resume this thread
|
||||
*/
|
||||
void resume();
|
||||
|
||||
/**
|
||||
* Cancel currently blocking operation
|
||||
*/
|
||||
void cancel_blocking();
|
||||
|
||||
/**
|
||||
* This thread is about to be bound
|
||||
*
|
||||
* \param thread_id local thread ID
|
||||
* \param l4_thread_id final L4 thread ID
|
||||
* \param pd platform pd, thread is bound to
|
||||
*/
|
||||
void bind(int thread_id, Native_thread_id l4_thread_id,
|
||||
Platform_pd *pd);
|
||||
|
||||
/**
|
||||
* Unbind this thread
|
||||
*/
|
||||
void unbind();
|
||||
|
||||
/**
|
||||
* 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();
|
||||
|
||||
/**
|
||||
* Set the executing CPU for this thread
|
||||
*
|
||||
* SMP is not supported on L4/Fiasco.
|
||||
*/
|
||||
void affinity(Affinity::Location) { }
|
||||
|
||||
/**
|
||||
* Request the affinity of this thread
|
||||
*/
|
||||
Affinity::Location affinity() { return Affinity::Location(); }
|
||||
|
||||
/**
|
||||
* Return the address space to which the thread is bound
|
||||
*/
|
||||
Weak_ptr<Address_space> address_space();
|
||||
|
||||
|
||||
/************************
|
||||
** Accessor functions **
|
||||
************************/
|
||||
|
||||
/**
|
||||
* Return/set pager
|
||||
*/
|
||||
Pager_object *pager() const { return _pager; }
|
||||
void pager(Pager_object *pager) { _pager = pager; }
|
||||
|
||||
/**
|
||||
* Return identification of thread when faulting
|
||||
*/
|
||||
unsigned long pager_object_badge() const {
|
||||
return convert_native_thread_id_to_badge(_l4_thread_id); }
|
||||
|
||||
|
||||
/*******************************
|
||||
** Fiasco-specific Accessors **
|
||||
*******************************/
|
||||
|
||||
int thread_id() const { return _thread_id; }
|
||||
Native_thread_id native_thread_id() const { return _l4_thread_id; }
|
||||
const char *name() const { return _name; }
|
||||
};
|
||||
}
|
||||
|
||||
#endif /* _CORE__INCLUDE__PLATFORM_THREAD_H_ */
|
||||
118
repos/base-fiasco/src/core/include/util.h
Normal file
118
repos/base-fiasco/src/core/include/util.h
Normal file
@@ -0,0 +1,118 @@
|
||||
/*
|
||||
* \brief Fiasco utilities
|
||||
* \author Christian Helmuth
|
||||
* \date 2006-04-11
|
||||
*
|
||||
* Is very practical now, but please keep the errors of the l4util pkg in mind.
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef _CORE__INCLUDE__UTIL_H_
|
||||
#define _CORE__INCLUDE__UTIL_H_
|
||||
|
||||
/* Genode includes */
|
||||
#include <base/stdint.h>
|
||||
#include <base/printf.h>
|
||||
#include <rm_session/rm_session.h>
|
||||
#include <util/touch.h>
|
||||
#include <fiasco/thread_helper.h>
|
||||
|
||||
/* Fiasco includes */
|
||||
namespace Fiasco {
|
||||
#include <l4/sys/types.h>
|
||||
#include <l4/sys/ipc.h>
|
||||
#include <l4/sys/kdebug.h>
|
||||
#include <l4/sys/ktrace.h>
|
||||
}
|
||||
|
||||
namespace Genode {
|
||||
|
||||
inline void log_event(const char *s)
|
||||
{
|
||||
Fiasco::fiasco_tbuf_log(s);
|
||||
}
|
||||
|
||||
inline void log_event(const char *s, unsigned v1, unsigned v2, unsigned v3)
|
||||
{
|
||||
Fiasco::fiasco_tbuf_log_3val(s, v1, v2, v3);
|
||||
}
|
||||
|
||||
inline void panic(const char *s)
|
||||
{
|
||||
using namespace Fiasco;
|
||||
outstring(s);
|
||||
enter_kdebug("> panic <");
|
||||
}
|
||||
|
||||
inline void touch_ro(const void *addr, unsigned size)
|
||||
{
|
||||
using namespace Fiasco;
|
||||
unsigned char const volatile *bptr;
|
||||
unsigned char const *eptr;
|
||||
|
||||
bptr = (unsigned char const volatile *)(((unsigned)addr) & L4_PAGEMASK);
|
||||
eptr = (unsigned char const *)(((unsigned)addr + size - 1) & L4_PAGEMASK);
|
||||
for ( ; bptr <= eptr; bptr += L4_PAGESIZE)
|
||||
touch_read(bptr);
|
||||
}
|
||||
|
||||
inline void touch_rw(const void *addr, unsigned size)
|
||||
{
|
||||
using namespace Fiasco;
|
||||
unsigned char volatile *bptr;
|
||||
unsigned char const *eptr;
|
||||
|
||||
bptr = (unsigned char volatile *)(((unsigned)addr) & L4_PAGEMASK);
|
||||
eptr = (unsigned char const *)(((unsigned)addr + size - 1) & L4_PAGEMASK);
|
||||
for (; bptr <= eptr; bptr += L4_PAGESIZE)
|
||||
touch_read_write(bptr);
|
||||
}
|
||||
|
||||
inline addr_t trunc_page(addr_t addr)
|
||||
{
|
||||
using namespace Fiasco;
|
||||
return l4_trunc_page(addr);
|
||||
}
|
||||
|
||||
inline addr_t round_page(addr_t addr)
|
||||
{
|
||||
using namespace Fiasco;
|
||||
return l4_round_page(addr);
|
||||
}
|
||||
|
||||
inline addr_t round_superpage(addr_t addr)
|
||||
{
|
||||
using namespace Fiasco;
|
||||
return l4_round_superpage(addr);
|
||||
}
|
||||
|
||||
constexpr size_t get_page_size() { return L4_PAGESIZE; }
|
||||
constexpr size_t get_page_size_log2() { return L4_LOG2_PAGESIZE; }
|
||||
constexpr size_t get_super_page_size() { return L4_SUPERPAGESIZE; }
|
||||
constexpr size_t get_super_page_size_log2() { return L4_LOG2_SUPERPAGESIZE; }
|
||||
|
||||
inline void print_page_fault(const char *msg, addr_t pf_addr, addr_t pf_ip,
|
||||
Rm_session::Fault_type pf_type,
|
||||
unsigned long badge)
|
||||
{
|
||||
Native_thread_id tid;
|
||||
tid.raw = badge;
|
||||
printf("%s (%s pf_addr=%p pf_ip=%p from %x.%02x)\n", msg,
|
||||
pf_type == Rm_session::WRITE_FAULT ? "WRITE" : "READ",
|
||||
(void *)pf_addr, (void *)pf_ip,
|
||||
(int)tid.id.task, (int)tid.id.lthread);
|
||||
}
|
||||
|
||||
inline addr_t map_src_addr(addr_t core_local_addr, addr_t phys_addr) {
|
||||
return core_local_addr; }
|
||||
|
||||
inline size_t constrain_map_size_log2(size_t size_log2) { return size_log2; }
|
||||
}
|
||||
|
||||
#endif /* _CORE__INCLUDE__UTIL_H_ */
|
||||
95
repos/base-fiasco/src/core/io_mem_session_support.cc
Normal file
95
repos/base-fiasco/src/core/io_mem_session_support.cc
Normal file
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
* \brief Fiasco-specific implementation of the IO_MEM session interface
|
||||
* \author Christian Helmuth
|
||||
* \date 2006-08-28
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/* core includes */
|
||||
#include <platform.h>
|
||||
#include <util.h>
|
||||
#include <io_mem_session_component.h>
|
||||
|
||||
/* Fiasco includes */
|
||||
namespace Fiasco {
|
||||
#include <l4/sys/ipc.h>
|
||||
#include <l4/sigma0/sigma0.h>
|
||||
}
|
||||
|
||||
using namespace Genode;
|
||||
|
||||
|
||||
void Io_mem_session_component::_unmap_local(addr_t base, size_t size)
|
||||
{
|
||||
platform()->region_alloc()->free(reinterpret_cast<void *>(base));
|
||||
}
|
||||
|
||||
|
||||
static inline bool can_use_super_page(addr_t base, size_t size) {
|
||||
return (base & (get_super_page_size() - 1)) == 0
|
||||
&& (size >= get_super_page_size()); }
|
||||
|
||||
|
||||
addr_t Io_mem_session_component::_map_local(addr_t base, size_t size)
|
||||
{
|
||||
using namespace Fiasco;
|
||||
|
||||
/* align large I/O dataspaces on a super-page boundary within core */
|
||||
size_t alignment = (size >= get_super_page_size()) ? get_super_page_size_log2()
|
||||
: get_page_size_log2();
|
||||
|
||||
/* find appropriate region for mapping */
|
||||
void *local_base = 0;
|
||||
if (platform()->region_alloc()->alloc_aligned(size, &local_base, alignment).is_error())
|
||||
return 0;
|
||||
|
||||
/* call sigma0 for I/O region */
|
||||
int err;
|
||||
l4_umword_t request;
|
||||
l4_umword_t dw0, dw1;
|
||||
l4_msgdope_t result;
|
||||
l4_msgtag_t tag;
|
||||
|
||||
l4_threadid_t sigma0 = sigma0_threadid;
|
||||
|
||||
unsigned offset = 0;
|
||||
while (size) {
|
||||
/* FIXME what about caching demands? */
|
||||
/* FIXME what about read / write? */
|
||||
|
||||
/* special case for page0, which is RAM in sigma0/x86 */
|
||||
if (base + offset == 0)
|
||||
request = SIGMA0_REQ_FPAGE_RAM;
|
||||
else
|
||||
request = SIGMA0_REQ_FPAGE_IOMEM;
|
||||
|
||||
size_t page_size_log2 = get_page_size_log2();
|
||||
if (can_use_super_page(base + offset, size))
|
||||
page_size_log2 = get_super_page_size_log2();
|
||||
|
||||
err = l4_ipc_call_tag(sigma0,
|
||||
L4_IPC_SHORT_MSG,
|
||||
request,
|
||||
l4_fpage(base + offset, page_size_log2, 0, 0).fpage,
|
||||
l4_msgtag(L4_MSGTAG_SIGMA0, 0, 0, 0),
|
||||
L4_IPC_MAPMSG((addr_t)local_base + offset, page_size_log2),
|
||||
&dw0, &dw1,
|
||||
L4_IPC_NEVER, &result, &tag);
|
||||
|
||||
if (err || !l4_ipc_fpage_received(result)) {
|
||||
PERR("%d %d", err, l4_ipc_fpage_received(result));
|
||||
return 0;
|
||||
}
|
||||
|
||||
offset += 1 << page_size_log2;
|
||||
size -= 1 << page_size_log2;
|
||||
}
|
||||
|
||||
return (addr_t)local_base;
|
||||
}
|
||||
122
repos/base-fiasco/src/core/irq_session_component.cc
Normal file
122
repos/base-fiasco/src/core/irq_session_component.cc
Normal file
@@ -0,0 +1,122 @@
|
||||
/*
|
||||
* \brief Core implementation of IRQ sessions
|
||||
* \author Christian Helmuth
|
||||
* \date 2007-09-13
|
||||
*
|
||||
* FIXME ram quota missing
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2007-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/arg_string.h>
|
||||
|
||||
/* core includes */
|
||||
#include <irq_root.h>
|
||||
#include <util.h>
|
||||
|
||||
/* Fiasco includes */
|
||||
namespace Fiasco {
|
||||
#include <l4/sys/ipc.h>
|
||||
#include <l4/sys/syscalls.h>
|
||||
#include <l4/sys/types.h>
|
||||
}
|
||||
|
||||
using namespace Genode;
|
||||
|
||||
|
||||
bool Irq_session_component::Irq_control_component::associate_to_irq(unsigned irq_number)
|
||||
{
|
||||
using namespace Fiasco;
|
||||
|
||||
int err;
|
||||
l4_threadid_t irq_tid;
|
||||
l4_umword_t dw0, dw1;
|
||||
l4_msgdope_t result;
|
||||
|
||||
l4_make_taskid_from_irq(irq_number, &irq_tid);
|
||||
|
||||
/* boost thread to IRQ priority */
|
||||
enum { IRQ_PRIORITY = 0xC0 };
|
||||
|
||||
l4_sched_param_t param = {sp:{prio:IRQ_PRIORITY, small:0, state:0, time_exp:0, time_man:0}};
|
||||
l4_threadid_t ext_preempter = L4_INVALID_ID;
|
||||
l4_threadid_t partner = L4_INVALID_ID;
|
||||
l4_sched_param_t old_param;
|
||||
l4_thread_schedule(l4_myself(), param, &ext_preempter, &partner, &old_param);
|
||||
|
||||
err = l4_ipc_receive(irq_tid,
|
||||
L4_IPC_SHORT_MSG, &dw0, &dw1,
|
||||
L4_IPC_BOTH_TIMEOUT_0, &result);
|
||||
|
||||
if (err != L4_IPC_RETIMEOUT) PERR("IRQ association failed");
|
||||
|
||||
return (err == L4_IPC_RETIMEOUT);
|
||||
}
|
||||
|
||||
|
||||
void Irq_session_component::wait_for_irq()
|
||||
{
|
||||
using namespace Fiasco;
|
||||
|
||||
l4_threadid_t irq_tid;
|
||||
l4_umword_t dw0=0, dw1=0;
|
||||
l4_msgdope_t result;
|
||||
|
||||
l4_make_taskid_from_irq(_irq_number, &irq_tid);
|
||||
|
||||
do {
|
||||
l4_ipc_call(irq_tid,
|
||||
L4_IPC_SHORT_MSG, 0, 0,
|
||||
L4_IPC_SHORT_MSG, &dw0, &dw1,
|
||||
L4_IPC_NEVER, &result);
|
||||
|
||||
if (L4_IPC_IS_ERROR(result)) PERR("Ipc error %lx", L4_IPC_ERROR(result));
|
||||
} while (L4_IPC_IS_ERROR(result));
|
||||
}
|
||||
|
||||
|
||||
Irq_session_component::Irq_session_component(Cap_session *cap_session,
|
||||
Range_allocator *irq_alloc,
|
||||
const char *args)
|
||||
:
|
||||
_irq_alloc(irq_alloc),
|
||||
_ep(cap_session, STACK_SIZE, "irqctrl"),
|
||||
_control_cap(_ep.manage(&_control_component)),
|
||||
_control_client(_control_cap)
|
||||
{
|
||||
bool shared = Arg_string::find_arg(args, "irq_shared").bool_value(false);
|
||||
if (shared) {
|
||||
PWRN("IRQ sharing not supported");
|
||||
throw Root::Invalid_args();
|
||||
}
|
||||
|
||||
long irq_number = Arg_string::find_arg(args, "irq_number").long_value(-1);
|
||||
if (irq_number == -1 || !irq_alloc ||
|
||||
irq_alloc->alloc_addr(1, irq_number).is_error()) {
|
||||
PERR("Unavailable IRQ %lx requested", irq_number);
|
||||
throw Root::Invalid_args();
|
||||
}
|
||||
_irq_number = irq_number;
|
||||
|
||||
if (!_control_client.associate_to_irq(irq_number)) {
|
||||
PWRN("IRQ association failed");
|
||||
throw Root::Invalid_args();
|
||||
}
|
||||
|
||||
/* initialize capability */
|
||||
_irq_cap = Irq_session_capability(_ep.manage(this));
|
||||
}
|
||||
|
||||
|
||||
Irq_session_component::~Irq_session_component()
|
||||
{
|
||||
PERR("Implement me, immediately!");
|
||||
}
|
||||
|
||||
521
repos/base-fiasco/src/core/platform.cc
Normal file
521
repos/base-fiasco/src/core/platform.cc
Normal file
@@ -0,0 +1,521 @@
|
||||
/*
|
||||
* \brief Fiasco platform interface implementation
|
||||
* \author Christian Helmuth
|
||||
* \date 2006-04-11
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/* Genode includes */
|
||||
#include <base/printf.h>
|
||||
#include <base/allocator_avl.h>
|
||||
#include <base/crt0.h>
|
||||
#include <base/sleep.h>
|
||||
#include <util/misc_math.h>
|
||||
#include <fiasco/thread_helper.h>
|
||||
|
||||
/* core includes */
|
||||
#include <core_parent.h>
|
||||
#include <platform.h>
|
||||
#include <platform_thread.h>
|
||||
#include <platform_pd.h>
|
||||
#include <util.h>
|
||||
#include <multiboot.h>
|
||||
|
||||
/* Fiasco includes */
|
||||
namespace Fiasco {
|
||||
#include <l4/sys/types.h>
|
||||
#include <l4/sys/syscalls.h>
|
||||
#include <l4/sys/ipc.h>
|
||||
#include <l4/sys/kernel.h>
|
||||
#include <l4/sys/kip.h>
|
||||
#include <l4/sigma0/sigma0.h>
|
||||
}
|
||||
|
||||
using namespace Genode;
|
||||
|
||||
|
||||
static const bool verbose = true;
|
||||
static const bool verbose_core_pf = false;
|
||||
static const bool verbose_region_alloc = false;
|
||||
|
||||
|
||||
/***********************************
|
||||
** Core address space management **
|
||||
***********************************/
|
||||
|
||||
static Synchronized_range_allocator<Allocator_avl> &_core_address_ranges()
|
||||
{
|
||||
static Synchronized_range_allocator<Allocator_avl> _core_address_ranges(0);
|
||||
return _core_address_ranges;
|
||||
}
|
||||
|
||||
enum { PAGER_STACK_ELEMENTS = 1024 };
|
||||
static unsigned long _core_pager_stack[PAGER_STACK_ELEMENTS];
|
||||
static unsigned _core_pager_arg;
|
||||
|
||||
|
||||
/**
|
||||
* Core pager "service loop"
|
||||
*/
|
||||
static void _core_pager_loop()
|
||||
{
|
||||
unsigned pd_id = _core_pager_arg;
|
||||
|
||||
using namespace Fiasco;
|
||||
|
||||
l4_threadid_t t;
|
||||
l4_umword_t dw0, dw1;
|
||||
l4_msgdope_t r;
|
||||
|
||||
bool send_reply = false;
|
||||
|
||||
while (1) {
|
||||
|
||||
if (send_reply)
|
||||
/* unblock faulter and wait for next pagefault */
|
||||
l4_ipc_reply_and_wait(t, L4_IPC_SHORT_MSG, 0, 0,
|
||||
&t, L4_IPC_SHORT_MSG, &dw0, &dw1,
|
||||
L4_IPC_NEVER, &r);
|
||||
else
|
||||
l4_ipc_wait(&t, L4_IPC_SHORT_MSG, &dw0, &dw1, L4_IPC_NEVER, &r);
|
||||
|
||||
/* ignore messages from non-core pds */
|
||||
if (t.id.task != pd_id) break;
|
||||
|
||||
/* detect local map request */
|
||||
if (dw1 == 0) {
|
||||
l4_msgdope_t ipc_result;
|
||||
l4_ipc_send(t, L4_IPC_SHORT_FPAGE, 0, dw0,
|
||||
L4_IPC_SEND_TIMEOUT_0, &ipc_result);
|
||||
send_reply = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
bool rw = dw0 & 2;
|
||||
addr_t pfa = dw0 & ~2;
|
||||
|
||||
if (pfa < L4_PAGESIZE) {
|
||||
|
||||
/* NULL pointer access */
|
||||
PERR("Possible null pointer %s in %x.%02x at %lx IP %lx",
|
||||
rw ? "WRITE" : "READ", (int)t.id.task, (int)t.id.lthread, pfa, dw1);
|
||||
/* do not unblock faulter */
|
||||
send_reply = false;
|
||||
continue;
|
||||
} else if (!_core_address_ranges().valid_addr(pfa)) {
|
||||
|
||||
/* page-fault address is not in RAM */
|
||||
PERR("%s access outside of RAM in %x.%02x at %lx IP %lx",
|
||||
rw ? "WRITE" : "READ", (int)t.id.task, (int)t.id.lthread, pfa, dw1);
|
||||
/* do not unblock faulter */
|
||||
send_reply = false;
|
||||
continue;
|
||||
} else if (verbose_core_pf)
|
||||
PDBG("pfa=%lx ip=%lx thread %x.%02x", pfa, dw1, (int)t.id.task, (int)t.id.lthread);
|
||||
|
||||
/* my pf handler is sigma0 - just touch the appropriate page */
|
||||
if (rw)
|
||||
touch_rw((void *)pfa, 1);
|
||||
else
|
||||
touch_ro((void *)pfa, 1);
|
||||
|
||||
send_reply = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Platform::Sigma0::Sigma0() : Pager_object(0, Affinity::Location())
|
||||
{
|
||||
cap(reinterpret_cap_cast<Cpu_thread>(Native_capability(Fiasco::sigma0_threadid, 0)));
|
||||
}
|
||||
|
||||
|
||||
Platform::Sigma0 *Platform::sigma0()
|
||||
{
|
||||
static Sigma0 _sigma0;
|
||||
return &_sigma0;
|
||||
}
|
||||
|
||||
|
||||
Platform::Core_pager::Core_pager(Platform_pd *core_pd)
|
||||
:
|
||||
Platform_thread("core.pager"), Pager_object(0, Affinity::Location())
|
||||
{
|
||||
Platform_thread::pager(sigma0());
|
||||
|
||||
core_pd->bind_thread(this);
|
||||
cap(Native_capability(native_thread_id(), 0));
|
||||
|
||||
/* pager needs to know core's pd ID */
|
||||
_core_pager_arg = core_pd->pd_id();
|
||||
|
||||
/* stack begins at the top end of the '_core_pager_stack' array */
|
||||
void *sp = (void *)&_core_pager_stack[PAGER_STACK_ELEMENTS - 1];
|
||||
start((void *)_core_pager_loop, sp);
|
||||
|
||||
using namespace Fiasco;
|
||||
|
||||
/* pager0 receives pagefaults from me - for NULL pointer detection */
|
||||
l4_umword_t d;
|
||||
l4_threadid_t preempter = L4_INVALID_ID;
|
||||
l4_threadid_t pager = native_thread_id();
|
||||
l4_thread_ex_regs(l4_myself(), ~0UL, ~0UL, &preempter, &pager, &d, &d, &d);
|
||||
}
|
||||
|
||||
|
||||
Platform::Core_pager *Platform::core_pager()
|
||||
{
|
||||
static Core_pager _core_pager(core_pd());
|
||||
return &_core_pager;
|
||||
}
|
||||
|
||||
|
||||
/***********************************
|
||||
** Helper for L4 region handling **
|
||||
***********************************/
|
||||
|
||||
struct Region
|
||||
{
|
||||
addr_t start;
|
||||
addr_t end;
|
||||
|
||||
Region() : start(0), end(0) { }
|
||||
Region(addr_t s, addr_t e) : start(s), end(e) { }
|
||||
|
||||
/**
|
||||
* Returns true if the specified range intersects with the region
|
||||
*/
|
||||
bool intersects(addr_t base, size_t size) const
|
||||
{
|
||||
return (((base + size) > start) && (base < end));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Log region
|
||||
*/
|
||||
static inline void print_region(Region r)
|
||||
{
|
||||
printf("[%08lx,%08lx) %08lx", r.start, r.end, r.end - r.start);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add region to allocator
|
||||
*/
|
||||
static inline void add_region(Region r, Range_allocator &alloc)
|
||||
{
|
||||
if (verbose_region_alloc) {
|
||||
printf("%p add: ", &alloc); print_region(r); printf("\n");
|
||||
}
|
||||
|
||||
/* adjust region */
|
||||
addr_t start = trunc_page(r.start);
|
||||
addr_t end = round_page(r.end);
|
||||
|
||||
alloc.add_range(start, end - start);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Remove region from allocator
|
||||
*/
|
||||
static inline void remove_region(Region r, Range_allocator &alloc)
|
||||
{
|
||||
if (verbose_region_alloc) {
|
||||
printf("%p remove: ", &alloc); print_region(r); printf("\n");
|
||||
}
|
||||
|
||||
/* adjust region */
|
||||
addr_t start = trunc_page(r.start);
|
||||
addr_t end = round_page(r.end);
|
||||
|
||||
alloc.remove_range(start, end - start);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Request any RAM page from Sigma0
|
||||
*/
|
||||
static inline int sigma0_req_region(addr_t *addr, unsigned log2size)
|
||||
{
|
||||
using namespace Fiasco;
|
||||
|
||||
/* XXX sigma0 always maps pages RW */
|
||||
l4_umword_t req_fpage = l4_fpage(0, log2size, 0, 0).fpage;
|
||||
void* rcv_window = L4_IPC_MAPMSG(0, L4_WHOLE_ADDRESS_SPACE);
|
||||
addr_t base;
|
||||
l4_fpage_t rcv_fpage;
|
||||
l4_msgdope_t result;
|
||||
l4_msgtag_t tag;
|
||||
|
||||
int err = l4_ipc_call_tag(Fiasco::sigma0_threadid,
|
||||
L4_IPC_SHORT_MSG, SIGMA0_REQ_FPAGE_ANY, req_fpage,
|
||||
l4_msgtag(L4_MSGTAG_SIGMA0, 0, 0, 0),
|
||||
rcv_window, &base, (l4_umword_t *)&rcv_fpage,
|
||||
L4_IPC_NEVER, &result, &tag);
|
||||
int ret = (err || !l4_ipc_fpage_received(result));
|
||||
|
||||
if (!ret) touch_rw((void *)addr, 1);
|
||||
|
||||
*addr = base;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
void Platform::_setup_mem_alloc()
|
||||
{
|
||||
/*
|
||||
* Completely map program image by touching all pages read-only to
|
||||
* prevent sigma0 from handing out those page as anonymous memory.
|
||||
*/
|
||||
volatile const char *beg, *end;
|
||||
beg = (const char *)(((unsigned)&_prog_img_beg) & L4_PAGEMASK);
|
||||
end = (const char *)&_prog_img_end;
|
||||
for ( ; beg < end; beg += L4_PAGESIZE) (void)(*beg);
|
||||
|
||||
/* request pages of known page size starting with largest */
|
||||
size_t log2_sizes[] = { L4_LOG2_SUPERPAGESIZE, L4_LOG2_PAGESIZE };
|
||||
|
||||
for (unsigned i = 0; i < sizeof(log2_sizes)/sizeof(*log2_sizes); ++i) {
|
||||
size_t log2_size = log2_sizes[i];
|
||||
size_t size = 1 << log2_size;
|
||||
|
||||
int err = 0;
|
||||
addr_t addr;
|
||||
Region region;
|
||||
|
||||
/* request any page of current size from sigma0 */
|
||||
do {
|
||||
err = sigma0_req_region(&addr, log2_size);
|
||||
if (!err) {
|
||||
/* XXX do not allocate page0 */
|
||||
if (addr == 0) {
|
||||
Fiasco::l4_fpage_unmap(Fiasco::l4_fpage(0, log2_size, 0, 0),
|
||||
L4_FP_FLUSH_PAGE | L4_FP_ALL_SPACES);
|
||||
continue;
|
||||
}
|
||||
|
||||
region.start = addr; region.end = addr + size;
|
||||
if (!region.intersects(Native_config::context_area_virtual_base(),
|
||||
Native_config::context_area_virtual_size())) {
|
||||
add_region(region, _ram_alloc);
|
||||
add_region(region, _core_address_ranges());
|
||||
}
|
||||
remove_region(region, _io_mem_alloc);
|
||||
remove_region(region, _region_alloc);
|
||||
}
|
||||
} while (!err);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Platform::_setup_irq_alloc() {
|
||||
_irq_alloc.add_range(0, 0x10); }
|
||||
|
||||
|
||||
void Platform::_setup_basics()
|
||||
{
|
||||
using namespace Fiasco;
|
||||
|
||||
int err;
|
||||
|
||||
/* region allocator is not setup yet */
|
||||
|
||||
/* map KIP one-to-one */
|
||||
void *fpage = L4_IPC_MAPMSG(0, L4_WHOLE_ADDRESS_SPACE);
|
||||
l4_umword_t dw0, dw1;
|
||||
l4_msgdope_t r;
|
||||
l4_msgtag_t tag;
|
||||
|
||||
err = l4_ipc_call_tag(Fiasco::sigma0_threadid,
|
||||
L4_IPC_SHORT_MSG, SIGMA0_REQ_KIP, 0,
|
||||
l4_msgtag(L4_MSGTAG_SIGMA0, 0, 0, 0),
|
||||
fpage, &dw0, &dw1,
|
||||
L4_IPC_NEVER, &r, &tag);
|
||||
|
||||
bool amok = false;
|
||||
if (err) {
|
||||
printf("IPC error %d\n", err);
|
||||
amok = true;
|
||||
}
|
||||
if (!l4_ipc_fpage_received(r)) {
|
||||
printf("No fpage received\n");
|
||||
amok = true;
|
||||
}
|
||||
|
||||
if (amok)
|
||||
panic("kip mapping failed");
|
||||
|
||||
/* store mapping base from received mapping */
|
||||
l4_kernel_info_t *kip = (l4_kernel_info_t *)dw0;
|
||||
|
||||
if (kip->magic != L4_KERNEL_INFO_MAGIC)
|
||||
panic("Sigma0 mapped something but not the KIP");
|
||||
|
||||
if (verbose) {
|
||||
printf("\n");
|
||||
printf("KIP @ %p\n", kip);
|
||||
printf(" magic: %08x\n", kip->magic);
|
||||
printf(" version: %08x\n", kip->version);
|
||||
printf(" sigma0 "); printf(" esp: %08lx eip: %08lx\n", kip->sigma0_esp, kip->sigma0_eip);
|
||||
printf(" sigma1 "); printf(" esp: %08lx eip: %08lx\n", kip->sigma1_esp, kip->sigma1_eip);
|
||||
printf(" root "); printf(" esp: %08lx eip: %08lx\n", kip->root_esp, kip->root_eip);
|
||||
}
|
||||
|
||||
/* add KIP as ROM module */
|
||||
_kip_rom = Rom_module((addr_t)kip, L4_PAGESIZE, "l4v2_kip");
|
||||
_rom_fs.insert(&_kip_rom);
|
||||
|
||||
/* update multi-boot info pointer from KIP */
|
||||
void *mb_info_ptr = (void *)kip->user_ptr;
|
||||
_mb_info = Multiboot_info(mb_info_ptr);
|
||||
if (verbose) printf("MBI @ %p\n", mb_info_ptr);
|
||||
|
||||
/* parse memory descriptors - look for virtual memory configuration */
|
||||
/* XXX we support only one VM region (here and also inside RM) */
|
||||
using L4::Kip::Mem_desc;
|
||||
|
||||
_vm_start = 0; _vm_size = 0;
|
||||
Mem_desc *desc = Mem_desc::first(kip);
|
||||
|
||||
for (unsigned i = 0; i < Mem_desc::count(kip); ++i)
|
||||
if (desc[i].is_virtual()) {
|
||||
_vm_start = round_page(desc[i].start());
|
||||
_vm_size = trunc_page(desc[i].end() - _vm_start + 1);
|
||||
|
||||
break;
|
||||
}
|
||||
if (_vm_size == 0)
|
||||
panic("Virtual memory configuration not found");
|
||||
|
||||
/* configure applicable address space but never use page0 */
|
||||
_vm_size = _vm_start == 0 ? _vm_size - L4_PAGESIZE : _vm_size;
|
||||
_vm_start = _vm_start == 0 ? L4_PAGESIZE : _vm_start;
|
||||
_region_alloc.add_range(_vm_start, _vm_size);
|
||||
|
||||
/* preserve context area in core's virtual address space */
|
||||
_region_alloc.remove_range(Native_config::context_area_virtual_base(),
|
||||
Native_config::context_area_virtual_size());
|
||||
|
||||
/* I/O memory could be the whole user address space */
|
||||
/* FIXME if the kernel helps to find out max address - use info here */
|
||||
_io_mem_alloc.add_range(0, ~0);
|
||||
|
||||
/* remove KIP and MBI area from region and IO_MEM allocator */
|
||||
remove_region(Region((addr_t)kip, (addr_t)kip + L4_PAGESIZE), _region_alloc);
|
||||
remove_region(Region((addr_t)kip, (addr_t)kip + L4_PAGESIZE), _io_mem_alloc);
|
||||
remove_region(Region((addr_t)mb_info_ptr, (addr_t)mb_info_ptr + _mb_info.size()), _region_alloc);
|
||||
remove_region(Region((addr_t)mb_info_ptr, (addr_t)mb_info_ptr + _mb_info.size()), _io_mem_alloc);
|
||||
|
||||
/* remove core program image memory from region and IO_MEM allocator */
|
||||
addr_t img_start = (addr_t) &_prog_img_beg;
|
||||
addr_t img_end = (addr_t) &_prog_img_end;
|
||||
remove_region(Region(img_start, img_end), _region_alloc);
|
||||
remove_region(Region(img_start, img_end), _io_mem_alloc);
|
||||
|
||||
/* image is accessible by core */
|
||||
add_region(Region(img_start, img_end), _core_address_ranges());
|
||||
}
|
||||
|
||||
|
||||
void Platform::_setup_rom()
|
||||
{
|
||||
Rom_module rom;
|
||||
|
||||
for (unsigned i = FIRST_ROM; i < _mb_info.num_modules(); i++) {
|
||||
if (!(rom = _mb_info.get_module(i)).valid()) continue;
|
||||
|
||||
Rom_module *new_rom = new(core_mem_alloc()) Rom_module(rom);
|
||||
_rom_fs.insert(new_rom);
|
||||
|
||||
if (verbose)
|
||||
printf(" mod[%d] [%p,%p) %s\n", i,
|
||||
(void *)new_rom->addr(), ((char *)new_rom->addr()) + new_rom->size(),
|
||||
new_rom->name());
|
||||
|
||||
/* zero remainder of last ROM page */
|
||||
size_t count = L4_PAGESIZE - rom.size() % L4_PAGESIZE;
|
||||
if (count != L4_PAGESIZE)
|
||||
memset(reinterpret_cast<void *>(rom.addr() + rom.size()), 0, count);
|
||||
|
||||
/* remove ROM area from region and IO_MEM allocator */
|
||||
remove_region(Region(new_rom->addr(), new_rom->addr() + new_rom->size()), _region_alloc);
|
||||
remove_region(Region(new_rom->addr(), new_rom->addr() + new_rom->size()), _io_mem_alloc);
|
||||
|
||||
/* add area to core-accessible ranges */
|
||||
add_region(Region(new_rom->addr(), new_rom->addr() + new_rom->size()), _core_address_ranges());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Platform::Platform() :
|
||||
_ram_alloc(0), _io_mem_alloc(core_mem_alloc()),
|
||||
_io_port_alloc(core_mem_alloc()), _irq_alloc(core_mem_alloc()),
|
||||
_region_alloc(core_mem_alloc())
|
||||
{
|
||||
/*
|
||||
* We must be single-threaded at this stage and so this is safe.
|
||||
*/
|
||||
static bool initialized = 0;
|
||||
if (initialized) panic("Platform constructed twice!");
|
||||
initialized = true;
|
||||
|
||||
_setup_basics();
|
||||
_setup_mem_alloc();
|
||||
_setup_io_port_alloc();
|
||||
_setup_irq_alloc();
|
||||
_setup_rom();
|
||||
|
||||
if (verbose) {
|
||||
printf(":ram_alloc: "); _ram_alloc.raw()->dump_addr_tree();
|
||||
printf(":region_alloc: "); _region_alloc.raw()->dump_addr_tree();
|
||||
printf(":io_mem: "); _io_mem_alloc.raw()->dump_addr_tree();
|
||||
printf(":io_port: "); _io_port_alloc.raw()->dump_addr_tree();
|
||||
printf(":irq: "); _irq_alloc.raw()->dump_addr_tree();
|
||||
printf(":rom_fs: "); _rom_fs.print_fs();
|
||||
printf(":core ranges: "); _core_address_ranges().raw()->dump_addr_tree();
|
||||
}
|
||||
|
||||
Fiasco::l4_threadid_t myself = Fiasco::l4_myself();
|
||||
|
||||
Platform_pd::init();
|
||||
|
||||
/* setup pd object for core pd */
|
||||
_core_label[0] = 0;
|
||||
_core_pd = new(core_mem_alloc()) Platform_pd(_core_label, myself.id.task, false);
|
||||
|
||||
/*
|
||||
* We setup the thread object for thread0 in core pd using a special
|
||||
* interface that allows us to specify the lthread number.
|
||||
*/
|
||||
Platform_thread *core_thread = new(core_mem_alloc()) Platform_thread("core.main", myself.id.lthread);
|
||||
core_thread->pager(sigma0());
|
||||
_core_pd->bind_thread(core_thread);
|
||||
|
||||
/* we never call _core_thread.start(), so set name directly */
|
||||
Fiasco::fiasco_register_thread_name(core_thread->native_thread_id(), core_thread->name());
|
||||
}
|
||||
|
||||
|
||||
/********************************
|
||||
** Generic platform interface **
|
||||
********************************/
|
||||
|
||||
void Platform::wait_for_exit()
|
||||
{
|
||||
/*
|
||||
* On Fiasco, Core never exits. So let us sleep forever.
|
||||
*/
|
||||
sleep_forever();
|
||||
}
|
||||
|
||||
|
||||
void Core_parent::exit(int exit_value) { }
|
||||
290
repos/base-fiasco/src/core/platform_pd.cc
Normal file
290
repos/base-fiasco/src/core/platform_pd.cc
Normal file
@@ -0,0 +1,290 @@
|
||||
/*
|
||||
* \brief Fiasco protection domain facility
|
||||
* \author Christian Helmuth
|
||||
* \date 2006-04-11
|
||||
*
|
||||
* On Fiasco, the pd class has several duties:
|
||||
*
|
||||
* - It is an allocator for L4 tasks and cares for versioning and recycling. We
|
||||
* do this with "static class members".
|
||||
* - L4 threads are tied to L4 tasks and there are only 128 per L4 task. So
|
||||
* each pd object is an allocator for its threads.
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/* Genode includes */
|
||||
#include <base/native_types.h>
|
||||
|
||||
/* core includes */
|
||||
#include <util.h>
|
||||
#include <platform_pd.h>
|
||||
|
||||
/* Fiasco includes */
|
||||
namespace Fiasco {
|
||||
#include <l4/sys/syscalls.h>
|
||||
}
|
||||
|
||||
using namespace Fiasco;
|
||||
using namespace Genode;
|
||||
|
||||
|
||||
static const bool verbose = false;
|
||||
|
||||
|
||||
/**************************
|
||||
** Static class members **
|
||||
**************************/
|
||||
|
||||
static bool _init = false;
|
||||
|
||||
|
||||
void Platform_pd::init()
|
||||
{
|
||||
if (_init) return;
|
||||
|
||||
unsigned i;
|
||||
Pd_alloc reserved(true, true, 0);
|
||||
Pd_alloc free(false, true, 0);
|
||||
|
||||
/* mark reserved protection domains */
|
||||
for (i = 0; i < PD_FIRST; ++i) _pds()[i] = reserved;
|
||||
/* init remainder */
|
||||
for ( ; i < PD_MAX; ++i) _pds()[i] = free;
|
||||
|
||||
_init = true;
|
||||
}
|
||||
|
||||
|
||||
/****************************
|
||||
** Private object members **
|
||||
****************************/
|
||||
|
||||
void Platform_pd::_create_pd(bool syscall)
|
||||
{
|
||||
l4_threadid_t l4t = l4_myself();
|
||||
l4t.id.task = _pd_id;
|
||||
l4t.id.lthread = 0;
|
||||
l4t.id.version_low = _version;
|
||||
|
||||
l4_taskid_t nt;
|
||||
if (syscall)
|
||||
nt = l4_task_new(l4t, 0, 0, 0, l4t);
|
||||
else
|
||||
nt = l4t;
|
||||
|
||||
if (l4_is_nil_id(nt))
|
||||
panic("pd creation failed");
|
||||
|
||||
_l4_task_id = nt;
|
||||
}
|
||||
|
||||
|
||||
void Platform_pd::_destroy_pd()
|
||||
{
|
||||
l4_threadid_t l4t = _l4_task_id;
|
||||
|
||||
/* L4 task deletion is: make inactive with myself as chief in 2nd parameter */
|
||||
l4_taskid_t nt = l4_task_new(l4t, convert_native_thread_id_to_badge(l4_myself()),
|
||||
0, 0, L4_NIL_ID);
|
||||
|
||||
if (l4_is_nil_id(nt))
|
||||
panic("pd destruction failed");
|
||||
|
||||
_l4_task_id = L4_INVALID_ID;
|
||||
}
|
||||
|
||||
|
||||
int Platform_pd::_alloc_pd(signed pd_id)
|
||||
{
|
||||
if (pd_id == PD_INVALID) {
|
||||
unsigned i;
|
||||
|
||||
for (i = PD_FIRST; i < PD_MAX; i++)
|
||||
if (_pds()[i].free) break;
|
||||
|
||||
/* no free protection domains available */
|
||||
if (i == PD_MAX) return -1;
|
||||
|
||||
pd_id = i;
|
||||
} else {
|
||||
if (!_pds()[pd_id].reserved || !_pds()[pd_id].free)
|
||||
return -1;
|
||||
}
|
||||
|
||||
_pds()[pd_id].free = 0;
|
||||
|
||||
_pd_id = pd_id;
|
||||
_version = _pds()[pd_id].version;
|
||||
|
||||
return pd_id;
|
||||
}
|
||||
|
||||
|
||||
void Platform_pd::_free_pd()
|
||||
{
|
||||
unsigned t = _pd_id;
|
||||
|
||||
/* XXX check and log double-free? */
|
||||
if (_pds()[t].free) return;
|
||||
|
||||
/* maximum reuse count reached leave non-free */
|
||||
if (_pds()[t].version == PD_VERSION_MAX) return;
|
||||
|
||||
_pds()[t].free = 1;
|
||||
++_pds()[t].version;
|
||||
}
|
||||
|
||||
|
||||
void Platform_pd::_init_threads()
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
for (i = 0; i < THREAD_MAX; ++i)
|
||||
_threads[i] = 0;
|
||||
}
|
||||
|
||||
|
||||
Platform_thread* Platform_pd::_next_thread()
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
/* look for bound thread */
|
||||
for (i = 0; i < THREAD_MAX; ++i)
|
||||
if (_threads[i]) break;
|
||||
|
||||
/* no bound threads */
|
||||
if (i == THREAD_MAX) return 0;
|
||||
|
||||
return _threads[i];
|
||||
}
|
||||
|
||||
|
||||
int Platform_pd::_alloc_thread(int thread_id, Platform_thread *thread)
|
||||
{
|
||||
int i = thread_id;
|
||||
|
||||
/* look for free thread */
|
||||
if (thread_id == Platform_thread::THREAD_INVALID) {
|
||||
for (i = 0; i < THREAD_MAX; ++i)
|
||||
if (!_threads[i]) break;
|
||||
|
||||
/* no free threads available */
|
||||
if (i == THREAD_MAX) return -1;
|
||||
} else {
|
||||
if (_threads[i]) return -2;
|
||||
}
|
||||
|
||||
_threads[i] = thread;
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
void Platform_pd::_free_thread(int thread_id)
|
||||
{
|
||||
if (!_threads[thread_id])
|
||||
PWRN("double-free of thread %x.%x detected", _pd_id, thread_id);
|
||||
|
||||
_threads[thread_id] = 0;
|
||||
}
|
||||
|
||||
|
||||
/***************************
|
||||
** Public object members **
|
||||
***************************/
|
||||
|
||||
int Platform_pd::bind_thread(Platform_thread *thread)
|
||||
{
|
||||
/* thread_id is THREAD_INVALID by default - only core is the special case */
|
||||
int thread_id = thread->thread_id();
|
||||
l4_threadid_t l4_thread_id;
|
||||
|
||||
int t = _alloc_thread(thread_id, thread);
|
||||
if (t < 0) {
|
||||
PERR("Thread alloc failed");
|
||||
return -1;
|
||||
}
|
||||
thread_id = t;
|
||||
|
||||
l4_thread_id = _l4_task_id;
|
||||
l4_thread_id.id.lthread = thread_id;
|
||||
|
||||
/* finally inform thread about binding */
|
||||
thread->bind(thread_id, l4_thread_id, this);
|
||||
|
||||
if (verbose) _debug_log_threads();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void Platform_pd::unbind_thread(Platform_thread *thread)
|
||||
{
|
||||
int thread_id = thread->thread_id();
|
||||
|
||||
/* unbind thread before proceeding */
|
||||
thread->unbind();
|
||||
|
||||
_free_thread(thread_id);
|
||||
|
||||
if (verbose) _debug_log_threads();
|
||||
}
|
||||
|
||||
|
||||
Platform_pd::Platform_pd(char const *, signed pd_id, bool create)
|
||||
{
|
||||
/* check correct init */
|
||||
if (!_init)
|
||||
panic("init pd facility via Platform_pd::init() before using it!");
|
||||
|
||||
/* init threads */
|
||||
_init_threads();
|
||||
|
||||
int ret = _alloc_pd(pd_id);
|
||||
if (ret < 0) {
|
||||
_debug_log_pds();
|
||||
panic("pd alloc failed");
|
||||
}
|
||||
|
||||
_create_pd(create);
|
||||
}
|
||||
|
||||
|
||||
Platform_pd::~Platform_pd()
|
||||
{
|
||||
/* unbind all threads */
|
||||
while (Platform_thread *t = _next_thread()) unbind_thread(t);
|
||||
|
||||
_destroy_pd();
|
||||
_free_pd();
|
||||
}
|
||||
|
||||
|
||||
/***********************
|
||||
** Debugging support **
|
||||
***********************/
|
||||
|
||||
void Platform_pd::_debug_log_threads()
|
||||
{
|
||||
int i;
|
||||
printf("[%02x] ", _pd_id);
|
||||
for (i = 0; i < THREAD_MAX; ++i) {
|
||||
printf("%c", !_threads[i] ? '.' : 'X');
|
||||
if (i == 63) printf("\n ");
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
|
||||
void Platform_pd::_debug_log_pds()
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < PD_MAX; ++i)
|
||||
printf("[%02x] %d %d %d\n", i, _pds()[i].reserved, _pds()[i].free,
|
||||
_pds()[i].version);
|
||||
}
|
||||
169
repos/base-fiasco/src/core/platform_thread.cc
Normal file
169
repos/base-fiasco/src/core/platform_thread.cc
Normal file
@@ -0,0 +1,169 @@
|
||||
/*
|
||||
* \brief Fiasco thread facility
|
||||
* \author Christian Helmuth
|
||||
* \date 2006-04-11
|
||||
*
|
||||
* This provides a thread object and uses l4_inter_task_ex_regs() for L4 thread
|
||||
* manipulation.
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/* Genode includes */
|
||||
#include <base/printf.h>
|
||||
#include <util/string.h>
|
||||
#include <cpu_session/cpu_session.h>
|
||||
|
||||
/* core includes */
|
||||
#include <platform_thread.h>
|
||||
|
||||
/* Fiasco includes */
|
||||
namespace Fiasco {
|
||||
#include <l4/sys/types.h>
|
||||
#include <l4/sys/syscalls.h>
|
||||
#include <l4/sys/utcb.h>
|
||||
#include <l4/sys/kdebug.h>
|
||||
}
|
||||
|
||||
using namespace Genode;
|
||||
using namespace Fiasco;
|
||||
|
||||
|
||||
int Platform_thread::start(void *ip, void *sp)
|
||||
{
|
||||
l4_umword_t dummy, old_eflags;
|
||||
l4_threadid_t thread = _l4_thread_id;
|
||||
l4_threadid_t pager = _pager ? _pager->cap().dst() : L4_INVALID_ID;
|
||||
l4_threadid_t preempter = L4_INVALID_ID;
|
||||
l4_threadid_t cap_handler = L4_INVALID_ID;
|
||||
|
||||
l4_inter_task_ex_regs(thread, (l4_umword_t)ip, (l4_umword_t)sp,
|
||||
&preempter, &pager, &cap_handler,
|
||||
&old_eflags, &dummy, &dummy,
|
||||
0, l4_utcb_get());
|
||||
if (old_eflags == ~0UL)
|
||||
PWRN("old eflags == ~0 on ex_regs %x.%x", (int)thread.id.task, (int)thread.id.lthread);
|
||||
|
||||
fiasco_register_thread_name(thread, _name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void Platform_thread::pause()
|
||||
{
|
||||
PDBG("not implemented");
|
||||
}
|
||||
|
||||
|
||||
void Platform_thread::resume()
|
||||
{
|
||||
PDBG("not implemented");
|
||||
}
|
||||
|
||||
|
||||
void Platform_thread::bind(int thread_id, l4_threadid_t l4_thread_id, Platform_pd *pd)
|
||||
{
|
||||
_thread_id = thread_id;
|
||||
_l4_thread_id = l4_thread_id;
|
||||
_platform_pd = pd;
|
||||
}
|
||||
|
||||
|
||||
void Platform_thread::unbind()
|
||||
{
|
||||
l4_umword_t dummy, old_eflags;
|
||||
l4_threadid_t thread = _l4_thread_id;
|
||||
l4_threadid_t pager = thread;
|
||||
l4_threadid_t preempter = L4_INVALID_ID;
|
||||
l4_threadid_t cap_handler = L4_INVALID_ID;
|
||||
|
||||
fiasco_register_thread_name(thread, "<dead>");
|
||||
|
||||
/*
|
||||
* The Fiasco thread is halted by setting itself as pager and forcing
|
||||
* pagefault at 0, where Genode never maps a page. The bottom line is the
|
||||
* thread blocks in IPC to itself.
|
||||
*/
|
||||
l4_inter_task_ex_regs(thread, 0, 0,
|
||||
&preempter, &pager, &cap_handler,
|
||||
&old_eflags, &dummy, &dummy,
|
||||
0, l4_utcb_get());
|
||||
if (old_eflags == ~0UL)
|
||||
PWRN("old eflags == ~0 on ex_regs %x.%x", (int)thread.id.task, (int)thread.id.lthread);
|
||||
|
||||
_thread_id = THREAD_INVALID;
|
||||
_l4_thread_id = L4_INVALID_ID;
|
||||
_platform_pd = 0;
|
||||
}
|
||||
|
||||
|
||||
void Platform_thread::state(Thread_state s)
|
||||
{
|
||||
PDBG("Not implemented");
|
||||
throw Cpu_session::State_access_failed();
|
||||
}
|
||||
|
||||
|
||||
Thread_state Platform_thread::state()
|
||||
{
|
||||
Thread_state s;
|
||||
|
||||
l4_umword_t old_eflags, ip, sp;
|
||||
l4_threadid_t thread = _l4_thread_id;
|
||||
l4_threadid_t pager = L4_INVALID_ID;
|
||||
l4_threadid_t preempter = L4_INVALID_ID;
|
||||
l4_threadid_t cap_handler = L4_INVALID_ID;
|
||||
|
||||
l4_inter_task_ex_regs(thread, ~0UL, ~0UL,
|
||||
&preempter, &pager, &cap_handler,
|
||||
&old_eflags, &ip, &sp,
|
||||
L4_THREAD_EX_REGS_NO_CANCEL, l4_utcb_get());
|
||||
if (old_eflags == ~0UL)
|
||||
PWRN("old eflags == ~0 on ex_regs %x.%x", (int)thread.id.task, (int)thread.id.lthread);
|
||||
|
||||
/* fill thread state structure */
|
||||
s.ip = ip;
|
||||
s.sp = sp;
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
void Platform_thread::cancel_blocking()
|
||||
{
|
||||
l4_umword_t dummy;
|
||||
l4_threadid_t invalid = L4_INVALID_ID;
|
||||
|
||||
l4_inter_task_ex_regs(_l4_thread_id, ~0UL, ~0UL,
|
||||
&invalid, &invalid, &invalid,
|
||||
&dummy, &dummy, &dummy, 0, l4_utcb_get());
|
||||
}
|
||||
|
||||
|
||||
Weak_ptr<Address_space> Platform_thread::address_space()
|
||||
{
|
||||
return _platform_pd->Address_space::weak_ptr();
|
||||
}
|
||||
|
||||
|
||||
Platform_thread::Platform_thread(const char *name, unsigned, addr_t, int thread_id)
|
||||
: _thread_id(thread_id), _l4_thread_id(L4_INVALID_ID), _pager(0)
|
||||
{
|
||||
strncpy(_name, name, sizeof(_name));
|
||||
}
|
||||
|
||||
|
||||
Platform_thread::~Platform_thread()
|
||||
{
|
||||
/*
|
||||
* We inform our protection domain about thread destruction, which will end up in
|
||||
* Thread::unbind()
|
||||
*/
|
||||
if (_platform_pd)
|
||||
_platform_pd->unbind_thread(this);
|
||||
}
|
||||
27
repos/base-fiasco/src/core/ram_session_support.cc
Normal file
27
repos/base-fiasco/src/core/ram_session_support.cc
Normal file
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* \brief Export RAM dataspace as shared memory object (dummy)
|
||||
* \author Norman Feske
|
||||
* \date 2006-07-03
|
||||
*
|
||||
* On L4, each dataspace _is_ a shared memory object.
|
||||
* Therefore, these functions are empty.
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "ram_session_component.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)
|
||||
{
|
||||
memset((void *)ds->phys_addr(), 0, ds->size());
|
||||
}
|
||||
48
repos/base-fiasco/src/core/rm_session_support.cc
Normal file
48
repos/base-fiasco/src/core/rm_session_support.cc
Normal file
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* \brief Fiasco-specific part of RM-session implementation
|
||||
* \author Norman Feske
|
||||
* \date 2009-04-10
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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>
|
||||
|
||||
/* Fiasco includes */
|
||||
namespace Fiasco {
|
||||
#include <l4/sys/syscalls.h>
|
||||
#include <l4/sys/types.h>
|
||||
}
|
||||
|
||||
using namespace Genode;
|
||||
|
||||
static const bool verbose_unmap = false;
|
||||
|
||||
|
||||
void Rm_client::unmap(addr_t core_local_base, addr_t virt_base, size_t size)
|
||||
{
|
||||
/*
|
||||
* Fiasco's 'unmap' syscall unmaps the specified flexpage from all address
|
||||
* spaces to which we mapped the pages. We cannot target this operation to
|
||||
* a specific L4 task. Hence, we unmap the dataspace from all tasks, not
|
||||
* only for this RM client.
|
||||
*/
|
||||
if (verbose_unmap) {
|
||||
Fiasco::l4_threadid_t tid; tid.raw = badge();
|
||||
printf("RM client %p (%x.%x) unmap core-local [%lx,%lx)\n",
|
||||
this, tid.id.task, tid.id.lthread, core_local_base, core_local_base + size);
|
||||
}
|
||||
|
||||
using namespace Fiasco;
|
||||
|
||||
addr_t addr = core_local_base;
|
||||
for (; addr < core_local_base + size; addr += L4_PAGESIZE)
|
||||
l4_fpage_unmap(l4_fpage(addr, L4_LOG2_PAGESIZE, 0, 0),
|
||||
L4_FP_FLUSH_PAGE);
|
||||
}
|
||||
57
repos/base-fiasco/src/core/target.inc
Normal file
57
repos/base-fiasco/src/core/target.inc
Normal file
@@ -0,0 +1,57 @@
|
||||
TARGET = core
|
||||
|
||||
GEN_CORE_DIR = $(BASE_DIR)/src/core
|
||||
|
||||
SRC_CC += main.cc \
|
||||
multiboot_info.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 \
|
||||
io_port_session_component.cc \
|
||||
irq_session_component.cc \
|
||||
signal_session_component.cc \
|
||||
signal_source_component.cc \
|
||||
trace_session_component.cc \
|
||||
dump_alloc.cc \
|
||||
context_area.cc \
|
||||
core_printf.cc
|
||||
|
||||
INC_DIR += $(REP_DIR)/src/core/include \
|
||||
$(GEN_CORE_DIR)/include \
|
||||
$(REP_DIR)/src/base/console \
|
||||
$(BASE_DIR)/src/base/thread
|
||||
|
||||
LIBS += base-common
|
||||
|
||||
include $(GEN_CORE_DIR)/version.inc
|
||||
|
||||
vpath main.cc $(GEN_CORE_DIR)
|
||||
vpath multiboot_info.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 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 dump_alloc.cc $(GEN_CORE_DIR)
|
||||
vpath context_area.cc $(GEN_CORE_DIR)
|
||||
vpath core_printf.cc $(BASE_DIR)/src/base/console
|
||||
vpath %.cc $(REP_DIR)/src/core
|
||||
60
repos/base-fiasco/src/core/thread_start.cc
Normal file
60
repos/base-fiasco/src/core/thread_start.cc
Normal file
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* \brief Implementation of Thread API interface on top of Platform_thread
|
||||
* \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.
|
||||
*/
|
||||
|
||||
/* Genode includes */
|
||||
#include <base/thread.h>
|
||||
#include <base/sleep.h>
|
||||
|
||||
/* core includes */
|
||||
#include <platform.h>
|
||||
#include <core_env.h>
|
||||
|
||||
using namespace Genode;
|
||||
|
||||
|
||||
void Thread_base::_thread_start()
|
||||
{
|
||||
Thread_base::myself()->_thread_bootstrap();
|
||||
Thread_base::myself()->entry();
|
||||
Thread_base::myself()->_join_lock.unlock();
|
||||
sleep_forever();
|
||||
}
|
||||
|
||||
|
||||
void Thread_base::start()
|
||||
{
|
||||
/* create and start platform thread */
|
||||
_tid.pt = new(platform()->core_mem_alloc()) Platform_thread(_context->name);
|
||||
|
||||
platform_specific()->core_pd()->bind_thread(_tid.pt);
|
||||
|
||||
_tid.pt->pager(platform_specific()->core_pager());
|
||||
_tid.l4id = _tid.pt->native_thread_id();
|
||||
|
||||
_tid.pt->start((void *)_thread_start, stack_top());
|
||||
}
|
||||
|
||||
|
||||
void Thread_base::cancel_blocking()
|
||||
{
|
||||
/*
|
||||
* Within core, we never need to unblock threads
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
void Thread_base::_deinit_platform_thread()
|
||||
{
|
||||
/* destruct platform thread */
|
||||
destroy(platform()->core_mem_alloc(), _tid.pt);
|
||||
}
|
||||
52
repos/base-fiasco/src/core/x86/platform_x86.cc
Normal file
52
repos/base-fiasco/src/core/x86/platform_x86.cc
Normal file
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* \brief Platform support specific to x86
|
||||
* \author Christian Helmuth
|
||||
* \date 2006-04-11
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <fiasco/thread_helper.h>
|
||||
|
||||
#include "platform.h"
|
||||
#include "util.h"
|
||||
|
||||
namespace Fiasco {
|
||||
#include <l4/sys/ipc.h>
|
||||
}
|
||||
|
||||
using namespace Genode;
|
||||
using namespace Fiasco;
|
||||
|
||||
void Platform::_setup_io_port_alloc()
|
||||
{
|
||||
l4_fpage_t fp;
|
||||
l4_umword_t dummy;
|
||||
l4_msgdope_t result;
|
||||
l4_msgtag_t tag;
|
||||
|
||||
/* get all I/O ports at once */
|
||||
int error = l4_ipc_call_tag(Fiasco::sigma0_threadid,
|
||||
L4_IPC_SHORT_MSG,
|
||||
l4_iofpage(0, L4_WHOLE_IOADDRESS_SPACE, 0).fpage, 0,
|
||||
l4_msgtag(L4_MSGTAG_IO_PAGE_FAULT, 0, 0, 0),
|
||||
L4_IPC_IOMAPMSG(0, L4_WHOLE_IOADDRESS_SPACE),
|
||||
&dummy, &fp.fpage,
|
||||
L4_IPC_NEVER, &result, &tag);
|
||||
|
||||
if (error ||
|
||||
!(l4_ipc_fpage_received(result) /* got something */
|
||||
&& fp.iofp.f == 0xf /* got IO ports */
|
||||
&& fp.iofp.iosize == L4_WHOLE_IOADDRESS_SPACE
|
||||
&& fp.iofp.iopage == 0)) /* got whole IO space */
|
||||
|
||||
panic("Received no I/O ports from sigma0");
|
||||
|
||||
/* setup allocator */
|
||||
_io_port_alloc.add_range(0, 0x10000);
|
||||
}
|
||||
8
repos/base-fiasco/src/core/x86/target.mk
Normal file
8
repos/base-fiasco/src/core/x86/target.mk
Normal file
@@ -0,0 +1,8 @@
|
||||
include $(PRG_DIR)/../target.inc
|
||||
|
||||
REQUIRES += x86
|
||||
SRC_CC += platform_x86.cc
|
||||
|
||||
vpath io_port_session_component.cc $(GEN_CORE_DIR)/x86
|
||||
vpath platform_services.cc $(GEN_CORE_DIR)/x86
|
||||
|
||||
23
repos/base-fiasco/src/kernel/target.inc
Normal file
23
repos/base-fiasco/src/kernel/target.inc
Normal file
@@ -0,0 +1,23 @@
|
||||
TARGET = fiasco
|
||||
REQUIRES += fiasco
|
||||
FIASCO_BUILD_DIR = $(BUILD_BASE_DIR)/kernel/$(TARGET)
|
||||
FIASCO = $(FIASCO_BUILD_DIR)/fiasco
|
||||
FIASCO_SRC = $(REP_DIR)/contrib/fiasco/snapshot/kernel/fiasco
|
||||
STARTUP_LIB =
|
||||
|
||||
$(TARGET): $(FIASCO)
|
||||
|
||||
$(FIASCO_BUILD_DIR):
|
||||
$(VERBOSE_MK) MAKEFLAGS= $(MAKE) SYSTEM_TARGET="$(CROSS_DEV_PREFIX)" \
|
||||
$(VERBOSE_DIR) -C $(FIASCO_SRC) BUILDDIR=$@
|
||||
$(VERBOSE)cp $(KERNEL_CONFIG) $@/globalconfig.out
|
||||
$(VERBOSE_MK) MAKEFLAGS= $(MAKE) SYSTEM_TARGET="$(CROSS_DEV_PREFIX)" \
|
||||
$(VERBOSE_DIR) -C $@ oldconfig
|
||||
|
||||
$(FIASCO): $(FIASCO_BUILD_DIR)
|
||||
$(VERBOSE_MK) MAKEFLAGS= $(MAKE) SYSTEM_TARGET="$(CROSS_DEV_PREFIX)" \
|
||||
$(VERBOSE_DIR) -C $(FIASCO_BUILD_DIR)
|
||||
$(VERBOSE)ln -sf $@ $(BUILD_BASE_DIR)/bin/$(TARGET)
|
||||
|
||||
clean cleanall:
|
||||
$(VERBOSE)rm -rf $(FIASCO_BUILD_DIR)
|
||||
4
repos/base-fiasco/src/kernel/x86/target.mk
Normal file
4
repos/base-fiasco/src/kernel/x86/target.mk
Normal file
@@ -0,0 +1,4 @@
|
||||
REQUIRES = x86 32bit
|
||||
KERNEL_CONFIG = $(REP_DIR)/config/kernel-config.x86
|
||||
|
||||
-include $(PRG_DIR)/../target.inc
|
||||
5
repos/base-fiasco/src/sigma0/target.mk
Normal file
5
repos/base-fiasco/src/sigma0/target.mk
Normal file
@@ -0,0 +1,5 @@
|
||||
TARGET = sigma0
|
||||
PKGS = sigma0/server
|
||||
LIBS = l4v2_support
|
||||
|
||||
include $(REP_DIR)/mk/l4_pkg.mk
|
||||
Reference in New Issue
Block a user