added STACK_INITIAL_SIZE to control the number of initial stack pages; added BUILD_BUG_ON() macro to catch compile-time errors

git-svn-id: svn://anubis/hos/trunk@88 5b3e749e-e535-0410-8002-a9bb6afbdfca
This commit is contained in:
josh 2010-01-22 19:35:43 +00:00
parent 53407d7b59
commit 0c78e21e14
3 changed files with 26 additions and 16 deletions

View File

@ -4,10 +4,6 @@
#include "hos_types.h"
#ifdef __cplusplus
extern "C" {
#endif
#define KERNEL_OFFSET 0x00000000
#define PAGE_LOG_SIZE 12
@ -17,11 +13,6 @@ extern "C" {
#define CONSOLE_MEMORY 0xB8000
extern u8_t _code;
extern u8_t _data;
extern u8_t _bss;
extern u8_t _end;
#define KERNEL_CODE (&_code)
#define KERNEL_DATA (&_data)
#define KERNEL_BSS (&_bss)
@ -31,10 +22,22 @@ extern u8_t _end;
#define KERNEL_VIRTUAL_ADDRESS ((u32_t)KERNEL_CODE)
#define KERNEL_SIZE ((u32_t)(KERNEL_END - KERNEL_CODE))
#define KERNEL_STACK_TOP 0x40000000
#define KERNEL_STACK_TOP 0x20000000
#define KERNEL_TIMER_FREQ 1000
#define BUILD_BUG_ON(condition) \
((void) sizeof(struct { int : -!!(condition); }))
#ifdef __cplusplus
extern "C" {
#endif
extern u8_t _code;
extern u8_t _data;
extern u8_t _bss;
extern u8_t _end;
#ifdef __cplusplus
}
#endif

View File

@ -9,6 +9,11 @@ void stack_bootstrap()
* running from our temporary stack while segmentation is enabled,
* set up the "permanent" stack for use while paging
*/
u32_t first_stack_page_base = mm_early_page_alloc();
mm_early_map(KERNEL_STACK_TOP - PAGE_SIZE, first_stack_page_base, 0, 1);
u32_t stack_page_virt = KERNEL_STACK_TOP - PAGE_SIZE;
for (int i = 0; i < STACK_INITIAL_SIZE; i++)
{
u32_t stack_page_phys = mm_early_page_alloc();
mm_early_map(stack_page_virt, stack_page_phys, 0, 1);
stack_page_virt -= PAGE_SIZE;
}
}

View File

@ -2,6 +2,8 @@
#ifndef STACK_H
#define STACK_H
#define STACK_INITIAL_SIZE 2 /* number of initial stack pages */
void stack_bootstrap();
#endif