2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
23 * @APPLE_LICENSE_HEADER_END@
30 #ifndef _PPC_THREAD_ACT_H_
31 #define _PPC_THREAD_ACT_H_
33 #include <mach_kgdb.h>
34 #include <mach/boolean.h>
35 #include <mach/ppc/vm_types.h>
36 #include <mach/thread_status.h>
37 #include <kern/lock.h>
38 #include <kern/clock.h>
39 #include <ppc/savearea.h>
42 * Kernel state structure
44 * This holds the kernel state that is saved and restored across context
49 * PPC process control block
51 * The PCB holds normal context. It does not contain vector or floating point
56 typedef struct savearea pcb
;
57 typedef struct savearea
*pcb_t
;
59 struct facility_context
{
61 savearea_fpu
*FPUsave
; /* The floating point savearea */
62 savearea
*FPUlevel
; /* The floating point context level */
63 unsigned int FPUcpu
; /* The last processor to enable floating point */
64 unsigned int FPUsync
; /* Sync lock */
65 savearea_vec
*VMXsave
; /* The VMX savearea */
66 savearea
*VMXlevel
; /* The VMX context level */
67 unsigned int VMXcpu
; /* The last processor to enable vector */
68 unsigned int VMXsync
; /* Sync lock */
69 struct thread_activation
*facAct
; /* Activation associated with context */
72 typedef struct facility_context facility_context
;
75 * Maps state flavor to number of words in the state:
77 extern unsigned int state_count
[];
79 #define USER_REGS(ThrAct) ((ThrAct)->mact.pcb)
81 #define user_pc(ThrAct) ((ThrAct)->mact.pcb->save_srr0)
83 #define act_machine_state_ptr(ThrAct) (thread_state_t)USER_REGS(ThrAct)
85 typedef struct MachineThrAct
{
87 * pointer to process control block control blocks. Potentially
88 * one for each active facility context. They may point to the
91 savearea
*pcb
; /* The "normal" savearea */
92 facility_context
*curctx
; /* Current facility context */
93 facility_context
*deferctx
; /* Deferred facility context */
94 facility_context facctx
; /* "Normal" facility context */
95 struct vmmCntrlEntry
*vmmCEntry
; /* Pointer current emulation context or 0 */
96 struct vmmCntrlTable
*vmmControl
; /* Pointer to virtual machine monitor control table */
97 uint64_t qactTimer
; /* Time thread needs to interrupt. This is a single-shot timer. Zero is unset */
98 unsigned int cioSpace
; /* Address space ID for in progress copyin/out */
99 #define cioSwitchAway 0x80000000 /* Context switched away from thread since MapUserAddressSpace */
100 #define cioSwitchAwayb 0
101 addr64_t cioRelo
; /* Relocation value for in progress copyin/out */
102 unsigned int ksp
; /* points to TOP OF STACK or zero */
103 unsigned int preemption_count
; /* preemption count */
104 unsigned int bbDescAddr
; /* Points to Blue Box Trap descriptor area in kernel (page aligned) */
105 unsigned int bbUserDA
; /* Points to Blue Box Trap descriptor area in user (page aligned) */
106 unsigned int bbTableStart
; /* Points to Blue Box Trap dispatch area in user */
107 unsigned int emPendRupts
; /* Number of pending emulated interruptions */
108 unsigned int bbTaskID
; /* Opaque task ID for Blue Box threads */
109 unsigned int bbTaskEnv
; /* Opaque task data reference for Blue Box threads */
110 unsigned int specFlags
; /* Special flags */
111 unsigned int pmcovfl
[8]; /* PMC overflow count */
112 unsigned int perfmonFlags
; /* Perfmon facility flags */
114 /* special flags bits */
116 #define ignoreZeroFaultbit 0
117 #define floatUsedbit 1
118 #define vectorUsedbit 2
119 #define runningVMbit 4
120 #define floatCngbit 5
121 #define vectorCngbit 6
122 #define timerPopbit 7
123 #define userProtKeybit 8
124 #define FamVMenabit 11
125 #define FamVMmodebit 12
126 #define perfMonitorbit 13
127 /* NOTE: Do not move or assign bit 31 without changing exception vector ultra fast path code */
128 #define bbThreadbit 28
129 #define bbNoMachSCbit 29
130 #define bbPreemptivebit 30
131 #define spfReserved1 31 /* See note above */
133 #define ignoreZeroFault 0x80000000 /* (1<<(31-ignoreZeroFaultbit)) */
134 #define floatUsed 0x40000000 /* (1<<(31-floatUsedbit)) */
135 #define vectorUsed 0x20000000 /* (1<<(31-vectorUsedbit)) */
137 #define runningVM 0x08000000 /* (1<<(31-runningVMbit)) */
138 #define floatCng 0x04000000 /* (1<<(31-floatCngbit)) */
139 #define vectorCng 0x02000000 /* (1<<(31-vectorCngbit)) */
140 #define timerPop 0x01000000 /* (1<<(31-timerPopbit)) */
142 #define userProtKey 0x00800000 /* (1<<(31-userProtKeybit)) */
144 #define FamVMena 0x00100000 /* (1<<(31-FamVMenabit)) */
145 #define FamVMmode 0x00080000 /* (1<<(31-FamVMmodebit)) */
146 #define perfMonitor 0x00040000 /* (1<<(31-perfMonitorbit)) */
148 #define bbThread 0x00000008 /* (1<<(31-bbThreadbit)) */
149 #define bbNoMachSC 0x00000004 /* (1<<(31-bbNoMachSCbit)) */
150 #define bbPreemptive 0x00000002 /* (1<<(31-bbPreemptivebit)) */
153 #define fvChk 0x80000000
156 unsigned long cthread_self
; /* for use of cthread package */
159 } MachineThrAct
, *MachineThrAct_t
;
161 extern struct savearea
*find_user_regs(thread_act_t act
);
162 extern struct savearea
*get_user_regs(thread_act_t
);
163 extern struct savearea_fpu
*find_user_fpu(thread_act_t act
);
164 extern struct savearea_vec
*find_user_vec(thread_act_t act
);
165 extern int thread_enable_fpe(thread_act_t act
, int onoff
);
167 extern void *act_thread_csave(void);
168 extern void act_thread_catt(void *ctx
);
169 extern void act_thread_cfree(void *ctx
);
171 #define current_act_fast() current_act()
173 #endif /* _PPC_THREAD_ACT_H_ */