Ignore:
File:
1 edited

Legend:

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

    r98000fb r1caeb2d  
    8484#include <main/main.h>
    8585#include <ipc/event.h>
     86#include <sysinfo/sysinfo.h>
     87#include <sysinfo/stats.h>
    8688
    8789/** Global configuration structure. */
     
    9597/** Boot allocations. */
    9698ballocs_t ballocs = {
    97         .base = NULL,
     99        .base = (uintptr_t) NULL,
    98100        .size = 0
    99101};
     
    101103context_t ctx;
    102104
    103 /*
    104  * These 'hardcoded' variables will be intialized by
    105  * the linker or the low level assembler code with
    106  * appropriate sizes and addresses.
    107  */
    108 
    109 /** Virtual address of where the kernel is loaded. */
    110 uintptr_t hardcoded_load_address = 0;
    111 /** Size of the kernel code in bytes. */
    112 size_t hardcoded_ktext_size = 0;
    113 /** Size of the kernel data in bytes. */
    114 size_t hardcoded_kdata_size = 0;
    115105/** Lowest safe stack virtual address. */
    116 uintptr_t stack_safe = 0;               
     106uintptr_t stack_safe = 0;
    117107
    118108/*
     
    123113 */
    124114static void main_bsp_separated_stack(void);
     115
    125116#ifdef CONFIG_SMP
    126117static void main_ap_separated_stack(void);
    127118#endif
    128119
    129 #define CONFIG_STACK_SIZE       ((1 << STACK_FRAMES) * STACK_SIZE)
     120#define CONFIG_STACK_SIZE  ((1 << STACK_FRAMES) * STACK_SIZE)
    130121
    131122/** Main kernel routine for bootstrap CPU.
     
    140131 *
    141132 */
    142 void main_bsp(void)
     133NO_TRACE void main_bsp(void)
    143134{
    144135        config.cpu_count = 1;
     
    156147        size_t i;
    157148        for (i = 0; i < init.cnt; i++) {
    158                 if (PA_overlaps(config.stack_base, config.stack_size,
     149                if (PA_OVERLAPS(config.stack_base, config.stack_size,
    159150                    init.tasks[i].addr, init.tasks[i].size))
    160151                        config.stack_base = ALIGN_UP(init.tasks[i].addr +
    161152                            init.tasks[i].size, config.stack_size);
    162153        }
    163 
     154       
    164155        /* Avoid placing stack on top of boot allocations. */
    165156        if (ballocs.size) {
    166                 if (PA_overlaps(config.stack_base, config.stack_size,
     157                if (PA_OVERLAPS(config.stack_base, config.stack_size,
    167158                    ballocs.base, ballocs.size))
    168159                        config.stack_base = ALIGN_UP(ballocs.base +
     
    180171}
    181172
    182 
    183173/** Main kernel routine for bootstrap CPU using new stack.
    184174 *
     
    186176 *
    187177 */
    188 void main_bsp_separated_stack(void) 
     178void main_bsp_separated_stack(void)
    189179{
    190180        /* Keep this the first thing. */
     
    193183        version_print();
    194184       
    195         LOG("\nconfig.base=%#" PRIp " config.kernel_size=%" PRIs
    196             "\nconfig.stack_base=%#" PRIp " config.stack_size=%" PRIs,
    197             config.base, config.kernel_size, config.stack_base,
    198             config.stack_size);
     185        LOG("\nconfig.base=%p config.kernel_size=%zu"
     186            "\nconfig.stack_base=%p config.stack_size=%zu",
     187            (void *) config.base, config.kernel_size,
     188            (void *) config.stack_base, config.stack_size);
    199189       
    200190#ifdef CONFIG_KCONSOLE
     
    204194         * commands.
    205195         */
    206         LOG_EXEC(kconsole_init());
     196        kconsole_init();
    207197#endif
    208198       
     
    211201         * starts adding its own handlers
    212202         */
    213         LOG_EXEC(exc_init());
     203        exc_init();
    214204       
    215205        /*
    216206         * Memory management subsystems initialization.
    217207         */
    218         LOG_EXEC(arch_pre_mm_init());
    219         LOG_EXEC(frame_init());
     208        arch_pre_mm_init();
     209        frame_init();
    220210       
    221211        /* Initialize at least 1 memory segment big enough for slab to work. */
    222         LOG_EXEC(slab_cache_init());
    223         LOG_EXEC(btree_init());
    224         LOG_EXEC(as_init());
    225         LOG_EXEC(page_init());
    226         LOG_EXEC(tlb_init());
    227         LOG_EXEC(ddi_init());
    228         LOG_EXEC(tasklet_init());
    229         LOG_EXEC(arch_post_mm_init());
    230         LOG_EXEC(arch_pre_smp_init());
    231         LOG_EXEC(smp_init());
     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();
    232223       
    233224        /* Slab must be initialized after we know the number of processors. */
    234         LOG_EXEC(slab_enable_cpucache());
    235        
    236         printf("Detected %" PRIs " CPU(s), %" PRIu64" MiB free memory\n",
    237             config.cpu_count, SIZE2MB(zone_total_size()));
    238        
    239         LOG_EXEC(cpu_init());
    240        
    241         LOG_EXEC(calibrate_delay_loop());
    242         LOG_EXEC(clock_counter_init());
    243         LOG_EXEC(timeout_init());
    244         LOG_EXEC(scheduler_init());
    245         LOG_EXEC(task_init());
    246         LOG_EXEC(thread_init());
    247         LOG_EXEC(futex_init());
     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();
    248239       
    249240        if (init.cnt > 0) {
    250241                size_t i;
    251242                for (i = 0; i < init.cnt; i++)
    252                         LOG("init[%" PRIs "].addr=%#" PRIp ", init[%" PRIs
    253                             "].size=%#" PRIs, i, init.tasks[i].addr, i,
    254                             init.tasks[i].size);
     243                        LOG("init[%zu].addr=%p, init[%zu].size=%zu",
     244                            i, (void *) init.tasks[i].addr, i, init.tasks[i].size);
    255245        } else
    256246                printf("No init binaries found.\n");
    257247       
    258         LOG_EXEC(ipc_init());
    259         LOG_EXEC(event_init());
    260         LOG_EXEC(klog_init());
     248        ipc_init();
     249        event_init();
     250        klog_init();
     251        stats_init();
    261252       
    262253        /*
     
    274265        if (!kinit_thread)
    275266                panic("Cannot create kinit thread.");
    276         LOG_EXEC(thread_ready(kinit_thread));
     267        thread_ready(kinit_thread);
    277268       
    278269        /*
     
    284275}
    285276
    286 
    287277#ifdef CONFIG_SMP
     278
    288279/** Main kernel routine for application CPUs.
    289280 *
     
    304295         */
    305296        config.cpu_active++;
    306 
     297       
    307298        /*
    308299         * The THE structure is well defined because ctx.sp is used as stack.
     
    319310        calibrate_delay_loop();
    320311        arch_post_cpu_init();
    321 
     312       
    322313        the_copy(THE, (the_t *) CPU->stack);
    323 
     314       
    324315        /*
    325316         * If we woke kmp up before we left the kernel stack, we could
     
    334325}
    335326
    336 
    337327/** Main kernel routine for application CPUs using new stack.
    338328 *
     
    346336         */
    347337        timeout_init();
    348 
     338       
    349339        waitq_wakeup(&ap_completion_wq, WAKEUP_FIRST);
    350340        scheduler();
    351341        /* not reached */
    352342}
     343
    353344#endif /* CONFIG_SMP */
    354345
Note: See TracChangeset for help on using the changeset viewer.