Subversion Repositories HelenOS-historic

Rev

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

Rev 955 Rev 1037
Line 61... Line 61...
61
#include <arch/smp/mps.h>
61
#include <arch/smp/mps.h>
62
#endif /* CONFIG_SMP */
62
#endif /* CONFIG_SMP */
63
#include <smp/smp.h>
63
#include <smp/smp.h>
64
 
64
 
65
config_t config;    /**< Global configuration structure. */
65
config_t config;    /**< Global configuration structure. */
-
 
66
init_t init = {0};  /**< Initial user-space tasks */
66
 
67
 
67
context_t ctx;
68
context_t ctx;
68
 
69
 
69
/**
70
/**
70
 * These 'hardcoded' variables will be intialized by
71
 * These 'hardcoded' variables will be intialized by
Line 73... Line 74...
73
 */
74
 */
74
__address hardcoded_load_address = 0;
75
__address hardcoded_load_address = 0;
75
size_t hardcoded_ktext_size = 0;
76
size_t hardcoded_ktext_size = 0;
76
size_t hardcoded_kdata_size = 0;
77
size_t hardcoded_kdata_size = 0;
77
 
78
 
78
__address init_addr = 0;
-
 
79
size_t init_size = 0;
-
 
80
 
-
 
81
void main_bsp(void);
79
void main_bsp(void);
82
void main_ap(void);
80
void main_ap(void);
83
 
81
 
84
/*
82
/*
85
 * These two functions prevent stack from underflowing during the
83
 * These two functions prevent stack from underflowing during the
Line 108... Line 106...
108
    config.cpu_count = 1;
106
    config.cpu_count = 1;
109
    config.cpu_active = 1;
107
    config.cpu_active = 1;
110
   
108
   
111
    config.base = hardcoded_load_address;
109
    config.base = hardcoded_load_address;
112
    config.memory_size = get_memory_size();
110
    config.memory_size = get_memory_size();
113
    config.init_addr = init_addr;
-
 
114
    config.init_size = init_size;
-
 
115
   
111
   
116
    config.kernel_size = ALIGN_UP(hardcoded_ktext_size + hardcoded_kdata_size, PAGE_SIZE);
112
    config.kernel_size = ALIGN_UP(hardcoded_ktext_size + hardcoded_kdata_size, PAGE_SIZE);
117
    stackaddr = config.base + config.kernel_size;
113
    stackaddr = config.base + config.kernel_size;
-
 
114
   
118
    /* Avoid placing kernel on top of init */
115
    /* Avoid placing kernel on top of init */
-
 
116
    count_t i;
119
    if (overlaps(stackaddr,CONFIG_STACK_SIZE,
117
    bool overlap = false;
120
             config.init_addr, config.init_size)) {
118
    for (i = 0; i < init.cnt; i++)
121
       
-
 
122
        stackaddr = ALIGN_UP(config.init_addr+config.init_size,
119
        if (overlaps(stackaddr, CONFIG_STACK_SIZE, init.tasks[i].addr, init.tasks[i].size)) {
123
                     CONFIG_STACK_SIZE);
120
            stackaddr = ALIGN_UP(init.tasks[i].addr + init.tasks[i].size, CONFIG_STACK_SIZE);
124
        config.init_size = ALIGN_UP(config.init_size,CONFIG_STACK_SIZE) + CONFIG_STACK_SIZE;
121
            init.tasks[i].size = ALIGN_UP(init.tasks[i].size, CONFIG_STACK_SIZE) + CONFIG_STACK_SIZE;
-
 
122
            overlap = true;
-
 
123
        }
-
 
124
   
125
    } else {
125
    if (!overlap)
126
        config.kernel_size += CONFIG_STACK_SIZE;
126
        config.kernel_size += CONFIG_STACK_SIZE;
127
    }
-
 
128
   
127
   
129
    context_save(&ctx);
128
    context_save(&ctx);
130
    context_set(&ctx, FADDR(main_bsp_separated_stack),
129
    context_set(&ctx, FADDR(main_bsp_separated_stack),
131
            stackaddr, CONFIG_STACK_SIZE);
130
            stackaddr, CONFIG_STACK_SIZE);
132
    context_restore(&ctx);
131
    context_restore(&ctx);
Line 149... Line 148...
149
     * kconsole data structures must be initialized very early
148
     * kconsole data structures must be initialized very early
150
     * because other subsystems will register their respective
149
     * because other subsystems will register their respective
151
     * commands.
150
     * commands.
152
     */
151
     */
153
    kconsole_init();
152
    kconsole_init();
154
 
153
   
155
    /*
154
    /*
156
     * Exception handler initialization, before architecture
155
     * Exception handler initialization, before architecture
157
     * starts adding its own handlers
156
     * starts adding its own handlers
158
     */
157
     */
159
    exc_init();
158
    exc_init();
Line 187... Line 186...
187
    timeout_init();
186
    timeout_init();
188
    scheduler_init();
187
    scheduler_init();
189
    task_init();
188
    task_init();
190
    thread_init();
189
    thread_init();
191
   
190
   
-
 
191
    count_t i;
192
    if (config.init_size > 0)
192
    for (i = 0; i < init.cnt; i++)
193
        printf("config.init_addr=%P, config.init_size=%d\n", config.init_addr, config.init_size);
193
        printf("init[%d].addr=%P, init[%d].size=%d\n", i, init.tasks[i].addr, i, init.tasks[i].size);
194
   
194
   
195
    ipc_init();
195
    ipc_init();
196
    /*
196
    /*
197
     * Create kernel task.
197
     * Create kernel task.
198
     */
198
     */