Quantcast

hppa copyin(9)

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

hppa copyin(9)

Mark Kettenis
Even though it isn't clear that we'll use the futex-based futex
implementation on hppa anytime soon, here is a diff that implements
copyin32(9) for hppa.

ok?

P.S. I'm also looking at alpha right now.  It would be nice if other
     people could take care of mips64 (visa@?) and m88k as that would
     complete the set of architectures for which we have
     MULTIPROCESSOR kernels.

Index: arch/hppa/hppa/locore.S
===================================================================
RCS file: /cvs/src/sys/arch/hppa/hppa/locore.S,v
retrieving revision 1.196
diff -u -p -r1.196 locore.S
--- arch/hppa/hppa/locore.S 30 Apr 2017 16:45:45 -0000 1.196
+++ arch/hppa/hppa/locore.S 18 May 2017 11:36:44 -0000
@@ -2737,6 +2737,48 @@ $spstrcpy_exit
 EXIT(spstrcpy)
 
 /*
+ * int spcopy32 (pa_space_t ssp, const uint32_t *src, pa_space_t dsp,
+ * uint32_t *dst)
+ * do an atomic space to space copy of a futex
+ */
+LEAF_ENTRY(spcopy32)
+ extru arg1, 31, 2, t3
+ extru arg3, 31, 2, t4
+ comb,<>,n 0, t3, $spcopy32_misaligned
+ comb,<>,n 0, t4, $spcopy32_misaligned
+
+ ldo 64(sp), sp
+ stw rp, HPPA_FRAME_CRP(sp)
+ /* setup fault handler */
+ mfctl cr29, t1
+ ldw CI_CURPROC(t1), t3
+ ldil L%copy_on_fault, t2
+ ldw P_ADDR(t3), r2
+ ldo R%copy_on_fault(t2), t2
+ ldw PCB_ONFAULT+U_PCB(r2), r1
+ stw t2, PCB_ONFAULT+U_PCB(r2)
+
+ mtsp arg0, sr1
+ mtsp arg2, sr2
+
+ ldw 0(sr1, arg1), t1
+ stw t1, 0(sr2, arg3)
+
+ mtsp r0, sr1
+ mtsp r0, sr2
+ /* reset fault handler */
+ stw r1, PCB_ONFAULT+U_PCB(r2)
+ ldw HPPA_FRAME_CRP(sp), rp
+ ldo -64(sp), sp
+ bv 0(rp)
+ copy r0, ret0
+
+$spcopy32_misaligned
+ bv 0(rp)
+ ldi EFAULT, ret0
+EXIT(spcopy32)
+
+/*
  * int cpu_switchto(struct proc *old, struct proc *new)
  * Switch from "old" proc to "new".
  */
Index: arch/hppa/hppa/machdep.c
===================================================================
RCS file: /cvs/src/sys/arch/hppa/hppa/machdep.c,v
retrieving revision 1.247
diff -u -p -r1.247 machdep.c
--- arch/hppa/hppa/machdep.c 9 Oct 2016 11:25:39 -0000 1.247
+++ arch/hppa/hppa/machdep.c 18 May 2017 11:36:44 -0000
@@ -1105,7 +1105,6 @@ copyinstr(const void *src, void *dst, si
     HPPA_SID_KERNEL, dst, size, lenp);
 }
 
-
 int
 copyoutstr(const void *src, void *dst, size_t size, size_t *lenp)
 {
@@ -1113,7 +1112,6 @@ copyoutstr(const void *src, void *dst, s
     curproc->p_addr->u_pcb.pcb_space, dst, size, lenp);
 }
 
-
 int
 copyin(const void *src, void *dst, size_t size)
 {
@@ -1126,6 +1124,13 @@ copyout(const void *src, void *dst, size
 {
  return spcopy(HPPA_SID_KERNEL, src,
     curproc->p_addr->u_pcb.pcb_space, dst, size);
+}
+
+int
+copyin32(const uint32_t *src, uint32_t *dst)
+{
+ return spcopy32(curproc->p_addr->u_pcb.pcb_space, src,
+    HPPA_SID_KERNEL, dst);
 }
 
 /*
Index: arch/hppa/include/cpu.h
===================================================================
RCS file: /cvs/src/sys/arch/hppa/include/cpu.h,v
retrieving revision 1.89
diff -u -p -r1.89 cpu.h
--- arch/hppa/include/cpu.h 10 May 2016 14:52:03 -0000 1.89
+++ arch/hppa/include/cpu.h 18 May 2017 11:36:44 -0000
@@ -228,6 +228,8 @@ void hppa_init(paddr_t start);
 void trap(int type, struct trapframe *frame);
 int spcopy(pa_space_t ssp, const void *src,
     pa_space_t dsp, void *dst, size_t size);
+int spcopy32(pa_space_t ssp, const uint32_t *src,
+    pa_space_t dsp, uint32_t *dst);
 int spstrcpy(pa_space_t ssp, const void *src,
       pa_space_t dsp, void *dst, size_t size, size_t *rsize);
 int copy_on_fault(void);

Loading...