diff options
Diffstat (limited to 'sys/i386/include')
-rw-r--r-- | sys/i386/include/asnames.h | 65 | ||||
-rw-r--r-- | sys/i386/include/cpufunc.h | 34 | ||||
-rw-r--r-- | sys/i386/include/frame.h | 6 | ||||
-rw-r--r-- | sys/i386/include/globaldata.h | 66 | ||||
-rw-r--r-- | sys/i386/include/globals.h | 147 | ||||
-rw-r--r-- | sys/i386/include/md_var.h | 5 | ||||
-rw-r--r-- | sys/i386/include/mptable.h | 167 | ||||
-rw-r--r-- | sys/i386/include/npx.h | 6 | ||||
-rw-r--r-- | sys/i386/include/pcb.h | 8 | ||||
-rw-r--r-- | sys/i386/include/pcpu.h | 66 | ||||
-rw-r--r-- | sys/i386/include/proc.h | 4 | ||||
-rw-r--r-- | sys/i386/include/reg.h | 38 | ||||
-rw-r--r-- | sys/i386/include/segments.h | 25 | ||||
-rw-r--r-- | sys/i386/include/smp.h | 9 | ||||
-rw-r--r-- | sys/i386/include/tss.h | 11 | ||||
-rw-r--r-- | sys/i386/include/vm86.h | 3 |
16 files changed, 396 insertions, 264 deletions
diff --git a/sys/i386/include/asnames.h b/sys/i386/include/asnames.h index 8ac432c..0cc77d6 100644 --- a/sys/i386/include/asnames.h +++ b/sys/i386/include/asnames.h @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: asnames.h,v 1.30 1999/02/25 12:53:34 bde Exp $ + * $Id: asnames.h,v 1.31 1999/04/16 21:22:16 peter Exp $ */ #ifndef _MACHINE_ASNAMES_H_ @@ -65,8 +65,8 @@ #define _PTD PTD #define _PTDpde PTDpde #define _PTmap PTmap -#define _SMP_ioapic SMP_ioapic -#define _SMP_prvpt SMP_prvpt +#define _SMP_prvspace SMP_prvspace +#define _SMPpt SMPpt #define _Xalign Xalign #define _Xbnd Xbnd #define _Xbpt Xbpt @@ -181,7 +181,7 @@ #define _bootDataSeg bootDataSeg #define _bootMP bootMP #define _bootMP_size bootMP_size -#define _bootPTD bootPTD +#define _bootSTK bootSTK #define _boot_get_mplock boot_get_mplock #define _bootdev bootdev #define _boothowto boothowto @@ -198,15 +198,12 @@ #define _checkstate_probed_cpus checkstate_probed_cpus #define _clock_lock clock_lock #define _cnt cnt -#define _common_tss common_tss -#define _common_tssd common_tssd #define _copyin_vector copyin_vector #define _copyout_vector copyout_vector #define _cpl cpl #define _cpl_lock cpl_lock #define _cpu cpu #define _cpu0prvpage cpu0prvpage -#define _cpu0prvpt cpu0prvpt #define _cpu_apic_versions cpu_apic_versions #define _cpu_class cpu_class #define _cpu_feature cpu_feature @@ -215,10 +212,6 @@ #define _cpu_num_to_apic_id cpu_num_to_apic_id #define _cpu_switch cpu_switch #define _cpu_vendor cpu_vendor -#define _cpuid cpuid -#define _curpcb curpcb -#define _curproc curproc -#define _currentldt currentldt #define _cypoll cypoll #define _default_halt default_halt #define _denormal_operand denormal_operand @@ -245,7 +238,7 @@ #define _get_isrlock get_isrlock #define _get_mplock get_mplock #define _get_syscall_lock get_syscall_lock -#define _getmicrouptime getmicrouptime +#define _getmicrouptime getmicrouptime #define _idqs idqs #define _ihandlers ihandlers #define _imen imen @@ -254,7 +247,6 @@ #define _init386 init386 #define _init_secondary init_secondary #define _initial_bioscalls initial_bioscalls -#define _inside_intr inside_intr #define _intr_countp intr_countp #define _intr_handler intr_handler #define _intr_mask intr_mask @@ -280,8 +272,6 @@ #define _mp_lock mp_lock #define _mp_ncpus mp_ncpus #define _mul64 mul64 -#define _my_idlePTD my_idlePTD -#define _my_tr my_tr #define _net_imask net_imask #define _netisr netisr #define _netisrs netisrs @@ -292,9 +282,7 @@ #define _npx_intrs_while_probing npx_intrs_while_probing #define _npx_traps_while_probing npx_traps_while_probing #define _npx_intr npx_intr -#define _npxproc npxproc #define _npxsave npxsave -#define _other_cpus other_cpus #define _ovbcopy_vector ovbcopy_vector #define _panic panic #define _pc98_system_parameter pc98_system_parameter @@ -307,14 +295,6 @@ #define _probetrap probetrap #define _proc0 proc0 #define _proc0paddr proc0paddr -#define _prv_CMAP1 prv_CMAP1 -#define _prv_CMAP2 prv_CMAP2 -#define _prv_CMAP3 prv_CMAP3 -#define _prv_CPAGE1 prv_CPAGE1 -#define _prv_CPAGE2 prv_CPAGE2 -#define _prv_CPAGE3 prv_CPAGE3 -#define _prv_PMAP1 prv_PMAP1 -#define _prv_PPAGE1 prv_PPAGE1 #define _qs qs #define _rcpoll rcpoll #define _real_2op_NaN real_2op_NaN @@ -354,8 +334,6 @@ #define _swi_generic swi_generic #define _swi_null swi_null #define _swi_vm swi_vm -#define _switchticks switchticks -#define _switchtime switchtime #define _syscall syscall #define _szsigcode szsigcode #define _ticks ticks @@ -390,4 +368,37 @@ #endif /* __ELF__ */ +#if defined(SMP) || defined(__ELF__) +#ifdef SMP +#define FS(x) %fs:gd_ ## x +#else +#define FS(x) x +#endif + +#define _common_tss FS(common_tss) +#define _common_tssd FS(common_tssd) +#define _cpuid FS(cpuid) +#define _cpu_lockid FS(cpu_lockid) +#define _curpcb FS(curpcb) +#define _curproc FS(curproc) +#define _currentldt FS(currentldt) +#define _inside_intr FS(inside_intr) +#define _npxproc FS(npxproc) +#define _other_cpus FS(other_cpus) +#define _prv_CADDR1 FS(prv_CADDR1) +#define _prv_CADDR2 FS(prv_CADDR2) +#define _prv_CADDR3 FS(prv_CADDR3) +#define _prv_CMAP1 FS(prv_CMAP1) +#define _prv_CMAP2 FS(prv_CMAP2) +#define _prv_CMAP3 FS(prv_CMAP3) +#define _prv_PADDR1 FS(prv_PADDR1) +#define _prv_PMAP1 FS(prv_PMAP1) +#define _ss_eflags FS(ss_eflags) +#define _switchticks FS(switchticks) +#define _switchtime FS(switchtime) +#define _idlestack FS(idlestack) +#define _idlestack_top FS(idlestack_top) + +#endif + #endif /* !_MACHINE_ASNAMES_H_ */ diff --git a/sys/i386/include/cpufunc.h b/sys/i386/include/cpufunc.h index ce6bf05..c1f9f17 100644 --- a/sys/i386/include/cpufunc.h +++ b/sys/i386/include/cpufunc.h @@ -30,7 +30,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: cpufunc.h,v 1.84 1999/01/08 19:51:02 bde Exp $ + * $Id: cpufunc.h,v 1.85 1999/01/09 13:00:27 bde Exp $ */ /* @@ -426,6 +426,34 @@ wrmsr(u_int msr, u_int64_t newval) __asm __volatile(".byte 0x0f, 0x30" : : "A" (newval), "c" (msr)); } +static __inline u_int +rfs(void) +{ + u_int sel; + __asm __volatile("movl %%fs,%0" : "=r" (sel)); + return (sel); +} + +static __inline u_int +rgs(void) +{ + u_int sel; + __asm __volatile("movl %%gs,%0" : "=r" (sel)); + return (sel); +} + +static __inline void +load_fs(u_int sel) +{ + __asm __volatile("movl %0,%%fs" : : "r" (sel)); +} + +static __inline void +load_gs(u_int sel) +{ + __asm __volatile("movl %0,%%gs" : : "r" (sel)); +} + #else /* !__GNUC__ */ int breakpoint __P((void)); @@ -456,6 +484,10 @@ void setbits __P((volatile u_int *addr, u_int bits)); void wbinvd __P((void)); void write_eflags __P((u_int ef)); void wrmsr __P((u_int msr, u_int64_t newval)); +u_int rfs __P((void)); +u_int rgs __P((void)); +void load_fs __P((u_int sel)); +void load_gs __P((u_int sel)); #endif /* __GNUC__ */ diff --git a/sys/i386/include/frame.h b/sys/i386/include/frame.h index 05092c2..7d70c14 100644 --- a/sys/i386/include/frame.h +++ b/sys/i386/include/frame.h @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * from: @(#)frame.h 5.2 (Berkeley) 1/18/91 - * $Id: frame.h,v 1.14 1997/02/22 09:34:38 peter Exp $ + * $Id: frame.h,v 1.15 1997/08/09 00:03:12 dyson Exp $ */ #ifndef _MACHINE_FRAME_H_ @@ -51,6 +51,7 @@ */ struct trapframe { + int tf_fs; int tf_es; int tf_ds; int tf_edi; @@ -75,6 +76,7 @@ struct trapframe { /* Superset of trap frame, for traps from virtual-8086 mode */ struct trapframe_vm86 { + int tf_fs; int tf_es; int tf_ds; int tf_edi; @@ -106,6 +108,7 @@ struct trapframe_vm86 { struct intrframe { int if_vec; int if_ppl; + int if_fs; int if_es; int if_ds; int if_edi; @@ -132,6 +135,7 @@ struct intrframe { struct clockframe { int cf_vec; int cf_ppl; + int cf_fs; int cf_es; int cf_ds; int cf_edi; diff --git a/sys/i386/include/globaldata.h b/sys/i386/include/globaldata.h index ec58799..f1d4fdd 100644 --- a/sys/i386/include/globaldata.h +++ b/sys/i386/include/globaldata.h @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: globaldata.h,v 1.6 1998/08/18 07:47:12 msmith Exp $ + * $Id: globaldata.h,v 1.7 1999/02/22 15:13:34 bde Exp $ */ /* @@ -39,31 +39,33 @@ * other processors" */ struct globaldata { - struct proc *curproc; - struct proc *npxproc; - struct pcb *curpcb; - struct i386tss common_tss; - struct timeval switchtime; - int switchticks; + struct privatespace *gd_prvspace; /* self-reference */ + struct proc *gd_curproc; + struct proc *gd_npxproc; + struct pcb *gd_curpcb; + struct timeval gd_switchtime; + struct i386tss gd_common_tss; + int gd_switchticks; #ifdef VM86 - struct segment_descriptor common_tssd; - u_int private_tss; - u_int my_tr; + struct segment_descriptor gd_common_tssd; #endif #ifdef USER_LDT - int currentldt; + int gd_currentldt; #endif #ifdef SMP - u_int cpuid; - u_int cpu_lockid; - u_int other_cpus; - pd_entry_t *my_idlePTD; - u_int ss_eflags; - pt_entry_t *prv_CMAP1; - pt_entry_t *prv_CMAP2; - pt_entry_t *prv_CMAP3; - pt_entry_t *prv_PMAP1; - int inside_intr; + u_int gd_cpuid; + u_int gd_cpu_lockid; + u_int gd_other_cpus; + int gd_inside_intr; + u_int gd_ss_eflags; + pt_entry_t *gd_prv_CMAP1; + pt_entry_t *gd_prv_CMAP2; + pt_entry_t *gd_prv_CMAP3; + pt_entry_t *gd_prv_PMAP1; + caddr_t gd_prv_CADDR1; + caddr_t gd_prv_CADDR2; + caddr_t gd_prv_CADDR3; + unsigned *gd_prv_PADDR1; #endif }; @@ -78,28 +80,16 @@ struct privatespace { struct globaldata globaldata; char __filler0[PAGE_SIZE - sizeof(struct globaldata)]; - /* page 1 - page table page */ - pt_entry_t prvpt[NPTEPG]; - - /* page 2 - local apic mapping */ - lapic_t lapic; - char __filler1[PAGE_SIZE - sizeof(lapic_t)]; - - /* page 3..2+UPAGES - idle stack (UPAGES pages) */ - char idlestack[UPAGES * PAGE_SIZE]; - - /* page 3+UPAGES..6+UPAGES - CPAGE1,CPAGE2,CPAGE3,PPAGE1 */ + /* page 1..4 - CPAGE1,CPAGE2,CPAGE3,PPAGE1 */ char CPAGE1[PAGE_SIZE]; char CPAGE2[PAGE_SIZE]; char CPAGE3[PAGE_SIZE]; char PPAGE1[PAGE_SIZE]; - /* page 7+UPAGES..15 - spare, unmapped */ - char __filler2[(9-UPAGES) * PAGE_SIZE]; + /* page 5..4+UPAGES - idle stack (UPAGES pages) */ + char idlestack[UPAGES * PAGE_SIZE]; +}; - /* page 16-31 - space for IO apics */ - char ioapics[16 * PAGE_SIZE]; +extern struct privatespace SMP_prvspace[]; - /* page 32-47 - maybe other cpu's globaldata pages? */ -}; #endif diff --git a/sys/i386/include/globals.h b/sys/i386/include/globals.h new file mode 100644 index 0000000..5a770f1 --- /dev/null +++ b/sys/i386/include/globals.h @@ -0,0 +1,147 @@ +/*- + * Copyright (c) 1999 Luoqi Chen <luoqi@freebsd.org> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $Id$ + */ + +#ifndef _MACHINE_GLOBALS_H_ +#define _MACHINE_GLOBALS_H_ + +#ifdef KERNEL + +#define GLOBAL_LVALUE(name, type) \ + (*(type *)_global_ptr_##name()) + +#define GLOBAL_RVALUE(name, type) \ + ((type)_global_##name()) + +/* non-volatile version */ +#define GLOBAL_LVALUE_NV(name, type) \ + (*(type *)_global_ptr_##name##_nv()) + +#define GLOBAL_RVALUE_NV(name, type) \ + ((type)_global_##name##_nv()) + +#define GLOBAL_FUNC(name) \ + static __inline void *_global_ptr_##name(void) { \ + void *val; \ + __asm __volatile("movl $gd_" #name ",%0;" \ + "addl %%fs:globaldata,%0" : "=r" (val)); \ + return (val); \ + } \ + static __inline void *_global_ptr_##name##_nv(void) { \ + void *val; \ + __asm("movl $gd_" #name ",%0;" \ + "addl %%fs:globaldata,%0" : "=r" (val)); \ + return (val); \ + } \ + static __inline int _global_##name(void) { \ + int val; \ + __asm __volatile("movl %%fs:gd_" #name ",%0" : "=r" (val)); \ + return (val); \ + } \ + static __inline int _global_##name##_nv(void) { \ + int val; \ + __asm("movl %%fs:gd_" #name ",%0" : "=r" (val)); \ + return (val); \ + } \ + static __inline void _global_##name##_set(int val) { \ + __asm __volatile("movl %0,%%fs:gd_" #name : : "r" (val)); \ + } \ + static __inline void _global_##name##_set_nv(int val) { \ + __asm("movl %0,%%fs:gd_" #name : : "r" (val)); \ + } + +#if defined(SMP) || defined(KLD_MODULE) || defined(ACTUALLY_LKM_NOT_KERNEL) +/* + * The following set of macros works for UP kernel as well, but for maximum + * performance we allow the global variables to be accessed directly. On the + * other hand, kernel modules should always use these macros to maintain + * portability between UP and SMP kernels. + */ +#define curproc GLOBAL_RVALUE_NV(curproc, struct proc *) +#define curpcb GLOBAL_RVALUE_NV(curpcb, struct pcb *) +#define npxproc GLOBAL_LVALUE(npxproc, struct proc *) +#define common_tss GLOBAL_LVALUE(common_tss, struct i386tss) +#define switchtime GLOBAL_LVALUE(switchtime, struct timeval) +#define switchticks GLOBAL_LVALUE(switchticks, int) + +#ifdef VM86 +#define common_tssd GLOBAL_LVALUE(common_tssd, struct segment_descriptor) +#endif + +#ifdef USER_LDT +#define currentldt GLOBAL_LVALUE(currentldt, int) +#endif + +#ifdef SMP +#define cpuid GLOBAL_RVALUE(cpuid, u_int) +#define other_cpus GLOBAL_LVALUE(other_cpus, u_int) +#define inside_intr GLOBAL_LVALUE(inside_intr, int) +#define prv_CMAP1 GLOBAL_LVALUE(prv_CMAP1, pt_entry_t *) +#define prv_CMAP2 GLOBAL_LVALUE(prv_CMAP2, pt_entry_t *) +#define prv_CMAP3 GLOBAL_LVALUE(prv_CMAP3, pt_entry_t *) +#define prv_PMAP1 GLOBAL_LVALUE(prv_PMAP1, pt_entry_t *) +#define prv_CADDR1 GLOBAL_RVALUE(prv_CADDR1, caddr_t) +#define prv_CADDR2 GLOBAL_RVALUE(prv_CADDR2, caddr_t) +#define prv_CADDR3 GLOBAL_RVALUE(prv_CADDR3, caddr_t) +#define prv_PADDR1 GLOBAL_RVALUE(prv_PADDR1, unsigned *) +#endif +#endif /*UP kernel*/ + +GLOBAL_FUNC(curproc) +GLOBAL_FUNC(curpcb) +GLOBAL_FUNC(npxproc) +GLOBAL_FUNC(common_tss) +GLOBAL_FUNC(switchtime) +GLOBAL_FUNC(switchticks) + +#ifdef VM86 +GLOBAL_FUNC(common_tssd) +#endif + +#ifdef USER_LDT +GLOBAL_FUNC(currentldt) +#endif + +#ifdef SMP +GLOBAL_FUNC(cpuid) +GLOBAL_FUNC(other_cpus) +GLOBAL_FUNC(inside_intr) +GLOBAL_FUNC(prv_CMAP1) +GLOBAL_FUNC(prv_CMAP2) +GLOBAL_FUNC(prv_CMAP3) +GLOBAL_FUNC(prv_PMAP1) +GLOBAL_FUNC(prv_CADDR1) +GLOBAL_FUNC(prv_CADDR2) +GLOBAL_FUNC(prv_CADDR3) +GLOBAL_FUNC(prv_PADDR1) +#endif + +#define SET_CURPROC(x) (_global_curproc_set_nv((int)x)) + +#endif /* KERNEL */ + +#endif /* !_MACHINE_GLOBALS_H_ */ diff --git a/sys/i386/include/md_var.h b/sys/i386/include/md_var.h index fd7bcfd..35b6545 100644 --- a/sys/i386/include/md_var.h +++ b/sys/i386/include/md_var.h @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: md_var.h,v 1.27 1998/10/30 05:41:15 msmith Exp $ + * $Id: md_var.h,v 1.28 1999/01/08 16:29:58 bde Exp $ */ #ifndef _MACHINE_MD_VAR_H_ @@ -69,7 +69,6 @@ void bcopyb __P((const void *from, void *to, size_t len)); void busdma_swi __P((void)); void cpu_halt __P((void)); void cpu_reset __P((void)); -void cpu_switch_load_fs __P((void)) __asm(__STRING(cpu_switch_load_fs)); void cpu_switch_load_gs __P((void)) __asm(__STRING(cpu_switch_load_gs)); void doreti_iret __P((void)) __asm(__STRING(doreti_iret)); void doreti_iret_fault __P((void)) __asm(__STRING(doreti_iret_fault)); @@ -77,6 +76,8 @@ void doreti_popl_ds __P((void)) __asm(__STRING(doreti_popl_ds)); void doreti_popl_ds_fault __P((void)) __asm(__STRING(doreti_popl_ds_fault)); void doreti_popl_es __P((void)) __asm(__STRING(doreti_popl_es)); void doreti_popl_es_fault __P((void)) __asm(__STRING(doreti_popl_es_fault)); +void doreti_popl_fs __P((void)) __asm(__STRING(doreti_popl_fs)); +void doreti_popl_fs_fault __P((void)) __asm(__STRING(doreti_popl_fs_fault)); int fill_fpregs __P((struct proc *, struct fpreg *)); int fill_regs __P((struct proc *p, struct reg *regs)); void fillw __P((int /*u_short*/ pat, void *base, size_t cnt)); diff --git a/sys/i386/include/mptable.h b/sys/i386/include/mptable.h index eca2601..dcca437 100644 --- a/sys/i386/include/mptable.h +++ b/sys/i386/include/mptable.h @@ -22,7 +22,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: mp_machdep.c,v 1.96 1999/04/11 00:43:43 tegge Exp $ + * $Id: mp_machdep.c,v 1.97 1999/04/13 03:24:47 tegge Exp $ */ #include "opt_smp.h" @@ -297,28 +297,15 @@ int apic_id_to_logical[NAPICID]; /* Bitmap of all available CPUs */ u_int all_cpus; -/* AP uses this PTD during bootstrap. Do not staticize. */ -pd_entry_t *bootPTD; +/* AP uses this during bootstrap. Do not staticize. */ +char *bootSTK; +int boot_cpuid; /* Hotwire a 0->4MB V==P mapping */ extern pt_entry_t *KPTphys; -/* Virtual address of per-cpu common_tss */ -extern struct i386tss common_tss; -#ifdef VM86 -extern struct segment_descriptor common_tssd; -extern u_int private_tss; /* flag indicating private tss */ -extern u_int my_tr; -#endif /* VM86 */ - -/* IdlePTD per cpu */ -pd_entry_t *IdlePTDS[NCPU]; - -/* "my" private page table page, for BSP init */ -extern pt_entry_t SMP_prvpt[]; - -/* Private page pointer to curcpu's PTD, used during BSP init */ -extern pd_entry_t *my_idlePTD; +/* SMP page table page */ +extern pt_entry_t *SMPpt; struct pcb stoppcbs[NCPU]; @@ -466,41 +453,42 @@ void init_secondary(void) { int gsel_tss; -#ifndef VM86 - u_int my_tr; -#endif + int x, myid = boot_cpuid; + + gdt_segs[GPRIV_SEL].ssd_base = (int) &SMP_prvspace[myid]; + gdt_segs[GPROC0_SEL].ssd_base = + (int) &SMP_prvspace[myid].globaldata.gd_common_tss; + SMP_prvspace[myid].globaldata.gd_prvspace = &SMP_prvspace[myid]; - r_gdt.rd_limit = sizeof(gdt[0]) * (NGDT + NCPU) - 1; - r_gdt.rd_base = (int) gdt; + for (x = 0; x < NGDT; x++) { + ssdtosd(&gdt_segs[x], &gdt[myid * NGDT + x].sd); + } + + r_gdt.rd_limit = NGDT * sizeof(gdt[0]) - 1; + r_gdt.rd_base = (int) &gdt[myid * NGDT]; lgdt(&r_gdt); /* does magic intra-segment return */ + lidt(&r_idt); + lldt(_default_ldt); #ifdef USER_LDT currentldt = _default_ldt; #endif - my_tr = NGDT + cpuid; - gsel_tss = GSEL(my_tr, SEL_KPL); - gdt[my_tr].sd.sd_type = SDT_SYS386TSS; + gsel_tss = GSEL(GPROC0_SEL, SEL_KPL); + gdt[myid * NGDT + GPROC0_SEL].sd.sd_type = SDT_SYS386TSS; common_tss.tss_esp0 = 0; /* not used until after switch */ common_tss.tss_ss0 = GSEL(GDATA_SEL, SEL_KPL); common_tss.tss_ioopt = (sizeof common_tss) << 16; #ifdef VM86 - common_tssd = gdt[my_tr].sd; - private_tss = 0; -#endif /* VM86 */ + common_tssd = gdt[myid * NGDT + GPROC0_SEL].sd; +#endif ltr(gsel_tss); load_cr0(0x8005003b); /* XXX! */ - PTD[0] = 0; pmap_set_opt((unsigned *)PTD); -#if 0 - putmtrr(); - pmap_setvidram(); -#endif - invltlb(); } @@ -558,11 +546,6 @@ mp_enable(u_int boot_addr) u_int ux; #endif /* APIC_IO */ -#if 0 - getmtrr(); - pmap_setvidram(); -#endif - POSTCODE(MP_ENABLE_POST); /* turn on 4MB of V == P addressing so we can get to MP table */ @@ -1770,14 +1753,11 @@ extern int wait_ap(unsigned int); static int start_all_aps(u_int boot_addr) { - int x, i; + int x, i, pg; u_char mpbiosreason; u_long mpbioswarmvec; - pd_entry_t *newptd; - pt_entry_t *newpt; struct globaldata *gd; char *stack; - pd_entry_t *myPTD; POSTCODE(START_ALL_APS_POST); @@ -1799,70 +1779,46 @@ start_all_aps(u_int boot_addr) /* record BSP in CPU map */ all_cpus = 1; + /* set up 0 -> 4MB P==V mapping for AP boot */ + *(int *)PTD = PG_V | PG_RW | ((uintptr_t)(void *)KPTphys & PG_FRAME); + invltlb(); + /* start each AP */ for (x = 1; x <= mp_naps; ++x) { /* This is a bit verbose, it will go away soon. */ - /* alloc new page table directory */ - newptd = (pd_entry_t *)(kmem_alloc(kernel_map, PAGE_SIZE)); - - /* Store the virtual PTD address for this CPU */ - IdlePTDS[x] = newptd; - - /* clone currently active one (ie: IdlePTD) */ - bcopy(PTD, newptd, PAGE_SIZE); /* inc prv page pde */ - - /* set up 0 -> 4MB P==V mapping for AP boot */ - newptd[0] = (void *)(uintptr_t)(PG_V | PG_RW | - ((uintptr_t)(void *)KPTphys & PG_FRAME)); - - /* store PTD for this AP's boot sequence */ - myPTD = (pd_entry_t *)vtophys(newptd); - - /* alloc new page table page */ - newpt = (pt_entry_t *)(kmem_alloc(kernel_map, PAGE_SIZE)); - - /* set the new PTD's private page to point there */ - newptd[MPPTDI] = (pt_entry_t)(PG_V | PG_RW | vtophys(newpt)); - - /* install self referential entry */ - newptd[PTDPTDI] = (pd_entry_t)(PG_V | PG_RW | vtophys(newptd)); + /* first page of AP's private space */ + pg = x * i386_btop(sizeof(struct privatespace)); /* allocate a new private data page */ gd = (struct globaldata *)kmem_alloc(kernel_map, PAGE_SIZE); /* wire it into the private page table page */ - newpt[0] = (pt_entry_t)(PG_V | PG_RW | vtophys(gd)); - - /* wire the ptp into itself for access */ - newpt[1] = (pt_entry_t)(PG_V | PG_RW | vtophys(newpt)); - - /* copy in the pointer to the local apic */ - newpt[2] = SMP_prvpt[2]; - - /* and the IO apic mapping[s] */ - for (i = 16; i < 32; i++) - newpt[i] = SMP_prvpt[i]; + SMPpt[pg] = (pt_entry_t)(PG_V | PG_RW | vtophys(gd)); /* allocate and set up an idle stack data page */ stack = (char *)kmem_alloc(kernel_map, UPAGES*PAGE_SIZE); for (i = 0; i < UPAGES; i++) - newpt[i + 3] = (pt_entry_t)(PG_V | PG_RW | vtophys(PAGE_SIZE * i + stack)); + SMPpt[pg + 5 + i] = (pt_entry_t) + (PG_V | PG_RW | vtophys(PAGE_SIZE * i + stack)); - newpt[3 + UPAGES] = 0; /* *prv_CMAP1 */ - newpt[4 + UPAGES] = 0; /* *prv_CMAP2 */ - newpt[5 + UPAGES] = 0; /* *prv_CMAP3 */ - newpt[6 + UPAGES] = 0; /* *prv_PMAP1 */ + SMPpt[pg + 1] = 0; /* *prv_CMAP1 */ + SMPpt[pg + 2] = 0; /* *prv_CMAP2 */ + SMPpt[pg + 3] = 0; /* *prv_CMAP3 */ + SMPpt[pg + 4] = 0; /* *prv_PMAP1 */ /* prime data page for it to use */ - gd->cpuid = x; - gd->cpu_lockid = x << 24; - gd->my_idlePTD = myPTD; - gd->prv_CMAP1 = &newpt[3 + UPAGES]; - gd->prv_CMAP2 = &newpt[4 + UPAGES]; - gd->prv_CMAP3 = &newpt[5 + UPAGES]; - gd->prv_PMAP1 = &newpt[6 + UPAGES]; + gd->gd_cpuid = x; + gd->gd_cpu_lockid = x << 24; + gd->gd_prv_CMAP1 = &SMPpt[pg + 1]; + gd->gd_prv_CMAP2 = &SMPpt[pg + 2]; + gd->gd_prv_CMAP3 = &SMPpt[pg + 3]; + gd->gd_prv_PMAP1 = &SMPpt[pg + 4]; + gd->gd_prv_CADDR1 = SMP_prvspace[x].CPAGE1; + gd->gd_prv_CADDR2 = SMP_prvspace[x].CPAGE2; + gd->gd_prv_CADDR3 = SMP_prvspace[x].CPAGE3; + gd->gd_prv_PADDR1 = (unsigned *)SMP_prvspace[x].PPAGE1; /* setup a vector to our boot code */ *((volatile u_short *) WARMBOOT_OFF) = WARMBOOT_TARGET; @@ -1872,7 +1828,9 @@ start_all_aps(u_int boot_addr) outb(CMOS_DATA, BIOS_WARM); /* 'warm-start' */ #endif - bootPTD = myPTD; + bootSTK = &SMP_prvspace[x].idlestack[UPAGES*PAGE_SIZE]; + boot_cpuid = x; + /* attempt to start the Application Processor */ CHECK_INIT(99); /* setup checkpoints */ if (!start_ap(x, boot_addr)) { @@ -1910,27 +1868,16 @@ start_all_aps(u_int boot_addr) * because the BSP is cpu#0 and the page is initially zero, and also * because we can refer to variables by name on the BSP.. */ - newptd = (pd_entry_t *)(kmem_alloc(kernel_map, PAGE_SIZE)); - - bcopy(PTD, newptd, PAGE_SIZE); /* inc prv page pde */ - IdlePTDS[0] = newptd; - - /* Point PTD[] to this page instead of IdlePTD's physical page */ - newptd[PTDPTDI] = (pd_entry_t)(PG_V | PG_RW | vtophys(newptd)); - - my_idlePTD = (pd_entry_t *)vtophys(newptd); /* Allocate and setup BSP idle stack */ stack = (char *)kmem_alloc(kernel_map, UPAGES * PAGE_SIZE); for (i = 0; i < UPAGES; i++) - SMP_prvpt[i + 3] = (pt_entry_t)(PG_V | PG_RW | vtophys(PAGE_SIZE * i + stack)); + SMPpt[5 + i] = (pt_entry_t) + (PG_V | PG_RW | vtophys(PAGE_SIZE * i + stack)); + *(int *)PTD = 0; pmap_set_opt_bsp(); - for (i = 0; i < mp_ncpus; i++) { - bcopy( (int *) PTD + KPTDI, (int *) IdlePTDS[i] + KPTDI, NKPDE * sizeof (int)); - } - /* number of APs actually started */ return mp_ncpus - 1; } @@ -2250,10 +2197,6 @@ ap_init() panic("cpuid mismatch! boom!!"); } -#if 0 - getmtrr(); -#endif - /* Init local apic for irq's */ apic_initialize(); @@ -2267,8 +2210,6 @@ ap_init() smp_started = 1; /* enable IPI's, tlb shootdown, freezes etc */ smp_active = 1; /* historic */ } - - curproc = NULL; /* make sure */ } #ifdef BETTER_CLOCK diff --git a/sys/i386/include/npx.h b/sys/i386/include/npx.h index a7608d5..10384c6 100644 --- a/sys/i386/include/npx.h +++ b/sys/i386/include/npx.h @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * from: @(#)npx.h 5.3 (Berkeley) 1/18/91 - * $Id: npx.h,v 1.13 1997/06/22 16:03:50 peter Exp $ + * $Id: npx.h,v 1.14 1997/07/20 11:06:44 bde Exp $ */ /* @@ -45,6 +45,8 @@ #ifndef _MACHINE_NPX_H_ #define _MACHINE_NPX_H_ +#include <machine/globals.h> + /* Environment information of floating point unit */ struct env87 { long en_cw; /* control word (16bits) */ @@ -135,7 +137,9 @@ struct save87 { #endif #ifdef KERNEL +#ifndef npxproc extern struct proc *npxproc; +#endif int npxdna __P((void)); void npxexit __P((struct proc *p)); diff --git a/sys/i386/include/pcb.h b/sys/i386/include/pcb.h index d76217f..9ab0856 100644 --- a/sys/i386/include/pcb.h +++ b/sys/i386/include/pcb.h @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * from: @(#)pcb.h 5.10 (Berkeley) 5/12/91 - * $Id: pcb.h,v 1.25 1997/10/10 12:40:09 peter Exp $ + * $Id: pcb.h,v 1.26 1998/02/03 21:27:50 bde Exp $ */ #ifndef _I386_PCB_H_ @@ -43,6 +43,7 @@ /* * Intel 386 process control block */ +#include <machine/globals.h> #include <machine/npx.h> struct pcb { @@ -64,14 +65,13 @@ struct pcb { #else u_long pcb_mpnest_dontuse; #endif - int pcb_fs; int pcb_gs; #ifdef VM86 struct pcb_ext *pcb_ext; /* optional pcb extension */ #else struct pcb_ext *pcb_ext_dontuse; #endif - u_long __pcb_spare[1]; /* adjust to avoid core dump size changes */ + u_long __pcb_spare[2]; /* adjust to avoid core dump size changes */ }; /* @@ -83,7 +83,9 @@ struct md_coredump { #ifdef KERNEL +#ifndef curpcb extern struct pcb *curpcb; /* our current running pcb */ +#endif void savectx __P((struct pcb *)); #endif diff --git a/sys/i386/include/pcpu.h b/sys/i386/include/pcpu.h index ec58799..f1d4fdd 100644 --- a/sys/i386/include/pcpu.h +++ b/sys/i386/include/pcpu.h @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: globaldata.h,v 1.6 1998/08/18 07:47:12 msmith Exp $ + * $Id: globaldata.h,v 1.7 1999/02/22 15:13:34 bde Exp $ */ /* @@ -39,31 +39,33 @@ * other processors" */ struct globaldata { - struct proc *curproc; - struct proc *npxproc; - struct pcb *curpcb; - struct i386tss common_tss; - struct timeval switchtime; - int switchticks; + struct privatespace *gd_prvspace; /* self-reference */ + struct proc *gd_curproc; + struct proc *gd_npxproc; + struct pcb *gd_curpcb; + struct timeval gd_switchtime; + struct i386tss gd_common_tss; + int gd_switchticks; #ifdef VM86 - struct segment_descriptor common_tssd; - u_int private_tss; - u_int my_tr; + struct segment_descriptor gd_common_tssd; #endif #ifdef USER_LDT - int currentldt; + int gd_currentldt; #endif #ifdef SMP - u_int cpuid; - u_int cpu_lockid; - u_int other_cpus; - pd_entry_t *my_idlePTD; - u_int ss_eflags; - pt_entry_t *prv_CMAP1; - pt_entry_t *prv_CMAP2; - pt_entry_t *prv_CMAP3; - pt_entry_t *prv_PMAP1; - int inside_intr; + u_int gd_cpuid; + u_int gd_cpu_lockid; + u_int gd_other_cpus; + int gd_inside_intr; + u_int gd_ss_eflags; + pt_entry_t *gd_prv_CMAP1; + pt_entry_t *gd_prv_CMAP2; + pt_entry_t *gd_prv_CMAP3; + pt_entry_t *gd_prv_PMAP1; + caddr_t gd_prv_CADDR1; + caddr_t gd_prv_CADDR2; + caddr_t gd_prv_CADDR3; + unsigned *gd_prv_PADDR1; #endif }; @@ -78,28 +80,16 @@ struct privatespace { struct globaldata globaldata; char __filler0[PAGE_SIZE - sizeof(struct globaldata)]; - /* page 1 - page table page */ - pt_entry_t prvpt[NPTEPG]; - - /* page 2 - local apic mapping */ - lapic_t lapic; - char __filler1[PAGE_SIZE - sizeof(lapic_t)]; - - /* page 3..2+UPAGES - idle stack (UPAGES pages) */ - char idlestack[UPAGES * PAGE_SIZE]; - - /* page 3+UPAGES..6+UPAGES - CPAGE1,CPAGE2,CPAGE3,PPAGE1 */ + /* page 1..4 - CPAGE1,CPAGE2,CPAGE3,PPAGE1 */ char CPAGE1[PAGE_SIZE]; char CPAGE2[PAGE_SIZE]; char CPAGE3[PAGE_SIZE]; char PPAGE1[PAGE_SIZE]; - /* page 7+UPAGES..15 - spare, unmapped */ - char __filler2[(9-UPAGES) * PAGE_SIZE]; + /* page 5..4+UPAGES - idle stack (UPAGES pages) */ + char idlestack[UPAGES * PAGE_SIZE]; +}; - /* page 16-31 - space for IO apics */ - char ioapics[16 * PAGE_SIZE]; +extern struct privatespace SMP_prvspace[]; - /* page 32-47 - maybe other cpu's globaldata pages? */ -}; #endif diff --git a/sys/i386/include/proc.h b/sys/i386/include/proc.h index e7a4744..ae6cd63 100644 --- a/sys/i386/include/proc.h +++ b/sys/i386/include/proc.h @@ -31,12 +31,14 @@ * SUCH DAMAGE. * * from: @(#)proc.h 7.1 (Berkeley) 5/15/91 - * $Id: proc.h,v 1.7 1997/02/22 09:34:59 peter Exp $ + * $Id: proc.h,v 1.8 1997/05/07 19:55:13 peter Exp $ */ #ifndef _MACHINE_PROC_H_ #define _MACHINE_PROC_H_ +#include <machine/globals.h> + /* * Machine-dependent part of the proc structure for i386. */ diff --git a/sys/i386/include/reg.h b/sys/i386/include/reg.h index 28466a8..2470116 100644 --- a/sys/i386/include/reg.h +++ b/sys/i386/include/reg.h @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * from: @(#)reg.h 5.5 (Berkeley) 1/18/91 - * $Id: reg.h,v 1.16 1998/09/14 22:43:40 jdp Exp $ + * $Id: reg.h,v 1.17 1999/04/03 22:19:59 jdp Exp $ */ #ifndef _MACHINE_REG_H_ @@ -51,22 +51,23 @@ * stopped accessing the registers in the trap frame via PT_{READ,WRITE}_U * and we can stop supporting the user area soon. */ -#define tES (0) -#define tDS (1) -#define tEDI (2) -#define tESI (3) -#define tEBP (4) -#define tISP (5) -#define tEBX (6) -#define tEDX (7) -#define tECX (8) -#define tEAX (9) -#define tERR (11) -#define tEIP (12) -#define tCS (13) -#define tEFLAGS (14) -#define tESP (15) -#define tSS (16) +#define tFS (0) +#define tES (1) +#define tDS (2) +#define tEDI (3) +#define tESI (4) +#define tEBP (5) +#define tISP (6) +#define tEBX (7) +#define tEDX (8) +#define tECX (9) +#define tEAX (10) +#define tERR (12) +#define tEIP (13) +#define tCS (14) +#define tEFLAGS (15) +#define tESP (16) +#define tSS (17) /* * Indices for registers in `struct regs' only. @@ -75,13 +76,13 @@ * other registers in application interfaces that copy all the registers * to or from a `struct regs'. */ -#define tFS (17) #define tGS (18) /* * Register set accessible via /proc/$pid/regs and PT_{SET,GET}REGS. */ struct reg { + unsigned int r_fs; unsigned int r_es; unsigned int r_ds; unsigned int r_edi; @@ -99,7 +100,6 @@ struct reg { unsigned int r_eflags; unsigned int r_esp; unsigned int r_ss; - unsigned int r_fs; unsigned int r_gs; }; diff --git a/sys/i386/include/segments.h b/sys/i386/include/segments.h index 674b0f3..eaecfa3 100644 --- a/sys/i386/include/segments.h +++ b/sys/i386/include/segments.h @@ -35,12 +35,14 @@ * SUCH DAMAGE. * * from: @(#)segments.h 7.1 (Berkeley) 5/9/91 - * $Id: segments.h,v 1.17 1997/08/21 06:32:49 charnier Exp $ + * $Id: segments.h,v 1.18 1999/01/28 11:45:49 newton Exp $ */ #ifndef _MACHINE_SEGMENTS_H_ #define _MACHINE_SEGMENTS_H_ +#include <machine/globals.h> + /* * 386 Segmentation Data Structures and definitions * William F. Jolitz (william@ernie.berkeley.edu) 6/20/1989 @@ -207,19 +209,20 @@ struct region_descriptor { #define GNULL_SEL 0 /* Null Descriptor */ #define GCODE_SEL 1 /* Kernel Code Descriptor */ #define GDATA_SEL 2 /* Kernel Data Descriptor */ -#define GLDT_SEL 3 /* LDT - eventually one per process */ -#define GTGATE_SEL 4 /* Process task switch gate */ -#define GPANIC_SEL 5 /* Task state to consider panic from */ -#define GPROC0_SEL 6 /* Task state process slot zero and up */ -#define GUSERLDT_SEL 7 /* User LDT */ -#define GAPMCODE32_SEL 8 /* APM BIOS 32-bit interface (32bit Code) */ -#define GAPMCODE16_SEL 9 /* APM BIOS 32-bit interface (16bit Code) */ -#define GAPMDATA_SEL 10 /* APM BIOS 32-bit interface (Data) */ +#define GPRIV_SEL 3 /* SMP Per-Processor Private Data */ +#define GPROC0_SEL 4 /* Task state process slot zero and up */ +#define GLDT_SEL 5 /* LDT - eventually one per process */ +#define GUSERLDT_SEL 6 /* User LDT */ +#define GTGATE_SEL 7 /* Process task switch gate */ +#define GPANIC_SEL 8 /* Task state to consider panic from */ +#define GAPMCODE32_SEL 9 /* APM BIOS 32-bit interface (32bit Code) */ +#define GAPMCODE16_SEL 10 /* APM BIOS 32-bit interface (16bit Code) */ +#define GAPMDATA_SEL 11 /* APM BIOS 32-bit interface (Data) */ #ifdef BDE_DEBUGGER #define NGDT 18 /* some of 11-17 are reserved for debugger */ #else -#define NGDT (GAPMDATA_SEL + 1) +#define NGDT 12 #endif /* @@ -237,7 +240,9 @@ struct region_descriptor { #define NLDT (LBSDICALLS_SEL + 1) #ifdef KERNEL +#ifndef currentldt extern int currentldt; +#endif extern int _default_ldt; extern union descriptor gdt[]; extern struct soft_segment_descriptor gdt_segs[]; diff --git a/sys/i386/include/smp.h b/sys/i386/include/smp.h index 0f4f915..3750c72 100644 --- a/sys/i386/include/smp.h +++ b/sys/i386/include/smp.h @@ -6,7 +6,7 @@ * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp * ---------------------------------------------------------------------------- * - * $Id: smp.h,v 1.43 1998/05/17 22:12:05 tegge Exp $ + * $Id: smp.h,v 1.44 1998/09/06 22:41:40 tegge Exp $ * */ @@ -112,7 +112,6 @@ struct apic_intmapinfo { }; extern struct apic_intmapinfo int_to_apicintpin[]; extern u_int all_cpus; -extern u_char SMP_ioapic[]; extern struct pcb stoppcbs[]; /* functions in mp_machdep.c */ @@ -175,12 +174,6 @@ extern int invltlb_ok; extern int smp_active; extern volatile int smp_idle_loops; -/* 'private' global data in locore.s */ -extern volatile u_int cpuid; -extern volatile u_int cpu_lockid; -extern int inside_intr; -extern volatile u_int other_cpus; - #endif /* !LOCORE */ #endif /* SMP || APIC_IO */ #endif /* KERNEL */ diff --git a/sys/i386/include/tss.h b/sys/i386/include/tss.h index 565defa..636133a 100644 --- a/sys/i386/include/tss.h +++ b/sys/i386/include/tss.h @@ -34,12 +34,14 @@ * SUCH DAMAGE. * * from: @(#)tss.h 5.4 (Berkeley) 1/18/91 - * $Id$ + * $Id: tss.h,v 1.8 1997/02/22 09:35:20 peter Exp $ */ #ifndef _MACHINE_TSS_H_ #define _MACHINE_TSS_H_ 1 +#include <machine/globals.h> + /* * Intel 386 Context Data Type */ @@ -79,4 +81,11 @@ struct i386tss { int tss_ioopt; /* options & io offset bitmap: currently zero */ /* XXX unimplemented .. i/o permission bitmap */ }; + +#ifdef KERNEL +#ifndef common_tss +extern struct i386tss common_tss; +#endif +#endif + #endif /* _MACHINE_TSS_H_ */ diff --git a/sys/i386/include/vm86.h b/sys/i386/include/vm86.h index 0862f49..a7d565c 100644 --- a/sys/i386/include/vm86.h +++ b/sys/i386/include/vm86.h @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: vm86.h,v 1.8 1998/09/29 09:06:00 bde Exp $ + * $Id: vm86.h,v 1.9 1999/03/18 04:37:35 jlemon Exp $ */ #ifndef _MACHINE_VM86_H_ @@ -49,6 +49,7 @@ typedef union { /* layout must match definition of struct trapframe_vm86 in <machine/frame.h> */ struct vm86frame { + int kernel_fs; int kernel_es; int kernel_ds; reg86_t edi; |