summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlmuHS <almuhs@github.com>2019-05-01 16:18:19 +0200
committerAlmuHS <almuhs@github.com>2019-05-01 16:18:19 +0200
commit9812e8c51ab26040534214928a5028ba31ab4bcc (patch)
treecc8cca0c8b879ce66e970579c352234a4295c776
parentb9323fbaa32d27918f26c114272bb99189c5c7c3 (diff)
Fix: reserve memory for all stacks
-rw-r--r--i386/i386/mp_desc.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/i386/i386/mp_desc.c b/i386/i386/mp_desc.c
index 794c8517..ca08bfcb 100644
--- a/i386/i386/mp_desc.c
+++ b/i386/i386/mp_desc.c
@@ -537,19 +537,23 @@ start_other_cpus(void)
machine_slot[0].apic_id = apic_id;
apic2kernel[apic_id] = 0;
+ //Reserve memory for cpu stack
+ if (!init_alloc_aligned(STACK_SIZE*(ncpu-1), &stack_start))
+ panic("not enough memory for cpu stacks");
+ stack_start = phystokv(stack_start);
+
+
for (cpu = 0; cpu < ncpu; cpu++)
{
if (cpu != cpu_number())
{
- if (!init_alloc_aligned(STACK_SIZE*(ncpu-1), &stack_start))
- panic("not enough memory for cpu stacks");
- stack_start = phystokv(stack_start);
- //Initialize cpu stack
- /*TODO: Put stacks in an array */
//*stack_ptr = (void*) kalloc(STACK_SIZE);
+
+ //Initialize cpu stack
cpu_stack[cpu] = stack_start;
_cpu_stack_top[cpu] = stack_start + STACK_SIZE;
+ stack_start += STACK_SIZE;
stack_ptr = (void*) cpu_stack[cpu];