MentOS  0.8.0
The Mentoring Operating System
Macros | Functions | Variables
Bootloader

Set of functions and variables for booting the kernel. More...

Macros

#define KERNEL_STACK_SIZE   0x100000
 Size of the kernel's stack.
 
#define SERIAL_COM1   (0x03F8)
 Serial port for QEMU.
 

Functions

void boot_kernel (uint32_t stack_pointer, uint32_t entry, struct boot_info_t *boot_info)
 External function implemented in boot.S. More...
 
static void __outportb (uint16_t port, uint8_t data)
 Use this to write to I/O ports to send bytes to devices. More...
 
static void __debug_putchar (char c)
 Writes the given character on the debug port. More...
 
static void __debug_puts (char *s)
 Writes the given string on the debug port. More...
 
static uint32_t __align_rup (uint32_t addr, uint32_t value)
 Align memory address to the specified value (round up). More...
 
static uint32_t __align_rdown (uint32_t addr, uint32_t value)
 Align memory address to the specified value (round down). More...
 
static void __setup_pages (uint32_t pfn_virt_start, uint32_t pfn_phys_start, uint32_t pfn_count)
 Prepares the page frames. More...
 
static void __setup_boot_paging (void)
 Setup paging mapping all the low memory to two places: one is the physical address of the memory itself the other is in the virtual kernel address space.
 
static void __get_kernel_low_high (elf_header_t *elf_hdr, uint32_t *virt_low, uint32_t *virt_high)
 Extract the starting and ending address of the kernel. More...
 
static uint32_t __get_address_after_modules (multiboot_info_t *header)
 Returns the first address after the modules. More...
 
static void __relocate_kernel_image (elf_header_t *elf_hdr)
 Relocate the kernel image. More...
 
void boot_main (uint32_t magic, multiboot_info_t *header, uint32_t esp)
 Entry point of the bootloader. More...
 

Variables

char _bootloader_start []
 Linker symbols for where the .data section of kernel.bin.o. More...
 
char _bootloader_end []
 Linker symbol for where the bootloader ends.
 
static boot_info_t boot_info
 Boot info provided to the kmain function.
 
static page_directory_t boot_pgdir
 Boot page directory.
 
static page_table_t boot_pgtables [1024]
 Boot page tables.
 

Detailed Description

Set of functions and variables for booting the kernel.

Function Documentation

◆ __align_rdown()

static uint32_t __align_rdown ( uint32_t  addr,
uint32_t  value 
)
inlinestatic

Align memory address to the specified value (round down).

Parameters
addrthe address to align
valuethe value used to align.
Returns
the aligned address.

◆ __align_rup()

static uint32_t __align_rup ( uint32_t  addr,
uint32_t  value 
)
inlinestatic

Align memory address to the specified value (round up).

Parameters
addrthe address to align
valuethe value used to align.
Returns
the aligned address.

◆ __debug_putchar()

static void __debug_putchar ( char  c)
inlinestatic

Writes the given character on the debug port.

Parameters
cthe character to send to the debug port.

◆ __debug_puts()

static void __debug_puts ( char *  s)
inlinestatic

Writes the given string on the debug port.

Parameters
sthe string to send to the debug port.

◆ __get_address_after_modules()

static uint32_t __get_address_after_modules ( multiboot_info_t header)
inlinestatic

Returns the first address after the modules.

Parameters
headerThe multiboot info structure from which we extract the info.
Returns
The address after the modules.

◆ __get_kernel_low_high()

static void __get_kernel_low_high ( elf_header_t elf_hdr,
uint32_t virt_low,
uint32_t virt_high 
)
static

Extract the starting and ending address of the kernel.

Parameters
elf_hdrThe elf header of the kernel.
virt_lowOutput variable where we store the lowest address of the kernel.
virt_highOutput variable where we store the highest address of the kernel.

◆ __outportb()

static void __outportb ( uint16_t  port,
uint8_t  data 
)
inlinestatic

Use this to write to I/O ports to send bytes to devices.

Parameters
portThe output port.
dataThe data to write.

◆ __relocate_kernel_image()

static void __relocate_kernel_image ( elf_header_t elf_hdr)
inlinestatic

Relocate the kernel image.

Parameters
elf_hdrThe elf header of the kernel.

◆ __setup_pages()

static void __setup_pages ( uint32_t  pfn_virt_start,
uint32_t  pfn_phys_start,
uint32_t  pfn_count 
)
static

Prepares the page frames.

Parameters
pfn_virt_startThe first virtual page frame.
pfn_phys_startThe first physical page frame.
pfn_countThe number of page frames.

◆ boot_kernel()

void boot_kernel ( uint32_t  stack_pointer,
uint32_t  entry,
struct boot_info_t boot_info 
)

External function implemented in boot.S.

Parameters
stack_pointerThe stack base pointer, usually at the end of the lowmem.
entry
boot_info

◆ boot_main()

void boot_main ( uint32_t  magic,
multiboot_info_t header,
uint32_t  esp 
)

Entry point of the bootloader.

Parameters
magicThe magic number coming from the multiboot assembly code.
headerMultiboot header provided by the bootloader.
espThe initial stack pointer.

Variable Documentation

◆ _bootloader_start

char _bootloader_start[]
extern

Linker symbols for where the .data section of kernel.bin.o.

Linker symbol for where the bootloader starts.