]>
git.saurik.com Git - apple/xnu.git/blob - osfmk/ppc/savearea.h
554cd2bb8afe872f4adae9c41efb610727ffa945
2 * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
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.
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
20 * @APPLE_LICENSE_HEADER_END@
22 #ifndef _PPC_SAVEAREA_H_
23 #define _PPC_SAVEAREA_H_
27 #include <sys/appleapiopts.h>
29 #ifdef __APPLE_API_PRIVATE
31 #ifdef MACH_KERNEL_PRIVATE
32 #include <mach/ppc/vm_types.h>
33 typedef struct savearea_comm
{
36 * The following fields are common to all saveareas and are used to manage individual
39 * Fields that start with "save" are part of the individual saveareas. Those that
40 * start with "sac" pertain to the free pool stuff and are valid only on the first slot
45 /* Keep the save_prev, sac_next, and sac_prev in these positions, some assemble code depends upon it to
46 * match up with fields in saveanchor.
48 struct savearea
*save_prev
; /* The address of the previous (or next) savearea */
49 unsigned int *sac_next
; /* Points to next savearea page that has a free slot - real */
50 unsigned int *sac_prev
; /* Points to previous savearea page that has a free slot - real */
51 unsigned int save_flags
; /* Various flags */
52 unsigned int save_level
; /* Context ID */
53 unsigned int save_time
[2]; /* Context save time - for debugging or performance */
54 struct thread_activation
*save_act
; /* Associated activation */
58 unsigned int sac_vrswap
; /* XOR mask to swap V to R or vice versa */
59 unsigned int sac_alloc
; /* Bitmap of allocated slots */
60 unsigned int sac_flags
; /* Various flags */
61 unsigned int save_misc0
; /* Various stuff */
62 unsigned int save_misc1
; /* Various stuff */
63 unsigned int save_misc2
; /* Various stuff */
64 unsigned int save_misc3
; /* Various stuff */
65 unsigned int save_misc4
; /* Various stuff */
67 unsigned int save_040
[8]; /* Fill 32 bytes */
73 #ifdef BSD_KERNEL_PRIVATE
74 typedef struct savearea_comm
{
75 unsigned int save_000
[24];
79 #if defined(MACH_KERNEL_PRIVATE) || defined(BSD_KERNEL_PRIVATE)
81 * This type of savearea contains all of the general context.
84 typedef struct savearea
{
86 savearea_comm save_hdr
; /* Stuff common to all saveareas */
88 unsigned int save_060
[8]; /* Fill 32 bytes */
100 unsigned int save_r8
;
101 unsigned int save_r9
;
102 unsigned int save_r10
;
103 unsigned int save_r11
;
104 unsigned int save_r12
;
105 unsigned int save_r13
;
106 unsigned int save_r14
;
107 unsigned int save_r15
;
110 unsigned int save_r16
;
111 unsigned int save_r17
;
112 unsigned int save_r18
;
113 unsigned int save_r19
;
114 unsigned int save_r20
;
115 unsigned int save_r21
;
116 unsigned int save_r22
;
117 unsigned int save_r23
;
120 unsigned int save_r24
;
121 unsigned int save_r25
;
122 unsigned int save_r26
;
123 unsigned int save_r27
;
124 unsigned int save_r28
;
125 unsigned int save_r29
;
126 unsigned int save_r30
;
127 unsigned int save_r31
;
130 unsigned int save_srr0
;
131 unsigned int save_srr1
;
132 unsigned int save_cr
;
133 unsigned int save_xer
;
134 unsigned int save_lr
;
135 unsigned int save_ctr
;
136 unsigned int save_dar
;
137 unsigned int save_dsisr
;
141 unsigned int save_vscr
[4];
142 unsigned int save_fpscrpad
;
143 unsigned int save_fpscr
;
144 unsigned int save_exception
;
145 unsigned int save_vrsave
;
148 unsigned int save_sr0
;
149 unsigned int save_sr1
;
150 unsigned int save_sr2
;
151 unsigned int save_sr3
;
152 unsigned int save_sr4
;
153 unsigned int save_sr5
;
154 unsigned int save_sr6
;
155 unsigned int save_sr7
;
158 unsigned int save_sr8
;
159 unsigned int save_sr9
;
160 unsigned int save_sr10
;
161 unsigned int save_sr11
;
162 unsigned int save_sr12
;
163 unsigned int save_sr13
;
164 unsigned int save_sr14
;
165 unsigned int save_sr15
;
168 unsigned int save_180
[8];
169 unsigned int save_1A0
[8];
170 unsigned int save_1C0
[8];
171 unsigned int save_1E0
[8];
172 unsigned int save_200
[8];
173 unsigned int save_220
[8];
174 unsigned int save_240
[8];
175 unsigned int save_260
[8];
182 * This type of savearea contains all of the floating point context.
185 typedef struct savearea_fpu
{
187 savearea_comm save_hdr
; /* Stuff common to all saveareas */
189 unsigned int save_060
[8]; /* Fill 32 bytes */
231 unsigned int save_180
[8];
232 unsigned int save_1A0
[8];
233 unsigned int save_1C0
[8];
234 unsigned int save_1E0
[8];
235 unsigned int save_200
[8];
236 unsigned int save_220
[8];
237 unsigned int save_240
[8];
238 unsigned int save_260
[8];
246 * This type of savearea contains all of the vector context.
249 typedef struct savearea_vec
{
251 savearea_comm save_hdr
; /* Stuff common to all saveareas */
253 unsigned int save_060
[7]; /* Fill 32 bytes */
254 unsigned int save_vrvalid
; /* Valid registers in saved context */
257 unsigned int save_vr0
[4];
258 unsigned int save_vr1
[4];
259 unsigned int save_vr2
[4];
260 unsigned int save_vr3
[4];
261 unsigned int save_vr4
[4];
262 unsigned int save_vr5
[4];
263 unsigned int save_vr6
[4];
264 unsigned int save_vr7
[4];
265 unsigned int save_vr8
[4];
266 unsigned int save_vr9
[4];
267 unsigned int save_vr10
[4];
268 unsigned int save_vr11
[4];
269 unsigned int save_vr12
[4];
270 unsigned int save_vr13
[4];
271 unsigned int save_vr14
[4];
272 unsigned int save_vr15
[4];
273 unsigned int save_vr16
[4];
274 unsigned int save_vr17
[4];
275 unsigned int save_vr18
[4];
276 unsigned int save_vr19
[4];
277 unsigned int save_vr20
[4];
278 unsigned int save_vr21
[4];
279 unsigned int save_vr22
[4];
280 unsigned int save_vr23
[4];
281 unsigned int save_vr24
[4];
282 unsigned int save_vr25
[4];
283 unsigned int save_vr26
[4];
284 unsigned int save_vr27
[4];
285 unsigned int save_vr28
[4];
286 unsigned int save_vr29
[4];
287 unsigned int save_vr30
[4];
288 unsigned int save_vr31
[4];
292 #endif /* MACH_KERNEL_PRIVATE || BSD_KERNEL_PRIVATE */
294 #ifdef MACH_KERNEL_PRIVATE
299 * Note that this force aligned in aligned_data.s and must be in V=R storage.
300 * Also, all addresses in chains are physical. This structure can only be
301 * updated with translation and interrupts disabled. This is because it is
302 * locked during exception processing and if we were to take a PTE miss while the
303 * lock were held, well, that would be very bad now wouldn't it?
306 unsigned int savelock
; /* Lock word for savearea free list manipulation */
307 unsigned int *savepoolfwd
; /* Forward anchor for the free pool */
308 unsigned int *savepoolbwd
; /* Backward anchor for the free pool */
309 volatile unsigned int savefree
; /* Anchor for the global free list */
310 volatile unsigned int savefreecnt
; /* Number of saveareas on global free list */
311 volatile int saveadjust
; /* If 0 number of saveareas is ok, otherwise number to change (positive means grow, negative means shrink */
312 volatile int saveinuse
; /* Number of areas in use counting those on the local free list */
313 volatile int savetarget
; /* Number of savearea's needed */
314 int savemaxcount
; /* Maximum saveareas ever allocated */
320 #define sac_cnt (4096 / sizeof(savearea)) /* Number of saveareas per page */
321 #define sac_empty (0xFFFFFFFF << (32 - sac_cnt)) /* Mask with all entries empty */
322 #define sac_perm 0x40000000 /* Page permanently assigned */
323 #define sac_permb 1 /* Page permanently assigned - bit position */
325 #define LocalSaveTarget (((8 + sac_cnt - 1) / sac_cnt) * sac_cnt) /* Target for size of local savearea free list */
326 #define LocalSaveMin (LocalSaveTarget / 2) /* Min size of local savearea free list before we grow */
327 #define LocalSaveMax (LocalSaveTarget * 2) /* Max size of local savearea free list before we trim */
329 #define FreeListMin (2 * LocalSaveTarget * NCPUS) /* Always make sure there are enough to fill local list twice per processor */
330 #define SaveLowHysteresis LocalSaveTarget /* The number off from target before we adjust upwards */
331 #define SaveHighHysteresis FreeListMin /* The number off from target before we adjust downwards */
332 #define InitialSaveAreas (2 * FreeListMin) /* The number of saveareas to make at boot time */
333 #define InitialSaveTarget FreeListMin /* The number of saveareas for an initial target. This should be the minimum ever needed. */
334 #define InitialSaveBloks (InitialSaveAreas + sac_cnt - 1) / sac_cnt /* The number of savearea blocks to allocate at boot */
337 void save_release(struct savearea
*); /* Release a save area */
338 struct savectl
*save_dequeue(void); /* Find and dequeue one that is all empty */
339 unsigned int save_queue(struct savearea
*); /* Add a new savearea block to the free list */
340 struct savearea
*save_get(void); /* Obtains a savearea from the free list (returns virtual address) */
341 struct savearea
*save_get_phys(void); /* Obtains a savearea from the free list (returns physical address) */
342 struct savearea
*save_alloc(void); /* Obtains a savearea and allocates blocks if needed */
343 struct savearea
*save_cpv(struct savearea
*); /* Converts a physical savearea address to virtual */
344 void save_ret(struct savearea
*); /* Returns a savearea to the free list */
345 void save_ret_phys(struct savearea
*); /* Returns a savearea to the free list */
346 void save_adjust(void); /* Adjust size of the global free list */
347 struct savearea_comm
*save_trim_freet(void); /* Remove free pages from savearea pool */
349 #endif /* MACH_KERNEL_PRIVATE */
350 #endif /* __APPLE_API_PRIVATE */
352 #endif /* ndef ASSEMBLER */
354 #define SAVattach 0x80000000 /* Savearea has valid context */
355 #define SAVrststk 0x00010000 /* Indicates that the current stack should be reset to empty */
356 #define SAVsyscall 0x00020000 /* Indicates that the savearea is associated with a syscall */
357 #define SAVredrive 0x00040000 /* Indicates that the low-level fault handler associated */
358 #define SAVtype 0x0000FF00 /* Shows type of savearea */
359 #define SAVtypeshft 8 /* Shift to position type */
360 #define SAVempty 0x86 /* Savearea is on free list */
361 #define SAVgeneral 0x01 /* Savearea contains general context */
362 #define SAVfloat 0x02 /* Savearea contains floating point context */
363 #define SAVvector 0x03 /* Savearea contains vector context */
365 #endif /* _PPC_SAVEAREA_H_ */