Non-working Quickthreads port
authorRobert Brunner <rbrunner@uiuc.edu>
Mon, 7 Jul 1997 23:01:16 +0000 (23:01 +0000)
committerRobert Brunner <rbrunner@uiuc.edu>
Mon, 7 Jul 1997 23:01:16 +0000 (23:01 +0000)
src/QuickThreads/md/t3e.h [new file with mode: 0644]
src/QuickThreads/md/t3e.s [new file with mode: 0644]
src/QuickThreads/md/t3e_b.s [new file with mode: 0644]

diff --git a/src/QuickThreads/md/t3e.h b/src/QuickThreads/md/t3e.h
new file mode 100644 (file)
index 0000000..ff951a0
--- /dev/null
@@ -0,0 +1,160 @@
+/*
+ * QuickThreads -- Threads-building toolkit.
+ * Copyright (c) 1993 by David Keppel
+ *
+ * Permission to use, copy, modify and distribute this software and
+ * its documentation for any purpose and without fee is hereby
+ * granted, provided that the above copyright notice and this notice
+ * appear in all copies.  This software is provided as a
+ * proof-of-concept and for demonstration purposes; there is no
+ * representation about the suitability of this software for any
+ * purpose.
+ */
+
+#ifndef QT_AXP_H
+#define QT_AXP_H
+
+#define QT_GROW_DOWN
+
+typedef unsigned long qt_word_t;
+
+
+/* Stack layout on the Alpha:
+
+   Integer:
+
+     Caller-save: r0..r8, r22..r25, r27..r29
+     argument/caller-save: r16..r21
+     callee-save: r9..r15
+     return pc *callee-save*: r26
+     stack pointer: r30
+     zero: r31
+
+   Floating-point:
+
+     Caller-save: f0..f1, f10..f15
+     argument/caller-save: f16..f21, f22..f30
+     callee-save: f2..f9
+     zero: f31
+
+   Non-varargs:
+
+   +---
+   | padding
+   | f9
+   | f8
+   | f7
+   | f6
+   | f5
+   | f4
+   | f3
+   | f2
+   | r26
+   +---
+   | padding
+   | r29
+   | r15
+   | r14
+   | r13
+   | r12       on startup === `only'
+   | r11       on startup === `userf'
+   | r10       on startup === `qt'
+   | r9                on startup === `qu'
+   | r26       on startup === qt_start         <--- qt.sp
+   +---
+
+   Conventions for varargs startup:
+
+   |  :
+   | arg6
+   | iarg5
+   |  :
+   | iarg0
+   | farg5
+   |  :
+   | farg0
+   +---
+   | padding
+   | r29
+   | r15
+   | r14
+   | r13
+   | r12       on startup === `startup'
+   | r11       on startup === `vuserf'
+   | r10       on startup === `cleanup'
+   | r9                on startup === `qt'
+   | r26       on startup === qt_vstart        <--- qt.sp
+   +---
+
+   Note: this is a pretty cheap/sleazy way to get things going,
+   but ``there must be a better way.''  For instance, some varargs
+   parameters could be loaded in to integer registers, or the return
+   address could be stored on top of the stack. */
+
+
+/* Stack must be 16-byte aligned. */
+#define QT_STKALIGN    (16)
+
+/* How much space is allocated to hold all the crud for
+   initialization: 7 registers times 8 bytes/register. */
+
+#define QT_STKBASE     (10 * 8)
+#define QT_VSTKBASE    QT_STKBASE
+
+
+/* Offsets of various registers. */
+#define QT_R26 0
+#define QT_R9  1
+#define QT_R10 2
+#define QT_R11 3
+#define QT_R12 4
+
+
+/* When a never-before-run thread is restored, the return pc points
+   to a fragment of code that starts the thread running.  For
+   non-vargs functions, it just calls the client's `only' function.
+   For varargs functions, it calls the startup, user, and cleanup
+   functions.
+
+   The varargs startup routine always reads 12 8-byte arguments from
+   the stack.  If fewer argumets were pushed, the startup routine
+   would read off the top of the stack.  To prevent errors we always
+   allocate enough space.  When there are fewer args, the preallocated
+   words are simply wasted. */
+
+extern void qt_start(void);
+#define QT_ARGS_MD(sp) (QT_SPUT (sp, QT_R26, qt_start))
+
+
+/* The AXP uses a struct for `va_list', so pass a pointer to the
+   struct.  This may break some uses of `QT_VARGS', but then we never
+   claimed it was totally portable. */
+
+typedef void (qt_function_t)(void);
+
+struct qt_t;
+struct va_list;
+extern struct qt_t *qt_vargs (struct qt_t *sp, int nbytes,
+                             struct va_list *vargs, void *pt,
+                             qt_function_t *startup,
+                             qt_function_t *vuserf,
+                             qt_function_t *cleanup);
+
+#define QT_VARGS(sp, nbytes, vargs, pt, startup, vuserf, cleanup) \
+  (qt_vargs (sp, nbytes, (struct va_list *)(&(vargs)), pt, \
+            (qt_function_t *) startup, (qt_function_t *)vuserf, \
+            (qt_function_t *)cleanup));
+
+
+/* The *index* (positive offset) of where to put each value. */
+#define QT_ONLY_INDEX  (QT_R12)
+#define QT_USER_INDEX  (QT_R11)
+#define QT_ARGT_INDEX  (QT_R10)
+#define QT_ARGU_INDEX  (QT_R9)
+
+#define QT_VCLEANUP_INDEX      (QT_R10)
+#define QT_VUSERF_INDEX                (QT_R11)
+#define QT_VSTARTUP_INDEX      (QT_R12)
+#define QT_VARGT_INDEX         (QT_R9)
+
+#endif /* ndef QT_AXP_H */
diff --git a/src/QuickThreads/md/t3e.s b/src/QuickThreads/md/t3e.s
new file mode 100644 (file)
index 0000000..b376423
--- /dev/null
@@ -0,0 +1,154 @@
+; /*
+;  * QuickThreads -- Threads-building toolkit.
+;  * Copyright (c) 1993 by David Keppel
+;  *
+;  * Permission to use, copy, modify and distribute this software and
+;  * its documentation for any purpose and without fee is hereby
+;  * granted, provided that the above copyright notice and this notice
+;  * appear in all copies.  This software is provided as a
+;  * proof-of-concept and for demonstration purposes; there is no
+;  * representation about the suitability of this software for any
+;  * purpose.
+;  */
+
+; /* t3e.s -- assembly support. */
+
+       .ident qt$s
+
+;      /*
+;      ** $16: ptr to function to call once curr is suspended
+;      **      and control is on r19's stack.
+;      ** $17: 1'th arg to (*$16)(...).
+;      ** $18: 2'th arg to (*$16)(...).
+;      ** $19: sp of thread to resume.
+;      **
+;      ** The helper routine returns a value that is passed on as the
+;      ** return value from the blocking routine.  Since we don't
+;      ** touch r0 between the helper's return and the end of
+;      ** function, we get this behavior for free.
+;      */
+
+       .extern qt_error
+       
+       .stack 256
+       .psect qt_blocki@code,code,cache
+         
+qt_blocki::
+       subq r30,80, r30
+       stq r26, 0(r30) 
+       stq  r9, 8(r30)
+       stq r10,16(r30)
+       stq r11,24(r30)
+       stq r12,32(r30)
+       stq r13,40(r30)
+       stq r14,48(r30)
+       stq r15,56(r30)
+       stq r29,64(r30)
+       
+qt_abort::
+       addq r16,r31, r27
+       addq r30,r31, r16
+       addq r19,r31, r30
+       jsr r26,(r27),0
+
+       ldq r26, 0(r30)
+       ldq  r9, 8(r30)
+       ldq r10,16(r30)
+       ldq r11,24(r30)
+       ldq r12,32(r30)
+       ldq r13,40(r30)
+       ldq r14,48(r30)
+       ldq r15,56(r30)
+       ldq r29,64(r30)
+
+       addq r30,80, r30
+       ret r31,(r26),1 
+       .endp
+
+
+;      /*
+;      ** Non-varargs thread startup.
+;      */
+       .stack 256
+       .psect qt_start@code,code,cache
+qt_start::     
+       addq r9,r31,  r16
+       addq r10,r31, r17
+       addq r11,r31, r18
+       addq r12,r31, r27
+       jsr r26,(r27),0         
+
+       bsr r26,qt_error        
+
+
+qt_vstart::    
+
+       addq r9,r31, r16        
+       addq r12,r31, r27       
+       jsr r26,(r27),0         
+
+       ldt f16, 0(r30)
+       ldt f17, 8(r30)
+       ldt f18,16(r30)
+       ldt f19,24(r30)
+       ldt f20,32(r30)
+       ldt f21,40(r30)
+       ldq r16,48(r30) 
+       ldq r17,56(r30)
+       ldq r18,64(r30)
+       ldq r19,72(r30)
+       ldq r20,80(r30)
+       ldq r21,88(r30)
+       addq r30,96,r30
+       addq r11,r31, r27
+       jsr r26,(r27),0         
+
+       addq r9,r31, r16        
+       addq r0,r31, r17        
+       addq r10,r31, r27       
+       jsr r26,(r27),0         
+
+       bsr r26,qt_error
+       .endp
+
+
+;      /*
+;      ** Save calle-save floating-point regs f2..f9.
+;      ** Also save return pc from whomever called us.
+;      **
+;      ** Return value from `qt_block' is the same as the return from
+;      ** `qt_blocki'.  We get that for free since we don't touch r0
+;      ** between the return from `qt_blocki' and the return from
+;      ** `qt_block'.
+;      */
+       .stack 256
+       .psect qt_block@code,code,cache
+qt_block::     
+       subq r30,80, r30
+       stq r26, 0(r30) 
+       stt f2, 8(r30)
+       stt f3,16(r30)
+       stt f4,24(r30)
+       stt f5,32(r30)
+       stt f6,40(r30)
+       stt f7,48(r30)
+       stt f8,56(r30)
+       stt f9,64(r30)
+
+       bsr r26,qt_blocki
+                               
+
+       ldq r26, 0(r30)         
+       ldt f2, 8(r30)
+       ldt f3,16(r30)
+       ldt f4,24(r30)
+       ldt f5,32(r30)
+       ldt f6,40(r30)
+       ldt f7,48(r30)
+       ldt f8,56(r30)
+       ldt f9,64(r30)
+
+       addq r30,80, r30        
+       ret r31,(r26),1         
+       .endp
+       .end qt$s
diff --git a/src/QuickThreads/md/t3e_b.s b/src/QuickThreads/md/t3e_b.s
new file mode 100644 (file)
index 0000000..60be726
--- /dev/null
@@ -0,0 +1,111 @@
+/*
+ * QuickThreads -- Threads-building toolkit.
+ * Copyright (c) 1993 by David Keppel
+ *
+ * Permission to use, copy, modify and distribute this software and
+ * its documentation for any purpose and without fee is hereby
+ * granted, provided that the above copyright notice and this notice
+ * appear in all copies.  This software is provided as a
+ * proof-of-concept and for demonstration purposes; there is no
+ * representation about the suitability of this software for any
+ * purpose.
+ */
+
+       .text
+       .globl b_call_reg
+       .globl b_call_imm
+       .globl b_add
+       .globl b_load
+
+       .ent b_null
+b_null:
+       ret $31,($18),1
+       .end b_null
+
+       .ent b_call_reg
+b_call_reg:
+       lda $27,b_null
+$L0:
+       jsr $18,($27)
+       jsr $18,($27)
+       jsr $18,($27)
+       jsr $18,($27)
+       jsr $18,($27)
+
+       jsr $18,($27)
+       jsr $18,($27)
+       jsr $18,($27)
+       jsr $18,($27)
+       jsr $18,($27)
+
+       subq $16,1,$16
+       bgt $16,$L0
+
+       ret $31,($26),1
+       .end
+
+
+       .ent b_call_imm
+b_call_imm:
+$L1:
+       jsr $18,b_null
+       jsr $18,b_null
+       jsr $18,b_null
+       jsr $18,b_null
+       jsr $18,b_null
+
+       jsr $18,b_null
+       jsr $18,b_null
+       jsr $18,b_null
+       jsr $18,b_null
+       jsr $18,b_null
+
+       subq $16,1,$16
+       bgt $16,$L1
+
+       ret $31,($26),1
+       .end
+
+
+       .ent b_add
+b_add:
+$L2:
+       addq $31,$31,$31
+       addq $31,$31,$31
+       addq $31,$31,$31
+       addq $31,$31,$31
+       addq $31,$31,$31
+
+       addq $31,$31,$31
+       addq $31,$31,$31
+       addq $31,$31,$31
+       addq $31,$31,$31
+       addq $31,$31,$31
+
+       subq $16,1,$16
+       bgt $16,$L2
+
+       ret $31,($26),1
+       .end
+
+
+       .ent b_load
+b_load:
+$L3:
+       ldq $31,0($30)
+       ldq $31,8($30)
+       ldq $31,16($30)
+       ldq $31,24($30)
+       ldq $31,32($30)
+
+       ldq $31,0($30)
+       ldq $31,8($30)
+       ldq $31,16($30)
+       ldq $31,24($30)
+       ldq $31,32($30)
+
+       subq $16,1,$16
+       bgt $16,$L3
+
+       ret $31,($26),1
+       .end