From ed09fa58fb5778d943b2636b13c873fa68d4daac Mon Sep 17 00:00:00 2001 From: Richard Braun Date: Thu, 14 Mar 2013 22:26:24 +0100 Subject: kern/{kernel,thread}: rework initialization Make cpu_count() available on kernel entry so that modules (and in particular the thread module) can allocate per-CPU resources from the BSP. This makes the initial state stable and simplifies code (no need to check for a transient early initialization state). --- kern/kernel.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'kern/kernel.c') diff --git a/kern/kernel.c b/kern/kernel.c index 07a0f660..93c0c19c 100644 --- a/kern/kernel.c +++ b/kern/kernel.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012 Richard Braun. + * Copyright (c) 2011, 2012, 2013 Richard Braun. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -27,12 +27,17 @@ kernel_main(void) { assert(!cpu_intr_enabled()); + /* Enable interrupts to allow inter-processor pmap updates */ + cpu_intr_enable(); + + /* Initialize the kernel */ task_setup(); thread_setup(); - cpu_intr_enable(); - cpu_mp_setup(); + /* Rendezvous with APs */ + cpu_mp_sync(); + /* Run the scheduler */ thread_run(); /* Never reached */ @@ -43,9 +48,16 @@ kernel_ap_main(void) { assert(!cpu_intr_enabled()); + /* + * Enable interrupts to allow inter-processor pmap updates while the BSP + * is initializing the kernel. + */ cpu_intr_enable(); + + /* Wait for the BSP to complete kernel initialization */ cpu_ap_sync(); + /* Run the scheduler */ thread_run(); /* Never reached */ -- cgit v1.2.3