From d330cc09e22a68625556b8cc012b4732330a9769 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Thu, 21 Oct 2004 01:45:43 +0000 Subject: [PATCH] Renamed some init2() functions to init_post_vm() to make clearer when and why they are called. Introduced a cpu_init_post_vm() that will now call arch_init_post_vm() instead of letting main() doing it. Fixed some return types (mostly from int to status_t). Some minor other cleanup. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@9439 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kernel/core/cpu.c | 32 +++++++++++++++++++------------- src/kernel/core/debug.c | 12 ++++++------ src/kernel/core/int.c | 16 ++++++++-------- src/kernel/core/main.c | 14 +++++++------- 4 files changed, 40 insertions(+), 34 deletions(-) diff --git a/src/kernel/core/cpu.c b/src/kernel/core/cpu.c index aacc4fe119..1a87677999 100644 --- a/src/kernel/core/cpu.c +++ b/src/kernel/core/cpu.c @@ -1,14 +1,12 @@ -/* This file contains the cpu functions (init, etc). */ - /* +** Copyright 2002-2004, The Haiku Team. All rights reserved. +** Distributed under the terms of the Haiku License. +** ** Copyright 2002, Travis Geiselbrecht. All rights reserved. ** Distributed under the terms of the NewOS License. */ -// ToDo: fix the atomic_*() functions and possibly move them elsewhere; -// they are exported in libroot.so anyway, so the best place would -// probably there. - +/* This file contains the cpu functions (init, etc). */ #include #include @@ -18,26 +16,34 @@ #include + /* global per-cpu structure */ cpu_ent cpu[MAX_BOOT_CPUS]; -int -cpu_init(kernel_args *ka) +status_t +cpu_init(kernel_args *args) { int i; memset(cpu, 0, sizeof(cpu)); - for(i = 0; i < MAX_BOOT_CPUS; i++) { + for (i = 0; i < MAX_BOOT_CPUS; i++) { cpu[i].info.cpu_num = i; } - return arch_cpu_init(ka); + return arch_cpu_init(args); } -int -cpu_preboot_init(kernel_args *ka) +status_t +cpu_init_post_vm(kernel_args *args) { - return arch_cpu_preboot_init(ka); + return arch_cpu_init_post_vm(args); +} + + +status_t +cpu_preboot_init(kernel_args *args) +{ + return arch_cpu_preboot_init(args); } diff --git a/src/kernel/core/debug.c b/src/kernel/core/debug.c index 72c753e184..b262a0ff5a 100644 --- a/src/kernel/core/debug.c +++ b/src/kernel/core/debug.c @@ -348,15 +348,15 @@ cmd_continue(int argc, char **argv) } -int -dbg_init(kernel_args *ka) +status_t +debug_init(kernel_args *args) { - return arch_dbg_con_init(ka); + return arch_dbg_con_init(args); } -int -dbg_init2(kernel_args *ka) +status_t +debug_init_post_vm(kernel_args *args) { add_debugger_command("help", &cmd_help, "List all debugger commands"); add_debugger_command("reboot", &cmd_reboot, "Reboot the system"); @@ -365,7 +365,7 @@ dbg_init2(kernel_args *ka) add_debugger_command("exit", &cmd_continue, NULL); add_debugger_command("es", &cmd_continue, NULL); - return arch_dbg_init(ka); + return arch_dbg_init(args); } // ToDo: this one is probably not needed diff --git a/src/kernel/core/int.c b/src/kernel/core/int.c index 0cc8b7c31c..09feb652bb 100644 --- a/src/kernel/core/int.c +++ b/src/kernel/core/int.c @@ -45,23 +45,23 @@ restore_interrupts(cpu_status status) } -int -int_init(kernel_args *ka) +status_t +int_init(kernel_args *args) { dprintf("init_int_handlers: entry\n"); - return arch_int_init(ka); + return arch_int_init(args); } -int -int_init2(kernel_args *ka) +status_t +int_init_post_vm(kernel_args *args) { int i; - + io_vectors = (struct io_vector *)malloc(sizeof(struct io_vector) * NUM_IO_VECTORS); if (io_vectors == NULL) - panic("int_init2: could not create io vector table!\n"); + panic("int_init_post_vm: could not create io vector table!\n"); /* initialize the vector list */ for (i = 0; i < NUM_IO_VECTORS; i++) { @@ -69,7 +69,7 @@ int_init2(kernel_args *ka) initque(&io_vectors[i].handler_list); /* initialize handler queue */ } - return arch_int_init2(ka); + return arch_int_init_post_vm(args); } diff --git a/src/kernel/core/main.c b/src/kernel/core/main.c index 8986655fc0..f10bb64427 100644 --- a/src/kernel/core/main.c +++ b/src/kernel/core/main.c @@ -14,8 +14,6 @@ #include #include #include -#include -#include #include #include #include @@ -77,7 +75,7 @@ _start(kernel_args *oldka, int cpu_num) smp_wait_for_ap_cpus(&ka); // setup debug output - dbg_init(&ka); + debug_init(&ka); set_dprintf_enabled(true); dprintf("Welcome to kernel debugger output!\n"); @@ -86,19 +84,21 @@ _start(kernel_args *oldka, int cpu_num) int_init(&ka); vm_init(&ka); + // Before vm_init_post_sem() is called, we have to make sure that + // the boot loader allocated region is not used anymore + TRACE(("vm up\n")); // now we can use the heap and create areas - dbg_init2(&ka); - int_init2(&ka); + debug_init_post_vm(&ka); + int_init_post_vm(&ka); + cpu_init_post_vm(&ka); faults_init(&ka); smp_init(&ka); rtc_init(&ka); timer_init(&ka); - arch_cpu_init2(&ka); - sem_init(&ka); TRACE(("##################################################################\n"));