diff options
author | marcel <marcel@FreeBSD.org> | 2002-10-30 05:55:29 +0000 |
---|---|---|
committer | marcel <marcel@FreeBSD.org> | 2002-10-30 05:55:29 +0000 |
commit | 38a01737c156ecff0abbad3f926b6619c0518c2a (patch) | |
tree | c2cd9b652fab7a16aa47dd7b2627da6d00254f4e /sys | |
parent | 3ab60f4a38aa50a3c9281a31f3473c04edb6dbb0 (diff) | |
download | FreeBSD-src-38a01737c156ecff0abbad3f926b6619c0518c2a.zip FreeBSD-src-38a01737c156ecff0abbad3f926b6619c0518c2a.tar.gz |
Rewrite cpu_switch(). The most notable change is the fact that we now
have f16-f31 as part of the context. The PCB has been reorganized to
better match how we save and restore the (preserved) registers. This
commit also moves the context restoriation to its own function (named
pcb_restore), as we did with pcb_save.
Only minimal effort has been put in writing optimal assembly. The
expectation is that there will be more rounds of changes.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/ia64/ia64/genassym.c | 32 | ||||
-rw-r--r-- | sys/ia64/ia64/locore.S | 2 | ||||
-rw-r--r-- | sys/ia64/ia64/locore.s | 2 | ||||
-rw-r--r-- | sys/ia64/ia64/machdep.c | 50 | ||||
-rw-r--r-- | sys/ia64/ia64/swtch.s | 470 | ||||
-rw-r--r-- | sys/ia64/ia64/vm_machdep.c | 22 | ||||
-rw-r--r-- | sys/ia64/include/pcb.h | 89 |
7 files changed, 364 insertions, 303 deletions
diff --git a/sys/ia64/ia64/genassym.c b/sys/ia64/ia64/genassym.c index 8dbc394..4a04842 100644 --- a/sys/ia64/ia64/genassym.c +++ b/sys/ia64/ia64/genassym.c @@ -112,36 +112,10 @@ ASSYM(TF_R_R14, offsetof(struct trapframe, tf_r[FRAME_R14])); ASSYM(TF_R_R15, offsetof(struct trapframe, tf_r[FRAME_R15])); ASSYM(TF_F, offsetof(struct trapframe, tf_f)); -ASSYM(PCB_R4, offsetof(struct pcb, pcb_r4)); -ASSYM(PCB_R5, offsetof(struct pcb, pcb_r5)); -ASSYM(PCB_R6, offsetof(struct pcb, pcb_r6)); -ASSYM(PCB_R7, offsetof(struct pcb, pcb_r7)); - -ASSYM(PCB_F2, offsetof(struct pcb, pcb_f2)); -ASSYM(PCB_F3, offsetof(struct pcb, pcb_f3)); -ASSYM(PCB_F4, offsetof(struct pcb, pcb_f4)); -ASSYM(PCB_F5, offsetof(struct pcb, pcb_f5)); - -ASSYM(PCB_B0, offsetof(struct pcb, pcb_b0)); -ASSYM(PCB_B1, offsetof(struct pcb, pcb_b1)); -ASSYM(PCB_B2, offsetof(struct pcb, pcb_b2)); -ASSYM(PCB_B3, offsetof(struct pcb, pcb_b3)); -ASSYM(PCB_B4, offsetof(struct pcb, pcb_b4)); -ASSYM(PCB_B5, offsetof(struct pcb, pcb_b5)); - -ASSYM(PCB_OLD_UNAT, offsetof(struct pcb, pcb_old_unat)); -ASSYM(PCB_SP, offsetof(struct pcb, pcb_sp)); -ASSYM(PCB_PFS, offsetof(struct pcb, pcb_pfs)); -ASSYM(PCB_BSPSTORE, offsetof(struct pcb, pcb_bspstore)); - -ASSYM(PCB_UNAT, offsetof(struct pcb, pcb_unat)); -ASSYM(PCB_RNAT, offsetof(struct pcb, pcb_rnat)); -ASSYM(PCB_PR, offsetof(struct pcb, pcb_pr)); -ASSYM(PCB_PMAP, offsetof(struct pcb, pcb_pmap)); - +ASSYM(PCB_CURRENT_PMAP, offsetof(struct pcb, pcb_current_pmap)); ASSYM(PCB_ONFAULT, offsetof(struct pcb, pcb_onfault)); - -ASSYM(PCB_HIGHFP, offsetof(struct pcb, pcb_highfp)); +ASSYM(PCB_RP, offsetof(struct pcb, pcb_rp)); +ASSYM(PCB_UNAT47, offsetof(struct pcb, pcb_unat47)); ASSYM(UC_MCONTEXT_MC_AR_BSP, offsetof(ucontext_t, uc_mcontext.mc_ar_bsp)); ASSYM(UC_MCONTEXT_MC_AR_RNAT, offsetof(ucontext_t, uc_mcontext.mc_ar_rnat)); diff --git a/sys/ia64/ia64/locore.S b/sys/ia64/ia64/locore.S index c7dc7a7..726586d 100644 --- a/sys/ia64/ia64/locore.S +++ b/sys/ia64/ia64/locore.S @@ -120,7 +120,7 @@ ENTRY(__start, 1) ;; ld8 out0=[out0] ;; - add r16=PCB_B0,out0 // return to mi_startup_trampoline + add r16=PCB_RP,out0 // return to mi_startup_trampoline movl r17=mi_startup_trampoline ;; st8 [r16]=r17 diff --git a/sys/ia64/ia64/locore.s b/sys/ia64/ia64/locore.s index c7dc7a7..726586d 100644 --- a/sys/ia64/ia64/locore.s +++ b/sys/ia64/ia64/locore.s @@ -120,7 +120,7 @@ ENTRY(__start, 1) ;; ld8 out0=[out0] ;; - add r16=PCB_B0,out0 // return to mi_startup_trampoline + add r16=PCB_RP,out0 // return to mi_startup_trampoline movl r17=mi_startup_trampoline ;; st8 [r16]=r17 diff --git a/sys/ia64/ia64/machdep.c b/sys/ia64/ia64/machdep.c index 4f739d2..030f8629 100644 --- a/sys/ia64/ia64/machdep.c +++ b/sys/ia64/ia64/machdep.c @@ -704,7 +704,7 @@ ia64_init(u_int64_t arg1, u_int64_t arg2) */ thread0.td_frame = (struct trapframe *)thread0.td_pcb - 1; thread0.td_pcb->pcb_sp = (u_int64_t)thread0.td_frame - 16; - thread0.td_pcb->pcb_bspstore = (u_int64_t)proc0kstack; + thread0.td_pcb->pcb_ar_bsp = (u_int64_t)proc0kstack; mutex_init(); @@ -1261,18 +1261,26 @@ fill_fpregs(td, fpregs) struct thread *td; struct fpreg *fpregs; { - fpregs->fpr_regs[2] = td->td_pcb->pcb_f2; - fpregs->fpr_regs[3] = td->td_pcb->pcb_f3; - fpregs->fpr_regs[4] = td->td_pcb->pcb_f4; - fpregs->fpr_regs[5] = td->td_pcb->pcb_f5; + struct pcb *pcb = td->td_pcb; - bcopy(td->td_frame->tf_f, fpregs->fpr_regs+6, + /* + * XXX - The PCB pointer should not point to the actual PCB, + * because it will not contain the preserved registers of + * the program being debugged. Instead, it should point to + * a PCB constructed by unwinding all the way up to the + * IVT handler. + */ + bcopy(pcb->pcb_f + PCB_F2, fpregs->fpr_regs + 2, + sizeof(pcb->pcb_f[0]) * 4); + + bcopy(td->td_frame->tf_f, fpregs->fpr_regs + 6, sizeof(td->td_frame->tf_f)); - /* XXX f16-f31 */ + bcopy(pcb->pcb_f + PCB_F16, fpregs->fpr_regs + 16, + sizeof(pcb->pcb_f[0]) * 16); ia64_fpstate_save(td, 0); - bcopy(td->td_pcb->pcb_highfp, fpregs->fpr_regs+32, + bcopy(pcb->pcb_highfp, fpregs->fpr_regs + 32, sizeof(td->td_pcb->pcb_highfp)); return (0); @@ -1283,18 +1291,30 @@ set_fpregs(td, fpregs) struct thread *td; struct fpreg *fpregs; { - td->td_pcb->pcb_f2 = fpregs->fpr_regs[2]; - td->td_pcb->pcb_f3 = fpregs->fpr_regs[3]; - td->td_pcb->pcb_f4 = fpregs->fpr_regs[4]; - td->td_pcb->pcb_f5 = fpregs->fpr_regs[5]; + struct pcb *pcb = td->td_pcb; + + /* + * XXX - The PCB pointer should not point to the actual PCB, + * because it will not contain the preserved registers of + * the program being debugged. Instead, it should point to + * a PCB constructed by unwinding all the way up to the + * IVT handler. + * XXX - An additional complication here is that we need to + * have the actual location of where the values should be + * stored as well. Some values may still reside in registers, + * while other may have been saved somewhere. + */ + bcopy(fpregs->fpr_regs + 2, pcb->pcb_f + PCB_F2, + sizeof(pcb->pcb_f[0]) * 4); - bcopy(fpregs->fpr_regs+6, td->td_frame->tf_f, + bcopy(fpregs->fpr_regs + 6, td->td_frame->tf_f, sizeof(td->td_frame->tf_f)); - /* XXX f16-f31 */ + bcopy(fpregs->fpr_regs + 16, pcb->pcb_f + PCB_F16, + sizeof(pcb->pcb_f[0]) * 16); ia64_fpstate_drop(td); - bcopy(fpregs->fpr_regs+32, td->td_pcb->pcb_highfp, + bcopy(fpregs->fpr_regs + 32, pcb->pcb_highfp, sizeof(td->td_pcb->pcb_highfp)); return (0); diff --git a/sys/ia64/ia64/swtch.s b/sys/ia64/ia64/swtch.s index da1e270..b17c92a 100644 --- a/sys/ia64/ia64/swtch.s +++ b/sys/ia64/ia64/swtch.s @@ -31,175 +31,304 @@ #include "assym.s" /* - * pcb_save: save process context, i.e. callee-saved registers. This + * pcb_save - save process context, i.e. callee-saved registers. This * function is called by savectx() and cpu_switch(). * + * The callee-saved (ie preserved) registers are: + * r4-r7 + * f2-f5, f16-f31 + * p1-p5, p16-p63 + * b1-b5 + * ar.unat, ar.lc + * + * Notes: + * o We don't need to save and restore gp because its value is constant. + * o We don't need to save and restore ar.rsc because its value is known. + * o We don't need to save and restore r13 because it always points to + * the pcpu structure. + * * Arguments: - * in0 'struct pcb *' of the process that needs its context saved. - * in1 return address. + * r8 'struct pcb *' of the process that needs its context saved. + * b6 return address. */ - -ENTRY(pcb_save,2) -{ .mmi - flushrs // push out caller's dirty regs - mov r22=ar.unat // caller's value for ar.unat - mov r16=in0 +ENTRY(pcb_save,0) +{ .mii + mov r16=ar.unat + add r9=8,r8 + mov r17=b0 ;; } { .mmi - mov ar.rsc=0 // stop the RSE after the flush - ;; - mov r22=ar.rnat // read RSE's NaT collection - add r17=8,r16 + st8 [r8]=r12,16 // sp + st8 [r9]=r16,16 // ar.unat + mov r18=pr ;; } { .mmi - .mem.offset 0,0 - st8.spill [r16]=r4,16 // save r4, ofs=&r6 - .mem.offset 8,0 - st8.spill [r17]=r5,16 // save r5, ofs=&r7 - mov r18=b0 + st8 [r8]=r17,16 // rp + st8 [r9]=r18,24 // pr + add r31=PC_CURRENT_PMAP,r13 ;; } -{ .mmi - .mem.offset 16,0 - st8.spill [r16]=r6,16 // save r6, ofs=&f2 - .mem.offset 24,0 - st8.spill [r17]=r7,24 // save r7, ofs=&f3 - mov r19=b1 + stf.spill [r8]=f2,32 + stf.spill [r9]=f3,32 ;; -} -{ .mmi - stf.spill [r16]=f2,32 // save f2, ofs=&f4 - stf.spill [r17]=f3,32 // save f3, ofs=&f5 - mov r20=b2 + stf.spill [r8]=f4,32 + stf.spill [r9]=f5,32 ;; -} -{ .mmi - stf.spill [r16]=f4,32 // save f4, ofs=&b0 - stf.spill [r17]=f5,24 // save f5, ofs=&b1 - mov r21=b3 + stf.spill [r8]=f16,32 + stf.spill [r9]=f17,32 ;; -} -{ .mmi - st8 [r16]=r18,16 // save b0, ofs=&b2 - st8 [r17]=r19,16 // save b1, ofs=&b3 - mov r18=b4 + stf.spill [r8]=f18,32 + stf.spill [r9]=f19,32 + ;; + stf.spill [r8]=f20,32 + stf.spill [r9]=f21,32 + ;; + stf.spill [r8]=f22,32 + stf.spill [r9]=f23,32 + ;; + stf.spill [r8]=f24,32 + stf.spill [r9]=f25,32 + ;; + stf.spill [r8]=f26,32 + stf.spill [r9]=f27,32 + ;; + stf.spill [r8]=f28,32 + stf.spill [r9]=f29,32 + ;; + stf.spill [r8]=f30,32 + stf.spill [r9]=f31,24 // BEWARE ;; -} { .mmi - st8 [r16]=r20,16 // save b2, ofs=&b4 - st8 [r17]=r21,16 // save b3, ofs=&b5 - mov r19=b5 + .mem.offset 0,0 + st8.spill [r8]=r4,16 + .mem.offset 8,0 + st8.spill [r9]=r5,16 + mov r17=b1 ;; } { .mmi - st8 [r16]=r18,16 // save b4, ofs=&old_unat - st8 [r17]=r19,16 // save b5, ofs=&sp - mov r18=ar.pfs + .mem.offset 16,0 + st8.spill [r8]=r6,16 + .mem.offset 24,0 + st8.spill [r9]=r7,16 + mov r18=b2 ;; } { .mmi - st8 [r16]=r22,16 // save old_unat, ofs=&pfs - st8 [r17]=sp,16 // save sp, ofs=&bspstore - mov r19=ar.lc + flushrs + mov r16=ar.unat + mov r19=b3 ;; } { .mmi - mov r20=ar.bspstore - mov r21=ar.unat - add r23=PC_CURRENT_PMAP,r13 + st8 [r8]=r16,16 // ar.unat + st8 [r9]=r17,16 // b1 + mov r20=b4 ;; } { .mmi - st8 [r16]=r18,16 // save pfs, ofs=&lc - st8 [r17]=r20,16 // save bspstore, ofs=&unat - mov r18=pr + st8 [r8]=r18,16 // b2 + st8 [r9]=r19,16 // b3 + mov r21=b5 ;; } + st8 [r8]=r20,16 // b4 + st8 [r9]=r21,16 // b5 + ;; { .mmi - st8 [r16]=r19,16 // save lc, ofs=&rnat - st8 [r17]=r21,16 // save unat, ofs=&pr - mov b6=in1 + mov ar.rsc=0 + mov r16=ar.bsp + mov r17=ar.pfs ;; } { .mmi - st8 [r16]=r22,16 // save rnat, ofs=&pmap - st8 [r17]=r18,16 // save pr, ofs=&ar.fsr - nop 1 + st8 [r8]=r16,16 // ar.bsp + st8 [r9]=r17,16 // ar.pfs + mov r18=ar.lc ;; } -{ .mmb - ld8 r19=[r23] - mov r18=ar.fsr - nop 2 + mov r17=ar.rnat + ld8 r19=[r31] ;; -} -{ .mmi - st8 [r16]=r19,16 // save pmap, ofs=&ar.fcr - st8 [r17]=r18,16 // save ar.fsr, ofs=&ar.fir - nop 3 + st8 [r8]=r17,16 // ar.rnat + st8 [r9]=r18,16 // ar.lc ;; -} -{ .mmb - mov r19=ar.fcr - mov r18=ar.fir - nop 4 + st8 [r8]=r19,16 // pc_current_pmap + mov r16=ar.fcr ;; -} -{ .mmi - st8 [r16]=r19,16 // save ar.fcr, ofs=&ar.fdr - st8 [r17]=r18,16 // save ar.fir, ofs=&ar.eflag - nop 5 + st8 [r9]=r16,16 // ar.fcr + mov r17=ar.eflag + ;; + st8 [r8]=r17,16 // ar.eflag + mov r16=ar.csd + ;; + st8 [r9]=r16,16 // ar.csd + mov r17=ar.ssd + ;; + st8 [r8]=r17,16 // ar.ssd + mov r16=ar.fsr + ;; + st8 [r9]=r16,16 // ar.fsr + mov r17=ar.fir + ;; + st8 [r8]=r17,16 // ar.fir + mov r16=ar.fdr ;; -} { .mmb - mov r19=ar.fdr - mov r18=ar.eflag - nop 6 + st8 [r9]=r16,16 // ar.fdr + mov ar.rsc=3 + br.sptk.many b6 ;; } +END(pcb_save) + +/* + * pcb_restore - restore a process context. This does not return. + * + * Arguments: + * r8 'struct pcb *' of the process that needs its context saved. + */ +ENTRY(pcb_restore,0) + mov ar.rsc=0 + add r9=8,r8 + add r31=PCB_UNAT47,r8 + ;; + ld8 r12=[r8],16 // sp + ld8 r30=[r9],16 // ar.unat + ;; + ld8 r16=[r8],16 // rp + ld8 r17=[r9],24 // pr + ;; + ldf.fill f2=[r8],32 + ldf.fill f3=[r9],32 + mov b0=r16 + ;; + ldf.fill f4=[r8],32 + ldf.fill f5=[r9],32 + mov pr=r17,0x1fffe + ;; + ldf.fill f16=[r8],32 + ldf.fill f17=[r9],32 + ;; + ldf.fill f18=[r8],32 + ldf.fill f19=[r9],32 + ;; + ldf.fill f20=[r8],32 + ldf.fill f21=[r9],32 + ;; + ldf.fill f22=[r8],32 + ldf.fill f23=[r9],32 + ;; + ldf.fill f24=[r8],32 + ldf.fill f25=[r9],32 + ;; + ldf.fill f26=[r8],32 + ldf.fill f27=[r9],32 + ;; + ldf.fill f28=[r8],32 + ldf.fill f29=[r9],32 + ;; + ldf.fill f30=[r8],32 + ldf.fill f31=[r9],24 // BEWARE + ;; + ld8 r16=[r31] + ;; + mov ar.unat=r16 + ;; + .mem.offset 0,0 + ld8.fill r4=[r8],16 + .mem.offset 8,0 + ld8.fill r5=[r9],16 + ;; + .mem.offset 16,0 + ld8.fill r6=[r8],24 + .mem.offset 24,0 + ld8.fill r7=[r9],24 + ;; + loadrs + mov ar.unat=r30 + ;; + ld8 r16=[r8],16 // b1 + ld8 r17=[r9],16 // b2 + ;; + ld8 r18=[r8],16 // b3 + ld8 r19=[r9],16 // b4 + mov b1=r16 + ;; + ld8 r20=[r8],16 // b5 + ld8 r21=[r9],16 // ar.bsp + mov b2=r17 + ;; + ld8 r22=[r8],16 // ar.pfs + ld8 r23=[r9],24 // ar.rnat + mov b3=r18 + ;; + ld8 r24=[r8],24 // ar.lc + mov b4=r19 + mov b5=r20 + ;; { .mmi - st8 [r16]=r19,16 // save ar.fdr, ofs=&ar.csd - st8 [r17]=r18,16 // save ar.eflag, ofs=&ssd - nop 7 + mov ar.bspstore=r21 ;; -} -{ .mmb - mov r19=ar.csd - mov r18=ar.ssd - nop 8 + mov ar.rnat=r23 + mov ar.pfs=r22 ;; } { .mmi - st8 [r16]=r19 // save ar.csd - st8 [r17]=r18 // save ar.ssd - nop 9 + invala + ;; + ld8 r16=[r9],16 // ar.fcr + mov r18=ar.lc + ;; } -{ .mib - mov ar.rsc=3 // turn RSE back on - mov ret0=r0 - br.sptk.few b6 + ld8 r17=[r8],16 // ar.eflag + mov ar.fcr=r16 + ;; + ld8 r16=[r9],16 // ar.csd + mov ar.eflag=r17 + ;; + ld8 r17=[r8],16 // ar.ssd + mov ar.csd=r16 + ;; + ld8 r16=[r9],16 // ar.fsr + mov ar.ssd=r17 + ;; + ld8 r17=[r8],16 // ar.fir + mov ar.fsr=r16 + ;; + ld8 r16=[r9],16 // ar.fdr + mov ar.fir=r17 + ;; +{ .mmb + mov ar.fdr=r16 + mov ar.rsc=3 + br.ret.sptk b0 ;; } -END(pcb_save) +END(pcb_restore) +/* + * savectx - Save current context. + */ ENTRY(savectx,1) { .mii -1: alloc r16=ar.pfs,0,0,2,0 +1: nop 1 mov r17=ip ;; - add r33=2f-1b,r17 + add r16=2f-1b,r17 + ;; } -{ .mfb - nop 1 - nop 2 - br.sptk.few pcb_save +{ .mib + mov r8=r32 + mov b6=r16 + br.sptk.many pcb_save } { .mfb -2: nop 3 - nop 4 - br.ret.sptk rp +2: nop 2 + nop 3 + br.ret.sptk rp } END(savectx) @@ -213,18 +342,15 @@ END(savectx) * Does not return. We arrange things so that savectx appears to * return a second time with a non-zero return value. */ - ENTRY(restorectx, 1) - - mov r15=in0 - br.cond.sptk.many 4f - + mov r8=in0 + br.cond.sptk.many pcb_restore + ;; END(restorectx) ENTRY(cpu_throw, 0) - - br.sptk.few 2f - + br.sptk.many 2f + ;; END(cpu_throw) ENTRY(cpu_switch, 0) @@ -233,16 +359,17 @@ ENTRY(cpu_switch, 0) mov r17=ip ;; } - add r33=1f-1b,r17 + add r16=1f-1b,r17 add r17=PC_CURTHREAD,r13 ;; ld8 r17=[r17] ;; add r17=TD_PCB,r17 + mov b6=r16 + ;; + ld8 r8=[r17] + br.sptk.many pcb_save ;; - ld8 r32=[r17] - br.sptk.few pcb_save - 1: #ifdef SMP add r17 = PC_CPUID, r13 @@ -263,10 +390,8 @@ ENTRY(cpu_switch, 0) br.sptk 3f #endif -2: srlz.i - mf - ;; - br.call.sptk.few rp=choosethread +2: br.call.sptk.few rp=choosethread + ;; mov r4=ret0 // save from call 3: @@ -276,6 +401,7 @@ ENTRY(cpu_switch, 0) ld8 out0=[r14] mov out1=1 br.call.sptk.few rp=ia64_fpstate_save // clear fpcurthread + ;; #endif add r14=PC_CURTHREAD,r13 @@ -287,96 +413,20 @@ ENTRY(cpu_switch, 0) ;; ld8 r15=[r15] ;; - add r15=PCB_PMAP,r15 // &pcb_pmap + add r15=PCB_CURRENT_PMAP,r15 // &pcb_pmap ;; ld8 out0=[r15] br.call.sptk.few rp=pmap_install // install RIDs etc. - + ;; add r15=TD_PCB,r4 add r16=TD_KSTACK,r4 ;; - ld8 r15=[r15] + ld8 r8=[r15] ld8 r16=[r16] ;; mov ar.k5=r16 - - // pcb_restore -4: - add r3=PCB_UNAT,r15 // point at NaT for r4..r7 - mov ar.rsc=0 ;; // switch off the RSE - ld8 r16=[r3] // load NaT for r4..r7 - ;; - mov ar.unat=r16 - ;; - ld8.fill r4=[r15],8 ;; // restore r4 - ld8.fill r5=[r15],8 ;; // restore r5 - ld8.fill r6=[r15],8 ;; // restore r6 - ld8.fill r7=[r15],8 ;; // restore r7 - - ldf.fill f2=[r15],16 ;; // restore f2 - ldf.fill f3=[r15],16 ;; // restore f3 - ldf.fill f4=[r15],16 ;; // restore f4 - ldf.fill f5=[r15],16 ;; // restore f5 - - ld8 r16=[r15],8 ;; // restore b0 - ld8 r17=[r15],8 ;; // restore b1 - ld8 r18=[r15],8 ;; // restore b2 - ld8 r19=[r15],8 ;; // restore b3 - ld8 r20=[r15],8 ;; // restore b4 - ld8 r21=[r15],8 ;; // restore b5 - - mov b0=r16 - mov b1=r17 - mov b2=r18 - mov b3=r19 - mov b4=r20 - mov b5=r21 - - ld8 r16=[r15],8 ;; // caller's ar.unat - ld8 sp=[r15],8 ;; // stack pointer - ld8 r17=[r15],8 ;; // ar.pfs - ld8 r18=[r15],8 ;; // ar.bspstore - ld8 r21=[r15],16 ;; // ar.lc, skip ar.unat - ld8 r19=[r15],8 ;; // ar.rnat - ld8 r20=[r15],16 ;; // pr, skip pmap - - loadrs // invalidate register stack - ;; - mov ar.unat=r16 - mov ar.pfs=r17 - mov ar.lc=r21 - mov ar.bspstore=r18 ;; - mov ar.rnat=r19 - mov pr=r20,0x1ffff - ;; - ld8 r16=[r15],8 // ar.fsr - ;; - ld8 r17=[r15],8 // ar.fcr - mov ar.fsr=r16 - ;; - ld8 r16=[r15],8 // ar.fir - mov ar.fcr=r17 - ;; - ld8 r17=[r15],8 // ar.fdr - mov ar.fir=r16 - ;; - ld8 r16=[r15],8 // ar.eflag - mov ar.fdr=r17 - ;; - ld8 r17=[r15],8 // ar.csd - mov ar.eflag=r16 - ;; - ld8 r16=[r15],8 // ar.ssd - mov ar.csd=r17 - ;; - mov ar.ssd=r16 - - mov ar.rsc=3 // restart RSE - invala + br.cond.sptk pcb_restore ;; -9: - br.ret.sptk.few rp - END(cpu_switch) /* @@ -397,13 +447,13 @@ ENTRY(savehighfp, 1) ;; stf.spill [in0]=f36,32 stf.spill [r14]=f37,32 - ;; + ;; stf.spill [in0]=f38,32 stf.spill [r14]=f39,32 - ;; + ;; stf.spill [in0]=f40,32 stf.spill [r14]=f41,32 - ;; + ;; stf.spill [in0]=f42,32 stf.spill [r14]=f43,32 ;; @@ -721,5 +771,5 @@ ENTRY(fork_trampoline, 0) br.call.sptk.few rp=fork_exit ;; br.cond.sptk.many exception_restore - - END(fork_trampoline) + ;; +END(fork_trampoline) diff --git a/sys/ia64/ia64/vm_machdep.c b/sys/ia64/ia64/vm_machdep.c index f0cdab0..6a63482 100644 --- a/sys/ia64/ia64/vm_machdep.c +++ b/sys/ia64/ia64/vm_machdep.c @@ -215,7 +215,7 @@ cpu_fork(td1, p2, td2, flags) if (p2tf->tf_cr_ipsr & IA64_PSR_IS) { p2tf->tf_r[FRAME_R8] = 0; /* child returns zero (eax) */ p2tf->tf_r[FRAME_R10] = 1; /* is child (edx) */ - td2->td_pcb->pcb_eflag &= ~PSL_C; /* no error */ + td2->td_pcb->pcb_ar_eflag &= ~PSL_C; /* no error */ } else { p2tf->tf_r[FRAME_R8] = 0; /* child's pid (linux) */ p2tf->tf_r[FRAME_R9] = 1; /* is child (FreeBSD) */ @@ -282,10 +282,10 @@ cpu_fork(td1, p2, td2, flags) * straight into exception_restore. Also initialise its * pmap to the containing proc's vmspace. */ - td2->td_pcb->pcb_bspstore = (u_int64_t)p2bs + td1->td_frame->tf_ndirty; - td2->td_pcb->pcb_rnat = rnat; - td2->td_pcb->pcb_pfs = 0; - td2->td_pcb->pcb_pmap = (u_int64_t) + td2->td_pcb->pcb_ar_bsp = (u_int64_t)p2bs + td1->td_frame->tf_ndirty; + td2->td_pcb->pcb_ar_rnat = rnat; + td2->td_pcb->pcb_ar_pfs = 0; + td2->td_pcb->pcb_current_pmap = (u_int64_t) vmspace_pmap(td2->td_proc->p_vmspace); /* @@ -298,10 +298,10 @@ cpu_fork(td1, p2, td2, flags) * available as scratch space. */ td2->td_pcb->pcb_sp = (u_int64_t)p2tf - 16; - td2->td_pcb->pcb_r4 = (u_int64_t)fork_return; - td2->td_pcb->pcb_r5 = FDESC_FUNC(exception_restore); - td2->td_pcb->pcb_r6 = (u_int64_t)td2; - td2->td_pcb->pcb_b0 = FDESC_FUNC(fork_trampoline); + td2->td_pcb->pcb_r[PCB_R4] = (u_int64_t)fork_return; + td2->td_pcb->pcb_r[PCB_R5] = FDESC_FUNC(exception_restore); + td2->td_pcb->pcb_r[PCB_R6] = (u_int64_t)td2; + td2->td_pcb->pcb_rp = FDESC_FUNC(fork_trampoline); } /* @@ -316,8 +316,8 @@ cpu_set_fork_handler(td, func, arg) void (*func)(void *); void *arg; { - td->td_pcb->pcb_r4 = (u_int64_t) func; - td->td_pcb->pcb_r6 = (u_int64_t) arg; + td->td_pcb->pcb_r[PCB_R4] = (u_int64_t) func; + td->td_pcb->pcb_r[PCB_R6] = (u_int64_t) arg; } /* diff --git a/sys/ia64/include/pcb.h b/sys/ia64/include/pcb.h index beba354..c5ee145 100644 --- a/sys/ia64/include/pcb.h +++ b/sys/ia64/include/pcb.h @@ -33,46 +33,63 @@ * PCB: process control block */ struct pcb { - u_int64_t pcb_r4; - u_int64_t pcb_r5; - u_int64_t pcb_r6; - u_int64_t pcb_r7; + uint64_t pcb_sp; + uint64_t pcb_ar_unat; + uint64_t pcb_rp; + uint64_t pcb_pr; + struct ia64_fpreg pcb_f[20]; +#define PCB_F2 0 +#define PCB_F3 1 +#define PCB_F4 2 +#define PCB_F5 3 +#define PCB_F16 4 +#define PCB_F17 5 +#define PCB_F18 6 +#define PCB_F19 7 +#define PCB_F20 8 +#define PCB_F21 9 +#define PCB_F22 10 +#define PCB_F23 11 +#define PCB_F24 12 +#define PCB_F25 13 +#define PCB_F26 14 +#define PCB_F27 15 +#define PCB_F28 16 +#define PCB_F29 17 +#define PCB_F30 18 +#define PCB_F31 19 + uint64_t pcb_r[4]; +#define PCB_R4 0 +#define PCB_R5 1 +#define PCB_R6 2 +#define PCB_R7 3 + uint64_t pcb_unat47; + uint64_t pcb_b[5]; +#define PCB_B1 0 +#define PCB_B2 1 +#define PCB_B3 2 +#define PCB_B4 3 +#define PCB_B5 4 + uint64_t pcb_ar_bsp; + uint64_t pcb_ar_pfs; + uint64_t pcb_ar_rnat; + uint64_t pcb_ar_lc; - struct ia64_fpreg pcb_f2; - struct ia64_fpreg pcb_f3; - struct ia64_fpreg pcb_f4; - struct ia64_fpreg pcb_f5; + uint64_t pcb_current_pmap; - u_int64_t pcb_b0; /* really restart address */ - u_int64_t pcb_b1; - u_int64_t pcb_b2; - u_int64_t pcb_b3; - u_int64_t pcb_b4; - u_int64_t pcb_b5; - - u_int64_t pcb_old_unat; /* caller's ar.unat */ - u_int64_t pcb_sp; - u_int64_t pcb_pfs; - u_int64_t pcb_bspstore; - u_int64_t pcb_lc; - - u_int64_t pcb_unat; /* ar.unat for r4..r7 */ - u_int64_t pcb_rnat; - u_int64_t pcb_pr; /* predicates */ - u_int64_t pcb_pmap; /* current pmap */ - - u_int64_t pcb_fsr; - u_int64_t pcb_fcr; - u_int64_t pcb_fir; - u_int64_t pcb_fdr; - u_int64_t pcb_eflag; - u_int64_t pcb_csd; - u_int64_t pcb_ssd; - - u_int64_t pcb_onfault; /* for copy faults */ - u_int64_t pcb_accessaddr; /* for [fs]uswintr */ + uint64_t pcb_ar_fcr; + uint64_t pcb_ar_eflag; + uint64_t pcb_ar_csd; + uint64_t pcb_ar_ssd; + uint64_t pcb_ar_fsr; + uint64_t pcb_ar_fir; + uint64_t pcb_ar_fdr; + /* Aligned! */ struct ia64_fpreg pcb_highfp[96]; /* f32-f127 */ + + uint64_t pcb_onfault; /* for copy faults */ + uint64_t pcb_accessaddr; /* for [fs]uswintr */ }; #ifdef _KERNEL |