112027Sjungma@eit.uni-kl.de/*
212027Sjungma@eit.uni-kl.de * QuickThreads -- Threads-building toolkit.
312027Sjungma@eit.uni-kl.de * Copyright (c) 1993 by David Keppel
412027Sjungma@eit.uni-kl.de *
512027Sjungma@eit.uni-kl.de * Permission to use, copy, modify and distribute this software and
612027Sjungma@eit.uni-kl.de * its documentation for any purpose and without fee is hereby
712027Sjungma@eit.uni-kl.de * granted, provided that the above copyright notice and this notice
812027Sjungma@eit.uni-kl.de * appear in all copies.  This software is provided as a
912027Sjungma@eit.uni-kl.de * proof-of-concept and for demonstration purposes; there is no
1012027Sjungma@eit.uni-kl.de * representation about the suitability of this software for any
1112027Sjungma@eit.uni-kl.de * purpose.
1212027Sjungma@eit.uni-kl.de */
1312027Sjungma@eit.uni-kl.de
1412027Sjungma@eit.uni-kl.de#ifndef QUICKTHREADS_VAX_H
1512027Sjungma@eit.uni-kl.de#define QUICKTHREADS_VAX_H
1612027Sjungma@eit.uni-kl.de
1712027Sjungma@eit.uni-kl.detypedef unsigned long qt_word_t;
1812027Sjungma@eit.uni-kl.de
1912027Sjungma@eit.uni-kl.de/* Thread's initial stack layout on the VAX:
2012027Sjungma@eit.uni-kl.de
2112027Sjungma@eit.uni-kl.de   non-varargs:
2212027Sjungma@eit.uni-kl.de
2312027Sjungma@eit.uni-kl.de   +---
2412027Sjungma@eit.uni-kl.de   | arg[2]	=== `userf' on startup
2512027Sjungma@eit.uni-kl.de   | arg[1]	=== `pt' on startup
2612027Sjungma@eit.uni-kl.de   | arg[0]	=== `pu' on startup
2712027Sjungma@eit.uni-kl.de   | ...	=== `only' on startup.
2812027Sjungma@eit.uni-kl.de   +---
2912027Sjungma@eit.uni-kl.de   | ret pc	=== `qt_start' on startup
3012027Sjungma@eit.uni-kl.de   | fp		=== 0 on startup
3112027Sjungma@eit.uni-kl.de   | ap		=== 0 on startup
3212027Sjungma@eit.uni-kl.de   | <mask>
3312027Sjungma@eit.uni-kl.de   | 0 (handler)			<--- qt_t.sp
3412027Sjungma@eit.uni-kl.de   +---
3512027Sjungma@eit.uni-kl.de
3612027Sjungma@eit.uni-kl.de   When a non-varargs thread is started, it ``returns'' to the start
3712027Sjungma@eit.uni-kl.de   routine, which calls the client's `only' function.
3812027Sjungma@eit.uni-kl.de
3912027Sjungma@eit.uni-kl.de   The varargs case is clearly bad code.  The various values should be
4012027Sjungma@eit.uni-kl.de   stored in a save area and snarfed in to callee-save registers on
4112027Sjungma@eit.uni-kl.de   startup.  However, it's too painful to figure out the register
4212027Sjungma@eit.uni-kl.de   mask (right now), so do it the slow way.
4312027Sjungma@eit.uni-kl.de
4412027Sjungma@eit.uni-kl.de   +---
4512027Sjungma@eit.uni-kl.de   | arg[n-1]
4612027Sjungma@eit.uni-kl.de   | ..
4712027Sjungma@eit.uni-kl.de   | arg[0]
4812027Sjungma@eit.uni-kl.de   | nargs
4912027Sjungma@eit.uni-kl.de   +---
5012027Sjungma@eit.uni-kl.de   |		=== `cleanup'
5112027Sjungma@eit.uni-kl.de   |		=== `vuserf'
5212027Sjungma@eit.uni-kl.de   |		=== `startup'
5312027Sjungma@eit.uni-kl.de   |		=== `pt'
5412027Sjungma@eit.uni-kl.de   +---
5512027Sjungma@eit.uni-kl.de   | ret pc	=== `qt_start' on startup
5612027Sjungma@eit.uni-kl.de   | fp		=== 0 on startup
5712027Sjungma@eit.uni-kl.de   | ap		=== 0 on startup
5812027Sjungma@eit.uni-kl.de   | <mask>
5912027Sjungma@eit.uni-kl.de   | 0 (handler)			<--- qt_t.sp
6012027Sjungma@eit.uni-kl.de   +---
6112027Sjungma@eit.uni-kl.de
6212027Sjungma@eit.uni-kl.de   When a varargs thread is started, it ``returns'' to the `qt_vstart'
6312027Sjungma@eit.uni-kl.de   startup code.  The startup code pops all the extra arguments, then
6412027Sjungma@eit.uni-kl.de   calls the appropriate functions. */
6512027Sjungma@eit.uni-kl.de
6612027Sjungma@eit.uni-kl.de
6712027Sjungma@eit.uni-kl.de/* What to do to start a thread running. */
6812027Sjungma@eit.uni-kl.deextern void qt_start (void);
6912027Sjungma@eit.uni-kl.deextern void qt_vstart (void);
7012027Sjungma@eit.uni-kl.de
7112027Sjungma@eit.uni-kl.de
7212027Sjungma@eit.uni-kl.de/* Initial call frame for non-varargs and varargs cases. */
7312027Sjungma@eit.uni-kl.de#define QUICKTHREADS_STKBASE	(10 * 4)
7412027Sjungma@eit.uni-kl.de#define QUICKTHREADS_VSTKBASE	(9 * 4)
7512027Sjungma@eit.uni-kl.de
7612027Sjungma@eit.uni-kl.de
7712027Sjungma@eit.uni-kl.de/* Stack "must be" 4-byte aligned.  (Actually, no, but it's
7812027Sjungma@eit.uni-kl.de   easiest and probably fastest to do so.) */
7912027Sjungma@eit.uni-kl.de
8012027Sjungma@eit.uni-kl.de#define QUICKTHREADS_STKALIGN	(4)
8112027Sjungma@eit.uni-kl.de
8212027Sjungma@eit.uni-kl.de
8312027Sjungma@eit.uni-kl.de/* Where to place various arguments. */
8412027Sjungma@eit.uni-kl.de#define QUICKTHREADS_ONLY_INDEX	(5)
8512027Sjungma@eit.uni-kl.de#define QUICKTHREADS_USER_INDEX	(8)
8612027Sjungma@eit.uni-kl.de#define QUICKTHREADS_ARGT_INDEX	(7)
8712027Sjungma@eit.uni-kl.de#define QUICKTHREADS_ARGU_INDEX	(6)
8812027Sjungma@eit.uni-kl.de
8912027Sjungma@eit.uni-kl.de#define QUICKTHREADS_VSTARTUP_INDEX	(6)
9012027Sjungma@eit.uni-kl.de#define QUICKTHREADS_VUSERF_INDEX		(7)
9112027Sjungma@eit.uni-kl.de#define QUICKTHREADS_VCLEANUP_INDEX	(8)
9212027Sjungma@eit.uni-kl.de#define QUICKTHREADS_VARGT_INDEX		(5)
9312027Sjungma@eit.uni-kl.de
9412027Sjungma@eit.uni-kl.de
9512027Sjungma@eit.uni-kl.de/* Stack grows down.  The top of the stack is the first thing to
9612027Sjungma@eit.uni-kl.de   pop off (predecrement, postincrement). */
9712027Sjungma@eit.uni-kl.de#define QUICKTHREADS_GROW_DOWN
9812027Sjungma@eit.uni-kl.de
9912027Sjungma@eit.uni-kl.de
10012027Sjungma@eit.uni-kl.deextern void qt_error (void);
10112027Sjungma@eit.uni-kl.de
10212027Sjungma@eit.uni-kl.de#define QUICKTHREADS_VAX_GMASK_NOREGS	(0)
10312027Sjungma@eit.uni-kl.de
10412027Sjungma@eit.uni-kl.de/* Push on the error return address, null termination to call chains,
10512027Sjungma@eit.uni-kl.de   number of arguments to `only', register save mask (save no
10612027Sjungma@eit.uni-kl.de   registers). */
10712027Sjungma@eit.uni-kl.de
10812027Sjungma@eit.uni-kl.de#define QUICKTHREADS_ARGS_MD(sto) \
10912027Sjungma@eit.uni-kl.de    (QUICKTHREADS_SPUT (sto, 0, 0), \
11012027Sjungma@eit.uni-kl.de     QUICKTHREADS_SPUT (sto, 1, QUICKTHREADS_VAX_GMASK_NOREGS), \
11112027Sjungma@eit.uni-kl.de     QUICKTHREADS_SPUT (sto, 2, 0), \
11212027Sjungma@eit.uni-kl.de     QUICKTHREADS_SPUT (sto, 3, 0), \
11312027Sjungma@eit.uni-kl.de     QUICKTHREADS_SPUT (sto, 4, qt_start))
11412027Sjungma@eit.uni-kl.de
11512027Sjungma@eit.uni-kl.de#define QUICKTHREADS_VARGS_MD0(sto, nbytes) \
11612027Sjungma@eit.uni-kl.de    (QUICKTHREADS_SPUT (sto, (-(nbytes)/4)-1, (nbytes)/4), \
11712027Sjungma@eit.uni-kl.de     ((char *)(((sto)-4) - QUICKTHREADS_STKROUNDUP(nbytes))))
11812027Sjungma@eit.uni-kl.de
11912027Sjungma@eit.uni-kl.de#define QUICKTHREADS_VARGS_ADJUST(sp)	((char *)sp + 4)
12012027Sjungma@eit.uni-kl.de
12112027Sjungma@eit.uni-kl.de#define QUICKTHREADS_VARGS_MD1(sto) \
12212027Sjungma@eit.uni-kl.de    (QUICKTHREADS_SPUT (sto, 0, 0), \
12312027Sjungma@eit.uni-kl.de     QUICKTHREADS_SPUT (sto, 1, QUICKTHREADS_VAX_GMASK_NOREGS), \
12412027Sjungma@eit.uni-kl.de     QUICKTHREADS_SPUT (sto, 2, 0), \
12512027Sjungma@eit.uni-kl.de     QUICKTHREADS_SPUT (sto, 3, 0), \
12612027Sjungma@eit.uni-kl.de     QUICKTHREADS_SPUT (sto, 4, qt_vstart))
12712027Sjungma@eit.uni-kl.de
12812027Sjungma@eit.uni-kl.de#define QUICKTHREADS_VARGS_DEFAULT
12912027Sjungma@eit.uni-kl.de
13012027Sjungma@eit.uni-kl.de#endif /* QUICKTHREADS_VAX_H */
131