Date: Thu, 16 Feb 2006 08:43:25 GMT From: Kip Macy <kmacy@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 91873 for review Message-ID: <200602160843.k1G8hPUS094660@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=91873 Change 91873 by kmacy@kmacy_storage:sun4v_work on 2006/02/16 08:43:14 set up trap table and comment areas for dev and cpu mondo initialization next steps - actually allocate and declare dev and cpu mondo areas and initialize kernel page tables Affected files ... .. //depot/projects/kmacy_sun4v/src/sys/sun4v/include/asi.h#5 edit .. //depot/projects/kmacy_sun4v/src/sys/sun4v/include/cpufunc.h#3 edit .. //depot/projects/kmacy_sun4v/src/sys/sun4v/include/pmap.h#4 edit .. //depot/projects/kmacy_sun4v/src/sys/sun4v/include/trap.h#2 edit .. //depot/projects/kmacy_sun4v/src/sys/sun4v/sun4v/intr_machdep.c#2 edit .. //depot/projects/kmacy_sun4v/src/sys/sun4v/sun4v/machdep.c#5 edit .. //depot/projects/kmacy_sun4v/src/sys/sun4v/sun4v/pmap.c#6 edit .. //depot/projects/kmacy_sun4v/src/sys/sun4v/sun4v/support.S#3 edit .. //depot/projects/kmacy_sun4v/src/sys/sun4v/sun4v/trap.c#3 edit Differences ... ==== //depot/projects/kmacy_sun4v/src/sys/sun4v/include/asi.h#5 (text+ko) ==== @@ -122,9 +122,10 @@ #define ASI_SCRATCHPAD_6_REG 0x30 #define ASI_SCRATCHPAD_7_REG 0x38 -#define SCRATCH_REG_PCPU ASI_SCRATCHPAD_0_REG -#define SCRATCH_REG_PCB ASI_SCRATCHPAD_1_REG -#define SCRATCH_REG_PTD ASI_SCRATCHPAD_2_REG +/* MMFSA == 0 */ +#define SCRATCH_REG_PCPU ASI_SCRATCHPAD_1_REG +#define SCRATCH_REG_PCB ASI_SCRATCHPAD_2_REG +#define SCRATCH_REG_PTD ASI_SCRATCHPAD_3_REG #define MMU_CID_P 0x08 #define MMU_CID_S 0x10 ==== //depot/projects/kmacy_sun4v/src/sys/sun4v/include/cpufunc.h#3 (text+ko) ==== @@ -224,7 +224,9 @@ void ascopyfrom(u_long sasi, vm_offset_t src, caddr_t dst, size_t len); void ascopyto(caddr_t src, u_long dasi, vm_offset_t dst, size_t len); void aszero(u_long asi, vm_offset_t dst, size_t len); - +void set_mmfsa_scratchpad(vm_paddr_t mmfsa); +void setwstate(u_long wstate); +void set_tba(void *tba); /* * Ultrasparc II doesn't implement popc in hardware. Suck. */ ==== //depot/projects/kmacy_sun4v/src/sys/sun4v/include/pmap.h#4 (text+ko) ==== @@ -90,7 +90,7 @@ int pmap_protect_tte(struct pmap *pm1, struct pmap *pm2, struct tte *tp, vm_offset_t va); -void pmap_map_tsb(void); +void pmap_set_tsbs(void); void pmap_clear_write(vm_page_t m); ==== //depot/projects/kmacy_sun4v/src/sys/sun4v/include/trap.h#2 (text+ko) ==== @@ -91,6 +91,7 @@ #ifndef LOCORE extern const char *trap_msg[]; +void trap_init(void); #endif #endif ==== //depot/projects/kmacy_sun4v/src/sys/sun4v/sun4v/intr_machdep.c#2 (text+ko) ==== @@ -228,6 +228,9 @@ { mtx_init(&intr_table_lock, "intr table", NULL, MTX_SPIN); + /* SUN4V_FIXME - declare cpu and dev mondo etc. areas + * to hypervisor here + */ } static void ==== //depot/projects/kmacy_sun4v/src/sys/sun4v/sun4v/machdep.c#5 (text+ko) ==== @@ -400,10 +400,16 @@ /* * Initialize global registers. + * needed for curthread to work */ cpu_setregs(pc); /* + * setup trap table and fault status area + */ + trap_init(); + + /* * Initialize the message buffer (after setting trap table). */ msgbufinit(msgbufp, MSGBUF_SIZE); ==== //depot/projects/kmacy_sun4v/src/sys/sun4v/sun4v/pmap.c#6 (text+ko) ==== @@ -79,6 +79,8 @@ struct ofw_mem_region sparc64_memreg[128]; int sparc64_nmemreg; +extern vm_paddr_t mmu_fault_status_area; + /* * First and last available kernel virtual addresses. @@ -274,6 +276,19 @@ tsb_kernel_phys = pa; PANIC_IF(hv_mem_scrub(tsb_kernel_phys, tsb_kernel_size, &scrubbed)); PANIC_IF(scrubbed != tsb_kernel_size); + + /* + * allocate MMU fault status areas for all CPUS + */ + mmu_fault_status_area = pmap_bootstrap_alloc(MMFSA_SIZE*MAXCPU); + + /* + * Allocate mondo areas for cpu / dev mondos + * + */ + + /* XXX SUN4V_FIXME - add allocation here */ + /* * Allocate and map the message buffer. */ @@ -453,7 +468,7 @@ void pmap_growkernel(vm_offset_t addr) { - + UNIMPLEMENTED; } void @@ -666,6 +681,20 @@ return (0); } +void +pmap_set_tsbs(void) +{ + uint64_t rv; + /* XXX SUN4V_FIXME + * we actually want to have the TSB be per-strand + * which means we don't necessarily want 128MB + * devoted to TSBs + */ + rv = hv_set_ctx0(1, tsb_kernel_phys); + if (rv != H_EOK) + panic("setting ctx0 tsb failed"); +} + /* * pmap_ts_referenced: * ==== //depot/projects/kmacy_sun4v/src/sys/sun4v/sun4v/support.S#3 (text+ko) ==== @@ -660,7 +660,25 @@ END(openfirmware_exit) #endif - +ENTRY(setwstate) + retl + wrpr %g0, %o0, %wstate +END(setwstate) + +ENTRY(set_mmfsa_scratchpad) + stxa %o0, [%g0]ASI_SCRATCHPAD + retl + nop +END(set_mmfsa_scratchpad) + +ENTRY(set_tba) + mov %o0, %o1 + rdpr %tba, %o0 + wrpr %o1, %tba + retl + nop +END(set_tba) + #ifdef GPROF ENTRY(user) ==== //depot/projects/kmacy_sun4v/src/sys/sun4v/sun4v/trap.c#3 (text+ko) ==== @@ -87,10 +87,14 @@ #include <machine/tlb.h> #include <machine/tsb.h> #include <machine/watch.h> +#include <machine/wstate.h> +#include <machine/hypervisor_api.h> void trap(struct trapframe *tf); void syscall(struct trapframe *tf); +vm_paddr_t mmu_fault_status_area; + static int trap_pfault(struct thread *td, struct trapframe *tf); extern char copy_fault[]; @@ -222,8 +226,29 @@ CTASSERT(sizeof(struct trapframe) == 256); int debugger_on_signal = 0; +#ifdef DEBUG SYSCTL_INT(_debug, OID_AUTO, debugger_on_signal, CTLFLAG_RW, &debugger_on_signal, 0, ""); +#endif + + +void +trap_init(void) +{ + vm_paddr_t mmfsa; + + mmfsa = mmu_fault_status_area + (MMFSA_SIZE*PCPU_GET(cpuid)); + setwstate(WSTATE_KERNEL); + set_mmfsa_scratchpad(mmfsa); +#ifdef notyet +/* XXX SUN4V_FIXME - need to add to OFW support code */ + OF_set_mmfsa_traptable(tl0_base, mmfsa); +#else + set_tba(tl0_base); +#endif + + pmap_set_tsbs(); +} void trap(struct trapframe *tf)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200602160843.k1G8hPUS094660>