Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. =================================================================== RCS file: /ftp/cvs/cvsroot/src/sys/arch/i386/include/cpu.h,v rcsdiff: /ftp/cvs/cvsroot/src/sys/arch/i386/include/cpu.h,v: warning: Unknown phrases like `commitid ...;' are present. retrieving revision 1.151 retrieving revision 1.151.4.4 diff -u -p -r1.151 -r1.151.4.4 --- src/sys/arch/i386/include/cpu.h 2007/12/03 22:17:28 1.151 +++ src/sys/arch/i386/include/cpu.h 2008/01/19 12:14:21 1.151.4.4 @@ -1,4 +1,4 @@ -/* $NetBSD: cpu.h,v 1.151 2007/12/03 22:17:28 joerg Exp $ */ +/* $NetBSD: cpu.h,v 1.151.4.4 2008/01/19 12:14:21 bouyer Exp $ */ /*- * Copyright (c) 1990 The Regents of the University of California. @@ -40,9 +40,9 @@ #ifdef _KERNEL #if defined(_KERNEL_OPT) #include "opt_multiprocessor.h" -#include "opt_math_emulate.h" #include "opt_user_ldt.h" #include "opt_vm86.h" +#include "opt_xen.h" #endif /* @@ -64,6 +64,9 @@ struct intrsource; struct pmap; +#define NIOPORTS 1024 /* # of ports we allow to be mapped */ +#define IOMAPSIZE (NIOPORTS / 8) /* I/O bitmap size in bytes */ + /* * a bunch of this belongs in cpuvar.h; move it later.. */ @@ -85,6 +88,10 @@ struct cpu_info { cpuid_t ci_cpuid; /* our CPU ID */ int ci_cpumask; /* (1 << CPU ID) */ u_int ci_apicid; /* our APIC ID */ + uint8_t ci_initapicid; /* our intitial APIC ID */ + uint8_t ci_packageid; + uint8_t ci_coreid; + uint8_t ci_smtid; struct cpu_data ci_data; /* MI per-cpu data */ struct cc_microtime_state ci_cc;/* cc_microtime state */ @@ -100,7 +107,11 @@ struct cpu_info { #define TLBSTATE_LAZY 1 /* tlbs are valid but won't be kept uptodate */ #define TLBSTATE_STALE 2 /* we might have stale user tlbs */ +#ifdef XEN + struct iplsource *ci_isources[NIPL]; +#else struct intrsource *ci_isources[MAX_INTR_SOURCES]; +#endif volatile int ci_mtx_count; /* Negative count of spin mutexes */ volatile int ci_mtx_oldspl; /* Old SPL at this ci_idepth */ @@ -117,7 +128,6 @@ struct cpu_info { uint32_t ci_imask[NIPL]; uint32_t ci_iunmask[NIPL]; - paddr_t ci_idle_pcb_paddr; /* PA of idle PCB */ uint32_t ci_flags; /* flags; see below */ uint32_t ci_ipis; /* interprocessor interrupts pending */ int sc_apic_version; /* local APIC version */ @@ -157,6 +167,37 @@ struct cpu_info { struct evcnt ci_ipi_events[X86_NIPI]; struct via_padlock ci_vp; /* VIA PadLock private storage */ + + struct i386tss ci_tss; /* Per-cpu TSS; shared among LWPs */ + char ci_iomap[IOMAPSIZE]; /* I/O Bitmap */ + int ci_tss_sel; /* TSS selector of this cpu */ + + /* + * The following two are actually region_descriptors, + * but that would pollute the namespace. + */ + uint32_t ci_suspend_gdt; + uint16_t ci_suspend_gdt_padding; + uint32_t ci_suspend_idt; + uint16_t ci_suspend_idt_padding; + + uint16_t ci_suspend_tr; + uint16_t ci_suspend_ldt; + uint16_t ci_suspend_fs; + uint16_t ci_suspend_gs; + uint32_t ci_suspend_ebx; + uint32_t ci_suspend_esi; + uint32_t ci_suspend_edi; + uint32_t ci_suspend_ebp; + uint32_t ci_suspend_esp; + uint32_t ci_suspend_efl; + uint32_t ci_suspend_cr0; + uint32_t ci_suspend_cr2; + uint32_t ci_suspend_cr3; + uint32_t ci_suspend_cr4; +#ifdef XEN + int ci_fpused; /* FPU was used by curlwp */ +#endif }; /* @@ -193,15 +234,15 @@ extern struct cpu_info *cpu_info_list; #define X86_MAXPROCS 32 /* because we use a bitmask */ -#define CPU_STARTUP(_ci) ((_ci)->ci_func->start(_ci)) -#define CPU_STOP(_ci) ((_ci)->ci_func->stop(_ci)) -#define CPU_START_CLEANUP(_ci) ((_ci)->ci_func->cleanup(_ci)) +#define CPU_STARTUP(_ci, _target) ((_ci)->ci_func->start(_ci, _target)) +#define CPU_STOP(_ci) ((_ci)->ci_func->stop(_ci)) +#define CPU_START_CLEANUP(_ci) ((_ci)->ci_func->cleanup(_ci)) #if defined(__GNUC__) && defined(_KERNEL) static struct cpu_info *x86_curcpu(void); static lwp_t *x86_curlwp(void); -__inline static struct cpu_info * __attribute__((__unused__)) +__inline static struct cpu_info * __unused x86_curcpu(void) { struct cpu_info *ci; @@ -213,7 +254,7 @@ x86_curcpu(void) return ci; } -__inline static lwp_t * __attribute__((__unused__)) +__inline static lwp_t * __unused x86_curlwp(void) { lwp_t *l; @@ -242,9 +283,14 @@ void cpu_boot_secondary_processors(void) void cpu_init_idle_lwps(void); extern uint32_t cpus_attached; - +#ifndef XEN #define curcpu() x86_curcpu() #define curlwp x86_curlwp() +#else +/* XXX initgdt() calls pmap_kenter_pa() which calls splvm() before %fs is set */ +#define curcpu() (&cpu_info_primary) +#define curlwp curcpu()->ci_curlwp +#endif #define curpcb (&curlwp->l_addr->u_pcb) /* @@ -334,7 +380,6 @@ extern int i386_has_sse2; /* machdep.c */ void dumpconf(void); -int cpu_maxproc(void); void cpu_reset(void); void i386_proc0_tss_ldt_init(void); @@ -354,35 +399,39 @@ void cpu_proc_fork(struct proc *, struct /* locore.s */ struct region_descriptor; void lgdt(struct region_descriptor *); +#ifdef XEN +void lgdt_finish(void); +void i386_switch_context(lwp_t *); +#endif void fillw(short, void *, size_t); struct pcb; void savectx(struct pcb *); void lwp_trampoline(void); - +#ifdef XEN +void startrtclock(void); +void xen_delay(unsigned int); +void xen_initclocks(void); +#else /* clock.c */ void initrtclock(u_long); void startrtclock(void); void i8254_delay(unsigned int); void i8254_microtime(struct timeval *); void i8254_initclocks(void); +#endif /* cpu.c */ void cpu_probe_features(struct cpu_info *); /* npx.c */ -void npxsave_lwp(struct lwp *, int); -void npxsave_cpu(struct cpu_info *, int); +void npxsave_lwp(struct lwp *, bool); +void npxsave_cpu(bool); /* vm_machdep.c */ int kvtop(void *); -#ifdef MATH_EMULATE -/* math_emulate.c */ -int math_emulate(struct trapframe *, ksiginfo_t *); -#endif - #ifdef USER_LDT /* sys_machdep.h */ int x86_get_ldt(struct lwp *, void *, register_t *);