diff options
author | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2020-09-19 21:51:22 +0200 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2020-09-19 21:55:57 +0200 |
commit | a76bc939142f61e615fcc39fc940961e39a26207 (patch) | |
tree | 5224c805761fd68311de079f32b7c4ef0c613bf6 | |
parent | b26973c8018b99bcf8fb071eb2aedc634039eea1 (diff) | |
download | gnumach-a76bc939142f61e615fcc39fc940961e39a26207.tar.gz gnumach-a76bc939142f61e615fcc39fc940961e39a26207.tar.bz2 gnumach-a76bc939142f61e615fcc39fc940961e39a26207.zip |
smp: Add --enable-ncpus option and fix build
* configfrag.ac (--enable-ncpus): Add option to set $mach_ncpus.
* i386/i386/cpu_number.h (CPU_NUMBER, cpu_number): New macros, set to 0 for
now.
* i386/i386/db_interface.c (cpu_interrupt_to_db): New function.
* i386/i386/db_interface.h (cpu_interrupt_to_db): New declaration.
* i386/i386/mp_desc.c (int_stack_base): New array.
(intel_startCPU): New function.
* i386/i386at/model_dep.c: Include <i386/smp.h>
(int_stack_top, int_stack_base): Turn into arrays
(i386at_init): Update accesses accordingly.
* i386/i386at/model_dep.h (int_stack_top, int_stack_base, ON_INT_STACK):
Likewise.
* i386/intel/pmap.c (cpus_active, cpus_idle, cpu_update_needed): Add
variables.
* i386/intel/pmap.h (cpus_active, cpus_idle, cpu_update_needed): Mark
extern.
* kern/cpu_number.h: Include <machine/cpu_number.h>
* linux/dev/arch/i386/kernel/irq.c (local_bh_count, local_irq_count):
Hardcode to the address of intr_count. We will not use the Linux code in
SMP mode anyway.
-rw-r--r-- | configfrag.ac | 5 | ||||
-rw-r--r-- | i386/i386/cpu_number.h | 4 | ||||
-rw-r--r-- | i386/i386/db_interface.c | 4 | ||||
-rw-r--r-- | i386/i386/db_interface.h | 2 | ||||
-rw-r--r-- | i386/i386/mp_desc.c | 5 | ||||
-rw-r--r-- | i386/i386at/model_dep.c | 9 | ||||
-rw-r--r-- | i386/i386at/model_dep.h | 4 | ||||
-rw-r--r-- | i386/intel/pmap.c | 5 | ||||
-rw-r--r-- | i386/intel/pmap.h | 6 | ||||
-rw-r--r-- | kern/cpu_number.h | 2 | ||||
-rw-r--r-- | linux/dev/arch/i386/kernel/irq.c | 3 |
11 files changed, 40 insertions, 9 deletions
diff --git a/configfrag.ac b/configfrag.ac index 91d737ef..3c3ba3aa 100644 --- a/configfrag.ac +++ b/configfrag.ac @@ -45,7 +45,10 @@ AC_DEFINE([BOOTSTRAP_SYMBOLS], [0], [BOOTSTRAP_SYMBOLS]) # Multiprocessor support is still broken. AH_TEMPLATE([MULTIPROCESSOR], [set things up for a uniprocessor]) -mach_ncpus=1 +AC_ARG_ENABLE([ncpus], + AS_HELP_STRING([--enable-ncpus=N], [specify the maximum number of cpus to be supported]), + [mach_ncpus=$enable_ncpus], + [mach_ncpus=1]) AC_DEFINE_UNQUOTED([NCPUS], [$mach_ncpus], [number of CPUs]) [if [ $mach_ncpus -gt 1 ]; then] AC_DEFINE([MULTIPROCESSOR], [1], [set things up for a multiprocessor]) diff --git a/i386/i386/cpu_number.h b/i386/i386/cpu_number.h index f32a44b8..9aef6370 100644 --- a/i386/i386/cpu_number.h +++ b/i386/i386/cpu_number.h @@ -40,6 +40,10 @@ #define CX(addr, reg) addr(,reg,8) #endif +/* XXX For now */ +#define CPU_NUMBER(reg) movl $0,reg +#define cpu_number() 0 + #else /* NCPUS == 1 */ #define CPU_NUMBER(reg) diff --git a/i386/i386/db_interface.c b/i386/i386/db_interface.c index e61d2961..cc23c15c 100644 --- a/i386/i386/db_interface.c +++ b/i386/i386/db_interface.c @@ -97,6 +97,10 @@ void db_load_context(pcb_t pcb) #endif } +void cpu_interrupt_to_db(int i){ + printf("TODO: cpu_interrupt_to_db\n"); +} + void db_get_debug_state( pcb_t pcb, struct i386_debug_state *state) diff --git a/i386/i386/db_interface.h b/i386/i386/db_interface.h index 18ee3291..f0a748f9 100644 --- a/i386/i386/db_interface.h +++ b/i386/i386/db_interface.h @@ -63,6 +63,8 @@ extern int db_user_to_kernel_address( extern void db_task_name (task_t task); +extern void cpu_interrupt_to_db(int i); + #define I386_DB_TYPE_X 0 #define I386_DB_TYPE_W 1 #define I386_DB_TYPE_RW 3 diff --git a/i386/i386/mp_desc.c b/i386/i386/mp_desc.c index 07cc389a..070a5388 100644 --- a/i386/i386/mp_desc.c +++ b/i386/i386/mp_desc.c @@ -52,6 +52,7 @@ */ vm_offset_t interrupt_stack[NCPUS]; vm_offset_t int_stack_top[NCPUS]; +vm_offset_t int_stack_base[NCPUS]; /* * Barrier address. @@ -164,6 +165,10 @@ mp_desc_init(int mycpu) } } +kern_return_t intel_startCPU(int slot_num) +{ + printf("TODO: intel_startCPU\n"); +} /* * Called after all CPUs have been found, but before the VM system diff --git a/i386/i386at/model_dep.c b/i386/i386at/model_dep.c index a13b46af..346f2b9c 100644 --- a/i386/i386at/model_dep.c +++ b/i386/i386at/model_dep.c @@ -65,6 +65,7 @@ #include <i386/vm_param.h> #include <i386/locore.h> #include <i386/model_dep.h> +#include <i386/smp.h> #include <i386at/autoconf.h> #include <i386at/biosmem.h> #include <i386at/elf.h> @@ -133,7 +134,9 @@ boolean_t rebootflag = FALSE; /* exported to kdintr */ /* Interrupt stack. */ static char int_stack[KERNEL_STACK_SIZE] __aligned(KERNEL_STACK_SIZE); -vm_offset_t int_stack_top, int_stack_base; +#if NCPUS <= 1 +vm_offset_t int_stack_top[1], int_stack_base[1]; +#endif #ifdef LINUX_DEV extern void linux_init(void); @@ -532,8 +535,8 @@ i386at_init(void) hyp_p2m_init(); #endif /* MACH_XEN */ - int_stack_base = (vm_offset_t)&int_stack; - int_stack_top = int_stack_base + KERNEL_STACK_SIZE - 4; + int_stack_base[0] = (vm_offset_t)&int_stack; + int_stack_top[0] = int_stack_base[0] + KERNEL_STACK_SIZE - 4; } /* diff --git a/i386/i386at/model_dep.h b/i386/i386at/model_dep.h index d47378a1..a972695f 100644 --- a/i386/i386at/model_dep.h +++ b/i386/i386at/model_dep.h @@ -25,10 +25,10 @@ /* * Interrupt stack. */ -extern vm_offset_t int_stack_top, int_stack_base; +extern vm_offset_t int_stack_top[NCPUS], int_stack_base[NCPUS]; /* Check whether P points to the interrupt stack. */ -#define ON_INT_STACK(P) (((P) & ~(KERNEL_STACK_SIZE-1)) == int_stack_base) +#define ON_INT_STACK(P) (((P) & ~(KERNEL_STACK_SIZE-1)) == int_stack_base[0]) extern vm_offset_t timemmap(dev_t dev, vm_offset_t off, vm_prot_t prot); diff --git a/i386/intel/pmap.c b/i386/intel/pmap.c index 0f650f2a..34b1153c 100644 --- a/i386/intel/pmap.c +++ b/i386/intel/pmap.c @@ -381,6 +381,11 @@ typedef struct pmap_update_list *pmap_update_list_t; struct pmap_update_list cpu_update_list[NCPUS]; +cpu_set cpus_active; +cpu_set cpus_idle; +volatile +boolean_t cpu_update_needed[NCPUS]; + #endif /* NCPUS > 1 */ /* diff --git a/i386/intel/pmap.h b/i386/intel/pmap.h index d6224d87..d2b533c8 100644 --- a/i386/intel/pmap.h +++ b/i386/intel/pmap.h @@ -247,18 +247,18 @@ extern void pmap_put_mapwindow(pmap_mapwindow_t *map); * Update operations must still be queued to cpus not in this * list. */ -cpu_set cpus_active; +extern cpu_set cpus_active; /* * List of cpus that are idle, but still operating, and will want * to see any kernel pmap updates when they become active. */ -cpu_set cpus_idle; +extern cpu_set cpus_idle; /* * Quick test for pmap update requests. */ -volatile +extern volatile boolean_t cpu_update_needed[NCPUS]; /* diff --git a/kern/cpu_number.h b/kern/cpu_number.h index e7b65324..0be2d338 100644 --- a/kern/cpu_number.h +++ b/kern/cpu_number.h @@ -27,6 +27,8 @@ #ifndef _KERN_CPU_NUMBER_H_ #define _KERN_CPU_NUMBER_H_ +#include <machine/cpu_number.h> + /* * Definitions for cpu identification in multi-processors. */ diff --git a/linux/dev/arch/i386/kernel/irq.c b/linux/dev/arch/i386/kernel/irq.c index 1e911f33..522ed0ac 100644 --- a/linux/dev/arch/i386/kernel/irq.c +++ b/linux/dev/arch/i386/kernel/irq.c @@ -56,6 +56,9 @@ /* XXX: This is the way it's done in linux 2.2. GNU Mach currently uses intr_count. It should be made using local_{bh/irq}_count instead (through hardirq_enter/exit) for SMP support. */ unsigned int local_bh_count[NR_CPUS]; unsigned int local_irq_count[NR_CPUS]; +#else +#define local_bh_count (&intr_count) +#define local_irq_count (&intr_count) #endif /* |