aboutsummaryrefslogtreecommitdiff
path: root/i386
diff options
context:
space:
mode:
authorDamien Zammit <damien@zamaudio.com>2023-06-20 10:29:38 +0000
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2023-06-20 13:30:09 +0200
commitd5464d531aaba049a3e734adb80fb0bfd28093a7 (patch)
tree64d0c263fe5ebe25ef10321931bafa5fb6e070c0 /i386
parented7f24debd15745f9e6c20151ec1c5989b58de4e (diff)
downloadgnumach-d5464d531aaba049a3e734adb80fb0bfd28093a7.tar.gz
gnumach-d5464d531aaba049a3e734adb80fb0bfd28093a7.tar.bz2
gnumach-d5464d531aaba049a3e734adb80fb0bfd28093a7.zip
i386/apic.c: Pre-initialize the lapic pointer with a dummy structure
Fixes an early crash when APIC is defined, NCPUS > 1 and LINUX_DEV is not defined. CPU_NUMBER can now be called before the local apic pointer is properly initialized. Message-Id: <20230620102925.551321-1-damien@zamaudio.com>
Diffstat (limited to 'i386')
-rw-r--r--i386/i386/apic.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/i386/i386/apic.c b/i386/i386/apic.c
index ff7ba3e2..c399074d 100644
--- a/i386/i386/apic.c
+++ b/i386/i386/apic.c
@@ -27,7 +27,13 @@
#include <kern/kalloc.h>
-volatile ApicLocalUnit* lapic = NULL;
+/*
+ * This dummy structure is needed so that CPU_NUMBER can be called
+ * before the lapic pointer is initialized to point to the real Local Apic.
+ * It causes the apic_id to be faked as 0, which is the master processor.
+ */
+static ApicLocalUnit dummy_lapic = {0};
+volatile ApicLocalUnit* lapic = &dummy_lapic;
ApicInfo apic_data;