/SPARTAN/trunk/src/main/main.c |
---|
73,6 → 73,16 |
size_t hardcoded_ktext_size = 0; |
size_t hardcoded_kdata_size = 0; |
/* |
* Size of memory in bytes taken by kernel and heap. |
*/ |
static size_t kernel_size; |
/* |
* Extra space on heap to make the stack start on page boundary. |
*/ |
static size_t heap_delta; |
void main_bsp(void); |
void main_ap(void); |
85,7 → 95,6 |
static void main_bsp_separated_stack(void); |
static void main_ap_separated_stack(void); |
/** Bootstrap CPU main kernel routine |
* |
* Initializes the kernel by bootstrap CPU. |
97,28 → 106,18 |
{ |
config.cpu_count = 1; |
config.cpu_active = 1; |
size_t size, delta; |
/* |
* Calculate 'size' that kernel and heap occupies in memory. |
*/ |
size = hardcoded_ktext_size + hardcoded_kdata_size + CONFIG_HEAP_SIZE; |
/* |
* We need the boot stack to start on page boundary. |
* That is why 'delta' is calculated. |
*/ |
delta = PAGE_SIZE - ((hardcoded_load_address + size) % PAGE_SIZE); |
delta = (delta == PAGE_SIZE) ? 0 : delta; |
size += delta; |
kernel_size = hardcoded_ktext_size + hardcoded_kdata_size + CONFIG_HEAP_SIZE; |
heap_delta = PAGE_SIZE - ((hardcoded_load_address + kernel_size) % PAGE_SIZE); |
heap_delta = (heap_delta == PAGE_SIZE) ? 0 : heap_delta; |
kernel_size += heap_delta; |
config.base = hardcoded_load_address; |
config.memory_size = get_memory_size(); |
config.kernel_size = size + CONFIG_STACK_SIZE; |
config.kernel_size = kernel_size + CONFIG_STACK_SIZE; |
context_save(&ctx); |
context_set(&ctx, FADDR(main_bsp_separated_stack), config.base + size, CONFIG_STACK_SIZE); |
context_set(&ctx, FADDR(main_bsp_separated_stack), config.base + kernel_size, CONFIG_STACK_SIZE); |
context_restore(&ctx); |
/* not reached */ |
} |
135,9 → 134,13 |
task_t *k; |
thread_t *t; |
THE->preemption_disabled = 0; |
THE->cpu = NULL; |
THE->thread = NULL; |
THE->task = NULL; |
arch_pre_mm_init(); |
heap_init(config.base + hardcoded_ktext_size + hardcoded_kdata_size, CONFIG_HEAP_SIZE); |
heap_init(config.base + hardcoded_ktext_size + hardcoded_kdata_size, CONFIG_HEAP_SIZE + heap_delta); |
frame_init(); |
page_init(); |
tlb_init(); |
/SPARTAN/trunk/arch/ia64/include/asm.h |
---|
32,10 → 32,19 |
#include <arch/types.h> |
#include <config.h> |
/* TODO: implement the real stuff */ |
/** Return base address of current stack |
* |
* Return the base address of the current stack. |
* The stack is assumed to be STACK_SIZE long. |
* The stack must start on page boundary. |
*/ |
static inline __address get_stack_base(void) |
{ |
return NULL; |
__u64 v; |
__asm__ volatile ("and %0 = %1, r12" : "=r" (v) : "r" (~(STACK_SIZE-1))); |
return v; |
} |
#endif |
/SPARTAN/trunk/arch/ia64/include/context.h |
---|
31,11 → 31,15 |
#include <arch/types.h> |
#define STACK_ITEM_SIZE 16 |
/* |
* context_save() and context_restore() are both leaf procedures. |
* No need to allocate scratch area. |
* |
* One item is put onto the stack to support get_stack_base(). |
*/ |
#define SP_DELTA 0 |
#define SP_DELTA (0+STACK_ITEM_SIZE) |
#ifdef context_set |
#undef context_set |
/SPARTAN/trunk/arch/mips/include/asm.h |
---|
38,6 → 38,7 |
* |
* Return the base address of the current stack. |
* The stack is assumed to be STACK_SIZE bytes long. |
* The stack must start on page boundary. |
*/ |
static inline __address get_stack_base(void) |
{ |
/SPARTAN/trunk/arch/mips/include/context.h |
---|
31,9 → 31,14 |
#include <arch/types.h> |
#define SP_DELTA 0 |
#define STACK_ITEM_SIZE 4 |
/* |
* Put one item onto the stack to support get_stack_base(). |
*/ |
#define SP_DELTA (0+STACK_ITEM_SIZE) |
struct context { |
__u32 r0; |
__u32 r1; |
/SPARTAN/trunk/arch/ia32/include/asm.h |
---|
161,6 → 161,7 |
* |
* Return the base address of the current stack. |
* The stack is assumed to be STACK_SIZE bytes long. |
* The stack must start on page boundary. |
*/ |
static inline __address get_stack_base(void) |
{ |
/SPARTAN/trunk/arch/ia32/include/context.h |
---|
31,11 → 31,15 |
#include <arch/types.h> |
#define STACK_ITEM_SIZE 4 |
/* |
* Both context_save() and context_restore() eat two doublewords from the stack. |
* First for pop of the saved register, second during ret instruction. |
* |
* One item is put onto stack to support get_stack_base(). |
*/ |
#define SP_DELTA 8 |
#define SP_DELTA (8+STACK_ITEM_SIZE) |
struct context { |
__u32 sp; |
/SPARTAN/trunk/arch/ia32/include/cpu.h |
---|
29,8 → 29,6 |
#ifndef __ia32_CPU_H__ |
#define __ia32_CPU_H__ |
#include <config.h> |
#include <proc/thread.h> |
#include <typedefs.h> |
#include <arch/pm.h> |
#include <arch/asm.h> |