Barrelfish
Functions | Variables
init.c File Reference

x86-64 architecture initialization. More...

Functions

void arch_init (uint64_t magic, void *pointer)
 Architecture-specific initialization function. More...
 

Variables

uintptr_t x86_64_kernel_stack [X86_64_KERNEL_STACK_SIZE/sizeof(uintptr_t)]
 Kernel stack. More...
 
union segment_descriptor gdt []
 Global Descriptor Table (GDT) for processor this kernel is running on. More...
 
bool idt_initialized = false
 

Detailed Description

x86-64 architecture initialization.

Function Documentation

void arch_init ( uint64_t  magic,
void *  pointer 
)

Architecture-specific initialization function.

This function is called by the bootup code in boot.S to initialize architecture-specific stuff. It is expected to call the kernel main loop. This function never returns.

The kernel expects one of two magic values in 'magic' that determine how it has been booted. If 'magic' is #MULTIBOOT_INFO_MAGIC the kernel has been booted by a (Multiboot-compliant) bootloader and this is the first image on the boot CPU. It will relocate itself to a default position. If 'magic' is KERNEL_BOOT_MAGIC it has been booted by another image of itself and is running on an (so-called) application CPU.

This function sets up new page tables to alias the kernel at MEMORY_OFFSET. It also does any relocations necessary to the "position-independent" code to make it run at the new location (e.g. relocating the GOT). After all relocations, it calls text_init() of the relocated image, which destroys the lower alias and may never return.

For bsp kernels, the void pointer is of type multiboot_info, for application CPUs, it is of type global. Global carries a pointer to multiboot_info. Global also contains pointers to memory that is shared between kernels.

Parameters
magicBoot magic value
pointerPointer to Multiboot Info or to Global structure

Variable Documentation

union segment_descriptor gdt[]

Global Descriptor Table (GDT) for processor this kernel is running on.

This descriptor table is completely static, as segments are basically turned off in 64-bit mode. They map flat-mode code and stack segments for both kernel- and user-space and the only Task State Segment (TSS).

bool idt_initialized = false

This flag is set to true once the IDT is initialized and exceptions can be caught.

uintptr_t x86_64_kernel_stack[X86_64_KERNEL_STACK_SIZE/sizeof(uintptr_t)]

Kernel stack.

The kernel stack.

This is the one and only kernel stack for a kernel instance.