1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
$NetBSD: patch-ac,v 1.6 2003/04/05 05:42:56 jtb Exp $
--- /dev/null
+++ config/unix/netbsd/powerpc.s
@@ -0,0 +1,48 @@
+#
+# coswitch for the PowerPC
+#
+
+ .file "rswitch.s"
+
+ .set RSIZE, 80 # room for regs 13-31, rounded up mod16
+
+ .text
+ .align 2
+ .globl coswitch
+ .type coswitch,@function
+
+coswitch:
+ stwu %r1, -RSIZE(%r1) # allocate stack frame
+
+ # Save Old Context:
+ stw %r1, 0(%r3) # SP
+ stw %r2, 4(%r3) # TOC
+ mflr %r0
+ stw %r0, 8(%r3) # LR (return address)
+ mfcr %r0
+ stw %r0, 12(%r3) # CR
+ stmw %r13, -RSIZE(%r1) # GPRs 13-31 (save on stack)
+
+ cmpi 0, %r5, 0
+ beq first # if first time
+
+ # Restore new context
+ lwz %r1, 0(%r4) # SP
+ lwz %r2, 4(%r4) # TOC
+ lwz %r0, 8(%r4) # LR
+ mtlr %r0
+ lwz %r0, 12(%r4) # CR
+ mtcr %r0
+ lmw %r13, -RSIZE(%r1) # GPRs 13-31 (from stack)
+
+ addic %r1, %r1, RSIZE # deallocate stack frame
+ blr # return into new context
+
+first: # First-time call:
+ lwz %r1, 0(%r4) # SP as figured by Icon
+ addic %r1, %r1, -64 # save area for callee
+ addi %r3, 0, 0 # arg1
+ addi %r4, 0, 0 # arg2
+ bl new_context # new_context(0,0)
+ addi %r3, 0, 0
+ bl syserr
|