Ignore:
File:
1 edited

Legend:

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

    r1caeb2d r98000fb  
    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};
     
    103101context_t ctx;
    104102
     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. */
     110uintptr_t hardcoded_load_address = 0;
     111/** Size of the kernel code in bytes. */
     112size_t hardcoded_ktext_size = 0;
     113/** Size of the kernel data in bytes. */
     114size_t hardcoded_kdata_size = 0;
    105115/** Lowest safe stack virtual address. */
    106 uintptr_t stack_safe = 0;
     116uintptr_t stack_safe = 0;               
    107117
    108118/*
     
    113123 */
    114124static void main_bsp_separated_stack(void);
    115 
    116125#ifdef CONFIG_SMP
    117126static void main_ap_separated_stack(void);
    118127#endif
    119128
    120 #define CONFIG_STACK_SIZE  ((1 << STACK_FRAMES) * STACK_SIZE)
     129#define CONFIG_STACK_SIZE       ((1 << STACK_FRAMES) * STACK_SIZE)
    121130
    122131/** Main kernel routine for bootstrap CPU.
     
    131140 *
    132141 */
    133 NO_TRACE void main_bsp(void)
     142void main_bsp(void)
    134143{
    135144        config.cpu_count = 1;
     
    147156        size_t i;
    148157        for (i = 0; i < init.cnt; i++) {
    149                 if (PA_OVERLAPS(config.stack_base, config.stack_size,
     158                if (PA_overlaps(config.stack_base, config.stack_size,
    150159                    init.tasks[i].addr, init.tasks[i].size))
    151160                        config.stack_base = ALIGN_UP(init.tasks[i].addr +
    152161                            init.tasks[i].size, config.stack_size);
    153162        }
    154        
     163
    155164        /* Avoid placing stack on top of boot allocations. */
    156165        if (ballocs.size) {
    157                 if (PA_OVERLAPS(config.stack_base, config.stack_size,
     166                if (PA_overlaps(config.stack_base, config.stack_size,
    158167                    ballocs.base, ballocs.size))
    159168                        config.stack_base = ALIGN_UP(ballocs.base +
     
    171180}
    172181
     182
    173183/** Main kernel routine for bootstrap CPU using new stack.
    174184 *
     
    176186 *
    177187 */
    178 void main_bsp_separated_stack(void)
     188void main_bsp_separated_stack(void) 
    179189{
    180190        /* Keep this the first thing. */
     
    183193        version_print();
    184194       
    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);
     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);
    189199       
    190200#ifdef CONFIG_KCONSOLE
     
    194204         * commands.
    195205         */
    196         kconsole_init();
     206        LOG_EXEC(kconsole_init());
    197207#endif
    198208       
     
    201211         * starts adding its own handlers
    202212         */
    203         exc_init();
     213        LOG_EXEC(exc_init());
    204214       
    205215        /*
    206216         * Memory management subsystems initialization.
    207217         */
    208         arch_pre_mm_init();
    209         frame_init();
     218        LOG_EXEC(arch_pre_mm_init());
     219        LOG_EXEC(frame_init());
    210220       
    211221        /* 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();
     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());
    223232       
    224233        /* 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();
     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());
    239248       
    240249        if (init.cnt > 0) {
    241250                size_t i;
    242251                for (i = 0; i < init.cnt; i++)
    243                         LOG("init[%zu].addr=%p, init[%zu].size=%zu",
    244                             i, (void *) init.tasks[i].addr, i, init.tasks[i].size);
     252                        LOG("init[%" PRIs "].addr=%#" PRIp ", init[%" PRIs
     253                            "].size=%#" PRIs, i, init.tasks[i].addr, i,
     254                            init.tasks[i].size);
    245255        } else
    246256                printf("No init binaries found.\n");
    247257       
    248         ipc_init();
    249         event_init();
    250         klog_init();
    251         stats_init();
     258        LOG_EXEC(ipc_init());
     259        LOG_EXEC(event_init());
     260        LOG_EXEC(klog_init());
    252261       
    253262        /*
     
    265274        if (!kinit_thread)
    266275                panic("Cannot create kinit thread.");
    267         thread_ready(kinit_thread);
     276        LOG_EXEC(thread_ready(kinit_thread));
    268277       
    269278        /*
     
    275284}
    276285
     286
    277287#ifdef CONFIG_SMP
    278 
    279288/** Main kernel routine for application CPUs.
    280289 *
     
    295304         */
    296305        config.cpu_active++;
    297        
     306
    298307        /*
    299308         * The THE structure is well defined because ctx.sp is used as stack.
     
    310319        calibrate_delay_loop();
    311320        arch_post_cpu_init();
    312        
     321
    313322        the_copy(THE, (the_t *) CPU->stack);
    314        
     323
    315324        /*
    316325         * If we woke kmp up before we left the kernel stack, we could
     
    325334}
    326335
     336
    327337/** Main kernel routine for application CPUs using new stack.
    328338 *
     
    336346         */
    337347        timeout_init();
    338        
     348
    339349        waitq_wakeup(&ap_completion_wq, WAKEUP_FIRST);
    340350        scheduler();
    341351        /* not reached */
    342352}
    343 
    344353#endif /* CONFIG_SMP */
    345354
Note: See TracChangeset for help on using the changeset viewer.