diff --exclude .svn -ur sys/mips/include/asm.h sys/mips/include/asm.h --- sys/mips/include/asm.h 2010-04-30 20:46:26.001144000 +0530 +++ sys/mips/include/asm.h 2010-05-05 14:36:29.000033000 +0530 @@ -792,9 +792,13 @@ #define DYNAMIC_STATUS_MASK_TOUSER(sr,scratch1) #endif +#ifdef TARGET_XLR_XLS +#define GET_CPU_PCPU(reg) \ + MFC0 reg, $22, 4 +#else #define GET_CPU_PCPU(reg) \ PTR_L reg, _C_LABEL(pcpup); - +#endif /* * Description of the setjmp buffer * diff --exclude .svn -ur sys/mips/include/cpufunc.h sys/mips/include/cpufunc.h --- sys/mips/include/cpufunc.h 2010-05-03 19:45:06.000362000 +0530 +++ sys/mips/include/cpufunc.h 2010-05-04 23:14:10.000069000 +0530 @@ -236,6 +236,23 @@ #undef MIPS_RDRW32_COP0 +static __inline uint32_t mips_rd_cop0(int reg, int sel) +{ + uint32_t val; + + __asm __volatile ( + "mfc0 %0, $%1, %2" + : "=r"(val) : "i"(reg), "i"(sel)); + return val; +} + +static __inline void mips_wr_cop0(int reg, int sel, uint32_t val) +{ + __asm __volatile ( + "mtc0 %0, $%1, %2" + : : "r"(val), "i"(reg), "i"(sel)); +} + static __inline register_t intr_disable(void) { diff --exclude .svn -ur sys/mips/include/pcpu.h sys/mips/include/pcpu.h --- sys/mips/include/pcpu.h 2010-02-10 14:58:24.002679000 +0530 +++ sys/mips/include/pcpu.h 2010-05-04 15:54:25.000020000 +0530 @@ -41,12 +41,17 @@ u_int pc_pending_ipis; /* IPIs pending to this CPU */ #ifdef _KERNEL +struct pcpu; extern char pcpu_space[MAXCPU][PAGE_SIZE * 2]; #define PCPU_ADDR(cpu) (struct pcpu *)(pcpu_space[(cpu)]) +#ifdef TARGET_XLR_XLS +#define PCPUP ((struct pcpu *)mips_rd_cop0(22, 4)) +#else extern struct pcpu *pcpup; #define PCPUP pcpup +#endif #define PCPU_ADD(member, value) (PCPUP->pc_ ## member += (value)) #define PCPU_GET(member) (PCPUP->pc_ ## member) @@ -55,12 +60,10 @@ #define PCPU_SET(member,value) (PCPUP->pc_ ## member = (value)) #define PCPU_LAZY_INC(member) (++PCPUP->pc_ ## member) -#ifdef SMP /* * Instantiate the wired TLB entry at PCPU_TLB_ENTRY to map 'pcpu' at 'pcpup'. */ -void mips_pcpu_tlb_init(struct pcpu *pcpu); -#endif +void mips_pcpup_init(struct pcpu *pcpu); #endif /* _KERNEL */ diff --exclude .svn -ur sys/mips/mips/machdep.c sys/mips/mips/machdep.c --- sys/mips/mips/machdep.c 2010-05-07 16:44:14.000953000 +0530 +++ sys/mips/mips/machdep.c 2010-05-04 23:08:05.000606000 +0530 @@ -133,7 +133,7 @@ char pcpu_space[MAXCPU][PAGE_SIZE * 2] \ __aligned(PAGE_SIZE * 2) __section(".data"); -struct pcpu *pcpup = (struct pcpu *)pcpu_space; +//struct pcpu *pcpup = (struct pcpu *)pcpu_space; vm_offset_t phys_avail[PHYS_AVAIL_ENTRIES + 2]; vm_offset_t physmem_desc[PHYS_AVAIL_ENTRIES + 2]; @@ -408,10 +408,18 @@ ((void(*)(void))(intptr_t)MIPS_VEC_RESET)(); } -#ifdef SMP +#ifdef TARGET_XLR_XLS +void +mips_pcpup_init(struct pcpu *pcpu) +{ + printf("PCPU %p\n\n", pcpu); + mips_wr_cop0(22, 4, (uint32_t)pcpu); +} +#else void -mips_pcpu_tlb_init(struct pcpu *pcpu) +mips_pcpup_init(struct pcpu *pcpu) { +#ifdef SMP vm_paddr_t pa; struct tlb tlb; int lobits; @@ -420,6 +428,8 @@ * Map the pcpu structure at the virtual address 'pcpup'. * We use a wired tlb index to do this one-time mapping. */ + if ((vm_offset_t)pcpup < VM_MIN_KERNEL_ADDRESS) + return; memset(&tlb, 0, sizeof(tlb)); pa = vtophys(pcpu); lobits = PTE_RW | PTE_V | PTE_G | PTE_CACHE; @@ -429,6 +439,7 @@ Mips_TLBWriteIndexed(PCPU_TLB_ENTRY, &tlb); } #endif +#endif /* * Initialise a struct pcpu. @@ -439,10 +450,7 @@ pcpu->pc_next_asid = 1; pcpu->pc_asid_generation = 1; -#ifdef SMP - if ((vm_offset_t)pcpup >= VM_MIN_KERNEL_ADDRESS) - mips_pcpu_tlb_init(pcpu); -#endif + mips_pcpup_init(pcpu); } int diff --exclude .svn -ur sys/mips/mips/pmap.c sys/mips/mips/pmap.c --- sys/mips/mips/pmap.c 2010-05-07 16:44:14.000767000 +0530 +++ sys/mips/mips/pmap.c 2010-05-05 20:17:21.000074000 +0530 @@ -105,7 +105,6 @@ #endif #undef PMAP_DEBUG -//#define PMAP_DEBUG #ifndef PMAP_SHPGPERPROC #define PMAP_SHPGPERPROC 200 @@ -414,13 +413,14 @@ virtual_avail = VM_MIN_KERNEL_ADDRESS; virtual_end = VM_MAX_KERNEL_ADDRESS; -#ifdef SMP +#if defined(SMP) && !defined(TARGET_XLR_XLS) /* * Steal some virtual address space to map the pcpu area. */ virtual_avail = roundup2(virtual_avail, PAGE_SIZE * 2); pcpup = (struct pcpu *)virtual_avail; virtual_avail += PAGE_SIZE * 2; +#endif /* * Initialize the wired TLB entry mapping the pcpu region for @@ -428,11 +428,10 @@ * with the 'pcpup' for the BSP pointing to a virtual address * in KSEG0 so there was no need for a TLB mapping. */ - mips_pcpu_tlb_init(PCPU_ADDR(0)); + mips_pcpup_init(PCPU_ADDR(0)); if (bootverbose) - printf("pcpu is available at virtual address %p.\n", pcpup); -#endif + printf("pcpu is available at virtual address %p.\n", PCPU_ADDR(0)); /* * Steal some virtual space that will not be in kernel_segmap. This