Main Page   Compound List   File List   Compound Members   File Members  

switch.h

Go to the documentation of this file.
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 and SUN SPARC architectures.
00009  */
00010 
00011 /*
00012  Copyright (c) 1992-1993 The Regents of the University of California.
00013  All rights reserved.  See copyright.h for copyright notice and limitation 
00014  of liability and disclaimer of warranty provisions.
00015  */
00016 
00017 #ifndef SWITCH_H
00018 #define SWITCH_H
00019 
00020 #include "copyright.h"
00021 
00022 #ifdef HOST_MIPS
00023 
00024 /* Registers that must be saved during a context switch. 
00025  * These are the offsets from the beginning of the Thread object, 
00026  * in bytes, used in switch.s
00027  */
00028 #define SP 0
00029 #define S0 4
00030 #define S1 8
00031 #define S2 12
00032 #define S3 16
00033 #define S4 20
00034 #define S5 24
00035 #define S6 28
00036 #define S7 32
00037 #define FP 36
00038 #define PC 40
00039 
00040 /* To fork a thread, we set up its saved register state, so that
00041  * when we switch to the thread, it will start running in ThreadRoot.
00042  *
00043  * The following are the initial registers we need to set up to
00044  * pass values into ThreadRoot (for instance, containing the procedure
00045  * for the thread to run).  The first set is the registers as used
00046  * by ThreadRoot; the second set is the locations for these initial
00047  * values in the Thread object -- used in Thread::AllocateStack().
00048  */
00049 
00050 #define InitialPC       s0
00051 #define InitialArg      s1
00052 #define WhenDonePC      s2
00053 #define StartupPC       s3
00054 
00055 #define PCState         (PC/4-1)
00056 #define FPState         (FP/4-1)
00057 #define InitialPCState  (S0/4-1)
00058 #define InitialArgState (S1/4-1)
00059 #define WhenDonePCState (S2/4-1)
00060 #define StartupPCState  (S3/4-1)
00061 
00062 #endif  // HOST_MIPS
00063 
00064 #ifdef HOST_SPARC
00065 
00066 /* Registers that must be saved during a context switch.  See comment above. */ 
00067 #define I0 4
00068 #define I1 8
00069 #define I2 12
00070 #define I3 16
00071 #define I4 20
00072 #define I5 24
00073 #define I6 28
00074 #define I7 32
00075 
00076 /* Aliases used for clearing code.  */
00077 #define FP I6
00078 #define PC I7
00079 
00080 /* Registers for ThreadRoot.  See comment above. */
00081 #define InitialPC       %o0
00082 #define InitialArg      %o1
00083 #define WhenDonePC      %o2
00084 #define StartupPC       %o3
00085 
00086 #define PCState         (PC/4-1)
00087 #define InitialPCState  (I0/4-1)
00088 #define InitialArgState (I1/4-1)
00089 #define WhenDonePCState (I2/4-1)
00090 #define StartupPCState  (I3/4-1)
00091 #endif  // HOST_SPARC
00092 
00093 #ifdef HOST_SNAKE
00094 
00095 /* Registers that must be saved during a context switch.  See comment above. */ 
00096 #define   SP   0
00097 #define   S0   4
00098 #define   S1   8
00099 #define   S2   12
00100 #define   S3   16
00101 #define   S4   20
00102 #define   S5   24
00103 #define   S6   28
00104 #define   S7   32
00105 #define   S8   36
00106 #define   S9   40
00107 #define   S10  44
00108 #define   S11  48
00109 #define   S12  52
00110 #define   S13  56
00111 #define   S14  60
00112 #define   S15  64
00113 #define   PC   68
00114 
00115 /* Registers for ThreadRoot.  See comment above. */
00116 #define InitialPC       %r3             /* S0 */
00117 #define InitialArg      %r4
00118 #define WhenDonePC      %r5
00119 #define StartupPC       %r6
00120 
00121 #define PCState         (PC/4-1)
00122 #define InitialPCState  (S0/4-1)
00123 #define InitialArgState (S1/4-1)
00124 #define WhenDonePCState (S2/4-1)
00125 #define StartupPCState  (S3/4-1)
00126 #endif  // HOST_SNAKE
00127 
00128 #ifdef HOST_i386
00129 
00130 /* the offsets of the registers from the beginning of the thread object */
00131 #define _ESP     0
00132 #define _EAX     4
00133 #define _EBX     8
00134 #define _ECX     12
00135 #define _EDX     16
00136 #define _EBP     20
00137 #define _ESI     24
00138 #define _EDI     28
00139 #define _PC      32
00140 
00141 /* These definitions are used in Thread::AllocateStack(). */
00142 #define PCState         (_PC/4-1)
00143 #define FPState         (_EBP/4-1)
00144 #define InitialPCState  (_ESI/4-1)
00145 #define InitialArgState (_EDX/4-1)
00146 #define WhenDonePCState (_EDI/4-1)
00147 #define StartupPCState  (_ECX/4-1)
00148 
00149 #define InitialPC       %esi
00150 #define InitialArg      %edx
00151 #define WhenDonePC      %edi
00152 #define StartupPC       %ecx
00153 #endif
00154 
00155 #endif // SWITCH_H

Generated on Mon Feb 10 09:54:47 2003 for nachos by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002
The University of Southern California does not screen or control the content on this website and thus does not guarantee the accuracy, integrity, or quality of such content. All content on this website is provided by and is the sole responsibility of the person from which such content originated, and such content does not necessarily reflect the opinions of the University administration or the Board of Trustees