Index: head/sys/sparc64/include/pcb.h =================================================================== --- head/sys/sparc64/include/pcb.h (revision 112916) +++ head/sys/sparc64/include/pcb.h (revision 112917) @@ -1,51 +1,51 @@ /*- * Copyright (c) 2001 Jake Burkholder. * 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. * * $FreeBSD$ */ #ifndef _MACHINE_PCB_H_ #define _MACHINE_PCB_H_ #include #include #define MAXWIN 8 /* NOTE: pcb_fpstate must be aligned on a 64 byte boundary. */ struct pcb { struct fpstate pcb_fpstate; - u_long pcb_fp; + u_long pcb_sp; u_long pcb_pc; u_long pcb_nsaved; u_long pcb_rwsp[MAXWIN]; struct rwindow pcb_rw[MAXWIN]; } __aligned(64); #ifdef _KERNEL int savectx(struct pcb *pcb); #endif #endif /* !_MACHINE_PCB_H_ */ Index: head/sys/sparc64/sparc64/db_trace.c =================================================================== --- head/sys/sparc64/sparc64/db_trace.c (revision 112916) +++ head/sys/sparc64/sparc64/db_trace.c (revision 112917) @@ -1,316 +1,316 @@ /*- * Copyright (c) 2001 Jake Burkholder. * 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. * * $FreeBSD$ */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include static int db_print_trap(struct thread *td, struct trapframe *); static void db_utrace(struct thread *td, struct trapframe *tf); #define INKERNEL(va) \ ((va) >= VM_MIN_KERNEL_ADDRESS && (va) <= VM_MAX_KERNEL_ADDRESS) struct db_variable db_regs[] = { { "g0", &ddb_regs.tf_global[0], FCN_NULL }, { "g1", &ddb_regs.tf_global[1], FCN_NULL }, { "g2", &ddb_regs.tf_global[2], FCN_NULL }, { "g3", &ddb_regs.tf_global[3], FCN_NULL }, { "g4", &ddb_regs.tf_global[4], FCN_NULL }, { "g5", &ddb_regs.tf_global[5], FCN_NULL }, { "g6", &ddb_regs.tf_global[6], FCN_NULL }, { "g7", &ddb_regs.tf_global[7], FCN_NULL }, { "i0", &ddb_regs.tf_out[0], FCN_NULL }, { "i1", &ddb_regs.tf_out[1], FCN_NULL }, { "i2", &ddb_regs.tf_out[2], FCN_NULL }, { "i3", &ddb_regs.tf_out[3], FCN_NULL }, { "i4", &ddb_regs.tf_out[4], FCN_NULL }, { "i5", &ddb_regs.tf_out[5], FCN_NULL }, { "i6", &ddb_regs.tf_out[6], FCN_NULL }, { "i7", &ddb_regs.tf_out[7], FCN_NULL }, { "tnpc", &ddb_regs.tf_tnpc, FCN_NULL }, { "tpc", &ddb_regs.tf_tpc, FCN_NULL }, { "tstate", &ddb_regs.tf_tstate, FCN_NULL }, }; struct db_variable *db_eregs = db_regs + sizeof(db_regs)/sizeof(db_regs[0]); void db_stack_trace_cmd(db_expr_t addr, boolean_t have_addr, db_expr_t count, char *modif) { struct trapframe *tf; struct frame *fp; struct proc *p; struct thread *td; const char *name; c_db_sym_t sym; db_expr_t offset; db_expr_t value; db_addr_t npc; db_addr_t pc; int trap; int user; pid_t pid; trap = 0; user = 0; npc = 0; if (count == -1) count = 1024; td = curthread; p = td->td_proc; /* * Provide an /a modifier to pass the stack address instead of a PID * as argument. * Note that, if this address is not on the stack of curthread, the * printed data may be wrong (at the moment, this applies only to the * sysent list). */ if (!have_addr) addr = DDB_REGS->tf_out[6]; else if (strcmp(modif, "a") != 0) { /* * addr was parsed as hex, convert so it is interpreted as * decimal (ugh). */ pid = (addr % 16) + ((addr >> 4) % 16) * 10 + ((addr >> 8) % 16) * 100 + ((addr >> 12) % 16) * 1000 + ((addr >> 16) % 16) * 10000; /* * The pcb for curproc is not valid at this point, * so fall back to the default case. */ if (pid == curthread->td_proc->p_pid) { td = curthread; p = td->td_proc; addr = DDB_REGS->tf_out[6]; } else { /* sx_slock(&allproc_lock); */ LIST_FOREACH(p, &allproc, p_list) { if (p->p_pid == pid) break; } /* sx_sunlock(&allproc_lock); */ if (p == NULL) { db_printf("pid %d not found\n", pid); return; } if ((p->p_sflag & PS_INMEM) == 0) { db_printf("pid %d swapped out\n", pid); return; } td = FIRST_THREAD_IN_PROC(p); /* XXXKSE */ - addr = td->td_pcb->pcb_fp; + addr = td->td_pcb->pcb_sp; } } fp = (struct frame *)(addr + SPOFF); while (count-- && !user) { pc = (db_addr_t)db_get_value((db_addr_t)&fp->fr_pc, sizeof(fp->fr_pc), FALSE); if (trap) { pc = npc; trap = 0; } if (!INKERNEL((vm_offset_t)pc)) break; sym = db_search_symbol(pc, DB_STGY_ANY, &offset); if (sym == C_DB_SYM_NULL) { value = 0; name = NULL; } else db_symbol_values(sym, &name, &value); if (name == NULL) name = "(null)"; fp = (struct frame *)(db_get_value((db_addr_t)&fp->fr_fp, sizeof(fp->fr_fp), FALSE) + SPOFF); if (bcmp(name, "tl0_", 4) == 0 || bcmp(name, "tl1_", 4) == 0) { tf = (struct trapframe *)(fp + 1); npc = db_get_value((db_addr_t)&tf->tf_tpc, sizeof(tf->tf_tpc), FALSE); user = db_print_trap(td, tf); trap = 1; } else { db_printf("%s() at ", name); db_printsym(pc, DB_STGY_PROC); db_printf("\n"); } } } static int db_print_trap(struct thread *td, struct trapframe *tf) { struct proc *p; const char *symname; c_db_sym_t sym; db_expr_t diff; db_addr_t func; db_addr_t tpc; u_long type; u_long sfar; u_long sfsr; u_long tar; u_long level; u_long pil; u_long code; u_long o7; int user; p = td->td_proc; type = db_get_value((db_addr_t)&tf->tf_type, sizeof(tf->tf_type), FALSE); db_printf("-- %s", trap_msg[type & ~T_KERNEL]); switch (type & ~T_KERNEL) { case T_DATA_PROTECTION: tar = (u_long)db_get_value((db_addr_t)&tf->tf_tar, sizeof(tf->tf_tar), FALSE); db_printf(" tar=%#lx", tar); /* fall through */ case T_DATA_EXCEPTION: case T_INSTRUCTION_EXCEPTION: case T_MEM_ADDRESS_NOT_ALIGNED: sfar = (u_long)db_get_value((db_addr_t)&tf->tf_sfar, sizeof(tf->tf_sfar), FALSE); sfsr = (u_long)db_get_value((db_addr_t)&tf->tf_sfsr, sizeof(tf->tf_sfsr), FALSE); db_printf(" sfar=%#lx sfsr=%#lx", sfar, sfsr); break; case T_DATA_MISS: case T_INSTRUCTION_MISS: tar = (u_long)db_get_value((db_addr_t)&tf->tf_tar, sizeof(tf->tf_tar), FALSE); db_printf(" tar=%#lx", tar); break; case T_SYSCALL: code = db_get_value((db_addr_t)&tf->tf_global[1], sizeof(tf->tf_global[1]), FALSE); db_printf(" (%ld", code); if (code >= 0 && code < p->p_sysent->sv_size) { func = (db_addr_t)p->p_sysent->sv_table[code].sy_call; sym = db_search_symbol(func, DB_STGY_ANY, &diff); if (sym != DB_SYM_NULL && diff == 0) { db_symbol_values(sym, &symname, NULL); db_printf(", %s, %s", p->p_sysent->sv_name, symname); } db_printf(")"); } break; case T_INTERRUPT: level = (u_long)db_get_value((db_addr_t)&tf->tf_level, sizeof(tf->tf_level), FALSE); pil = (u_long)db_get_value((db_addr_t)&tf->tf_pil, sizeof(tf->tf_pil), FALSE); db_printf(" level=%#lx pil=%#lx", level, pil); break; default: break; } o7 = (u_long)db_get_value((db_addr_t)&tf->tf_out[7], sizeof(tf->tf_out[7]), FALSE); db_printf(" %%o7=%#lx --\n", o7); user = (type & T_KERNEL) == 0; if (user) { tpc = db_get_value((db_addr_t)&tf->tf_tpc, sizeof(tf->tf_tpc), FALSE); db_printf("userland() at "); db_printsym(tpc, DB_STGY_PROC); db_printf("\n"); db_utrace(td, tf); } return (user); } /* * User stack trace (debugging aid). */ static void db_utrace(struct thread *td, struct trapframe *tf) { struct pcb *pcb; db_addr_t sp, rsp, o7, pc; int i, found; pcb = td->td_pcb; sp = db_get_value((db_addr_t)&tf->tf_sp, sizeof(tf->tf_sp), FALSE); o7 = db_get_value((db_addr_t)&tf->tf_out[7], sizeof(tf->tf_out[7]), FALSE); pc = db_get_value((db_addr_t)&tf->tf_tpc, sizeof(tf->tf_tpc), FALSE); db_printf("user trace: trap %%o7=%#lx\n", o7); while (sp != 0) { db_printf("pc %#lx, sp %#lx\n", pc, sp); /* First, check whether the frame is in the pcb. */ found = 0; for (i = 0; i < pcb->pcb_nsaved; i++) { if (pcb->pcb_rwsp[i] == sp) { found = 1; sp = pcb->pcb_rw[i].rw_in[6]; pc = pcb->pcb_rw[i].rw_in[7]; break; } } if (!found) { rsp = sp + SPOFF; sp = NULL; if (copyin((void *)(rsp + offsetof(struct frame, fr_fp)), &sp, sizeof(sp)) != 0 || copyin((void *)(rsp + offsetof(struct frame, fr_pc)), &pc, sizeof(pc)) != 0) break; } } db_printf("done\n"); } void db_print_backtrace(void) { u_long *sp; sp = __builtin_frame_address(1); db_stack_trace_cmd((db_expr_t)sp, TRUE, -1, "a"); } Index: head/sys/sparc64/sparc64/genassym.c =================================================================== --- head/sys/sparc64/sparc64/genassym.c (revision 112916) +++ head/sys/sparc64/sparc64/genassym.c (revision 112917) @@ -1,306 +1,306 @@ /*- * Copyright (c) 2001 Jake Burkholder. * 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. * * from: @(#)genassym.c 5.11 (Berkeley) 5/10/91 * $FreeBSD$ */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include ASSYM(KERNBASE, KERNBASE); ASSYM(VM_MIN_PROM_ADDRESS, VM_MIN_PROM_ADDRESS); ASSYM(EFAULT, EFAULT); ASSYM(ENAMETOOLONG, ENAMETOOLONG); ASSYM(KSTACK_PAGES, KSTACK_PAGES); ASSYM(KSTACK_GUARD_PAGES, KSTACK_GUARD_PAGES); ASSYM(PCPU_PAGES, PCPU_PAGES); ASSYM(UAREA_PAGES, UAREA_PAGES); ASSYM(PIL_TICK, PIL_TICK); ASSYM(FPRS_DL, FPRS_DL); ASSYM(FPRS_DU, FPRS_DU); ASSYM(FPRS_FEF, FPRS_FEF); ASSYM(LSU_VW, LSU_VW); ASSYM(TAR_VPN_SHIFT, TAR_VPN_SHIFT); ASSYM(TLB_DAR_SLOT_SHIFT, TLB_DAR_SLOT_SHIFT); ASSYM(TLB_DEMAP_NUCLEUS, TLB_DEMAP_NUCLEUS); ASSYM(TLB_DEMAP_PRIMARY, TLB_DEMAP_PRIMARY); ASSYM(TLB_DEMAP_CONTEXT, TLB_DEMAP_CONTEXT); ASSYM(TLB_DEMAP_PAGE, TLB_DEMAP_PAGE); ASSYM(TLB_DIRECT_TO_TTE_MASK, TLB_DIRECT_TO_TTE_MASK); ASSYM(TSB_BUCKET_MASK, TSB_BUCKET_MASK); ASSYM(TSB_BUCKET_SHIFT, TSB_BUCKET_SHIFT); ASSYM(INT_SHIFT, INT_SHIFT); ASSYM(PTR_SHIFT, PTR_SHIFT); ASSYM(PAGE_SHIFT, PAGE_SHIFT); ASSYM(PAGE_SHIFT_8K, PAGE_SHIFT_8K); ASSYM(PAGE_SHIFT_4M, PAGE_SHIFT_4M); ASSYM(PAGE_SIZE, PAGE_SIZE); ASSYM(CPU_CLKSYNC, CPU_CLKSYNC); ASSYM(CPU_INIT, CPU_INIT); ASSYM(CSA_MID, offsetof(struct cpu_start_args, csa_mid)); ASSYM(CSA_PCPU, offsetof(struct cpu_start_args, csa_pcpu)); ASSYM(CSA_STATE, offsetof(struct cpu_start_args, csa_state)); ASSYM(CSA_TICK, offsetof(struct cpu_start_args, csa_tick)); ASSYM(CSA_VER, offsetof(struct cpu_start_args, csa_ver)); ASSYM(CSA_TTES, offsetof(struct cpu_start_args, csa_ttes)); ASSYM(DC_TAG_SHIFT, DC_TAG_SHIFT); ASSYM(DC_TAG_MASK, DC_TAG_MASK); ASSYM(DC_VALID_SHIFT, DC_VALID_SHIFT); ASSYM(DC_VALID_MASK, DC_VALID_MASK); ASSYM(IC_TAG_SHIFT, IC_TAG_SHIFT); ASSYM(IC_TAG_MASK, IC_TAG_MASK); ASSYM(IC_VALID_SHIFT, IC_VALID_SHIFT); ASSYM(IC_VALID_MASK, IC_VALID_MASK); ASSYM(DC_SIZE, offsetof(struct cacheinfo, dc_size)); ASSYM(DC_LINESIZE, offsetof(struct cacheinfo, dc_linesize)); ASSYM(IC_SIZE, offsetof(struct cacheinfo, ic_size)); ASSYM(IC_LINESIZE, offsetof(struct cacheinfo, ic_linesize)); ASSYM(ICA_PA, offsetof(struct ipi_cache_args, ica_pa)); ASSYM(KTR_PROC, KTR_PROC); ASSYM(KTR_TRAP, KTR_TRAP); ASSYM(KTR_SMP, KTR_SMP); ASSYM(KTR_SYSC, KTR_SYSC); ASSYM(KTR_INTR, KTR_INTR); ASSYM(KTR_CT1, KTR_CT1); ASSYM(KTR_CT2, KTR_CT2); ASSYM(KTR_CT3, KTR_CT3); ASSYM(KTR_CT4, KTR_CT4); ASSYM(KTR_CT5, KTR_CT5); ASSYM(KTR_CT6, KTR_CT6); ASSYM(KTR_CT7, KTR_CT7); ASSYM(KTR_CT8, KTR_CT8); ASSYM(KTR_SIZEOF, sizeof(struct ktr_entry)); ASSYM(KTR_LINE, offsetof(struct ktr_entry, ktr_line)); ASSYM(KTR_FILE, offsetof(struct ktr_entry, ktr_file)); ASSYM(KTR_DESC, offsetof(struct ktr_entry, ktr_desc)); ASSYM(KTR_CPU, offsetof(struct ktr_entry, ktr_cpu)); ASSYM(KTR_TIMESTAMP, offsetof(struct ktr_entry, ktr_timestamp)); ASSYM(KTR_PARM1, offsetof(struct ktr_entry, ktr_parms[0])); ASSYM(KTR_PARM2, offsetof(struct ktr_entry, ktr_parms[1])); ASSYM(KTR_PARM3, offsetof(struct ktr_entry, ktr_parms[2])); ASSYM(KTR_PARM4, offsetof(struct ktr_entry, ktr_parms[3])); ASSYM(KTR_PARM5, offsetof(struct ktr_entry, ktr_parms[4])); ASSYM(KTR_PARM6, offsetof(struct ktr_entry, ktr_parms[5])); ASSYM(TTE_VPN, offsetof(struct tte, tte_vpn)); ASSYM(TTE_DATA, offsetof(struct tte, tte_data)); ASSYM(TTE_SHIFT, TTE_SHIFT); ASSYM(TD_EXEC, TD_EXEC); ASSYM(TD_REF, TD_REF); ASSYM(TD_SW, TD_SW); ASSYM(TD_V, TD_V); ASSYM(TD_8K, TD_8K); ASSYM(TD_CP, TD_CP); ASSYM(TD_CV, TD_CV); ASSYM(TD_L, TD_L); ASSYM(TD_W, TD_W); ASSYM(TS_MIN, TS_MIN); ASSYM(TS_MAX, TS_MAX); ASSYM(TV_SIZE_BITS, TV_SIZE_BITS); ASSYM(V_INTR, offsetof(struct vmmeter, v_intr)); ASSYM(PC_CURTHREAD, offsetof(struct pcpu, pc_curthread)); ASSYM(PC_CURPCB, offsetof(struct pcpu, pc_curpcb)); ASSYM(PC_CPUID, offsetof(struct pcpu, pc_cpuid)); ASSYM(PC_CPUMASK, offsetof(struct pcpu, pc_cpumask)); ASSYM(PC_IRHEAD, offsetof(struct pcpu, pc_irhead)); ASSYM(PC_IRTAIL, offsetof(struct pcpu, pc_irtail)); ASSYM(PC_IRFREE, offsetof(struct pcpu, pc_irfree)); ASSYM(PC_MID, offsetof(struct pcpu, pc_mid)); ASSYM(PC_TLB_CTX, offsetof(struct pcpu, pc_tlb_ctx)); ASSYM(PC_TLB_CTX_MAX, offsetof(struct pcpu, pc_tlb_ctx_max)); ASSYM(PC_TLB_CTX_MIN, offsetof(struct pcpu, pc_tlb_ctx_min)); ASSYM(PC_VMSPACE, offsetof(struct pcpu, pc_vmspace)); ASSYM(PC_SIZEOF, sizeof(struct pcpu)); ASSYM(IH_SHIFT, IH_SHIFT); ASSYM(IRSR_BUSY, IRSR_BUSY); ASSYM(IR_NEXT, offsetof(struct intr_request, ir_next)); ASSYM(IR_FUNC, offsetof(struct intr_request, ir_func)); ASSYM(IR_ARG, offsetof(struct intr_request, ir_arg)); ASSYM(IR_PRI, offsetof(struct intr_request, ir_pri)); ASSYM(IR_VEC, offsetof(struct intr_request, ir_vec)); ASSYM(ITA_MASK, offsetof(struct ipi_tlb_args, ita_mask)); ASSYM(ITA_PMAP, offsetof(struct ipi_tlb_args, ita_pmap)); ASSYM(ITA_START, offsetof(struct ipi_tlb_args, ita_start)); ASSYM(ITA_END, offsetof(struct ipi_tlb_args, ita_end)); ASSYM(ITA_VA, offsetof(struct ipi_tlb_args, ita_va)); ASSYM(IV_SHIFT, IV_SHIFT); ASSYM(IV_FUNC, offsetof(struct intr_vector, iv_func)); ASSYM(IV_ARG, offsetof(struct intr_vector, iv_arg)); ASSYM(IV_PRI, offsetof(struct intr_vector, iv_pri)); ASSYM(IV_MAX, IV_MAX); ASSYM(TDF_ASTPENDING, TDF_ASTPENDING); ASSYM(TDF_NEEDRESCHED, TDF_NEEDRESCHED); ASSYM(MD_UTRAP, offsetof(struct mdproc, md_utrap)); ASSYM(MTX_LOCK, offsetof(struct mtx, mtx_lock)); ASSYM(P_COMM, offsetof(struct proc, p_comm)); ASSYM(P_MD, offsetof(struct proc, p_md)); ASSYM(P_PID, offsetof(struct proc, p_pid)); ASSYM(P_SFLAG, offsetof(struct proc, p_sflag)); ASSYM(P_VMSPACE, offsetof(struct proc, p_vmspace)); ASSYM(RW_SHIFT, RW_SHIFT); ASSYM(TD_FLAGS, offsetof(struct thread, td_flags)); ASSYM(TD_FRAME, offsetof(struct thread, td_frame)); ASSYM(TD_KSTACK, offsetof(struct thread, td_kstack)); ASSYM(TD_PCB, offsetof(struct thread, td_pcb)); ASSYM(TD_PROC, offsetof(struct thread, td_proc)); ASSYM(PCB_SIZEOF, sizeof(struct pcb)); ASSYM(PCB_FPSTATE, offsetof(struct pcb, pcb_fpstate)); -ASSYM(PCB_FP, offsetof(struct pcb, pcb_fp)); +ASSYM(PCB_SP, offsetof(struct pcb, pcb_sp)); ASSYM(PCB_PC, offsetof(struct pcb, pcb_pc)); ASSYM(PCB_NSAVED, offsetof(struct pcb, pcb_nsaved)); ASSYM(PCB_RWSP, offsetof(struct pcb, pcb_rwsp)); ASSYM(PCB_RW, offsetof(struct pcb, pcb_rw)); ASSYM(VM_PMAP, offsetof(struct vmspace, vm_pmap)); ASSYM(PM_ACTIVE, offsetof(struct pmap, pm_active)); ASSYM(PM_CONTEXT, offsetof(struct pmap, pm_context)); ASSYM(PM_TSB, offsetof(struct pmap, pm_tsb)); ASSYM(FP_FB0, offsetof(struct fpstate, fp_fb[0])); ASSYM(FP_FB1, offsetof(struct fpstate, fp_fb[1])); ASSYM(FP_FB2, offsetof(struct fpstate, fp_fb[2])); ASSYM(FP_FB3, offsetof(struct fpstate, fp_fb[3])); ASSYM(CCFSZ, sizeof(struct frame)); ASSYM(SPOFF, SPOFF); ASSYM(SF_UC, offsetof(struct sigframe, sf_uc)); ASSYM(_JB_FP, offsetof(struct _jmp_buf, _jb[_JB_FP])); ASSYM(_JB_PC, offsetof(struct _jmp_buf, _jb[_JB_PC])); ASSYM(_JB_SP, offsetof(struct _jmp_buf, _jb[_JB_SP])); ASSYM(_JB_SIGFLAG, offsetof(struct _jmp_buf, _jb[_JB_SIGFLAG])); ASSYM(_JB_SIGMASK, offsetof(struct _jmp_buf, _jb[_JB_SIGMASK])); ASSYM(TF_G0, offsetof(struct trapframe, tf_global[0])); ASSYM(TF_G1, offsetof(struct trapframe, tf_global[1])); ASSYM(TF_G2, offsetof(struct trapframe, tf_global[2])); ASSYM(TF_G3, offsetof(struct trapframe, tf_global[3])); ASSYM(TF_G4, offsetof(struct trapframe, tf_global[4])); ASSYM(TF_G5, offsetof(struct trapframe, tf_global[5])); ASSYM(TF_G6, offsetof(struct trapframe, tf_global[6])); ASSYM(TF_G7, offsetof(struct trapframe, tf_global[7])); ASSYM(TF_O0, offsetof(struct trapframe, tf_out[0])); ASSYM(TF_O1, offsetof(struct trapframe, tf_out[1])); ASSYM(TF_O2, offsetof(struct trapframe, tf_out[2])); ASSYM(TF_O3, offsetof(struct trapframe, tf_out[3])); ASSYM(TF_O4, offsetof(struct trapframe, tf_out[4])); ASSYM(TF_O5, offsetof(struct trapframe, tf_out[5])); ASSYM(TF_O6, offsetof(struct trapframe, tf_out[6])); ASSYM(TF_O7, offsetof(struct trapframe, tf_out[7])); ASSYM(TF_FPRS, offsetof(struct trapframe, tf_fprs)); ASSYM(TF_FSR, offsetof(struct trapframe, tf_fsr)); ASSYM(TF_GSR, offsetof(struct trapframe, tf_gsr)); ASSYM(TF_LEVEL, offsetof(struct trapframe, tf_level)); ASSYM(TF_PIL, offsetof(struct trapframe, tf_pil)); ASSYM(TF_SFAR, offsetof(struct trapframe, tf_sfar)); ASSYM(TF_SFSR, offsetof(struct trapframe, tf_sfsr)); ASSYM(TF_TAR, offsetof(struct trapframe, tf_tar)); ASSYM(TF_TNPC, offsetof(struct trapframe, tf_tnpc)); ASSYM(TF_TPC, offsetof(struct trapframe, tf_tpc)); ASSYM(TF_TSTATE, offsetof(struct trapframe, tf_tstate)); ASSYM(TF_TYPE, offsetof(struct trapframe, tf_type)); ASSYM(TF_Y, offsetof(struct trapframe, tf_y)); ASSYM(TF_WSTATE, offsetof(struct trapframe, tf_wstate)); ASSYM(TF_SIZEOF, sizeof(struct trapframe)); ASSYM(UT_MAX, UT_MAX); Index: head/sys/sparc64/sparc64/swtch.S =================================================================== --- head/sys/sparc64/sparc64/swtch.S (revision 112916) +++ head/sys/sparc64/sparc64/swtch.S (revision 112917) @@ -1,308 +1,308 @@ /*- * Copyright (c) 2001 Jake Burkholder. * 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. * * $FreeBSD$ */ #include #include #include #include .register %g2, #ignore .register %g3, #ignore #include "assym.s" ENTRY(cpu_throw) save %sp, -CCFSZ, %sp call choosethread ldx [PCPU(CURTHREAD)], %l0 flushw b,a %xcc, .Lsw1 nop END(cpu_throw) ENTRY(cpu_switch) /* * Choose a new thread. If its the same as the current one, do * nothing. */ save %sp, -CCFSZ, %sp call choosethread ldx [PCPU(CURTHREAD)], %l0 cmp %l0, %o0 be,a,pn %xcc, 4f nop ldx [%l0 + TD_PCB], %l1 /* * If the current thread was using floating point, save its context. */ ldx [%l0 + TD_FRAME], %l2 ldx [%l2 + TF_FPRS], %l3 andcc %l3, FPRS_FEF, %g0 bz,a,pt %xcc, 1f nop wr %g0, FPRS_FEF, %fprs wr %g0, ASI_BLK_S, %asi stda %f0, [%l1 + PCB_FPSTATE + FP_FB0] %asi stda %f16, [%l1 + PCB_FPSTATE + FP_FB1] %asi stda %f32, [%l1 + PCB_FPSTATE + FP_FB2] %asi stda %f48, [%l1 + PCB_FPSTATE + FP_FB3] %asi membar #Sync wr %g0, 0, %fprs andn %l3, FPRS_FEF, %l3 stx %l3, [%l2 + TF_FPRS] /* * Flush the windows out to the stack and save the current frame * pointer and program counter. */ 1: flushw wrpr %g0, 0, %cleanwin - stx %fp, [%l1 + PCB_FP] + stx %fp, [%l1 + PCB_SP] stx %i7, [%l1 + PCB_PC] /* * Load the new thread's frame pointer and program counter, and set * the current thread and pcb. */ .Lsw1: #if KTR_COMPILE & KTR_PROC CATR(KTR_PROC, "cpu_switch: new td=%p pc=%#lx fp=%#lx" , %g1, %g2, %g3, 7, 8, 9) stx %o0, [%g1 + KTR_PARM1] ldx [%o0 + TD_PCB], %g2 ldx [%g2 + PCB_PC], %g3 stx %g3, [%g1 + KTR_PARM2] - ldx [%g2 + PCB_FP], %g3 + ldx [%g2 + PCB_SP], %g3 stx %g3, [%g1 + KTR_PARM3] 9: #endif ldx [%o0 + TD_PCB], %o1 - ldx [%o1 + PCB_FP], %fp + ldx [%o1 + PCB_SP], %fp ldx [%o1 + PCB_PC], %i7 sub %fp, CCFSZ, %sp stx %o0, [PCPU(CURTHREAD)] stx %o1, [PCPU(CURPCB)] SET(sched_lock, %o3, %o2) stx %o0, [%o2 + MTX_LOCK] wrpr %g0, PSTATE_NORMAL, %pstate mov %o1, PCB_REG wrpr %g0, PSTATE_ALT, %pstate mov %o1, PCB_REG wrpr %g0, PSTATE_KERNEL, %pstate /* * Point to the vmspaces of the new process, and of the last non-kernel * process to run. */ ldx [%o0 + TD_PROC], %o2 ldx [PCPU(VMSPACE)], %l2 ldx [%o2 + P_VMSPACE], %o2 #if KTR_COMPILE & KTR_PROC CATR(KTR_PROC, "cpu_switch: new vm=%p old vm=%p" , %g1, %g2, %g3, 7, 8, 9) stx %o2, [%g1 + KTR_PARM1] stx %l2, [%g1 + KTR_PARM2] 9: #endif /* * If they are the same we are done. */ cmp %l2, %o2 be,a,pn %xcc, 4f nop /* * If the new process has nucleus context we are done. */ lduw [PCPU(CPUID)], %o3 sllx %o3, INT_SHIFT, %o3 add %o2, VM_PMAP + PM_CONTEXT, %o4 lduw [%o3 + %o4], %o5 #if KTR_COMPILE & KTR_PROC CATR(KTR_PROC, "cpu_switch: ctx=%#lx" , %g1, %g2, %g3, 7, 8, 9) stx %o5, [%g1 + KTR_PARM1] 9: #endif brz,a,pn %o5, 4f nop /* * If there was no non-kernel vmspace, don't try to deactivate it. */ brz,a,pn %l2, 2f nop /* * Mark the pmap of the last non-kernel vmspace to run as no longer * active on this cpu. */ lduw [%l2 + VM_PMAP + PM_ACTIVE], %l3 lduw [PCPU(CPUMASK)], %l4 andn %l3, %l4, %l3 stw %l3, [%l2 + VM_PMAP + PM_ACTIVE] /* * Take away its context. */ lduw [PCPU(CPUID)], %l3 sllx %l3, INT_SHIFT, %l3 add %l2, VM_PMAP + PM_CONTEXT, %l4 mov -1, %l5 stw %l5, [%l3 + %l4] /* * Find the current free tlb context for this cpu and install it as * the new primary context. */ 2: lduw [PCPU(TLB_CTX)], %o5 stw %o5, [%o3 + %o4] mov AA_DMMU_PCXR, %o4 stxa %o5, [%o4] ASI_DMMU membar #Sync /* * See if we have run out of free contexts. */ lduw [PCPU(TLB_CTX_MAX)], %o3 #if KTR_COMPILE & KTR_PROC CATR(KTR_PROC, "cpu_switch: ctx=%#lx next=%#lx max=%#lx" , %g1, %g2, %g3, 7, 8, 9) stx %o5, [%g1 + KTR_PARM1] add %o5, 1, %g2 stx %g2, [%g1 + KTR_PARM2] stx %o3, [%g1 + KTR_PARM3] 9: #endif add %o5, 1, %o5 cmp %o3, %o5 bne,a,pt %xcc, 3f stw %o5, [PCPU(TLB_CTX)] #if KTR_COMPILE & KTR_PROC CATR(KTR_PROC, "cpu_switch: context rollover" , %g1, %g2, %g3, 7, 8, 9) 9: #endif /* * We will start re-using contexts on the next switch. Flush all * non-nucleus mappings from the tlb, and reset the next free context. */ call pmap_context_rollover nop ldx [PCPU(CURTHREAD)], %o0 ldx [%o0 + TD_PROC], %o2 ldx [%o2 + P_VMSPACE], %o2 /* * Mark the pmap as active on this cpu. */ 3: lduw [%o2 + VM_PMAP + PM_ACTIVE], %o3 lduw [PCPU(CPUMASK)], %o4 or %o3, %o4, %o3 stw %o3, [%o2 + VM_PMAP + PM_ACTIVE] /* * Make note of the change in vmspace. */ stx %o2, [PCPU(VMSPACE)] /* * Load the tsb registers. */ ldx [%o2 + VM_PMAP + PM_TSB], %o3 mov AA_DMMU_TSB, %o4 stxa %o3, [%o4] ASI_DMMU mov AA_IMMU_TSB, %o4 stxa %o3, [%o4] ASI_IMMU membar #Sync 4: #if KTR_COMPILE & KTR_PROC CATR(KTR_PROC, "cpu_switch: return" , %g1, %g2, %g3, 7, 8, 9) 9: #endif /* * Done. Return and load the new process's window from the stack. */ ret restore END(cpu_switch) ENTRY(savectx) save %sp, -CCFSZ, %sp flushw call savefpctx mov %i0, %o0 - stx %fp, [%i0 + PCB_FP] + stx %fp, [%i0 + PCB_SP] stx %i7, [%i0 + PCB_PC] ret restore %g0, 0, %o0 END(savectx) /* * void savefpctx(struct fpstate *); */ ENTRY(savefpctx) wr %g0, FPRS_FEF, %fprs wr %g0, ASI_BLK_S, %asi stda %f0, [%o0 + PCB_FPSTATE + FP_FB0] %asi stda %f16, [%o0 + PCB_FPSTATE + FP_FB1] %asi stda %f32, [%o0 + PCB_FPSTATE + FP_FB2] %asi stda %f48, [%o0 + PCB_FPSTATE + FP_FB3] %asi membar #Sync retl wr %g0, 0, %fprs END(savefpctx) /* * void restorefpctx(struct fpstate *); */ ENTRY(restorefpctx) wr %g0, FPRS_FEF, %fprs wr %g0, ASI_BLK_S, %asi ldda [%o0 + PCB_FPSTATE + FP_FB0] %asi, %f0 ldda [%o0 + PCB_FPSTATE + FP_FB1] %asi, %f16 ldda [%o0 + PCB_FPSTATE + FP_FB2] %asi, %f32 ldda [%o0 + PCB_FPSTATE + FP_FB3] %asi, %f48 membar #Sync retl wr %g0, 0, %fprs END(restorefpctx) Index: head/sys/sparc64/sparc64/vm_machdep.c =================================================================== --- head/sys/sparc64/sparc64/vm_machdep.c (revision 112916) +++ head/sys/sparc64/sparc64/vm_machdep.c (revision 112917) @@ -1,376 +1,376 @@ /*- * Copyright (c) 1982, 1986 The Regents of the University of California. * Copyright (c) 1989, 1990 William Jolitz * Copyright (c) 1994 John Dyson * Copyright (c) 2001 Jake Burkholder. * All rights reserved. * * This code is derived from software contributed to Berkeley by * the Systems Programming Group of the University of Utah Computer * Science Department, and William Jolitz. * * 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. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. * * from: @(#)vm_machdep.c 7.3 (Berkeley) 5/13/91 * Utah $Hdr: vm_machdep.c 1.16.1.1 89/06/23$ * from: FreeBSD: src/sys/i386/i386/vm_machdep.c,v 1.167 2001/07/12 * $FreeBSD$ */ #include "opt_pmap.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include extern struct ofw_mem_region sparc64_memreg[]; extern int sparc64_nmemreg; PMAP_STATS_VAR(uma_nsmall_alloc); PMAP_STATS_VAR(uma_nsmall_alloc_oc); PMAP_STATS_VAR(uma_nsmall_free); void cpu_exit(struct thread *td) { struct md_utrap *ut; struct proc *p; p = td->td_proc; p->p_md.md_sigtramp = NULL; if ((ut = p->p_md.md_utrap) != NULL) { ut->ut_refcnt--; if (ut->ut_refcnt == 0) free(ut, M_SUBPROC); p->p_md.md_utrap = NULL; } } void cpu_sched_exit(struct thread *td) { struct vmspace *vm; struct pcpu *pc; struct proc *p; mtx_assert(&sched_lock, MA_OWNED); p = td->td_proc; vm = p->p_vmspace; if (vm->vm_refcnt > 1) return; SLIST_FOREACH(pc, &cpuhead, pc_allcpu) { if (pc->pc_vmspace == vm) { vm->vm_pmap.pm_active &= ~pc->pc_cpumask; vm->vm_pmap.pm_context[pc->pc_cpuid] = -1; pc->pc_vmspace = NULL; } } } void cpu_thread_exit(struct thread *td) { } void cpu_thread_clean(struct thread *td) { } void cpu_thread_setup(struct thread *td) { } void cpu_set_upcall(struct thread *td, void *pcb) { } void cpu_set_upcall_kse(struct thread *td, struct kse_upcall *ku) { } /* * Finish a fork operation, with process p2 nearly set up. * Copy and update the pcb, set up the stack so that the child * ready to run and return to user mode. */ void cpu_fork(struct thread *td1, struct proc *p2, struct thread *td2, int flags) { struct md_utrap *ut; struct trapframe *tf; struct frame *fp; struct pcb *pcb1; struct pcb *pcb2; vm_offset_t sp; int error; int i; KASSERT(td1 == curthread || td1 == &thread0, ("cpu_fork: p1 not curproc and not proc0")); if ((flags & RFPROC) == 0) return; p2->p_md.md_sigtramp = td1->td_proc->p_md.md_sigtramp; if ((ut = td1->td_proc->p_md.md_utrap) != NULL) ut->ut_refcnt++; p2->p_md.md_utrap = ut; /* The pcb must be aligned on a 64-byte boundary. */ pcb1 = td1->td_pcb; pcb2 = (struct pcb *)((td2->td_kstack + KSTACK_PAGES * PAGE_SIZE - sizeof(struct pcb)) & ~0x3fUL); td2->td_pcb = pcb2; /* * Ensure that p1's pcb is up to date. */ if ((td1->td_frame->tf_fprs & FPRS_FEF) != 0) { mtx_lock_spin(&sched_lock); savefpctx(&pcb1->pcb_fpstate); mtx_unlock_spin(&sched_lock); } /* Make sure the copied windows are spilled. */ flushw(); /* Copy the pcb (this will copy the windows saved in the pcb, too). */ bcopy(pcb1, pcb2, sizeof(*pcb1)); /* * If we're creating a new user process and we're sharing the address * space, the parent's top most frame must be saved in the pcb. The * child will pop the frame when it returns to user mode, and may * overwrite it with its own data causing much suffering for the * parent. We check if its already in the pcb, and if not copy it * in. Its unlikely that the copyin will fail, but if so there's not * much we can do. The parent will likely crash soon anyway in that * case. */ if ((flags & RFMEM) != 0 && td1 != &thread0) { sp = td1->td_frame->tf_sp; for (i = 0; i < pcb1->pcb_nsaved; i++) { if (pcb1->pcb_rwsp[i] == sp) break; } if (i == pcb1->pcb_nsaved) { error = copyin((caddr_t)sp + SPOFF, &pcb1->pcb_rw[i], sizeof(struct rwindow)); if (error == 0) { pcb1->pcb_rwsp[i] = sp; pcb1->pcb_nsaved++; } } } /* * Create a new fresh stack for the new process. * Copy the trap frame for the return to user mode as if from a * syscall. This copies most of the user mode register values. */ tf = (struct trapframe *)pcb2 - 1; bcopy(td1->td_frame, tf, sizeof(*tf)); tf->tf_out[0] = 0; /* Child returns zero */ tf->tf_out[1] = 0; tf->tf_tstate &= ~TSTATE_XCC_C; /* success */ tf->tf_fprs = 0; td2->td_frame = tf; fp = (struct frame *)tf - 1; fp->fr_local[0] = (u_long)fork_return; fp->fr_local[1] = (u_long)td2; fp->fr_local[2] = (u_long)tf; - pcb2->pcb_fp = (u_long)fp - SPOFF; + pcb2->pcb_sp = (u_long)fp - SPOFF; pcb2->pcb_pc = (u_long)fork_trampoline - 8; /* * Now, cpu_switch() can schedule the new process. */ } void cpu_reset(void) { static char bspec[64] = ""; phandle_t chosen; static struct { cell_t name; cell_t nargs; cell_t nreturns; cell_t bootspec; } args = { (cell_t)"boot", 1, 0, (cell_t)bspec }; if ((chosen = OF_finddevice("/chosen")) != 0) { if (OF_getprop(chosen, "bootpath", bspec, sizeof(bspec)) == -1) bspec[0] = '\0'; bspec[sizeof(bspec) - 1] = '\0'; } openfirmware_exit(&args); } /* * Intercept the return address from a freshly forked process that has NOT * been scheduled yet. * * This is needed to make kernel threads stay in kernel mode. */ void cpu_set_fork_handler(struct thread *td, void (*func)(void *), void *arg) { struct frame *fp; struct pcb *pcb; pcb = td->td_pcb; - fp = (struct frame *)(pcb->pcb_fp + SPOFF); + fp = (struct frame *)(pcb->pcb_sp + SPOFF); fp->fr_local[0] = (u_long)func; fp->fr_local[1] = (u_long)arg; } void cpu_wait(struct proc *p) { } int is_physical_memory(vm_offset_t addr) { struct ofw_mem_region *mr; for (mr = sparc64_memreg; mr < sparc64_memreg + sparc64_nmemreg; mr++) if (addr >= mr->mr_start && addr < mr->mr_start + mr->mr_size) return (1); return (0); } void swi_vm(void *v) { /* * Nothing to do here yet - busdma bounce buffers are not yet * implemented. */ } void * uma_small_alloc(uma_zone_t zone, int bytes, u_int8_t *flags, int wait) { static vm_pindex_t color; vm_offset_t pa; vm_page_t m; int pflags; void *va; PMAP_STATS_INC(uma_nsmall_alloc); *flags = UMA_SLAB_PRIV; if ((wait & (M_NOWAIT|M_USE_RESERVE)) == M_NOWAIT) pflags = VM_ALLOC_INTERRUPT; else pflags = VM_ALLOC_SYSTEM; if (wait & M_ZERO) pflags |= VM_ALLOC_ZERO; for (;;) { m = vm_page_alloc(NULL, color++, pflags | VM_ALLOC_NOOBJ); if (m == NULL) { if (wait & M_NOWAIT) return (NULL); else VM_WAIT; } else break; } pa = VM_PAGE_TO_PHYS(m); if (m->md.color != DCACHE_COLOR(pa)) { KASSERT(m->md.colors[0] == 0 && m->md.colors[1] == 0, ("uma_small_alloc: free page still has mappings!")); PMAP_STATS_INC(uma_nsmall_alloc_oc); m->md.color = DCACHE_COLOR(pa); dcache_page_inval(pa); } va = (void *)TLB_PHYS_TO_DIRECT(pa); if ((m->flags & PG_ZERO) == 0) bzero(va, PAGE_SIZE); return (va); } void uma_small_free(void *mem, int size, u_int8_t flags) { vm_page_t m; PMAP_STATS_INC(uma_nsmall_free); m = PHYS_TO_VM_PAGE(TLB_DIRECT_TO_PHYS((vm_offset_t)mem)); vm_page_lock_queues(); vm_page_free(m); vm_page_unlock_queues(); }