Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

i386.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_386_H
00015 #define QUICKTHREADS_386_H
00016 
00017 typedef unsigned long qt_word_t;
00018 
00019 /* Thread's initial stack layout on the i386:
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    +---
00028    | ret pc === qt_error
00029    +---
00030    | ret pc === `only' on startup
00031    +---
00032    | %ebp
00033    | %esi
00034    | %edi
00035    | %ebx       <--- qt_t.sp
00036    +---
00037 
00038    When a non-varargs thread is started, it ``returns'' directly to
00039    the client's `only' function.
00040 
00041    varargs:
00042 
00043    +---
00044    | arg[n-1]
00045    | ..
00046    | arg[0]
00047    +---
00048    | ret pc === `qt_vstart'
00049    +---
00050    | %ebp === `startup'
00051    | %esi === `cleanup'
00052    | %edi === `pt'
00053    | %ebx === `vuserf'    <--- qt_t.sp
00054    +---
00055 
00056    When a varargs thread is started, it ``returns'' to the `qt_vstart'
00057    startup code.  The startup code calls the appropriate functions. */
00058 
00059 
00060 /* What to do to start a varargs thread running. */
00061 extern void qt_vstart (void);
00062 
00063 
00064 /* Hold 4 saved regs plus two return pcs (qt_error, qt_start) plus
00065    three args. */
00066 #define QUICKTHREADS_STKBASE  (9 * 4)
00067 
00068 /* Hold 4 saved regs plus one return pc (qt_vstart). */
00069 #define QUICKTHREADS_VSTKBASE (5 * 4)
00070 
00071 
00072 /* Stack must be 4-byte aligned. */
00073 #define QUICKTHREADS_STKALIGN (4)
00074 
00075 
00076 /* Where to place various arguments. */
00077 #define QUICKTHREADS_ONLY_INDEX (QUICKTHREADS_PC)
00078 #define QUICKTHREADS_USER_INDEX (QUICKTHREADS_ARG2)
00079 #define QUICKTHREADS_ARGT_INDEX (QUICKTHREADS_ARG1)
00080 #define QUICKTHREADS_ARGU_INDEX (QUICKTHREADS_ARG0)
00081 
00082 #define QUICKTHREADS_VSTARTUP_INDEX (QUICKTHREADS_EBP)
00083 #define QUICKTHREADS_VUSERF_INDEX   (QUICKTHREADS_EBX)
00084 #define QUICKTHREADS_VCLEANUP_INDEX (QUICKTHREADS_ESI)
00085 #define QUICKTHREADS_VARGT_INDEX    (QUICKTHREADS_EDI)
00086 
00087 
00088 #define QUICKTHREADS_EBX  0
00089 #define QUICKTHREADS_EDI  1
00090 #define QUICKTHREADS_ESI  2
00091 #define QUICKTHREADS_EBP  3
00092 #define QUICKTHREADS_PC 4
00093 /* The following are defined only for non-varargs. */
00094 #define QUICKTHREADS_RPC  5
00095 #define QUICKTHREADS_ARG0 6
00096 #define QUICKTHREADS_ARG1 7
00097 #define QUICKTHREADS_ARG2 8
00098 
00099 
00100 /* Stack grows down.  The top of the stack is the first thing to
00101    pop off (preincrement, postdecrement). */
00102 #define QUICKTHREADS_GROW_DOWN
00103 
00104 extern void qt_error (void);
00105 
00106 /* Push on the error return address. */
00107 #define QUICKTHREADS_ARGS_MD(sto) \
00108   (QUICKTHREADS_SPUT (sto, QUICKTHREADS_RPC, qt_error))
00109 
00110 
00111 /* When varargs are pushed, allocate space for all the args. */
00112 #define QUICKTHREADS_VARGS_MD0(sto, nbytes) \
00113   ((qt_t *)(((char *)(sto)) - QUICKTHREADS_STKROUNDUP(nbytes)))
00114 
00115 #define QUICKTHREADS_VARGS_MD1(sto) \
00116   (QUICKTHREADS_SPUT (sto, QUICKTHREADS_PC, qt_vstart))
00117 
00118 #define QUICKTHREADS_VARGS_DEFAULT
00119 
00120 #endif /* QUICKTHREADS_386_H */

Generated on Fri Jan 14 08:28:59 2005 for SystemC2.1beta11(excludingMSLib)(IncludingSCV)\nProvidedby:www.openverificationfoundation.org by doxygen1.2.18