diff options
-rw-r--r-- | share/man/man9/arch.9 | 31 | ||||
-rw-r--r-- | sys/arch/amd64/lapic.c | 4 | ||||
-rw-r--r-- | sys/include/arch/amd64/cpu.h | 7 |
3 files changed, 36 insertions, 6 deletions
diff --git a/share/man/man9/arch.9 b/share/man/man9/arch.9 index 6948e81..94ccd6a 100644 --- a/share/man/man9/arch.9 +++ b/share/man/man9/arch.9 @@ -48,16 +48,43 @@ struct which contains CPU specific fields. Example .Ft cpu_info -structure for x86_64 is shown below: +structure shown below: .Bd -literal struct cpu_info { + /* Per-arch fields */ void *pmap; /* Current pmap */ - volatile uint32_t lapic_freq; + uint32_t id; + struct spinlock lock; + /* AMD64 */ ... }; .Ed +There will be some per-architecture fields that, for the sake +of keeping things tidy, should remain at the top of the struct. +These fields will be described below. + +The +.Ft pmap +field points to the current virtual memory context +which shall be NULL if not used. + +The +.Ft id +field simply identifies the CPU with a specific "ID". + +The +.Ft lock +field is a spinlock to prevent race conditions +while accessing this structure. This must be acquired +when accessing a +.Ft cpu_info +instance. + +There are also some common helper macros that shall +be implemented, these are described below. + The macro .Ft this_cpu() calls an internal function that fetches the diff --git a/sys/arch/amd64/lapic.c b/sys/arch/amd64/lapic.c index 1ea80c4..8058e3f 100644 --- a/sys/arch/amd64/lapic.c +++ b/sys/arch/amd64/lapic.c @@ -285,8 +285,8 @@ lapic_init(void) cur_cpu->lapic_tmr_freq = tmr_freq; /* Set the Local APIC ID */ - cur_cpu->lapic_id = lapic_get_id(); + cur_cpu->id = lapic_get_id(); - BSP_KINFO("BSP Local APIC ID: %d\n", cur_cpu->lapic_id); + BSP_KINFO("BSP Local APIC ID: %d\n", cur_cpu->id); CPU_INFO_UNLOCK(cur_cpu); } diff --git a/sys/include/arch/amd64/cpu.h b/sys/include/arch/amd64/cpu.h index 59d1dcd..e93e8a2 100644 --- a/sys/include/arch/amd64/cpu.h +++ b/sys/include/arch/amd64/cpu.h @@ -46,10 +46,13 @@ * acquire the spinlock themselves! */ struct cpu_info { + /* Per-arch fields */ void *pmap; /* Current pmap */ - uint32_t lapic_id; - volatile size_t lapic_tmr_freq; + uint32_t id; struct spinlock lock; + + /* AMD64 */ + volatile size_t lapic_tmr_freq; }; struct cpu_info *amd64_this_cpu(void); |