Barrelfish
Macros | Functions | Variables
init.c File Reference

x86-32 architecture initialization. More...

Macros

#define SYSCALL_FMASK   (~(EFLAGS_ALWAYS1) & 0xffffffff)
 
#define SYSCALL_STAR
 

Functions

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

Variables

uintptr_t x86_32_kernel_stack [X86_32_KERNEL_STACK_SIZE/sizeof(uintptr_t)]
 Kernel stack. More...
 
bool idt_initialized = false
 

Detailed Description

x86-32 architecture initialization.

Macro Definition Documentation

#define SYSCALL_FMASK   (~(EFLAGS_ALWAYS1) & 0xffffffff)

EFLAGS mask for fast system calls. Put values to mask out here. We mask out everything (including interrupts).

#define SYSCALL_STAR
Value:
((((uint64_t)GSEL(KSTACK_SEL, SEL_UPL)) << 48) | \
((uint64_t)GSEL(KCODE_SEL, SEL_KPL) << 32))
#define KSTACK_SEL
Definition: irq.h:131
#define KCODE_SEL
Definition: irq.h:130

Segment selector bases for both kernel- and user-space for fast system calls

Function Documentation

void arch_init ( uint32_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. It expects 'dest' to be a physical address pointing to the base of a memory area to relocate itself to.

For x86-64, after performing some sanity checks to the kernel image, this function first copies the whole kernel to a CPU-local version and then calls local_init(), at the offset of the local copy, to initialize that local copy. local_init() should 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

bool idt_initialized = false

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

uintptr_t x86_32_kernel_stack[X86_32_KERNEL_STACK_SIZE/sizeof(uintptr_t)]

Kernel stack.

The kernel stack.

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