base-mb: Fix compile and link errors

Fix #531
This commit is contained in:
Martin Stein 2012-11-28 11:33:19 +01:00 committed by Norman Feske
parent 1258126986
commit ab0296bd20
18 changed files with 334 additions and 723 deletions

View File

@ -46,16 +46,22 @@ namespace Genode {
struct Native_config
{
enum {
CONTEXT_AREA_VIRTUAL_BASE = 0x40000000,
CONTEXT_AREA_VIRTUAL_SIZE = 0x10000000,
CONTEXT_VIRTUAL_SIZE = 0x00100000,
};
/**
* Thread-context area configuration.
*/
static addr_t context_area_virtual_base() { return 0x40000000UL; }
static addr_t context_area_virtual_size() { return 0x10000000UL; }
static addr_t context_area_virtual_base() { return CONTEXT_AREA_VIRTUAL_BASE; }
static addr_t context_area_virtual_size() { return CONTEXT_AREA_VIRTUAL_SIZE; }
/**
* Size of virtual address region holding the context of one thread
*/
static addr_t context_virtual_size() { return 0x00100000UL; }
static addr_t context_virtual_size() { return CONTEXT_VIRTUAL_SIZE; }
};
struct Native_pd_args { };

View File

@ -0,0 +1,36 @@
/*
* \brief CPU state
* \author Martin Stein
* \date 2012-11-26
*/
/*
* Copyright (C) 2012 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 _BASE_MB__INCLUDE__CPU__CPU_STATE_H_
#define _BASE_MB__INCLUDE__CPU__CPU_STATE_H_
/* Genode includes */
#include <base/stdint.h>
namespace Genode {
/**
* Basic CPU state
*/
struct Cpu_state
{
/**
* Registers
*/
addr_t sp; /* stack pointer */
addr_t ip; /* instruction pointer */
};
}
#endif /* _BASE_MB__INCLUDE__CPU__CPU_STATE_H_ */

View File

@ -0,0 +1,54 @@
/*
* \brief Cpu specifi memcpy
* \author Martin Stein
* \date 2012-11-27
*/
/*
* Copyright (C) 2012 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 _BASE_MB__INCLUDE__CPU__STRING_H_
#define _BASE_MB__INCLUDE__CPU__STRING_H_
#include <base/stdint.h>
namespace Genode
{
/**
* Copy memory block
*
* \param dst destination memory block
* \param src source memory block
* \param size number of bytes to copy
*
* \return Number of bytes not copied
*/
inline size_t memcpy_cpu(void *dst, const void *src, size_t size)
{
unsigned char *d = (unsigned char *)dst, *s = (unsigned char *)src;
/* check 4 byte; alignment */
size_t d_align = (size_t)d & 0x3;
size_t s_align = (size_t)s & 0x3;
/* at least 32 bytes, 4 byte aligned, same alignment */
if (size < 32 || (d_align ^ s_align))
return size;
/* copy to 4 byte alignment */
for (size_t i = 0; i < s_align; i++, *d++ = *s++, size--);
/* copy words */
uint32_t * dw = (uint32_t *)d;
uint32_t * sw = (uint32_t *)s;
for (; size >= 4; size -= 4, dw++, sw++) *dw = *sw;
return size;
}
}
#endif /* _BASE_MB__INCLUDE__CPU__STRING_H_ */

View File

