Changeset 46c20c8 in mainline for kernel/generic/src/main


Ignore:
Timestamp:
2010-11-26T20:08:10Z (15 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
45df59a
Parents:
fb150d78 (diff), ffdd2b9 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge mainline changes.

Location:
kernel/generic/src/main
Files:
4 edited

Legend:

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

    rfb150d78 r46c20c8  
    6666#include <ipc/ipc.h>
    6767#include <debug.h>
    68 #include <string.h>
     68#include <str.h>
     69#include <sysinfo/stats.h>
    6970
    7071#ifdef CONFIG_SMP
     
    9495void kinit(void *arg)
    9596{
    96 
    97 #if defined(CONFIG_SMP) || defined(CONFIG_KCONSOLE)
    9897        thread_t *thread;
    99 #endif
    10098       
    10199        /*
     
    109107        if (config.cpu_count > 1) {
    110108                waitq_initialize(&ap_completion_wq);
     109               
    111110                /*
    112111                 * Create the kmp thread and wait for its completion.
     
    117116                thread = thread_create(kmp, NULL, TASK, THREAD_FLAG_WIRED, "kmp", true);
    118117                if (thread != NULL) {
    119                         spinlock_lock(&thread->lock);
     118                        irq_spinlock_lock(&thread->lock, false);
    120119                        thread->cpu = &cpus[0];
    121                         spinlock_unlock(&thread->lock);
     120                        irq_spinlock_unlock(&thread->lock, false);
    122121                        thread_ready(thread);
    123122                } else
    124123                        panic("Unable to create kmp thread.");
     124               
    125125                thread_join(thread);
    126126                thread_detach(thread);
    127         }
    128        
    129         if (config.cpu_count > 1) {
    130                 size_t i;
    131127               
    132128                /*
    133129                 * For each CPU, create its load balancing thread.
    134130                 */
     131                unsigned int i;
     132               
    135133                for (i = 0; i < config.cpu_count; i++) {
    136134                        thread = thread_create(kcpulb, NULL, TASK, THREAD_FLAG_WIRED, "kcpulb", true);
    137135                        if (thread != NULL) {
    138                                 spinlock_lock(&thread->lock);
     136                                irq_spinlock_lock(&thread->lock, false);
    139137                                thread->cpu = &cpus[i];
    140                                 spinlock_unlock(&thread->lock);
     138                                irq_spinlock_unlock(&thread->lock, false);
    141139                                thread_ready(thread);
    142140                        } else
    143                                 printf("Unable to create kcpulb thread for cpu" PRIs "\n", i);
     141                                printf("Unable to create kcpulb thread for cpu%u\n", i);
    144142                }
    145143        }
     
    150148         */
    151149        arch_post_smp_init();
     150       
     151        /* Start thread computing system load */
     152        thread = thread_create(kload, NULL, TASK, 0, "kload", false);
     153        if (thread != NULL)
     154                thread_ready(thread);
     155        else
     156                printf("Unable to create kload thread\n");
    152157       
    153158#ifdef CONFIG_KCONSOLE
     
    174179        for (i = 0; i < init.cnt; i++) {
    175180                if (init.tasks[i].addr % FRAME_SIZE) {
    176                         printf("init[%" PRIs "].addr is not frame aligned\n", i);
     181                        printf("init[%zu].addr is not frame aligned\n", i);
     182                        programs[i].task = NULL;
    177183                        continue;
    178184                }
     
    184190               
    185191                char namebuf[TASK_NAME_BUFLEN];
    186                 char *name;
    187                
    188                 name = init.tasks[i].name;
     192               
     193                const char *name = init.tasks[i].name;
    189194                if (name[0] == 0)
    190195                        name = "<unknown>";
     
    194199                str_cpy(namebuf + INIT_PREFIX_LEN,
    195200                    TASK_NAME_BUFLEN - INIT_PREFIX_LEN, name);
    196 
     201               
    197202                int rc = program_create_from_image((void *) init.tasks[i].addr,
    198203                    namebuf, &programs[i]);
     
    203208                         */
    204209                        cap_set(programs[i].task, CAP_CAP | CAP_MEM_MANAGER |
    205                             CAP_IO_MANAGER | CAP_PREEMPT_CONTROL | CAP_IRQ_REG);
     210                            CAP_IO_MANAGER | CAP_IRQ_REG);
    206211                       
    207212                        if (!ipc_phone_0)
     
    214219                       
    215220                        if (rd != RE_OK)
    216                                 printf("Init binary %" PRIs " not used (error %d)\n", i, rd);
     221                                printf("Init binary %zu not used (error %d)\n", i, rd);
    217222                }
    218223        }
  • kernel/generic/src/main/main.c

    rfb150d78 r46c20c8  
    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};
     
    102104
    103105/** Lowest safe stack virtual address. */
    104 uintptr_t stack_safe = 0;               
     106uintptr_t stack_safe = 0;
    105107
    106108/*
     
    111113 */
    112114static void main_bsp_separated_stack(void);
     115
    113116#ifdef CONFIG_SMP
    114117static void main_ap_separated_stack(void);
    115118#endif
    116119
    117 #define CONFIG_STACK_SIZE       ((1 << STACK_FRAMES) * STACK_SIZE)
     120#define CONFIG_STACK_SIZE  ((1 << STACK_FRAMES) * STACK_SIZE)
    118121
    119122/** Main kernel routine for bootstrap CPU.
     
    128131 *
    129132 */
    130 void main_bsp(void)
     133NO_TRACE void main_bsp(void)
    131134{
    132135        config.cpu_count = 1;
     
    144147        size_t i;
    145148        for (i = 0; i < init.cnt; i++) {
    146                 if (PA_overlaps(config.stack_base, config.stack_size,
     149                if (PA_OVERLAPS(config.stack_base, config.stack_size,
    147150                    init.tasks[i].addr, init.tasks[i].size))
    148151                        config.stack_base = ALIGN_UP(init.tasks[i].addr +
    149152                            init.tasks[i].size, config.stack_size);
    150153        }
    151 
     154       
    152155        /* Avoid placing stack on top of boot allocations. */
    153156        if (ballocs.size) {
    154                 if (PA_overlaps(config.stack_base, config.stack_size,
     157                if (PA_OVERLAPS(config.stack_base, config.stack_size,
    155158                    ballocs.base, ballocs.size))
    156159                        config.stack_base = ALIGN_UP(ballocs.base +
     
    168171}
    169172
    170 
    171173/** Main kernel routine for bootstrap CPU using new stack.
    172174 *
     
    174176 *
    175177 */
    176 void main_bsp_separated_stack(void) 
     178void main_bsp_separated_stack(void)
    177179{
    178180        /* Keep this the first thing. */
     
    181183        version_print();
    182184       
    183         LOG("\nconfig.base=%#" PRIp " config.kernel_size=%" PRIs
    184             "\nconfig.stack_base=%#" PRIp " config.stack_size=%" PRIs,
     185        LOG("\nconfig.base=%p config.kernel_size=%zu"
     186            "\nconfig.stack_base=%p config.stack_size=%zu",
    185187            config.base, config.kernel_size, config.stack_base,
    186188            config.stack_size);
     
    192194         * commands.
    193195         */
    194         LOG_EXEC(kconsole_init());
     196        kconsole_init();
    195197#endif
    196198       
     
    199201         * starts adding its own handlers
    200202         */
    201         LOG_EXEC(exc_init());
     203        exc_init();
    202204       
    203205        /*
    204206         * Memory management subsystems initialization.
    205207         */
    206         LOG_EXEC(arch_pre_mm_init());
    207         LOG_EXEC(frame_init());
     208        arch_pre_mm_init();
     209        frame_init();
    208210       
    209211        /* Initialize at least 1 memory segment big enough for slab to work. */
    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());
     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();
    220223       
    221224        /* Slab must be initialized after we know the number of processors. */
    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());
     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();
    236239       
    237240        if (init.cnt > 0) {
    238241                size_t i;
    239242                for (i = 0; i < init.cnt; i++)
    240                         LOG("init[%" PRIs "].addr=%#" PRIp ", init[%" PRIs
    241                             "].size=%#" PRIs, i, init.tasks[i].addr, i,
    242                             init.tasks[i].size);
     243                        LOG("init[%zu].addr=%p, init[%zu].size=%zu",
     244                            i, init.tasks[i].addr, i, init.tasks[i].size);
    243245        } else
    244246                printf("No init binaries found.\n");
    245247       
    246         LOG_EXEC(ipc_init());
    247         LOG_EXEC(event_init());
    248         LOG_EXEC(klog_init());
     248        ipc_init();
     249        event_init();
     250        klog_init();
     251        stats_init();
    249252       
    250253        /*
     
    262265        if (!kinit_thread)
    263266                panic("Cannot create kinit thread.");
    264         LOG_EXEC(thread_ready(kinit_thread));
     267        thread_ready(kinit_thread);
    265268       
    266269        /*
     
    272275}
    273276
    274 
    275277#ifdef CONFIG_SMP
     278
    276279/** Main kernel routine for application CPUs.
    277280 *
     
    292295         */
    293296        config.cpu_active++;
    294 
     297       
    295298        /*
    296299         * The THE structure is well defined because ctx.sp is used as stack.
     
    307310        calibrate_delay_loop();
    308311        arch_post_cpu_init();
    309 
     312       
    310313        the_copy(THE, (the_t *) CPU->stack);
    311 
     314       
    312315        /*
    313316         * If we woke kmp up before we left the kernel stack, we could
     
    322325}
    323326
    324 
    325327/** Main kernel routine for application CPUs using new stack.
    326328 *
     
    334336         */
    335337        timeout_init();
    336 
     338       
    337339        waitq_wakeup(&ap_completion_wq, WAKEUP_FIRST);
    338340        scheduler();
    339341        /* not reached */
    340342}
     343
    341344#endif /* CONFIG_SMP */
    342345
  • kernel/generic/src/main/uinit.c

    rfb150d78 r46c20c8  
    4242 
    4343#include <main/uinit.h>
    44 #include <arch/types.h>
     44#include <typedefs.h>
    4545#include <proc/thread.h>
    4646#include <userspace.h>
  • kernel/generic/src/main/version.c

    rfb150d78 r46c20c8  
    3737#include <macros.h>
    3838
    39 char *project = "SPARTAN kernel";
    40 char *copyright = "Copyright (c) 2001-2009 HelenOS project";
    41 char *release = STRING(RELEASE);
    42 char *name = STRING(NAME);
    43 char *arch = STRING(KARCH);
     39static const char *project = "SPARTAN kernel";
     40static const char *copyright = "Copyright (c) 2001-2010 HelenOS project";
     41static const char *release = STRING(RELEASE);
     42static const char *name = STRING(NAME);
     43static const char *arch = STRING(KARCH);
    4444
    4545#ifdef REVISION
    46         char *revision = ", revision " STRING(REVISION);
     46        static const char *revision = ", revision " STRING(REVISION);
    4747#else
    48         char *revision = "";
     48        static const char *revision = "";
    4949#endif
    5050
    5151#ifdef TIMESTAMP
    52         char *timestamp = " on " STRING(TIMESTAMP);
     52        static const char *timestamp = " on " STRING(TIMESTAMP);
    5353#else
    54         char *timestamp = "";
     54        static const char *timestamp = "";
    5555#endif
    5656
     
    5959{
    6060        printf("%s, release %s (%s)%s\nBuilt%s for %s\n%s\n",
    61                 project, release, name, revision, timestamp, arch, copyright);
     61            project, release, name, revision, timestamp, arch, copyright);
    6262}
    6363
Note: See TracChangeset for help on using the changeset viewer.