vax.h

Go to the documentation of this file.
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 #ifndef QUICKTHREADS_VAX_H
00015 #define QUICKTHREADS_VAX_H
00016 
00017 typedef unsigned long qt_word_t;
00018 
00019 /* Thread's initial stack layout on the VAX:
00020 
00021    non-varargs:
00022 
00023    +---
00024    | arg[2] === `userf' on startup
00025    | arg[1] === `pt' on startup
00026    | arg[0] === `pu' on startup
00027    | ...    === `only' on startup.
00028    +---
00029    | ret pc === `qt_start' on startup
00030    | fp     === 0 on startup
00031    | ap     === 0 on startup
00032    | <mask>
00033    | 0 (handler)            <--- qt_t.sp
00034    +---
00035 
00036    When a non-varargs thread is started, it ``returns'' to the start
00037    routine, which calls the client's `only' function.
00038 
00039    The varargs case is clearly bad code.  The various values should be
00040    stored in a save area and snarfed in to callee-save registers on
00041    startup.  However, it's too painful to figure out the register
00042    mask (right now), so do it the slow way.
00043 
00044    +---
00045    | arg[n-1]
00046    | ..
00047    | arg[0]
00048    | nargs
00049    +---
00050    |        === `cleanup'
00051    |        === `vuserf'
00052    |        === `startup'
00053    |        === `pt'
00054    +---
00055    | ret pc === `qt_start' on startup
00056    | fp     === 0 on startup
00057    | ap     === 0 on startup
00058    | <mask>
00059    | 0 (handler)            <--- qt_t.sp
00060    +---
00061 
00062    When a varargs thread is started, it ``returns'' to the `qt_vstart'
00063    startup code.  The startup code pops all the extra arguments, then
00064    calls the appropriate functions. */
00065 
00066 
00067 /* What to do to start a thread running. */
00068 extern void qt_start (void);
00069 extern void qt_vstart (void);
00070 
00071 
00072 /* Initial call frame for non-varargs and varargs cases. */
00073 #define QUICKTHREADS_STKBASE    (10 * 4)
00074 #define QUICKTHREADS_VSTKBASE   (9 * 4)
00075 
00076 
00077 /* Stack "must be" 4-byte aligned.  (Actually, no, but it's
00078    easiest and probably fastest to do so.) */
00079 
00080 #define QUICKTHREADS_STKALIGN   (4)
00081 
00082 
00083 /* Where to place various arguments. */
00084 #define QUICKTHREADS_ONLY_INDEX (5)
00085 #define QUICKTHREADS_USER_INDEX (8)
00086 #define QUICKTHREADS_ARGT_INDEX (7)
00087 #define QUICKTHREADS_ARGU_INDEX (6)
00088 
00089 #define QUICKTHREADS_VSTARTUP_INDEX (6)
00090 #define QUICKTHREADS_VUSERF_INDEX       (7)
00091 #define QUICKTHREADS_VCLEANUP_INDEX (8)
00092 #define QUICKTHREADS_VARGT_INDEX        (5)
00093 
00094 
00095 /* Stack grows down.  The top of the stack is the first thing to
00096    pop off (predecrement, postincrement). */
00097 #define QUICKTHREADS_GROW_DOWN
00098 
00099 
00100 extern void qt_error (void);
00101 
00102 #define QUICKTHREADS_VAX_GMASK_NOREGS   (0)
00103 
00104 /* Push on the error return address, null termination to call chains,
00105    number of arguments to `only', register save mask (save no
00106    registers). */
00107 
00108 #define QUICKTHREADS_ARGS_MD(sto) \
00109     (QUICKTHREADS_SPUT (sto, 0, 0), \
00110      QUICKTHREADS_SPUT (sto, 1, QUICKTHREADS_VAX_GMASK_NOREGS), \
00111      QUICKTHREADS_SPUT (sto, 2, 0), \
00112      QUICKTHREADS_SPUT (sto, 3, 0), \
00113      QUICKTHREADS_SPUT (sto, 4, qt_start))
00114 
00115 #define QUICKTHREADS_VARGS_MD0(sto, nbytes) \
00116     (QUICKTHREADS_SPUT (sto, (-(nbytes)/4)-1, (nbytes)/4), \
00117      ((char *)(((sto)-4) - QUICKTHREADS_STKROUNDUP(nbytes))))
00118 
00119 #define QUICKTHREADS_VARGS_ADJUST(sp)   ((char *)sp + 4)
00120 
00121 #define QUICKTHREADS_VARGS_MD1(sto) \
00122     (QUICKTHREADS_SPUT (sto, 0, 0), \
00123      QUICKTHREADS_SPUT (sto, 1, QUICKTHREADS_VAX_GMASK_NOREGS), \
00124      QUICKTHREADS_SPUT (sto, 2, 0), \
00125      QUICKTHREADS_SPUT (sto, 3, 0), \
00126      QUICKTHREADS_SPUT (sto, 4, qt_vstart))
00127 
00128 #define QUICKTHREADS_VARGS_DEFAULT
00129 
00130 #endif /* QUICKTHREADS_VAX_H */

Generated on Wed Jan 21 15:32:10 2009 for SystemC by  doxygen 1.5.5