Subversion Repositories HelenOS-historic

Rev

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

Rev 207 Rev 210
Line 51... Line 51...
51
#include <mm/frame.h>
51
#include <mm/frame.h>
52
#include <mm/page.h>
52
#include <mm/page.h>
53
#include <mm/tlb.h>
53
#include <mm/tlb.h>
54
#include <synch/waitq.h>
54
#include <synch/waitq.h>
55
 
55
 
-
 
56
#include <arch/arch.h>
56
#include <arch.h>
57
#include <arch.h>
57
#include <arch/faddr.h>
58
#include <arch/faddr.h>
58
 
59
 
59
#include <typedefs.h>
60
#include <typedefs.h>
60
 
61
 
Line 104... Line 105...
104
 */
105
 */
105
void main_bsp(void)
106
void main_bsp(void)
106
{
107
{
107
    config.cpu_count = 1;
108
    config.cpu_count = 1;
108
    config.cpu_active = 1;
109
    config.cpu_active = 1;
109
 
110
   
110
    kernel_size = hardcoded_ktext_size + hardcoded_kdata_size + CONFIG_HEAP_SIZE;    
111
    kernel_size = hardcoded_ktext_size + hardcoded_kdata_size + CONFIG_HEAP_SIZE;    
111
    heap_delta = PAGE_SIZE - ((hardcoded_load_address + kernel_size) % PAGE_SIZE);
112
    heap_delta = PAGE_SIZE - ((hardcoded_load_address + kernel_size) % PAGE_SIZE);
112
    heap_delta = (heap_delta == PAGE_SIZE) ? 0 : heap_delta;
113
    heap_delta = (heap_delta == PAGE_SIZE) ? 0 : heap_delta;
113
    kernel_size += heap_delta;
114
    kernel_size += heap_delta;
114
 
115
   
115
    config.base = hardcoded_load_address;
116
    config.base = hardcoded_load_address;
116
    config.memory_size = get_memory_size();
117
    config.memory_size = get_memory_size();
117
    config.kernel_size = kernel_size + CONFIG_STACK_SIZE;
118
    config.kernel_size = kernel_size + CONFIG_STACK_SIZE;
118
 
119
   
119
    context_save(&ctx);
120
    context_save(&ctx);
-
 
121
    early_mapping(config.base + hardcoded_ktext_size + hardcoded_kdata_size + heap_delta, CONFIG_STACK_SIZE + CONFIG_HEAP_SIZE);
120
    context_set(&ctx, FADDR(main_bsp_separated_stack), config.base + kernel_size, CONFIG_STACK_SIZE);
122
    context_set(&ctx, FADDR(main_bsp_separated_stack), config.base + kernel_size, CONFIG_STACK_SIZE);
121
    context_map_stack(config.base + kernel_size, CONFIG_STACK_SIZE);
-
 
122
    context_restore(&ctx);
123
    context_restore(&ctx);
123
    /* not reached */
124
    /* not reached */
124
}
125
}
125
 
126
 
126
 
127
 
Line 155... Line 156...
155
    printf("config.memory_size=%dM\n", config.memory_size/(1024*1024));
156
    printf("config.memory_size=%dM\n", config.memory_size/(1024*1024));
156
    printf("config.cpu_count=%d\n", config.cpu_count);
157
    printf("config.cpu_count=%d\n", config.cpu_count);
157
 
158
 
158
    cpu_init();
159
    cpu_init();
159
    calibrate_delay_loop();
160
    calibrate_delay_loop();
160
 
161
   
161
    timeout_init();
162
    timeout_init();
162
    scheduler_init();
163
    scheduler_init();
163
    task_init();
164
    task_init();
164
    thread_init();
165
    thread_init();
165
 
166
 
166
    /*
167
    /*
167
     * Create kernel vm mapping.
168
     * Create kernel vm mapping.
168
     */
169
     */
169
    m = vm_create(GET_PTL0_ADDRESS());
170
    m = vm_create(GET_PTL0_ADDRESS());
-
 
171
    if (!m)
170
    if (!m) panic("can't create kernel vm address space\n");
172
        panic("can't create kernel vm address space\n");
171
 
173
 
172
    /*
174
    /*
173
     * Create kernel task.
175
     * Create kernel task.
174
     */
176
     */
175
    k = task_create(m);
177
    k = task_create(m);
-
 
178
    if (!k)
176
    if (!k) panic("can't create kernel task\n");
179
        panic("can't create kernel task\n");
177
 
180
       
178
    /*
181
    /*
179
     * Create the first thread.
182
     * Create the first thread.
180
     */
183
     */
181
    t = thread_create(kinit, NULL, k, 0);
184
    t = thread_create(kinit, NULL, k, 0);
-
 
185
    if (!t)
182
    if (!t) panic("can't create kinit thread\n");
186
        panic("can't create kinit thread\n");
183
    thread_ready(t);
187
    thread_ready(t);
184
 
188
 
185
    /*
189
    /*
186
     * This call to scheduler() will return to kinit,
190
     * This call to scheduler() will return to kinit,
187
     * starting the thread of kernel threads.
191
     * starting the thread of kernel threads.