Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/main/main.c

    r7e752b2 rbae6169  
    8484#include <main/main.h>
    8585#include <ipc/event.h>
    86 #include <sysinfo/sysinfo.h>
    87 #include <sysinfo/stats.h>
    8886
    8987/** Global configuration structure. */
     
    9795/** Boot allocations. */
    9896ballocs_t ballocs = {
    99         .base = (uintptr_t) NULL,
     97        .base = NULL,
    10098        .size = 0
    10199};
     
    104102
    105103/** Lowest safe stack virtual address. */
    106 uintptr_t stack_safe = 0;
     104uintptr_t stack_safe = 0;               
    107105
    108106/*
     
    113111 */
    114112static void main_bsp_separated_stack(void);
    115 
    116113#ifdef CONFIG_SMP
    117114static void main_ap_separated_stack(void);
    118115#endif
    119116
    120 #define CONFIG_STACK_SIZE  ((1 << STACK_FRAMES) * STACK_SIZE)
     117#define CONFIG_STACK_SIZE       ((1 << STACK_FRAMES) * STACK_SIZE)
    121118
    122119/** Main kernel routine for bootstrap CPU.
     
    131128 *
    132129 */
    133 NO_TRACE void main_bsp(void)
     130void main_bsp(void)
    134131{
    135132        config.cpu_count = 1;
     
    147144        size_t i;
    148145        for (i = 0; i < init.cnt; i++) {
    149                 if (PA_OVERLAPS(config.stack_base, config.stack_size,
     146                if (PA_overlaps(config.stack_base, config.stack_size,
    150147                    init.tasks[i].addr, init.tasks[i].size))
    151148                        config.stack_base = ALIGN_UP(init.tasks[i].addr +
    152149                            init.tasks[i].size, config.stack_size);
    153150        }
    154        
     151
    155152        /* Avoid placing stack on top of boot allocations. */
    156153        if (ballocs.size) {
    157                 if (PA_OVERLAPS(config.stack_base, config.stack_size,
     154                if (PA_overlaps(config.stack_base, config.stack_size,
    158155                    ballocs.base, ballocs.size))
    159156                        config.stack_base = ALIGN_UP(ballocs.base +
     
    171168}
    172169
     170
    173171/** Main kernel routine for bootstrap CPU using new stack.
    174172 *
     
    176174 *
    177175 */
    178 void main_bsp_separated_stack(void)
     176void main_bsp_separated_stack(void) 
    179177{
    180178        /* Keep this the first thing. */
     
    183181        version_print();
    184182       
    185         LOG("\nconfig.base=%p config.kernel_size=%zu"
    186             "\nconfig.stack_base=%p config.stack_size=%zu",
     183        LOG("\nconfig.base=%#" PRIp " config.kernel_size=%" PRIs
     184            "\nconfig.stack_base=%#" PRIp " config.stack_size=%" PRIs,
    187185            config.base, config.kernel_size, config.stack_base,
    188186            config.stack_size);
     
    194192         * commands.
    195193         */
    196         kconsole_init();
     194        LOG_EXEC(kconsole_init());
    197195#endif
    198196       
     
    201199         * starts adding its own handlers
    202200         */
    203         exc_init();
     201        LOG_EXEC(exc_init());
    204202       
    205203        /*
    206204         * Memory management subsystems initialization.
    207205         */
    208         arch_pre_mm_init();
    209         frame_init();
     206        LOG_EXEC(arch_pre_mm_init());
     207        LOG_EXEC(frame_init());
    210208       
    211209        /* Initialize at least 1 memory segment big enough for slab to work. */
    212         slab_cache_init();
    213         sysinfo_init();
    214         btree_init();
    215         as_init();
    216         page_init();
    217         tlb_init();
    218         ddi_init();
    219         tasklet_init();
    220         arch_post_mm_init();
    221         arch_pre_smp_init();
    222         smp_init();
     210        LOG_EXEC(slab_cache_init());
     211        LOG_EXEC(btree_init());
     212        LOG_EXEC(as_init());
     213        LOG_EXEC(page_init());
     214        LOG_EXEC(tlb_init());
     215        LOG_EXEC(ddi_init());
     216        LOG_EXEC(tasklet_init());
     217        LOG_EXEC(arch_post_mm_init());
     218        LOG_EXEC(arch_pre_smp_init());
     219        LOG_EXEC(smp_init());
    223220       
    224221        /* Slab must be initialized after we know the number of processors. */
    225         slab_enable_cpucache();
    226        
    227         printf("Detected %u CPU(s), %" PRIu64 " MiB free memory\n",
    228             config.cpu_count, SIZE2MB(zones_total_size()));
    229        
    230         cpu_init();
    231        
    232         calibrate_delay_loop();
    233         clock_counter_init();
    234         timeout_init();
    235         scheduler_init();
    236         task_init();
    237         thread_init();
    238         futex_init();
     222        LOG_EXEC(slab_enable_cpucache());
     223       
     224        printf("Detected %" PRIs " CPU(s), %" PRIu64" MiB free memory\n",
     225            config.cpu_count, SIZE2MB(zone_total_size()));
     226       
     227        LOG_EXEC(cpu_init());
     228       
     229        LOG_EXEC(calibrate_delay_loop());
     230        LOG_EXEC(clock_counter_init());
     231        LOG_EXEC(timeout_init());
     232        LOG_EXEC(scheduler_init());
     233        LOG_EXEC(task_init());
     234        LOG_EXEC(thread_init());
     235        LOG_EXEC(futex_init());
    239236       
    240237        if (init.cnt > 0) {
    241238                size_t i;
    242239                for (i = 0; i < init.cnt; i++)
    243                         LOG("init[%zu].addr=%p, init[%zu].size=%zu",
    244                             i, init.tasks[i].addr, i, init.tasks[i].size);
     240                        LOG("init[%" PRIs "].addr=%#" PRIp ", init[%" PRIs
     241                            "].size=%#" PRIs, i, init.tasks[i].addr, i,
     242                            init.tasks[i].size);
    245243        } else
    246244                printf("No init binaries found.\n");
    247245       
    248         ipc_init();
    249         event_init();
    250         klog_init();
    251         stats_init();
     246        LOG_EXEC(ipc_init());
     247        LOG_EXEC(event_init());
     248        LOG_EXEC(klog_init());
    252249       
    253250        /*
     
    265262        if (!kinit_thread)
    266263                panic("Cannot create kinit thread.");
    267         thread_ready(kinit_thread);
     264        LOG_EXEC(thread_ready(kinit_thread));
    268265       
    269266        /*
     
    275272}
    276273
     274
    277275#ifdef CONFIG_SMP
    278 
    279276/** Main kernel routine for application CPUs.
    280277 *
     
    295292         */
    296293        config.cpu_active++;
    297        
     294
    298295        /*
    299296         * The THE structure is well defined because ctx.sp is used as stack.
     
    310307        calibrate_delay_loop();
    311308        arch_post_cpu_init();
    312        
     309
    313310        the_copy(THE, (the_t *) CPU->stack);
    314        
     311
    315312        /*
    316313         * If we woke kmp up before we left the kernel stack, we could
     
    325322}
    326323
     324
    327325/** Main kernel routine for application CPUs using new stack.
    328326 *
     
    336334         */
    337335        timeout_init();
    338        
     336
    339337        waitq_wakeup(&ap_completion_wq, WAKEUP_FIRST);
    340338        scheduler();
    341339        /* not reached */
    342340}
    343 
    344341#endif /* CONFIG_SMP */
    345342
Note: See TracChangeset for help on using the changeset viewer.