]>
Commit | Line | Data |
---|---|---|
1 | /* | |
2 | * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. | |
3 | * | |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
6 | * The contents of this file constitute Original Code as defined in and | |
7 | * are subject to the Apple Public Source License Version 1.1 (the | |
8 | * "License"). You may not use this file except in compliance with the | |
9 | * License. Please obtain a copy of the License at | |
10 | * http://www.apple.com/publicsource and read it before using this file. | |
11 | * | |
12 | * This Original Code and all software distributed under the License are | |
13 | * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
14 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, | |
15 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
16 | * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the | |
17 | * License for the specific language governing rights and limitations | |
18 | * under the License. | |
19 | * | |
20 | * @APPLE_LICENSE_HEADER_END@ | |
21 | */ | |
22 | /*----------------------------------------------------------------------- | |
23 | ** vmachmon.h | |
24 | ** | |
25 | ** C routines that we are adding to the MacOS X kernel. | |
26 | ** | |
27 | ** Wierd Apple PSL stuff goes here... | |
28 | ** | |
29 | ** Until then, Copyright 2000, Connectix | |
30 | ** | |
31 | -----------------------------------------------------------------------*/ | |
32 | ||
33 | #include <ppc/exception.h> | |
34 | ||
35 | #ifndef _VEMULATION_H_ | |
36 | #define _VEMULATION_H_ | |
37 | ||
38 | /************************************************************************************* | |
39 | External Emulation Types | |
40 | **************************************************************************************/ | |
41 | ||
42 | typedef union vmm_vector_register_t { | |
43 | unsigned long i[4]; | |
44 | unsigned short s[8]; | |
45 | unsigned char b[16]; | |
46 | } vmm_vector_register_t; | |
47 | ||
48 | typedef union vmm_fp_register_t { | |
49 | double d; | |
50 | unsigned long i[2]; | |
51 | unsigned short s[4]; | |
52 | unsigned char b[8]; | |
53 | } vmm_fp_register_t; | |
54 | ||
55 | typedef struct vmm_processor_state_t { | |
56 | /* | |
57 | * NOTE: The general context needs to correspond to the order of the savearea for quick swaps | |
58 | */ | |
59 | unsigned long ppcPC; | |
60 | unsigned long ppcMSR; | |
61 | ||
62 | unsigned long ppcGPRs[32]; | |
63 | ||
64 | unsigned long ppcCR; | |
65 | unsigned long ppcXER; | |
66 | unsigned long ppcLR; | |
67 | unsigned long ppcCTR; | |
68 | unsigned long ppcMQ; /* Obsolete */ | |
69 | unsigned long ppcVRSave; | |
70 | unsigned long ppcReserved1[40]; /* Future processor state can go here */ | |
71 | ||
72 | /* We must be 16-byte aligned here */ | |
73 | ||
74 | vmm_vector_register_t ppcVRs[32]; | |
75 | vmm_vector_register_t ppcVSCR; | |
76 | ||
77 | /* We must be 8-byte aligned here */ | |
78 | ||
79 | vmm_fp_register_t ppcFPRs[32]; | |
80 | vmm_fp_register_t ppcFPSCR; | |
81 | unsigned long ppcReserved2[2]; /* Pad out to multiple of 16 bytes */ | |
82 | } vmm_processor_state_t; | |
83 | ||
84 | typedef unsigned long vmm_return_code_t; | |
85 | ||
86 | typedef unsigned long vmm_thread_index_t; | |
87 | enum { | |
88 | kVmmCurrentVersion = 0x00010000 | |
89 | }; | |
90 | ||
91 | typedef unsigned long vmm_features_t; | |
92 | enum { | |
93 | kVmmFeature_LittleEndian = 0x00000001 | |
94 | }; | |
95 | ||
96 | typedef unsigned long vmm_version_t; | |
97 | ||
98 | typedef struct vmm_state_page_t { | |
99 | /* This structure must remain below 4Kb (one page) in size */ | |
100 | vmm_version_t interface_version; | |
101 | vmm_thread_index_t thread_index; | |
102 | unsigned int vmmStat; /* Note: this field is identical to vmmFlags in vmmCntrlEntry */ | |
103 | unsigned int vmmCntrl; | |
104 | #define vmmFloatLoad 0x80000000 | |
105 | #define vmmFloatLoadb 0 | |
106 | #define vmmVectLoad 0x40000000 | |
107 | #define vmmVectLoadb 1 | |
108 | #define vmmVectVRall 0x20000000 | |
109 | #define vmmVectVRallb 2 | |
110 | #define vmmVectVAss 0x10000000 | |
111 | #define vmmVectVAssb 3 | |
112 | vmm_return_code_t return_code; | |
113 | unsigned long return_params[4]; | |
114 | unsigned long gas[7]; /* For alignment */ | |
115 | ||
116 | /* The next portion of the structure must remain 32-byte aligned */ | |
117 | vmm_processor_state_t vmm_proc_state; | |
118 | ||
119 | } vmm_state_page_t; | |
120 | ||
121 | enum { | |
122 | /* Function Indices (passed in r3) */ | |
123 | kVmmGetVersion = 0, | |
124 | kVmmvGetFeatures, | |
125 | kVmmInitContext, | |
126 | kVmmTearDownContext, | |
127 | kVmmTearDownAll, | |
128 | kVmmMapPage, | |
129 | kVmmGetPageMapping, | |
130 | kVmmUnmapPage, | |
131 | kVmmUnmapAllPages, | |
132 | kVmmGetPageDirtyFlag, | |
133 | kVmmGetFloatState, | |
134 | kVmmGetVectorState, | |
135 | kVmmSetTimer, | |
136 | kVmmGetTimer, | |
137 | kVmmExecuteVM | |
138 | }; | |
139 | ||
140 | #define kVmmReturnNull 0 | |
141 | #define kVmmBogusContext 1 | |
142 | #define kVmmReturnDataPageFault 3 | |
143 | #define kVmmReturnInstrPageFault 4 | |
144 | #define kVmmReturnAlignmentFault 6 | |
145 | #define kVmmReturnProgramException 7 | |
146 | #define kVmmReturnSystemCall 12 | |
147 | #define kVmmReturnTraceException 13 | |
148 | #define kVmmAltivecAssist 22 | |
149 | ||
150 | ||
151 | /************************************************************************************* | |
152 | Internal Emulation Types | |
153 | **************************************************************************************/ | |
154 | ||
155 | #define kVmmMaxContextsPerThread 32 | |
156 | ||
157 | enum { | |
158 | kVmmCurrentFeatures = kVmmFeature_LittleEndian | |
159 | }; | |
160 | ||
161 | typedef struct vmmCntrlEntry { /* Virtual Machine Monitor control table entry */ | |
162 | unsigned int vmmFlags; /* Assorted control flags */ | |
163 | #define vmmInUse 0x80000000 | |
164 | #define vmmInUseb 0 | |
165 | #define vmmFloatCngd 0x40000000 | |
166 | #define vmmFloatCngdb 1 | |
167 | #define vmmVectCngd 0x20000000 | |
168 | #define vmmVectCngdb 2 | |
169 | #define vmmTimerPop 0x10000000 | |
170 | #define vmmTimerPopb 3 | |
171 | #define vmmMapDone 0x08000000 | |
172 | #define vmmMapDoneb 4 | |
173 | #define vmmSpfSave 0x000000FF | |
174 | #define vmmSpfSaveb 24 | |
175 | pmap_t vmmPmap; /* pmap for alternate context's view of task memory */ | |
176 | vmm_state_page_t *vmmContextKern; /* Kernel address of context communications area */ | |
177 | vmm_state_page_t *vmmContextUser; /* User address of context communications area */ | |
178 | pcb_t vmmFPU_pcb; /* Saved floating point context */ | |
179 | unsigned int vmmFPU_cpu; /* CPU saved fp context is valid on */ | |
180 | pcb_t vmmVMX_pcb; /* Saved vector context */ | |
181 | unsigned int vmmVMX_cpu; /* CPU saved vector context is valid on */ | |
182 | AbsoluteTime vmmTimer; /* Last set timer value. Zero means unset */ | |
183 | vm_offset_t vmmLastMap; /* Last vaddr mapping into virtual machine */ | |
184 | } vmmCntrlEntry; | |
185 | ||
186 | typedef struct vmmCntrlTable { /* Virtual Machine Monitor Control table */ | |
187 | vmmCntrlEntry vmmc[kVmmMaxContextsPerThread]; /* One entry for each possible Virtual Machine Monitor context */ | |
188 | } vmmCntrlTable; | |
189 | ||
190 | /* function decls for kernel level routines... */ | |
191 | extern vmmCntrlEntry *vmm_get_entry(thread_act_t act, vmm_thread_index_t index); | |
192 | extern kern_return_t vmm_tear_down_context(thread_act_t act, vmm_thread_index_t index); | |
193 | extern kern_return_t vmm_get_float_state(thread_act_t act, vmm_thread_index_t index); | |
194 | extern kern_return_t vmm_get_vector_state(thread_act_t act, vmm_thread_index_t index); | |
195 | extern kern_return_t vmm_set_timer(thread_act_t act, vmm_thread_index_t index, unsigned int timerhi, unsigned int timerlo); | |
196 | extern kern_return_t vmm_get_timer(thread_act_t act, vmm_thread_index_t index); | |
197 | extern void vmm_tear_down_all(thread_act_t act); | |
198 | extern kern_return_t vmm_map_page(thread_act_t act, vmm_thread_index_t hindex, vm_offset_t cva, | |
199 | vm_offset_t ava, vm_prot_t prot); | |
200 | extern vm_offset_t vmm_get_page_mapping(thread_act_t act, vmm_thread_index_t index, | |
201 | vm_offset_t va); | |
202 | extern kern_return_t vmm_unmap_page(thread_act_t act, vmm_thread_index_t index, vm_offset_t va); | |
203 | extern void vmm_unmap_all_pages(thread_act_t act, vmm_thread_index_t index); | |
204 | extern boolean_t vmm_get_page_dirty_flag(thread_act_t act, vmm_thread_index_t index, | |
205 | vm_offset_t va, unsigned int reset); | |
206 | extern int vmm_get_features(struct savearea *); | |
207 | extern int vmm_get_version(struct savearea *); | |
208 | extern int vmm_init_context(struct savearea *); | |
209 | extern int vmm_dispatch(struct savearea *); | |
210 | extern int vmm_exit(thread_act_t act, struct savearea *); | |
211 | extern void vmm_force_exit(thread_act_t act, struct savearea *); | |
212 | void vmm_timer_pop(thread_act_t act); | |
213 | ||
214 | #endif | |
215 |