genode/repos/base-hw/src/core/spec/x86_64/crt0.s
Stefan Kalkowski 4e97a6511b hw: switch page-tables only when necessary
* Instead of always re-load page-tables when a thread context is switched
  only do this when another user PD's thread is the next target,
  core-threads are always executed within the last PD's page-table set
* remove the concept of the mode transition
* instead map the exception vector once in bootstrap code into kernel's
  memory segment
* when a new page directory is constructed for a user PD, copy over the
  top-level kernel segment entries on RISCV and X86, on ARM we use a designated
  page directory register for the kernel segment
* transfer the current CPU id from bootstrap to core/kernel in a register
  to ease first stack address calculation
* align cpu context member of threads and vms, because of x86 constraints
  regarding the stack-pointer loading
* introduce Align_at template for members with alignment constraints
* let the x86 hardware do part of the context saving in ISS, by passing
  the thread context into the TSS before leaving to user-land
* use one exception vector for all ARM platforms including Arm_v6

Fix #2091
2017-10-19 13:31:18 +02:00

62 lines
1.5 KiB
ArmAsm

/**
* \brief Startup code for Genode 64Bit applications
* \author Sebastian Sumpf
* \author Martin Stein
* \date 2011-05-11
*/
/*
* Copyright (C) 2011-2017 Genode Labs GmbH
*
* This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU Affero General Public License version 3.
*/
.section ".text"
/***********************
** kernel entry code **
***********************/
.global _start
_start:
/* switch to kernel stack */
mov kernel_stack@GOTPCREL(%rip), %rax
mov kernel_stack_size@GOTPCREL(%rip), %rbx
add (%rbx), %rax
mov %rax, %rsp
/* jump to C entry code */
jmp kernel_init
/*********************************
** core main thread entry code **
*********************************/
.global _core_start
_core_start:
/* initialize GLOBAL OFFSET TABLE */
leaq _GLOBAL_OFFSET_TABLE_(%rip), %r15
/* create proper environment for the main thread */
call init_main_thread
/* apply environment that was created by init_main_thread */
movq init_main_thread_result@GOTPCREL(%rip), %rax
movq (%rax), %rsp
/* clear the base pointer in order that stack backtraces will work */
xorq %rbp, %rbp
/*
* We jump into initial C code instead of calling it as it should never
* return on the one hand and because the alignment of the stack pointer
* that init_main_thread returned expects a jump at the other hand. The
* latter matters because GCC expects the initial stack pointer to be
* aligned to 16 byte for at least the handling of floating points.
*/
jmp _main