1/** 2 * \file 3 * \brief Bootstrap the kernel. 4 */ 5 6/* 7 * Copyright (c) 2007, 2008, ETH Zurich. 8 * All rights reserved. 9 * 10 * This file is distributed under the terms in the attached LICENSE file. 11 * If you do not find this file, copies can be found by writing to: 12 * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group. 13 */ 14 15#include <multiboot.h> 16 17#ifdef __k1om__ 18#include <target/k1om/offsets_target.h> 19#define KERNEL_STACK_SIZE K1OM_KERNEL_STACK_SIZE 20#define KERNEL_STACK k1om_kernel_stack 21#else 22#include <target/x86_64/offsets_target.h> 23#define KERNEL_STACK_SIZE X86_64_KERNEL_STACK_SIZE 24#define KERNEL_STACK x86_64_kernel_stack 25#endif 26 27/* The flags for the Multiboot header */ 28#define MB_FLAGS (MULTIBOOT_HEADER_FLAG_MODS_PGALIGNED | MULTIBOOT_HEADER_FLAG_NEED_MEMINFO) 29 30 .text 31 .globl start, halt 32 33 /* Multiboot header, 4-byte aligned */ 34 .align 4 35 .long MULTIBOOT_HEADER_MAGIC /* magic */ 36 .long MB_FLAGS /* flags */ 37 .long -(MULTIBOOT_HEADER_MAGIC + MB_FLAGS) /* checksum */ 38 39start: 40 /* Initialize the stack pointer */ 41 lea (KERNEL_STACK + KERNEL_STACK_SIZE)(%rip), %rsp 42 43 /* Reset EFLAGS */ 44 pushq $0 45 popf 46 47 /* Enter architecture-specific init -- this should never return */ 48 movl %eax, %edi /* Multiboot magic value */ 49 movl %ebx, %esi /* Pointer to multiboot info struct */ 50 call arch_init 51 52 /* Halt -- this should never be reached */ 53halt: hlt 54 jmp halt 55