added mm/stack module; initializing "permanent" stack for kernel use while paging, crashing when calling k_main() though...
git-svn-id: svn://anubis/hos/trunk@52 5b3e749e-e535-0410-8002-a9bb6afbdfca
This commit is contained in:
parent
cf2d28f5ce
commit
bf9c7d74eb
@ -12,6 +12,8 @@
|
|||||||
|
|
||||||
%define PAGE_SIZE 0x1000 ; 4KB pages
|
%define PAGE_SIZE 0x1000 ; 4KB pages
|
||||||
|
|
||||||
|
%define KERNEL_STACK_TOP 0xF0000000 ; permanent stack top
|
||||||
|
|
||||||
; Symbols from the linker
|
; Symbols from the linker
|
||||||
extern _end, _bss
|
extern _end, _bss
|
||||||
|
|
||||||
@ -107,7 +109,7 @@ segmentation_disabled:
|
|||||||
mov cx, 0x0700 + 'f'
|
mov cx, 0x0700 + 'f'
|
||||||
mov [CONSOLE_MEMORY+160*8+5*2], cx
|
mov [CONSOLE_MEMORY+160*8+5*2], cx
|
||||||
|
|
||||||
; TODO: set up a stack!
|
; mov esp, KERNEL_STACK_TOP
|
||||||
; call k_main
|
; call k_main
|
||||||
|
|
||||||
idle_loop:
|
idle_loop:
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include "multiboot.h"
|
#include "multiboot.h"
|
||||||
#include "k_early_panic.h"
|
#include "k_early_panic.h"
|
||||||
#include "mm/mm.h"
|
#include "mm/mm.h"
|
||||||
|
#include "mm/stack.h"
|
||||||
#include "lang/kio.h"
|
#include "lang/kio.h"
|
||||||
|
|
||||||
#define DEBUG_LETTER(col,chr) *(u16_t *)(KERNEL_OFFSET + CONSOLE_MEMORY \
|
#define DEBUG_LETTER(col,chr) *(u16_t *)(KERNEL_OFFSET + CONSOLE_MEMORY \
|
||||||
@ -46,18 +47,9 @@ u32_t k_bootstrap(mb_info_t * mb_info, u32_t mb_magic)
|
|||||||
* before calling them.
|
* before calling them.
|
||||||
*/
|
*/
|
||||||
mm_bootstrap();
|
mm_bootstrap();
|
||||||
|
stack_bootstrap(); /* after mm */
|
||||||
kio_bootstrap();
|
kio_bootstrap();
|
||||||
|
|
||||||
kprintf("Hello from kprintf()! %d, %x, %u, %l\n", 42, 0xabcd0123, 0xFFFFFFFF, -1234567891234ll);
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
kprintf("d1: 0x%X\n", MAKE_DESCRIPTOR(0, 0xFFFFF, 1, 0, 1, 1));
|
|
||||||
kprintf("d2: 0x%X\n", MAKE_DESCRIPTOR(0, 0xFFFFF, 1, 0, 1, 0));
|
|
||||||
|
|
||||||
for (;;)
|
|
||||||
;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,11 @@
|
|||||||
|
|
||||||
|
#include "lang/kio.h"
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
|
||||||
void k_main()
|
void k_main()
|
||||||
{
|
{
|
||||||
|
kprintf("Hi from k_main()!\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} /* extern "C" */
|
||||||
|
@ -29,6 +29,8 @@ extern u8_t _end;
|
|||||||
#define KERNEL_VIRTUAL_ADDRESS ((u32_t)KERNEL_CODE)
|
#define KERNEL_VIRTUAL_ADDRESS ((u32_t)KERNEL_CODE)
|
||||||
#define KERNEL_SIZE ((u32_t)(KERNEL_END - KERNEL_CODE))
|
#define KERNEL_SIZE ((u32_t)(KERNEL_END - KERNEL_CODE))
|
||||||
|
|
||||||
|
#define KERNEL_STACK_TOP 0xF0000000
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -96,7 +96,7 @@ void kvprintf(const char * fmt, va_list args)
|
|||||||
|
|
||||||
void kputc(char c)
|
void kputc(char c)
|
||||||
{
|
{
|
||||||
u16_t * console_memory = (u16_t *) (CONSOLE_MEMORY + KERNEL_OFFSET);
|
u16_t * console_memory = (u16_t *) CONSOLE_MEMORY;
|
||||||
console_memory += 80 * cursor_y + cursor_x;
|
console_memory += 80 * cursor_y + cursor_x;
|
||||||
switch (c)
|
switch (c)
|
||||||
{
|
{
|
||||||
|
14
kernel/mm/stack.cc
Executable file
14
kernel/mm/stack.cc
Executable file
@ -0,0 +1,14 @@
|
|||||||
|
|
||||||
|
#include "stack.h"
|
||||||
|
#include "mm.h"
|
||||||
|
#include "hos_defines.h"
|
||||||
|
|
||||||
|
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_page_alloc();
|
||||||
|
mm_map(KERNEL_STACK_TOP - PAGE_SIZE, first_stack_page_base, 0, 1);
|
||||||
|
}
|
7
kernel/mm/stack.h
Executable file
7
kernel/mm/stack.h
Executable file
@ -0,0 +1,7 @@
|
|||||||
|
|
||||||
|
#ifndef STACK_H
|
||||||
|
#define STACK_H
|
||||||
|
|
||||||
|
void stack_bootstrap();
|
||||||
|
|
||||||
|
#endif
|
Loading…
x
Reference in New Issue
Block a user