Subversion Repositories HelenOS-historic

Rev

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

Rev 799 Rev 814
Line 41... Line 41...
41
#include <console/kconsole.h>
41
#include <console/kconsole.h>
42
#include <cpu.h>
42
#include <cpu.h>
43
#include <align.h>
43
#include <align.h>
44
#include <interrupt.h>
44
#include <interrupt.h>
45
#include <arch/mm/memory_init.h>
45
#include <arch/mm/memory_init.h>
46
#include <mm/heap.h>
-
 
47
#include <mm/frame.h>
46
#include <mm/frame.h>
48
#include <mm/page.h>
47
#include <mm/page.h>
49
#include <genarch/mm/page_pt.h>
48
#include <genarch/mm/page_pt.h>
50
#include <mm/tlb.h>
49
#include <mm/tlb.h>
51
#include <mm/as.h>
50
#include <mm/as.h>
Line 101... Line 100...
101
 * Assuming interrupts_disable().
100
 * Assuming interrupts_disable().
102
 *
101
 *
103
 */
102
 */
104
void main_bsp(void)
103
void main_bsp(void)
105
{
104
{
-
 
105
    __address stackaddr;
-
 
106
 
106
    config.cpu_count = 1;
107
    config.cpu_count = 1;
107
    config.cpu_active = 1;
108
    config.cpu_active = 1;
108
   
109
   
109
    config.base = hardcoded_load_address;
110
    config.base = hardcoded_load_address;
110
    config.memory_size = get_memory_size();
111
    config.memory_size = get_memory_size();
111
    config.init_addr = init_addr;
112
    config.init_addr = init_addr;
112
    config.init_size = init_size;
113
    config.init_size = init_size;
113
   
114
   
-
 
115
    config.kernel_size = ALIGN_UP(hardcoded_ktext_size + hardcoded_kdata_size, PAGE_SIZE);
114
    if (init_size > 0)
116
    stackaddr = config.base + config.kernel_size;
115
        config.heap_addr = init_addr + init_size;
117
    /* Avoid placing kernel on top of init */
116
    else
-
 
117
        config.heap_addr = hardcoded_load_address + hardcoded_ktext_size + hardcoded_kdata_size;
118
    if (overlaps(stackaddr,stackaddr+CONFIG_STACK_SIZE,
118
   
-
 
119
    config.heap_size = CONFIG_HEAP_SIZE + (config.memory_size / FRAME_SIZE) * sizeof(frame_t);
119
             config.init_addr, config.init_addr+config.init_size)) {
120
   
120
       
121
    config.kernel_size = ALIGN_UP(config.heap_addr - hardcoded_load_address + config.heap_size, PAGE_SIZE);
121
        stackaddr = ALIGN_UP(config.init_addr+config.init_size,
-
 
122
                     CONFIG_STACK_SIZE);
122
    config.heap_delta = config.kernel_size - (config.heap_addr - hardcoded_load_address + config.heap_size);
123
        config.init_size = ALIGN_UP(config.init_size,CONFIG_STACK_SIZE) + CONFIG_STACK_SIZE;
-
 
124
    } else {
123
    config.kernel_size = config.kernel_size + CONFIG_STACK_SIZE;
125
        config.kernel_size += CONFIG_STACK_SIZE;
-
 
126
    }
124
   
127
   
125
    context_save(&ctx);
128
    context_save(&ctx);
126
    context_set(&ctx, FADDR(main_bsp_separated_stack), config.base + config.kernel_size - CONFIG_STACK_SIZE, CONFIG_STACK_SIZE);
129
    context_set(&ctx, FADDR(main_bsp_separated_stack),
-
 
130
            stackaddr, CONFIG_STACK_SIZE);
127
    context_restore(&ctx);
131
    context_restore(&ctx);
128
    /* not reached */
132
    /* not reached */
129
}
133
}
130
 
134
 
131
 
135
 
Line 138... Line 142...
138
{
142
{
139
    task_t *k;
143
    task_t *k;
140
    thread_t *t;
144
    thread_t *t;
141
   
145
   
142
    the_initialize(THE);
146
    the_initialize(THE);
143
   
-
 
144
    /*
147
    /*
145
     * kconsole data structures must be initialized very early
148
     * kconsole data structures must be initialized very early
146
     * because other subsystems will register their respective
149
     * because other subsystems will register their respective
147
     * commands.
150
     * commands.
148
     */
151
     */
Line 156... Line 159...
156
 
159
 
157
    /*
160
    /*
158
     * Memory management subsystems initialization.
161
     * Memory management subsystems initialization.
159
     */
162
     */
160
    arch_pre_mm_init();
163
    arch_pre_mm_init();
161
    early_heap_init(config.heap_addr, config.heap_size + config.heap_delta);
164
    /* Initialize at least 1 memory segment big enough for slab to work */
162
    frame_init();
165
    frame_init();
163
    slab_cache_init();
166
    slab_cache_init();
164
    as_init();
167
    as_init();
165
    page_init();
168
    page_init();
166
    tlb_init();
169
    tlb_init();
167
    arch_post_mm_init();
170
    arch_post_mm_init();   
168
 
-
 
169
    version_print();
171
    version_print();
170
 
172
 
171
    printf("%P: hardcoded_ktext_size=%dK, hardcoded_kdata_size=%dK\n",
173
    printf("%P: hardcoded_ktext_size=%dK, hardcoded_kdata_size=%dK\n",
172
        config.base, hardcoded_ktext_size/1024, hardcoded_kdata_size/1024);
174
        config.base, hardcoded_ktext_size/1024, hardcoded_kdata_size/1024);
173
 
175
 
Line 176... Line 178...
176
    /* Slab must be initialized AFTER we know the number of processors */
178
    /* Slab must be initialized AFTER we know the number of processors */
177
    slab_enable_cpucache();
179
    slab_enable_cpucache();
178
 
180
 
179
    printf("config.memory_size=%dM\n", config.memory_size/(1024*1024));
181
    printf("config.memory_size=%dM\n", config.memory_size/(1024*1024));
180
    printf("config.cpu_count=%d\n", config.cpu_count);
182
    printf("config.cpu_count=%d\n", config.cpu_count);
181
 
-
 
182
    cpu_init();
183
    cpu_init();
183
 
184
 
184
    calibrate_delay_loop();
185
    calibrate_delay_loop();
185
 
-
 
186
    timeout_init();
186
    timeout_init();
187
    scheduler_init();
187
    scheduler_init();
188
    task_init();
188
    task_init();
189
    thread_init();
189
    thread_init();
190
   
190