00001 /* 00002 * QuickThreads -- Threads-building toolkit. 00003 * Copyright (c) 1993 by David Keppel 00004 * 00005 * Permission to use, copy, modify and distribute this software and 00006 * its documentation for any purpose and without fee is hereby 00007 * granted, provided that the above copyright notice and this notice 00008 * appear in all copies. This software is provided as a 00009 * proof-of-concept and for demonstration purposes; there is no 00010 * representation about the suitability of this software for any 00011 * purpose. 00012 */ 00013 00014 /* 00015 * This file (pa-risc.h) is part of the port of QuickThreads for the 00016 * PA-RISC 1.1 architecture. This file is a machine dependent header 00017 * file. It was written in 1994 by Uwe Reder 00018 * (`uereder@cip.informatik.uni-erlangen.de') for the Operating Systems 00019 * Department (IMMD4) at the University of Erlangen/Nuernberg Germany. 00020 */ 00021 00022 00023 #ifndef QUICKTHREADS_PA_RISC_H 00024 #define QUICKTHREADS_PA_RISC_H 00025 00026 #if 0 00027 #include <qt.h> 00028 #endif 00029 00030 /* size of an integer-register (32 bit) */ 00031 typedef unsigned long qt_word_t; 00032 00033 /* PA-RISC's stack grows up */ 00034 #define QUICKTHREADS_GROW_UP 00035 00036 /* Stack layout on PA-RISC according to PA-RISC Procedure Calling Conventions: 00037 00038 Callee-save registers are: gr3-gr18, fr12-fr21. 00039 Also save gr2, return pointer. 00040 00041 +--- 00042 | fr12 Each floating register is a double word (8 bytes). 00043 | fr13 Floating registers are only saved if `qt_block' is 00044 | fr14 called, in which case it saves the floating-point 00045 | fr15 registers then calls `qt_blocki' to save the integer 00046 | fr16 registers. 00047 | fr17 00048 | fr18 00049 | fr19 00050 | fr20 00051 | fr21 00052 | <arg word 3> fixed arguments (must be allocated; may remain unused) 00053 | <arg word 2> 00054 | <arg word 1> 00055 | <arg word 0> 00056 | <LPT> frame marker 00057 | <LPT'> 00058 | <RP'> 00059 | <Current RP> 00060 | <Static Link> 00061 | <Clean Up> 00062 | <RP''> 00063 | <Previous SP> 00064 +--- 00065 | gr3 word each (4 bytes) 00066 | gr4 00067 | gr5 00068 | gr6 00069 | gr7 00070 | gr8 00071 | gr9 00072 | gr10 00073 | gr11 00074 | gr12 00075 | gr13 00076 | gr14 00077 | gr15 00078 | gr16 00079 | gr17 00080 | gr18 00081 | <16 bytes filled in (sp has to be 64-bytes aligned)> 00082 | <arg word 3> fixed arguments (must be allocated; may remain unused) 00083 | <arg word 2> 00084 | <arg word 1> 00085 | <arg word 0> 00086 | <LPT> frame marker 00087 | <LPT'> 00088 | <RP'> 00089 | <Current RP> 00090 | <Static Link> 00091 | <Clean Up> 00092 | <RP''> 00093 | <Previous SP> 00094 +--- <--- sp 00095 */ 00096 00097 /* When a never-before-run thread is restored, the return pc points 00098 to a fragment of code that starts the thread running. For 00099 non-vargs functions, it just calls the client's `only' function. 00100 For varargs functions, it calls the startup, user, and cleanup 00101 functions. */ 00102 00103 /* Note: Procedue Labels on PA-RISC 00104 00105 <--2--><-------28---------><1-><1-> 00106 ----------------------------------- 00107 | SID | Adress Part | L | X | 00108 ----------------------------------- 00109 00110 On HP-UX the L field is used to flag wheather the procedure 00111 label (plabel) is a pointer to an LT entry or to the entry point 00112 of the procedure (PA-RISC Procedure Calling Conventions Reference 00113 Manual, 5.3.2 Procedure Labels and Dynamic Calls). */ 00114 00115 #define QUICKTHREADS_PA_RISC_READ_PLABEL(plabel) \ 00116 ( (((int)plabel) & 2) ? \ 00117 ( (*((int *)(((int)plabel) & 0xfffffffc)))) : ((int)plabel) ) 00118 00119 /* Stack must be 64 bytes aligned. */ 00120 #define QUICKTHREADS_STKALIGN (64) 00121 00122 /* Internal helper for putting stuff on stack (negative index!). */ 00123 #define QUICKTHREADS_SPUT(top, at, val) \ 00124 (((qt_word_t *)(top))[-(at)] = (qt_word_t)(val)) 00125 00126 /* Offsets of various registers which are modified on the stack. 00127 rp (return-pointer) has to be stored in the frame-marker-area 00128 of the "older" stack-segment. */ 00129 00130 #define QUICKTHREADS_crp (12+4+16+5) 00131 #define QUICKTHREADS_15 (12+4+4) 00132 #define QUICKTHREADS_16 (12+4+3) 00133 #define QUICKTHREADS_17 (12+4+2) 00134 #define QUICKTHREADS_18 (12+4+1) 00135 00136 00139 /* Stack looks like this (2 stack frames): 00140 00141 <--- 64-bytes aligned --><------- 64-bytes aligned ------------> 00142 | || | 00143 <--16--><------48-------><----16*4-----><--16-><------48-------> 00144 || | || | | || 00145 ||filler|arg|frame-marker||register-save|filler|arg|frame-marker|| 00146 ------------------------------------------------------------------ 00147 */ 00148 00149 #define QUICKTHREADS_STKBASE (16+48+(16*sizeof(qt_word_t))+16+48) 00150 00151 /* The index, relative to sp, of where to put each value. */ 00152 #define QUICKTHREADS_ONLY_INDEX (QUICKTHREADS_15) 00153 #define QUICKTHREADS_USER_INDEX (QUICKTHREADS_16) 00154 #define QUICKTHREADS_ARGT_INDEX (QUICKTHREADS_17) 00155 #define QUICKTHREADS_ARGU_INDEX (QUICKTHREADS_18) 00156 00157 extern void qt_start(void); 00158 #define QUICKTHREADS_ARGS_MD(sp) \ 00159 (QUICKTHREADS_SPUT (sp, QUICKTHREADS_crp, QUICKTHREADS_PA_RISC_READ_PLABEL(qt_start))) 00160 00161 00164 #define QUICKTHREADS_VARGS_DEFAULT 00165 00166 /* Stack looks like this (2 stack frames): 00167 00168 <------ 64-bytes aligned -------><--------- 64-bytes aligned ----------> 00169 | || | 00170 <---?--><--?---><16><----32-----><----16*4-----><-16--><16><----32-----> 00171 || | | | || | | | || 00172 ||filler|varargs|arg|frame-marker||register-save|filler|arg|frame-marker|| 00173 -------------------------------------------------------------------------- 00174 */ 00175 00176 /* Sp is moved to the end of the first stack frame. */ 00177 #define QUICKTHREADS_VARGS_MD0(sp, vasize) \ 00178 ((qt_t *)(((char *)sp) + QUICKTHREADS_STKROUNDUP(vasize + 4*4 + 32))) 00179 00180 /* To reach the arguments from the end of the first stack frame use 32 00181 as a negative adjustment. */ 00182 #define QUICKTHREADS_VARGS_ADJUST(sp) ((qt_t *)(((char *)sp) - 32)) 00183 00184 /* Offset to reach the end of the second stack frame. */ 00185 #define QUICKTHREADS_VSTKBASE ((16*sizeof(qt_word_t)) + 16 + 4*4 + 32) 00186 00187 extern void qt_vstart(void); 00188 #define QUICKTHREADS_VARGS_MD1(sp) \ 00189 (QUICKTHREADS_SPUT (sp, QUICKTHREADS_crp, QUICKTHREADS_PA_RISC_READ_PLABEL(qt_vstart))) 00190 00191 #define QUICKTHREADS_VARGT_INDEX (QUICKTHREADS_15) 00192 #define QUICKTHREADS_VSTARTUP_INDEX (QUICKTHREADS_16) 00193 #define QUICKTHREADS_VUSERF_INDEX (QUICKTHREADS_17) 00194 #define QUICKTHREADS_VCLEANUP_INDEX (QUICKTHREADS_18) 00195 00196 #endif /* ndef QUICKTHREADS_PA_RISC_H */
1.2.18