Page principale | Liste des namespaces | Hiérarchie des classes | Liste des classes | Répertoires | Liste des fichiers | Membres de namespace | Membres de classe | Membres de fichier

switch.h

Aller à la documentation de ce fichier.
00001 /* switch.h
00002  *      Definitions needed for implementing context switching.
00003  *
00004  *      Context switching is inherently machine dependent, since
00005  *      the registers to be saved, how to set up an initial
00006  *      call frame, etc, are all specific to a processor architecture.
00007  *
00008  *      This file currently supports the DEC MIPS, DEC Alpha, SUN SPARC,
00009  *  HP PARISC, IBM PowerPC, and Intel x86 architectures.
00010  */
00011 
00012 /*
00013  Copyright (c) 1992-1996 The Regents of the University of California.
00014  All rights reserved.  See copyright.h for copyright notice and limitation 
00015  of liability and disclaimer of warranty provisions.
00016  */
00017 
00018 #ifndef SWITCH_H
00019 #define SWITCH_H
00020 
00021 #include "copyright.h"
00022 
00023 #ifdef DECMIPS
00024 
00025 /* Registers that must be saved during a context switch. 
00026  * These are the offsets from the beginning of the Thread object, 
00027  * in bytes, used in switch.s
00028  */
00029 #define SP 0
00030 #define S0 4
00031 #define S1 8
00032 #define S2 12
00033 #define S3 16
00034 #define S4 20
00035 #define S5 24
00036 #define S6 28
00037 #define S7 32
00038 #define FP 36
00039 #define PC 40
00040 
00041 /* To fork a thread, we set up its saved register state, so that
00042  * when we switch to the thread, it will start running in ThreadRoot.
00043  *
00044  * The following are the initial registers we need to set up to
00045  * pass values into ThreadRoot (for instance, containing the procedure
00046  * for the thread to run).  The first set is the registers as used
00047  * by ThreadRoot; the second set is the locations for these initial
00048  * values in the Thread object -- used in Thread::AllocateStack().
00049  */
00050 
00051 #define InitialPC       s0
00052 #define InitialArg      s1
00053 #define WhenDonePC      s2
00054 #define StartupPC       s3
00055 
00056 #define PCState         (PC/4-1)
00057 #define FPState         (FP/4-1)
00058 #define InitialPCState  (S0/4-1)
00059 #define InitialArgState (S1/4-1)
00060 #define WhenDonePCState (S2/4-1)
00061 #define StartupPCState  (S3/4-1)
00062 
00063 #endif  // DECMIPS
00064 
00065 #ifdef SPARC
00066 
00067 /* Registers that must be saved during a context switch.  See comment above. */ 
00068 #define I0 4
00069 #define I1 8
00070 #define I2 12
00071 #define I3 16
00072 #define I4 20
00073 #define I5 24
00074 #define I6 28
00075 #define I7 32
00076 
00077 /* Aliases used for clearing code.  */
00078 #define FP I6
00079 #define PC I7
00080 
00081 /* Registers for ThreadRoot.  See comment above. */
00082 #define InitialPC       %o0
00083 #define InitialArg      %o1
00084 #define WhenDonePC      %o2
00085 #define StartupPC       %o3
00086 
00087 #define PCState         (PC/4-1)
00088 #define InitialPCState  (I0/4-1)
00089 #define InitialArgState (I1/4-1)
00090 #define WhenDonePCState (I2/4-1)
00091 #define StartupPCState  (I3/4-1)
00092 
00093 #endif  // SPARC
00094 
00095 #ifdef PARISC
00096 
00097 /* Registers that must be saved during a context switch.  See comment above. */ 
00098 #define   SP   0
00099 #define   S0   4
00100 #define   S1   8
00101 #define   S2   12
00102 #define   S3   16
00103 #define   S4   20
00104 #define   S5   24
00105 #define   S6   28
00106 #define   S7   32
00107 #define   S8   36
00108 #define   S9   40
00109 #define   S10  44
00110 #define   S11  48
00111 #define   S12  52
00112 #define   S13  56
00113 #define   S14  60
00114 #define   S15  64
00115 #define   PC   68
00116 
00117 /* Registers for ThreadRoot.  See comment above. */
00118 #define InitialPC       %r3             /* S0 */
00119 #define InitialArg      %r4
00120 #define WhenDonePC      %r5
00121 #define StartupPC       %r6
00122 
00123 #define PCState         (PC/4-1)
00124 #define InitialPCState  (S0/4-1)
00125 #define InitialArgState (S1/4-1)
00126 #define WhenDonePCState (S2/4-1)
00127 #define StartupPCState  (S3/4-1)
00128 
00129 #endif  // PARISC
00130 
00131 #ifdef x86
00132 
00133 /* the offsets of the registers from the beginning of the thread object */
00134 #define _ESP     0
00135 #define _EAX     4
00136 #define _EBX     8
00137 #define _ECX     12
00138 #define _EDX     16
00139 #define _EBP     20
00140 #define _ESI     24
00141 #define _EDI     28
00142 #define _PC      32
00143 
00144 /* These definitions are used in Thread::AllocateStack(). */
00145 #define PCState         (_PC/4-1)
00146 #define FPState         (_EBP/4-1)
00147 #define InitialPCState  (_ESI/4-1)
00148 #define InitialArgState (_EDX/4-1)
00149 #define WhenDonePCState (_EDI/4-1)
00150 #define StartupPCState  (_ECX/4-1)
00151 
00152 #define InitialPC       %esi
00153 #define InitialArg      %edx
00154 #define WhenDonePC      %edi
00155 #define StartupPC       %ecx
00156 
00157 #endif // x86
00158 
00159 #ifdef PowerPC 
00160 
00161  #define        SP        0    // stack pointer 
00162  #define        P1        4    // parameters
00163  #define        P2        8
00164  #define        P3       12
00165  #define        P4       16 
00166  #define        GP13     20    // general purpose registers 13-31
00167  #define        GP14     24
00168  #define        GP15     28     
00169  #define        GP16     32
00170  #define        GP17     36
00171  #define        GP18     40  
00172  #define        GP19     44
00173  #define        GP20     48
00174  #define        GP21     52
00175  #define        GP22     56
00176  #define        GP23     60
00177  #define        GP24     64
00178  #define        GP25     68     
00179  #define        GP26     72
00180  #define        GP27     76
00181  #define        GP28     80  
00182  #define        GP29     84
00183  #define        GP30     88
00184  #define        GP31     92
00185  #define        FP13     96    // floating point registers 14-31
00186  #define        FP15    104     
00187  #define        FP16    112
00188  #define        FP17    120
00189  #define        FP18    128  
00190  #define        FP19    136
00191  #define        FP20    144
00192  #define        FP21    152
00193  #define        FP22    160
00194  #define        FP23    168
00195  #define        FP24    176
00196  #define        FP25    184     
00197  #define        FP26    192
00198  #define        FP27    200
00199  #define        FP28    208  
00200  #define        FP29    216
00201  #define        FP30    224
00202  #define        FP31    232
00203  #define        CR      240   // control register
00204  #define        LR      244   // link register
00205  #define        TOC     248   // Table Of Contents
00206 
00207 
00208  // for ThreadRoot assembly function 
00209 
00210  #define        InitialPCState  0  //  (P1/4 - 1)  // user function address 
00211  #define        InitialArgState 1  //  (P2/4 - 1)  // user function argument       
00212  #define        WhenDonePCState 2  //  (P3/4 - 1)  // clean up function addr 
00213  #define        StartupPCState  3  //  (P4/4 - 1)  // start up function addr 
00214  #define        PCState         60 //  (LR/4 - 1)  // ThreadRoot addr (first time).
00215                                                    // Later PC addr when SWITCH 
00216                                                    // occured
00217                    
00218  #define        InitialLR       21
00219  #define        InitialArg      22
00220  #define        WhenDoneLR      23
00221  #define        StartupLR       24
00222 
00223 #endif  // PowerPC 
00224 
00225 #ifdef ALPHA
00226 
00227 /* 
00228  * Porting to Alpha was done by Shuichi Oikawa (shui@sfc.keio.ac.jp).
00229  */
00230 /* Registers that must be saved during a context switch. 
00231  * These are the offsets from the beginning of the Thread object, 
00232  * in bytes, used in switch.s
00233  */
00234 #define SP      (0*8)
00235 #define S0      (1*8)
00236 #define S1      (2*8)
00237 #define S2      (3*8)
00238 #define S3      (4*8)
00239 #define S4      (5*8)
00240 #define S5      (6*8)
00241 #define S6      (7*8)           /* used as FP (Frame Pointer) */
00242 #define GP      (8*8)
00243 #define PC      (9*8)
00244 
00245 /* To fork a thread, we set up its saved register state, so that
00246  * when we switch to the thread, it will start running in ThreadRoot.
00247  *
00248  * The following are the initial registers we need to set up to
00249  * pass values into ThreadRoot (for instance, containing the procedure
00250  * for the thread to run).  The first set is the registers as used
00251  * by ThreadRoot; the second set is the locations for these initial
00252  * values in the Thread object -- used in Thread::StackAllocate().
00253  */
00254 #define InitialPC       s0
00255 #define InitialArg      s1
00256 #define WhenDonePC      s2
00257 #define StartupPC       s3
00258 
00259 #define PCState         (PC/8-1)
00260 #define FPState         (S6/8-1)
00261 #define InitialPCState  (S0/8-1)
00262 #define InitialArgState (S1/8-1)
00263 #define WhenDonePCState (S2/8-1)
00264 #define StartupPCState  (S3/8-1)
00265 
00266 #endif // HOST_ALPHA
00267  
00268 #endif // SWITCH_H

Généré le Sun Jan 15 00:45:45 2006 pour Système NachOS : par  doxygen 1.4.4