hos/kernel/boot/k_bootstrap.cc
2009-07-24 14:51:23 +00:00

57 lines
1.6 KiB
C++

#include "hos_types.h"
#include "hos_defines.h"
#include "multiboot.h"
#include "k_early_panic.h"
#include "mm/mm.h"
#include "mm/stack.h"
#include "lang/kio.h"
#define DEBUG_LETTER(col,chr) *(u16_t *)(KERNEL_OFFSET + CONSOLE_MEMORY \
+ 160 * 8 + (col) * 2) \
= 0x0700 | (chr)
extern "C" {
u8_t bootstrap_stack[4096];
/**************************************************************************
* This function is invoked before paging is enabled. Segmentation is *
* utilized to map virtual address 0xE000_0000 to physical address 0x0. *
*************************************************************************/
u32_t k_bootstrap(mb_info_t * mb_info, u32_t mb_magic)
{
DEBUG_LETTER(2, 'c');
if (mb_magic != MB_BOOTLOADER_MAGIC)
{
k_early_panic("Bad multiboot magic identifier!");
}
if ( ! (mb_info->flags & MB_BOOTLOADER_MMAP) )
{
k_early_panic("No memory map provided by bootloader!");
}
mb_mmap_t * mmap = (mb_mmap_t *) (mb_info->mmap_addr + KERNEL_OFFSET - 4);
for (unsigned int sz = 0; sz < mb_info->mmap_length; sz += mmap->size + 4)
{
mm_record_mmap_entry(mmap);
mmap = (mb_mmap_t *) (((u32_t)mmap) + mmap->size + 4);
}
DEBUG_LETTER(3, 'd');
/*
* These functions could destroy the multiboot information block and
* associated structures, so we must be finished reading those structures
* before calling them.
*/
mm_bootstrap();
stack_bootstrap();
kio_bootstrap();
return 0;
}
} /* extern "C" */