|
|
1.1 root 1: /*
2: * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
3: *
4: * @APPLE_LICENSE_HEADER_START@
5: *
6: * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
7: * Reserved. This file contains Original Code and/or Modifications of
8: * Original Code as defined in and that are subject to the Apple Public
9: * Source License Version 1.1 (the "License"). You may not use this file
10: * except in compliance with the License. Please obtain a copy of the
11: * License at http://www.apple.com/publicsource and read it before using
12: * this file.
13: *
14: * The Original Code and all software distributed under the License are
15: * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16: * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17: * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18: * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
19: * License for the specific language governing rights and limitations
20: * under the License.
21: *
22: * @APPLE_LICENSE_HEADER_END@
23: */
24:
25: /*
26: * Copyright (c) 1993 NeXT Computer, Inc.
27: *
28: * PC support public declarations.
29: *
30: * HISTORY
31: *
32: * 9 Mar 1993 ? at NeXT
33: * Created.
34: */
35:
36: #import <mach/mach_types.h>
37: #if !KERNEL
38: #import <mach/vm_param.h>
39: #endif
40:
41: #import <architecture/i386/sel.h>
42: #import <architecture/i386/cpu.h>
43: #import <architecture/i386/fpu.h>
44:
45: #import <bsd/i386/signal.h>
46:
47: /*
48: * PCVERSIONNUMBER is incremented whenever
49: * a change is made that is not backwards
50: * compatible. This should never be done
51: * after the first release, since it will
52: * break the existing libraries.
53: *
54: * PCRELEASENUMBER is incremented whenever
55: * a change is made that is backwards compatible
56: * but must be distingished from earlier releases.
57: *
58: * NEXTSTEP for Intel Processors Release 3.1 is
59: * defined to be PCVERSIONNUMBER 15, PCRELEASENUMBER 0.
60: */
61:
62: #define PCVERSIONNUMBER 15
63: #define PCRELEASENUMBER 1
64:
65: typedef struct _PCcpuState {
66: unsigned int eax;
67: unsigned int ebx;
68: unsigned int ecx;
69: unsigned int edx;
70: unsigned int edi;
71: unsigned int esi;
72: unsigned int ebp;
73: unsigned int esp;
74: sel_t ss;
75: unsigned short :16;
76: unsigned int eflags;
77: unsigned int eip;
78: sel_t cs;
79: unsigned short :16;
80: sel_t ds;
81: unsigned short :16;
82: sel_t es;
83: unsigned short :16;
84: sel_t fs;
85: unsigned short :16;
86: sel_t gs;
87: unsigned short :16;
88: cr0_t cr0;
89: } _PCcpuState_t;
90:
91: typedef struct fp_state _PCfpuState_t;
92:
93: /*
94: * There are a total of PCMAXCONTEXT - 1
95: * contexts, since the initial context is
96: * not really a context.
97: *
98: * Each time a new context is created,
99: * the following fields are copied from
100: * the previous one:
101: * runOptions
102: * timeout
103: * tick
104: */
105:
106: #define PCMAXCONTEXT 8
107:
108: typedef struct PCcontext {
109: // Saved context of call to PCrun()
110: struct sigcontext runState;
111:
112: // True when running PC code (not in monitor)
113: boolean_t running;
114:
115: // Last exception or interrupt info
116: unsigned int trapNum;
117: unsigned int errCode;
118: kern_return_t exceptionResult;
119: unsigned int callHandler;
120: #define PC_HANDLE_NONE 0
121: #define PC_HANDLE_FAULT 1
122: #define PC_HANDLE_INTN 2
123: #define PC_HANDLE_BOP 3
124: #define PC_HANDLE_EXIT 4
125:
126: // Monitor callback conditions
127: unsigned int runOptions;
128: #define PC_RUN_IF_SET 1
129: #define PC_RUN_TIMEOUT 2
130: #define PC_RUN_TICK 4
131: unsigned int timeout;
132: unsigned int tick;
133:
134: // Interrupt flag for instruction emulation
135: boolean_t IF_flag;
136:
137: // TRUE means all FP instructions should trap
138: boolean_t EM_bit;
139:
140: // Extra flag bits for which we must simulate set/clear
141: unsigned short X_flags;
142:
143: // Mask of pending callbacks, updated synchronously
144: unsigned int pendingCallbacks;
145: #define PC_CALL_IF_SET PC_RUN_IF_SET
146: #define PC_CALL_TIMEOUT PC_RUN_TIMEOUT
147: #define PC_CALL_TICK PC_RUN_TICK
148: #define PC_CALL_WOKEN 8
149:
150: // Mask of timer callbacks to be delivered
151: unsigned int pendingTimers;
152:
153: // Mask of timers that are scheduled
154: unsigned int expectedTimers;
155:
156: // Debugging features
157: unsigned int debugOptions;
158: #define PC_DEBUG_PRESERVE_TRACE 1
159: } *PCcontext_t;
160:
161: typedef unsigned char PCfaultMask_t[32/BYTE_SIZE];
162: typedef unsigned char PCintNMask_t[256/BYTE_SIZE];
163: typedef struct {
164: vm_offset_t address;
165: vm_size_t length;
166: } PCdescTbl_t;
167:
168: /*
169: * Top level structure of the memory
170: * region shared by the kernel and the
171: * library. The 'versionNumber' field
172: * must come first.
173: */
174:
175: typedef struct PCshared {
176: unsigned int versionNumber;
177: PCfaultMask_t faultMask;
178: PCintNMask_t intNMask;
179: void (*callbackHelper)(void);
180: PCfaultMask_t machMask;
181: PCdescTbl_t IDT;
182: PCdescTbl_t LDT;
183: _PCcpuState_t cpuState;
184: int currentContext;
185: struct PCcontext contexts[PCMAXCONTEXT];
186: unsigned int releaseNumber;
187: _PCfpuState_t fpuState;
188: boolean_t
189: fpuOwned :1,
190: fpuStateValid :1;
191: } *PCshared_t;
192:
193: /*
194: * Arguments to mode switch
195: * BOPs (passed on stack).
196: */
197:
198: typedef struct {
199: unsigned int eip;
200: sel_t cs;
201: unsigned short :16;
202: unsigned int eflags;
203: unsigned int esp;
204: sel_t ss;
205: unsigned short :16;
206: } PCbopFD_t, PCbopFA_t;
207:
208: typedef struct {
209: unsigned short ip;
210: sel_t cs;
211: unsigned short flags;
212: unsigned short sp;
213: sel_t ss;
214: } PCbopFC_t;
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.