Subversion Repositories HelenOS

Rev

Rev 177 | Rev 184 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 177 Rev 180
Line 71... Line 71...
71
 */
71
 */
72
__address hardcoded_load_address = 0;
72
__address hardcoded_load_address = 0;
73
size_t hardcoded_ktext_size = 0;
73
size_t hardcoded_ktext_size = 0;
74
size_t hardcoded_kdata_size = 0;
74
size_t hardcoded_kdata_size = 0;
75
 
75
 
-
 
76
/*
-
 
77
 * Size of memory in bytes taken by kernel and heap.
-
 
78
 */
-
 
79
static size_t kernel_size;
-
 
80
 
-
 
81
/*
-
 
82
 * Extra space on heap to make the stack start on page boundary.
-
 
83
 */
-
 
84
static size_t heap_delta;
-
 
85
 
76
void main_bsp(void);
86
void main_bsp(void);
77
void main_ap(void);
87
void main_ap(void);
78
 
88
 
79
/*
89
/*
80
 * These two functions prevent stack from underflowing during the
90
 * These two functions prevent stack from underflowing during the
Line 83... Line 93...
83
 * pop sequence otherwise.
93
 * pop sequence otherwise.
84
 */
94
 */
85
static void main_bsp_separated_stack(void);
95
static void main_bsp_separated_stack(void);
86
static void main_ap_separated_stack(void);
96
static void main_ap_separated_stack(void);
87
 
97
 
88
 
-
 
89
/** Bootstrap CPU main kernel routine
98
/** Bootstrap CPU main kernel routine
90
 *
99
 *
91
 * Initializes the kernel by bootstrap CPU.
100
 * Initializes the kernel by bootstrap CPU.
92
 *
101
 *
93
 * Assuming cpu_priority_high().
102
 * Assuming cpu_priority_high().
Line 95... Line 104...
95
 */
104
 */
96
void main_bsp(void)
105
void main_bsp(void)
97
{
106
{
98
    config.cpu_count = 1;
107
    config.cpu_count = 1;
99
    config.cpu_active = 1;
108
    config.cpu_active = 1;
100
    size_t size, delta;
-
 
101
 
109
 
102
    /*
-
 
103
     * Calculate 'size' that kernel and heap occupies in memory.
-
 
104
     */
-
 
105
    size = hardcoded_ktext_size + hardcoded_kdata_size + CONFIG_HEAP_SIZE;   
110
    kernel_size = hardcoded_ktext_size + hardcoded_kdata_size + CONFIG_HEAP_SIZE;    
106
     
-
 
107
    /*
-
 
108
     * We need the boot stack to start on page boundary.
-
 
109
     * That is why 'delta' is calculated.
-
 
110
     */
-
 
111
    delta = PAGE_SIZE - ((hardcoded_load_address + size) % PAGE_SIZE);
111
    heap_delta = PAGE_SIZE - ((hardcoded_load_address + kernel_size) % PAGE_SIZE);
112
    delta = (delta == PAGE_SIZE) ? 0 : delta;
112
    heap_delta = (heap_delta == PAGE_SIZE) ? 0 : heap_delta;
113
   
-
 
114
    size += delta;
113
    kernel_size += heap_delta;
115
 
114
 
116
    config.base = hardcoded_load_address;
115
    config.base = hardcoded_load_address;
117
    config.memory_size = get_memory_size();
116
    config.memory_size = get_memory_size();
118
    config.kernel_size = size + CONFIG_STACK_SIZE;
117
    config.kernel_size = kernel_size + CONFIG_STACK_SIZE;
119
 
118
 
120
    context_save(&ctx);
119
    context_save(&ctx);
121
    context_set(&ctx, FADDR(main_bsp_separated_stack), config.base + size, CONFIG_STACK_SIZE);
120
    context_set(&ctx, FADDR(main_bsp_separated_stack), config.base + kernel_size, CONFIG_STACK_SIZE);
122
    context_restore(&ctx);
121
    context_restore(&ctx);
123
    /* not reached */
122
    /* not reached */
124
}
123
}
125
 
124
 
126
 
125
 
Line 133... Line 132...
133
{
132
{
134
    vm_t *m;
133
    vm_t *m;
135
    task_t *k;
134
    task_t *k;
136
    thread_t *t;
135
    thread_t *t;
137
 
136
 
-
 
137
    THE->preemption_disabled = 0;
-
 
138
    THE->cpu = NULL;
138
    arch_pre_mm_init();
139
    THE->thread = NULL;
-
 
140
    THE->task = NULL;
139
 
141
 
-
 
142
    arch_pre_mm_init();
140
    heap_init(config.base + hardcoded_ktext_size + hardcoded_kdata_size, CONFIG_HEAP_SIZE);
143
    heap_init(config.base + hardcoded_ktext_size + hardcoded_kdata_size, CONFIG_HEAP_SIZE + heap_delta);
141
    frame_init();
144
    frame_init();
142
    page_init();
145
    page_init();
143
    tlb_init();
146
    tlb_init();
144
 
147
 
145
    arch_post_mm_init();
148
    arch_post_mm_init();