@ -31,6 +31,8 @@ namespace Genode {
Ram_session *env_context_area_ram_session();
}
static addr_t context_virtual_base_mask() {
return ~(Native_config::context_virtual_size() - 1); }
/******************************
** Thread-context allocator **
@ -45,7 +47,7 @@ Thread_base::Context *Thread_base::Context_allocator::base_to_context(addr_t bas
addr_t Thread_base::Context_allocator::addr_to_base(void *addr)
{
return ((addr_t)addr) & CONTEXT_VIRTUAL_BASE_MASK;
return ((addr_t)addr) & context_virtual_base_mask();
}
@ -205,3 +207,9 @@ Thread_base::~Thread_base()
_deinit_platform_thread();
_free_context();
}
void Thread_base::join()
{
_join_lock.lock();
}

View File

@ -49,7 +49,7 @@ class Context_area_rm_session : public Rm_session
*/
Local_addr attach(Dataspace_capability ds_cap,
size_t size, off_t offset,
bool use_local_addr, Local_addr local_addr)
bool use_local_addr, Local_addr local_addr, bool)
{
Dataspace_component *ds = context_ds[ds_cap.local_name()];
if (!ds) {
@ -105,7 +105,7 @@ class Context_area_ram_session : public Ram_session
}
context_ds[i] = new (platform()->core_mem_alloc())
Dataspace_component(size, 0, (addr_t)phys_base, false, true);
Dataspace_component(size, 0, (addr_t)phys_base, false, true, 0);
/*
* We do not manage the dataspace via an entrypoint because it will

View File

@ -0,0 +1,27 @@
/*
* \brief Platform specific parts of CPU session
* \author Martin Stein
* \date 2012-11-27
*/
/*
* Copyright (C) 2012 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 <dataspace/capability.h>
/* core includes */
#include <cpu_session_component.h>
using namespace Genode;
Ram_dataspace_capability Cpu_session_component::utcb(Thread_capability) {
PDBG("Not implemented");
return Ram_dataspace_capability();
};

View File

@ -56,17 +56,20 @@ namespace Genode {
addr_t context_offset_mask() {
return ~context_base_mask();
}
addr_t max_context_id {
return context_area_size()/context_size()-1;
}
enum {
CONTEXT_SIZE = Native_config::CONTEXT_VIRTUAL_SIZE,
CONTEXT_AREA_SIZE = Native_config::CONTEXT_AREA_VIRTUAL_SIZE,
MAX_CONTEXT_ID = CONTEXT_AREA_SIZE / CONTEXT_SIZE - 1
};
Native_process_id _pid;
Native_thread_id owner_tid_by_context_id[max_context_id()+1];
Native_thread_id owner_tid_by_context_id[MAX_CONTEXT_ID + 1];
void _free_context(Native_thread_id const & t)
{
for (Context_id cid = 0; cid <= max_context_id(); cid++) {
for (Context_id cid = 0; cid <= MAX_CONTEXT_ID; cid++) {
if (owner_tid_by_context_id[cid] == t) {
owner_tid_by_context_id[cid] = 0;
}
@ -83,7 +86,7 @@ namespace Genode {
{
static bool const verbose = false;
if ((unsigned)User::MAX_THREAD_ID>(unsigned)max_context_id()) {
if ((unsigned)User::MAX_THREAD_ID>(unsigned)MAX_CONTEXT_ID) {
PERR("More threads allowed than context areas available");
return;
}
@ -125,7 +128,7 @@ namespace Genode {
Context *context_by_tid(Native_thread_id tid)
{
for (unsigned cid = 0; cid <= max_context_id(); cid++)
for (unsigned cid = 0; cid <= MAX_CONTEXT_ID; cid++)
if (owner_tid_by_context_id[cid] == tid)
return context(cid);
@ -139,7 +142,7 @@ namespace Genode {
if (!cid_if_context_address(a, &cid))
return false;
if (cid > max_context_id()) {
if (cid > MAX_CONTEXT_ID) {
PERR("Context ID %i out of range", (unsigned int)cid);
return false;
}
@ -152,7 +155,7 @@ namespace Genode {
return false;
}
addr_t offset = a & CONTEXT_OFFSET_MASK;
addr_t offset = a & context_offset_mask();
Context *context = (Context *)(context_size() - sizeof(Context));
if ((void*)offset >= &context->utcb) {
@ -171,7 +174,7 @@ namespace Genode {
{
static bool const verbose = false;
if (cid > max_context_id())
if (cid > MAX_CONTEXT_ID)
return 0;
if (owner_tid_by_context_id[cid]){
@ -193,21 +196,21 @@ namespace Genode {
* First thread is assumed to be the main thread and gets last
* context-area by convention
*/
if (!owner_tid_by_context_id[max_context_id()]){
owner_tid_by_context_id[max_context_id()] = tid;
if (!owner_tid_by_context_id[MAX_CONTEXT_ID]){
owner_tid_by_context_id[MAX_CONTEXT_ID] = tid;
if (verbose)
PDBG("Thread %i owns Context %i (0x%p) of Protection Domain %i",
tid, max_context_id(), context(max_context_id()), _pid);
tid, MAX_CONTEXT_ID, context(MAX_CONTEXT_ID), _pid);
return context(max_context_id());
return context(MAX_CONTEXT_ID);
}
for (unsigned i = 0; i <= max_context_id() - 1; i++) {
for (unsigned i = 0; i <= MAX_CONTEXT_ID - 1; i++) {
if (!owner_tid_by_context_id[i]) {
owner_tid_by_context_id[i] = tid;
if (verbose)
PDBG("Thread %i owns Context %i (0x%p) of Protection Domain %i",
tid, max_context_id(), context(max_context_id()), _pid);
tid, MAX_CONTEXT_ID, context(MAX_CONTEXT_ID), _pid);
return context(i);
}
}
@ -247,7 +250,7 @@ namespace Genode {
*/
void free_context(Context_id const & c)
{
if (c > max_context_id()) { return; }
if (c > MAX_CONTEXT_ID) { return; }
owner_tid_by_context_id[c] = Kernel::INVALID_THREAD_ID;
}

View File

@ -17,6 +17,7 @@ SRC_CC = \
platform.cc \
platform_services.cc \
platform_thread.cc \
cpu_session_support.cc \
ram_session_component.cc \
ram_session_support.cc \
rm_session_component.cc \

View File

@ -11,8 +11,6 @@
* under the terms of the GNU General Public License version 2.
*/
.include "linker_commands.s"
.global _atomic_cmpxchg
@ -24,7 +22,10 @@
* it is bothsides aligned - so that no common functions could gain
* interruptsave status because it were linked inside this page too
*/
_BEGIN_ATOMIC_OPS
.section ".Atomic_ops"
.global _atomic_ops_begin
.align 12
_atomic_ops_begin:
/**
* Atomic compare and exchange, see cmpxchg
@ -86,7 +87,7 @@ _atomic_syscall_yield:
addik r1, r1, +2*4
bri _atomic_cmpxchg_yield_return
_END_ATOMIC_OPS
.global _atomic_ops_end
.align 12
_atomic_ops_end:

View File

@ -4,9 +4,6 @@
* \date 21.06.2010
*/
.include "linker_commands.s"
.include "errors.s"
.extern _main
.global _main_utcb_addr
@ -22,7 +19,10 @@
.endm
_BEGIN_ELF_ENTRY_CODE
/* _BEGIN_ELF_ENTRY_CODE */
.global _start
.section ".Elf_entry"
_start:
_INIT_MAIN_UTCB
_INIT_MAIN_STACK
@ -30,10 +30,12 @@ _BEGIN_ELF_ENTRY_CODE
bralid r15, _main
or r0, r0, r0
_ERROR_NOTHING_LEFT_TO_CALL_BY_CRT0
/* _ERROR_NOTHING_LEFT_TO_CALL_BY_CRT0 */
brai 0x99000001
_BEGIN_READABLE_WRITEABLE
/* _BEGIN_READABLE_WRITEABLE */
.section ".bss"
.align 4
_main_utcb_addr: .space 1*4

View File

@ -11,10 +11,6 @@
* under the terms of the GNU General Public License version 2.
*/
/* platform includes */
.include "errors.s"
.include "linker_commands.s"
/*
* To be compatible to crt0.s for common programs,
* the following labels are used for roottasks main-thread
@ -73,15 +69,20 @@
/* linker links this section to kernelbase + offset 0 */
_BEGIN_ELF_ENTRY_CODE
/* _BEGIN_ELF_ENTRY_CODE */
.global _start
.section ".Elf_entry"
_start:
_CALL_KERNEL__USES_R15
_CALL_AFTER_KERNEL__USES_R3_R15
_ERROR_NOTHING_LEFT_TO_CALL_BY_CRT0
/* ERROR_NOTHING_LEFT_TO_CALL_BY_CRT0 */
brai 0x99000001
_BEGIN_READABLE_WRITEABLE
/* _BEGIN_READABLE_WRITEABLE */
.section ".bss"
.align 4
_main_utcb_addr: .space 4*1

View File

@ -1,23 +0,0 @@
/*
* \brief Assembler Errors
* \author Martin Stein
* \date 2010-10-06
*
* Grouped into one include file for better management and identification
*/
/*
* Copyright (C) 2010-2012 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.
*/
.macro _ERROR_NOTHING_LEFT_TO_CALL_BY_CRT0
brai 0x99000001
.endm
.macro _ERROR_UNKNOWN_USERLAND_BLOCKING_TYPE
brai 0x99000003
.endm

View File

@ -1,527 +0,0 @@
/*
* \brief Access to execution context internals
* \author Martin Stein
* \date 2010-10-06
*/
/*
* Copyright (C) 2010-2012 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.
*/
/**********************************************************
** Overwrite specific parts of the execution context **
** **
** \param r15 base address of the execution context **
** \param (rx) value that shall be written - except **
** r1, rpc and r15 - the register itself, **
** otherwise use "prestore" labels or r3 **
**********************************************************/
.macro _SAVE_R2_TO_R13_TO_CONTEXT__USES_R2_TO_R13_R15
swi r2, r15, 2*4
swi r3, r15, 3*4
swi r4, r15, 4*4
swi r5, r15, 5*4
swi r6, r15, 6*4
swi r7, r15, 7*4
swi r8, r15, 8*4
swi r9, r15, 9*4
swi r10, r15, 10*4
swi r11, r15, 11*4
swi r12, r15, 12*4
swi r13, r15, 13*4
.endm
.macro _SAVE_R18_TO_R31_TO_CONTEXT__TO_R15_R18_TO_R31
swi r18, r15, 18*4
swi r19, r15, 19*4
swi r20, r15, 20*4
swi r21, r15, 21*4
swi r22, r15, 22*4
swi r23, r15, 23*4
swi r24, r15, 24*4
swi r25, r15, 25*4
swi r26, r15, 26*4
swi r27, r15, 27*4
swi r28, r15, 28*4
swi r29, r15, 29*4
swi r30, r15, 30*4
swi r31, r15, 31*4
.endm
.macro _SAVE_PRESTORED_R1_R15_RPC_TO_CONTEXT__USES_R3_R15
lwi r3, r0, _prestored_r1
swi r3, r15, 1*4
lwi r3, r0, _prestored_r15
swi r3, r15, 15*4
lwi r3, r0, _prestored_rpc
swi r3, r15, 32*4
.endm
.macro _SAVE_RMSR_TO_CONTEXT__USES_R3_R15
mfs r3, rmsr
swi r3, r15, 33*4
.endm
.macro _SAVE_RPID_TO_CONTEXT__USES_R3_R15
mfs r3, rpid
swi r3, r15, 36*4
.endm
.macro _SAVE_BLOCKING_TYPE_TO_CONTEXT__USES_R3_R15
swi r3, r15, 37*4
.endm
.macro _SAVE_RESR_TO_CONTEXT__USES_R3_R15
mfs r3, resr
swi r3, r15, 35*4
.endm
.macro _SAVE_REAR_TO_CONTEXT__USES_R3_R15
mfs r3, rear
swi r3, r15, 34*4
.endm
/***********************************************************
** Load a specifics values from the execution context **
** **
** \param r15 base address of the execution context **
** \return (rx) value that has been loaded - except **
** r1, rpc and r15 - the register itself, **
** otherwise use "preload" labels or r3 **
***********************************************************/
.macro _LOAD_R2_TO_R13_FROM_CONTEXT__USES_R2_TO_R13_R15
lwi r2, r15, 2*4
lwi r3, r15, 3*4
lwi r4, r15, 4*4
lwi r5, r15, 5*4
lwi r6, r15, 6*4
lwi r7, r15, 7*4
lwi r8, r15, 8*4
lwi r9, r15, 9*4
lwi r10, r15, 10*4
lwi r11, r15, 11*4
lwi r12, r15, 12*4
lwi r13, r15, 13*4
.endm
.macro _LOAD_R18_TO_R31_FROM_CONTEXT__TO_R15_R18_TO_R31
lwi r18, r15, 18*4
lwi r19, r15, 19*4
lwi r20, r15, 20*4
lwi r21, r15, 21*4
lwi r22, r15, 22*4
lwi r23, r15, 23*4
lwi r24, r15, 24*4
lwi r25, r15, 25*4
lwi r26, r15, 26*4
lwi r27, r15, 27*4
lwi r28, r15, 28*4
lwi r29, r15, 29*4
lwi r30, r15, 30*4
lwi r31, r15, 31*4
.endm
.macro _PRELOAD_R1_R15_RPC_FROM_CONTEXT__USES_R3_R15
lwi r3, r15, 1*4
swi r3, r0, _preloaded_r1
lwi r3, r15, 15*4
swi r3, r0, _preloaded_r15
lwi r3, r15, 32*4
swi r3, r0, _preloaded_rpc
.endm
.macro _LOAD_RMSR_FROM_CONTEXT__USES_R3_R4_R15
lwi r3, r15, 33*4
mts rmsr, r3
_SYNCHRONIZING_OP
.endm
.macro _LOAD_RPID_FROM_CONTEXT__USES_R3_R15
lwi r3, r15, 36*4
mts rpid, r3
_SYNCHRONIZING_OP
.endm
.macro _LOAD_BLOCKING_TYPE_FROM_CONTEXT__USES_R3_R15
lwi r3, r15, 37*4
.endm
.macro _VARIABLES_TO_WRITE_EXEC_CONTEXT
.align 4
_prestored_r1: .space 4
.align 4
_prestored_r15: .space 4
.align 4
_prestored_rpc: .space 4
.endm
.macro _VARIABLES_TO_READ_EXEC_CONTEXT
.align 4
_preloaded_r1: .space 4
.align 4
_preloaded_r15: .space 4
.align 4
_preloaded_rpc: .space 4
.endm
/**
* Macros to print out context content
*
* (any value hexadecimal and padded with
* leading zeros to 8 digits)
* output has following format:
*
* r1 r2 r3 r4
* ...
* ...
* r28 r29 r30 r31
* rmsr
*
*/
.macro _4BIT_SHIFT_RIGHT__ARG_30__RET_30
srl r30, r30
srl r30, r30
srl r30, r30
srl r30, r30
.endm
.macro _PRINT_ASCII8__ARG_30
swi r30, r0, 0x84000004
.endm
.macro _PRINT_HEX8__ARG_30
swi r29, r0, _print_hex8__buffer_0
andi r30, r30, 0xf
rsubi r29, r30, 9
addi r30, r30, 48
bgei r29, 8
addi r30, r30, 39
_PRINT_ASCII8__ARG_30
lwi r29, r0, _print_hex8__buffer_0
.endm
.macro _PRINT_HEX32__ARG_31
swi r31, r0, _print_hex32__buffer_1
swi r30, r0, _print_hex32__buffer_0
lwi r31, r0, _print_hex32__buffer_1-3
add r30, r31, r0
_4BIT_SHIFT_RIGHT__ARG_30__RET_30
_PRINT_HEX8__ARG_30
add r30, r31, r0
_PRINT_HEX8__ARG_30
lwi r31, r0, _print_hex32__buffer_1-2
add r30, r31, r0
_4BIT_SHIFT_RIGHT__ARG_30__RET_30
_PRINT_HEX8__ARG_30
add r30, r31, r0
_PRINT_HEX8__ARG_30
lwi r31, r0, _print_hex32__buffer_1-1
add r30, r31, r0
_4BIT_SHIFT_RIGHT__ARG_30__RET_30
_PRINT_HEX8__ARG_30
add r30, r31, r0
_PRINT_HEX8__ARG_30
lwi r31, r0, _print_hex32__buffer_1-0
add r30, r31, r0
_4BIT_SHIFT_RIGHT__ARG_30__RET_30
_PRINT_HEX8__ARG_30
add r30, r31, r0
_PRINT_HEX8__ARG_30
lwi r31, r0, _print_hex32__buffer_1
lwi r30, r0, _print_hex32__buffer_0
.endm
.macro _PRINT_ASCII_SPACE
swi r30, r0, _print_ascii_space__buffer_0
addi r30, r0, 32
_PRINT_ASCII8__ARG_30
lwi r30, r0, _print_ascii_space__buffer_0
.endm
.macro _PRINT_ASCII_BREAK
swi r30, r0, _print_ascii_break__buffer_0
addi r30, r0, 13
_PRINT_ASCII8__ARG_30
addi r30, r0, 10
_PRINT_ASCII8__ARG_30
lwi r30, r0, _print_ascii_break__buffer_0
.endm
.macro _PRINT_ASCII_STOP
swi r30, r0, _print_ascii_stop__buffer_0
addi r30, r0, 115
_PRINT_ASCII8__ARG_30
addi r30, r0, 116
_PRINT_ASCII8__ARG_30
addi r30, r0, 111
_PRINT_ASCII8__ARG_30
addi r30, r0, 112
_PRINT_ASCII8__ARG_30
_PRINT_ASCII_BREAK
lwi r30, r0, _print_ascii_stop__buffer_0
.endm
.macro _PRINT_ASCII_RUN
swi r30, r0, _print_ascii_run__buffer_0
addi r30, r0, 114
_PRINT_ASCII8__ARG_30
addi r30, r0, 117
_PRINT_ASCII8__ARG_30
addi r30, r0, 110
_PRINT_ASCII8__ARG_30
_PRINT_ASCII_BREAK
lwi r30, r0, _print_ascii_run__buffer_0
.endm
.macro _PRINT_CONTEXT
swi r31, r0, _print_context__buffer_0
_PRINT_ASCII_BREAK
add r31, r0, r0
_PRINT_HEX32__ARG_31
_PRINT_ASCII_SPACE
add r31, r0, r1
_PRINT_HEX32__ARG_31
_PRINT_ASCII_SPACE
add r31, r0, r2
_PRINT_HEX32__ARG_31
_PRINT_ASCII_SPACE
add r31, r0, r3
_PRINT_HEX32__ARG_31
_PRINT_ASCII_SPACE
add r31, r0, r4
_PRINT_HEX32__ARG_31
_PRINT_ASCII_SPACE
add r31, r0, r5
_PRINT_HEX32__ARG_31
_PRINT_ASCII_SPACE
add r31, r0, r6
_PRINT_HEX32__ARG_31
_PRINT_ASCII_SPACE
add r31, r0, r7
_PRINT_HEX32__ARG_31
_PRINT_ASCII_BREAK
add r31, r0, r8
_PRINT_HEX32__ARG_31
_PRINT_ASCII_SPACE
add r31, r0, r9
_PRINT_HEX32__ARG_31
_PRINT_ASCII_SPACE
add r31, r0, r10
_PRINT_HEX32__ARG_31
_PRINT_ASCII_SPACE
add r31, r0, r11
_PRINT_HEX32__ARG_31
_PRINT_ASCII_SPACE
add r31, r0, r12
_PRINT_HEX32__ARG_31
_PRINT_ASCII_SPACE
add r31, r0, r13
_PRINT_HEX32__ARG_31
_PRINT_ASCII_SPACE
add r31, r0, r14
_PRINT_HEX32__ARG_31
_PRINT_ASCII_SPACE
add r31, r0, r15
_PRINT_HEX32__ARG_31
_PRINT_ASCII_BREAK
add r31, r0, r16
_PRINT_HEX32__ARG_31
_PRINT_ASCII_SPACE
add r31, r0, r17
_PRINT_HEX32__ARG_31
_PRINT_ASCII_SPACE
add r31, r0, r18
_PRINT_HEX32__ARG_31
_PRINT_ASCII_SPACE
add r31, r0, r19
_PRINT_HEX32__ARG_31
_PRINT_ASCII_SPACE
add r31, r0, r20
_PRINT_HEX32__ARG_31
_PRINT_ASCII_SPACE
add r31, r0, r21
_PRINT_HEX32__ARG_31
_PRINT_ASCII_SPACE
add r31, r0, r22
_PRINT_HEX32__ARG_31
_PRINT_ASCII_SPACE
add r31, r0, r23
_PRINT_HEX32__ARG_31
_PRINT_ASCII_BREAK
add r31, r0, r24
_PRINT_HEX32__ARG_31
_PRINT_ASCII_SPACE
add r31, r0, r25
_PRINT_HEX32__ARG_31
_PRINT_ASCII_SPACE
add r31, r0, r26
_PRINT_HEX32__ARG_31
_PRINT_ASCII_SPACE
add r31, r0, r27
_PRINT_HEX32__ARG_31
_PRINT_ASCII_SPACE
add r31, r0, r28
_PRINT_HEX32__ARG_31
_PRINT_ASCII_SPACE
add r31, r0, r29
_PRINT_HEX32__ARG_31
_PRINT_ASCII_SPACE
add r31, r0, r30
_PRINT_HEX32__ARG_31
_PRINT_ASCII_SPACE
lwi r31, r0, _print_context__buffer_0
_PRINT_HEX32__ARG_31
_PRINT_ASCII_BREAK
mfs r31, rmsr
_PRINT_HEX32__ARG_31
_PRINT_ASCII_SPACE
lwi r31, r0, _current_context_label
_PRINT_HEX32__ARG_31
_PRINT_ASCII_SPACE
lwi r31, r0, _print_context__buffer_0
.endm
.macro _PRINT_ASCII_STOP__VARIABLES
.align 4
_print_ascii_stop__buffer_0: .space 1*4
.endm
.macro _PRINT_ASCII_RUN__VARIABLES
.align 4
_print_ascii_run__buffer_0: .space 1*4
.endm
.macro _PRINT_ASCII_BREAK__VARIABLES
.align 4
_print_ascii_break__buffer_0: .space 1*4
.endm
.macro _PRINT_ASCII_SPACE__VARIABLES
.align 4
_print_ascii_space__buffer_0: .space 1*4
.endm
.macro _PRINT_HEX8__VARIABLES
.align 4
_print_hex8__buffer_0: .space 1*4
.align 4
_print_hex8__buffer_1: .space 1*4
.endm
.macro _PRINT_HEX32__VARIABLES
.align 4
_print_hex32__buffer_0: .space 1*4
.align 4
_print_hex32__buffer_1: .space 1*4
.endm
.macro _PRINT_CONTEXT__VARIABLES
.align 4
_print_context__buffer_0: .space 1*4
.endm

View File

@ -1,34 +0,0 @@
.macro _BEGIN_ELF_ENTRY_CODE
.global _start
.section ".Elf_entry"
_start:
.endm
.macro _BEGIN_ATOMIC_OPS
.section ".Atomic_ops"
.global _atomic_ops_begin
.align 12
_atomic_ops_begin:
.endm
.macro _END_ATOMIC_OPS
.global _atomic_ops_end
.align 12
_atomic_ops_end:
.endm
.macro _BEGIN_READABLE_EXECUTABLE
.section ".text"
.endm
.macro _BEGIN_READABLE_WRITEABLE
.section ".bss"
.endm

View File

@ -1,59 +0,0 @@
/**
* Assembler macros for machine status register access
*
* \author Martin Stein
* \date 2010-10-05
*/
/*
* Copyright (C) 2010-2012 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.
*/
.macro _SYNCHRONIZING_OP
bri 4
.endm
.macro _AWAIT_DELAY_OP
or r0, r0, r0
.endm
.macro _ENABLE_EXCEPTIONS
msrset r0, 0x100
_SYNCHRONIZING_OP
.endm
.macro _DISABLE_EXCEPTIONS
msrclr r0, 0x100
_SYNCHRONIZING_OP
.endm
.macro _ENABLE_INTERRUPTS
msrset r0, 0x002
_SYNCHRONIZING_OP
.endm
.macro _DISABLE_INTERRUPTS
msrclr r0, 0x002
_SYNCHRONIZING_OP
.endm
.macro _RELEASE_EXCEPTION
msrclr r0, 0x200
_SYNCHRONIZING_OP
.endm
.macro _RELEASE_BREAK
msrclr r0, 0x008
_SYNCHRONIZING_OP
.endm

View File

@ -14,12 +14,6 @@
*/
.include "special_registers.s"
.include "errors.s"
.include "exec_context.s"
.include "linker_commands.s"
/* We have to know wich userland context was the last that was executed */
.extern _userland_context
@ -83,7 +77,9 @@
.macro _BLOCKING_TYPE_IS_INTERRUPT__USES_R3_R15
addi r3, r0, 1
lwi r15, r0, _userland_context
_SAVE_BLOCKING_TYPE_TO_CONTEXT__USES_R3_R15
/* _SAVE_BLOCKING_TYPE_TO_CONTEXT__USES_R3_R15 */
swi r3, r15, 37*4
.endm
@ -103,7 +99,9 @@
.macro _BLOCKING_TYPE_IS_EXCEPTION__USES_R3_R15
addi r3, r0, 2
lwi r15, r0, _userland_context
_SAVE_BLOCKING_TYPE_TO_CONTEXT__USES_R3_R15
/* _SAVE_BLOCKING_TYPE_TO_CONTEXT__USES_R3_R15 */
swi r3, r15, 37*4
.endm
@ -117,22 +115,68 @@
.macro _BLOCKING_TYPE_IS_SYSCALL__USES_R3_R15
addi r3, r0, 3
lwi r15, r0, _userland_context
_SAVE_BLOCKING_TYPE_TO_CONTEXT__USES_R3_R15
/* _SAVE_BLOCKING_TYPE_TO_CONTEXT__USES_R3_R15 */
swi r3, r15, 37*4
.endm
.macro _BACKUP_PRESTORED_CONTEXT__USES_R2_TO_R31
lwi r15, r0, _userland_context
_SAVE_R2_TO_R13_TO_CONTEXT__USES_R2_TO_R13_R15
_SAVE_R18_TO_R31_TO_CONTEXT__TO_R15_R18_TO_R31
/* _SAVE_R2_TO_R13_TO_CONTEXT__USES_R2_TO_R13_R15 */
swi r2, r15, 2*4
swi r3, r15, 3*4
swi r4, r15, 4*4
swi r5, r15, 5*4
swi r6, r15, 6*4
swi r7, r15, 7*4
swi r8, r15, 8*4
swi r9, r15, 9*4
swi r10, r15, 10*4
swi r11, r15, 11*4
swi r12, r15, 12*4
swi r13, r15, 13*4
_SAVE_RPID_TO_CONTEXT__USES_R3_R15
_SAVE_RMSR_TO_CONTEXT__USES_R3_R15
_SAVE_RESR_TO_CONTEXT__USES_R3_R15
_SAVE_REAR_TO_CONTEXT__USES_R3_R15
/* _SAVE_R18_TO_R31_TO_CONTEXT__TO_R15_R18_TO_R31 */
swi r18, r15, 18*4
swi r19, r15, 19*4
swi r20, r15, 20*4
swi r21, r15, 21*4
swi r22, r15, 22*4
swi r23, r15, 23*4
swi r24, r15, 24*4
swi r25, r15, 25*4
swi r26, r15, 26*4
swi r27, r15, 27*4
swi r28, r15, 28*4
swi r29, r15, 29*4
swi r30, r15, 30*4
swi r31, r15, 31*4
_SAVE_PRESTORED_R1_R15_RPC_TO_CONTEXT__USES_R3_R15
/* _SAVE_RPID_TO_CONTEXT__USES_R3_R15 */
mfs r3, rpid
swi r3, r15, 36*4
/* _SAVE_RMSR_TO_CONTEXT__USES_R3_R15 */
mfs r3, rmsr
swi r3, r15, 33*4
/* _SAVE_RESR_TO_CONTEXT__USES_R3_R15 */
mfs r3, resr
swi r3, r15, 35*4
/* _SAVE_REAR_TO_CONTEXT__USES_R3_R15 */
mfs r3, rear
swi r3, r15, 34*4
/* _SAVE_PRESTORED_R1_R15_RPC_TO_CONTEXT__USES_R3_R15 */
lwi r3, r0, _prestored_r1
swi r3, r15, 1*4
lwi r3, r0, _prestored_r15
swi r3, r15, 15*4
lwi r3, r0, _prestored_rpc
swi r3, r15, 32*4
.endm
@ -145,9 +189,8 @@
.endm
_BEGIN_READABLE_EXECUTABLE
/* _BEGIN_READABLE_EXECUTABLE */
.section ".text"
_interrupt_entry:
@ -197,13 +240,21 @@ _BEGIN_READABLE_EXECUTABLE
_BEGIN_READABLE_WRITEABLE
/* _BEGIN_READABLE_WRITEABLE */
.section ".bss"
.global _current_context_label
.align 4
_current_context_label: .space 1*4
_VARIABLES_TO_WRITE_EXEC_CONTEXT
/* _VARIABLES_TO_WRITE_EXEC_CONTEXT */
.align 4
_prestored_r1: .space 4
.align 4
_prestored_r15: .space 4
.align 4
_prestored_rpc: .space 4
_MAY_BE_VERBOSE_VARIABLES

View File

@ -14,11 +14,6 @@
* under the terms of the GNU General Public License version 2.
*/
.include "special_registers.s"
.include "errors.s"
.include "exec_context.s"
.include "linker_commands.s"
.global _userland_entry
.global _userland_context
@ -73,13 +68,57 @@
.macro _PREPARE_CONTEXT__USES_R2_TO_R31
lwi r15, r0, _userland_context
_PRELOAD_R1_R15_RPC_FROM_CONTEXT__USES_R3_R15
/* _PRELOAD_R1_R15_RPC_FROM_CONTEXT__USES_R3_R15 */
lwi r3, r15, 1*4
swi r3, r0, _preloaded_r1
lwi r3, r15, 15*4
swi r3, r0, _preloaded_r15
lwi r3, r15, 32*4
swi r3, r0, _preloaded_rpc
_LOAD_RPID_FROM_CONTEXT__USES_R3_R15
_LOAD_RMSR_FROM_CONTEXT__USES_R3_R4_R15
/* _LOAD_RPID_FROM_CONTEXT__USES_R3_R15 */
lwi r3, r15, 36*4
mts rpid, r3
_LOAD_R2_TO_R13_FROM_CONTEXT__USES_R2_TO_R13_R15
_LOAD_R18_TO_R31_FROM_CONTEXT__TO_R15_R18_TO_R31
/* _SYNCHRONIZING_OP */
bri 4
/* _LOAD_RMSR_FROM_CONTEXT__USES_R3_R4_R15 */
lwi r3, r15, 33*4
mts rmsr, r3
/* _SYNCHRONIZING_OP */
bri 4
/* _LOAD_R2_TO_R13_FROM_CONTEXT__USES_R2_TO_R13_R15 */
lwi r2, r15, 2*4
lwi r3, r15, 3*4
lwi r4, r15, 4*4
lwi r5, r15, 5*4
lwi r6, r15, 6*4
lwi r7, r15, 7*4
lwi r8, r15, 8*4
lwi r9, r15, 9*4
lwi r10, r15, 10*4
lwi r11, r15, 11*4
lwi r12, r15, 12*4
lwi r13, r15, 13*4
/* _LOAD_R18_TO_R31_FROM_CONTEXT__TO_R15_R18_TO_R31 */
lwi r18, r15, 18*4
lwi r19, r15, 19*4
lwi r20, r15, 20*4
lwi r21, r15, 21*4
lwi r22, r15, 22*4
lwi r23, r15, 23*4
lwi r24, r15, 24*4
lwi r25, r15, 25*4
lwi r26, r15, 26*4
lwi r27, r15, 27*4
lwi r28, r15, 28*4
lwi r29, r15, 29*4
lwi r30, r15, 30*4
lwi r31, r15, 31*4
.endm
@ -127,7 +166,12 @@
lwi r1, r0, _preloaded_r1
lwi r15, r0, _preloaded_r15
_ENABLE_EXCEPTIONS
/* _ENABLE_EXCEPTIONS */
msrset r0, 0x100
/*_SYNCHRONIZING_OP */
bri 4
_START_KERNEL_TIMER
rtid r14, 0
@ -137,7 +181,9 @@
.macro _SWITCH_USERLAND_BLOCKING_TYPE__USES_R3_R15
lwi r15, r0, _userland_context
_LOAD_BLOCKING_TYPE_FROM_CONTEXT__USES_R3_R15
/* _LOAD_BLOCKING_TYPE_FROM_CONTEXT__USES_R3_R15 */
lwi r3, r15, 37*4
.endm
@ -165,7 +211,8 @@
.endm
_BEGIN_READABLE_EXECUTABLE
/* _BEGIN_READABLE_EXECUTABLE */
.section ".text"
_userland_entry:
_SWITCH_USERLAND_BLOCKING_TYPE__USES_R3_R15
@ -199,7 +246,9 @@ _BEGIN_READABLE_EXECUTABLE
_end_case_initial:
_case_default:
_ERROR_UNKNOWN_USERLAND_BLOCKING_TYPE
/* _ERROR_UNKNOWN_USERLAND_BLOCKING_TYPE */
brai 0x99000003
/* system halted */
_end_case_default:
@ -207,7 +256,8 @@ _BEGIN_READABLE_EXECUTABLE
_end_userland_entry:
_BEGIN_READABLE_WRITEABLE
/* _BEGIN_READABLE_WRITEABLE */
.section ".bss"
.align 4
_kernel_timer_ctrl: .space 1*4
@ -215,7 +265,14 @@ _BEGIN_READABLE_WRITEABLE
_kernel_timer_ctrl_start: .space 1*4
_START_KERNEL_TIMER__VARIABLES
_VARIABLES_TO_READ_EXEC_CONTEXT
/* _VARIABLES_TO_READ_EXEC_CONTEXT */
.align 4
_preloaded_r1: .space 4
.align 4
_preloaded_r15: .space 4
.align 4
_preloaded_rpc: .space 4
_MAY_BE_VERBOSE_VARIABLES
.align 4

View File

@ -36,3 +36,10 @@ _stack_low:
.globl _stack_high
_stack_high:
/*
* Symbol referenced by ldso's crt0.s, which is needed by base-hw only.
* It is defined here merely to resolve the symbol for non-base-hw
* platforms.
*/
.globl _main_utcb
_main_utcb: .long 0