mirror of
https://github.com/genodelabs/genode.git
synced 2025-02-21 02:01:38 +00:00
parent
c288973bf2
commit
722154f0a8
@ -34,8 +34,6 @@
|
||||
_nop 8
|
||||
|
||||
/* zero-fill BSS segment, BSS boundaries must be aligned to 4 */
|
||||
.extern _bss_start
|
||||
.extern _bss_end
|
||||
ldr r0, =_bss_start
|
||||
ldr r1, =_bss_end
|
||||
mov r2, #0
|
||||
@ -47,17 +45,15 @@
|
||||
b 1b
|
||||
2:
|
||||
|
||||
/* enable C++ to prepare the first kernel run */
|
||||
/* prepare the first call of the kernel main-routine */
|
||||
ldr sp, =_kernel_stack_high
|
||||
bl init_phys_kernel
|
||||
bl setup_kernel
|
||||
|
||||
/* call kernel routine */
|
||||
.extern kernel
|
||||
_start_kernel:
|
||||
/* call the kernel main-routine */
|
||||
ldr sp, =_kernel_stack_high
|
||||
bl kernel
|
||||
|
||||
/* catch erroneous kernel return */
|
||||
/* catch erroneous return */
|
||||
3: b 3b
|
||||
|
||||
.section .bss
|
||||
|
@ -192,80 +192,74 @@ namespace Kernel
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare the system for the first run of 'kernel'
|
||||
*/
|
||||
extern "C" void init_phys_kernel() {
|
||||
Cpu::init_phys_kernel(); }
|
||||
|
||||
/**
|
||||
* Kernel main routine
|
||||
* Prepare the first call of the kernel main-routine
|
||||
*/
|
||||
extern "C" void setup_kernel()
|
||||
{
|
||||
/* initialize processor in physical mode */
|
||||
Cpu::init_phys_kernel();
|
||||
|
||||
/* enable kernel timer */
|
||||
pic()->unmask(Timer::IRQ);
|
||||
|
||||
/* TrustZone initialization code */
|
||||
trustzone_initialization(pic());
|
||||
|
||||
/* enable performance counter */
|
||||
perf_counter()->enable();
|
||||
|
||||
/* switch to core address space */
|
||||
Cpu::init_virt_kernel(core()->tlb()->base(), core_id());
|
||||
|
||||
/*
|
||||
* From this point on, it is safe to use 'cmpxchg', i.e., to create
|
||||
* singleton objects via the static-local object pattern. See
|
||||
* the comment in 'src/base/singleton.h'.
|
||||
*/
|
||||
|
||||
/* create the core main thread */
|
||||
{
|
||||
/* get stack memory that fullfills the constraints for core stacks */
|
||||
enum {
|
||||
STACK_ALIGNM = 1 << Genode::CORE_STACK_ALIGNM_LOG2,
|
||||
STACK_SIZE = DEFAULT_STACK_SIZE,
|
||||
};
|
||||
if (STACK_SIZE > STACK_ALIGNM - sizeof(Core_thread_id)) {
|
||||
PERR("stack size does not fit stack alignment of core");
|
||||
}
|
||||
static char s[STACK_SIZE] __attribute__((aligned(STACK_ALIGNM)));
|
||||
|
||||
/* provide thread ident at the aligned base of the stack */
|
||||
*(Core_thread_id *)s = 0;
|
||||
|
||||
/* start thread with stack pointer at the top of stack */
|
||||
static Native_utcb utcb;
|
||||
static Thread t(Priority::MAX, "core");
|
||||
_main_thread_id = t.id();
|
||||
_main_thread_utcb = &utcb;
|
||||
_main_thread_utcb->start_info()->init(t.id(), Genode::Native_capability());
|
||||
t.ip = (addr_t)CORE_MAIN;;
|
||||
t.sp = (addr_t)s + STACK_SIZE;
|
||||
t.init(0, core_id(), &utcb, 1);
|
||||
}
|
||||
/* kernel initialization finished */
|
||||
init_platform();
|
||||
reset_lap_time();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Main routine of every kernel pass
|
||||
*/
|
||||
extern "C" void kernel()
|
||||
{
|
||||
static bool initial_call = true;
|
||||
|
||||
/* an exception occurred */
|
||||
if (!initial_call)
|
||||
{
|
||||
/* handle exception that interrupted the last user */
|
||||
cpu_scheduler()->head()->handle_exception();
|
||||
|
||||
/* kernel initialization */
|
||||
} else {
|
||||
|
||||
/* enable kernel timer */
|
||||
pic()->unmask(Timer::IRQ);
|
||||
|
||||
/* TrustZone initialization code */
|
||||
trustzone_initialization(pic());
|
||||
|
||||
/* enable performance counter */
|
||||
perf_counter()->enable();
|
||||
|
||||
/* switch to core address space */
|
||||
Cpu::init_virt_kernel(core()->tlb()->base(), core_id());
|
||||
|
||||
/*
|
||||
* From this point on, it is safe to use 'cmpxchg', i.e., to create
|
||||
* singleton objects via the static-local object pattern. See
|
||||
* the comment in 'src/base/singleton.h'.
|
||||
*/
|
||||
|
||||
/* create the core main thread */
|
||||
{
|
||||
/* get stack memory that fullfills the constraints for core stacks */
|
||||
enum {
|
||||
STACK_ALIGNM = 1 << Genode::CORE_STACK_ALIGNM_LOG2,
|
||||
STACK_SIZE = DEFAULT_STACK_SIZE,
|
||||
};
|
||||
if (STACK_SIZE > STACK_ALIGNM - sizeof(Core_thread_id)) {
|
||||
PERR("stack size does not fit stack alignment of core");
|
||||
}
|
||||
static char s[STACK_SIZE] __attribute__((aligned(STACK_ALIGNM)));
|
||||
|
||||
/* provide thread ident at the aligned base of the stack */
|
||||
*(Core_thread_id *)s = 0;
|
||||
|
||||
/* start thread with stack pointer at the top of stack */
|
||||
static Native_utcb utcb;
|
||||
static Thread t(Priority::MAX, "core");
|
||||
_main_thread_id = t.id();
|
||||
_main_thread_utcb = &utcb;
|
||||
_main_thread_utcb->start_info()->init(t.id(), Genode::Native_capability());
|
||||
t.ip = (addr_t)CORE_MAIN;;
|
||||
t.sp = (addr_t)s + STACK_SIZE;
|
||||
t.init(0, core_id(), &utcb, 1);
|
||||
}
|
||||
/* kernel initialization finished */
|
||||
init_platform();
|
||||
reset_lap_time();
|
||||
initial_call = false;
|
||||
}
|
||||
/* will jump to the context related mode-switch */
|
||||
cpu_scheduler()->head()->handle_exception();
|
||||
cpu_scheduler()->head()->proceed();
|
||||
}
|
||||
|
||||
|
||||
Kernel::Mode_transition_control * Kernel::mtc()
|
||||
{
|
||||
/* compose CPU context for kernel entry */
|
||||
|
@ -180,7 +180,9 @@ Thread::Thread(unsigned const priority, char const * const label)
|
||||
_utcb_phys(0),
|
||||
_signal_receiver(0),
|
||||
_label(label)
|
||||
{ }
|
||||
{
|
||||
cpu_exception = RESET;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
@ -236,6 +238,8 @@ void Thread::handle_exception()
|
||||
case FAST_INTERRUPT_REQUEST:
|
||||
handle_interrupt();
|
||||
return;
|
||||
case RESET:
|
||||
return;
|
||||
default:
|
||||
PERR("unknown exception");
|
||||
_stop();
|
||||
|
Loading…
x
Reference in New Issue
Block a user