2 * Copyright (c) 2000 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@
27 #ifndef _PPC_THREAD_ACT_H_
28 #define _PPC_THREAD_ACT_H_
30 #include <mach_kgdb.h>
31 #include <mach/boolean.h>
32 #include <mach/ppc/vm_types.h>
33 #include <mach/thread_status.h>
34 #include <kern/lock.h>
35 #include <kern/clock.h>
36 #include <ppc/savearea.h>
39 * Kernel state structure
41 * This holds the kernel state that is saved and restored across context
46 * PPC process control block
48 * The PCB holds normal context. It does not contain vector or floating point
53 typedef struct savearea pcb
;
54 typedef struct savearea
*pcb_t
;
56 struct facility_context
{
58 savearea_fpu
*FPUsave
; /* The floating point savearea */
59 savearea
*FPUlevel
; /* The floating point context level */
60 unsigned int FPUcpu
; /* The last processor to enable floating point */
61 unsigned int FPUsync
; /* Sync lock */
62 savearea_vec
*VMXsave
; /* The VMX savearea */
63 savearea
*VMXlevel
; /* The VMX context level */
64 unsigned int VMXcpu
; /* The last processor to enable vector */
65 unsigned int VMXsync
; /* Sync lock */
66 struct thread_activation
*facAct
; /* Activation associated with context */
69 typedef struct facility_context facility_context
;
72 * Maps state flavor to number of words in the state:
74 extern unsigned int state_count
[];
76 #define USER_REGS(ThrAct) ((ThrAct)->mact.pcb)
78 #define user_pc(ThrAct) ((ThrAct)->mact.pcb->save_srr0)
80 #define act_machine_state_ptr(ThrAct) (thread_state_t)USER_REGS(ThrAct)
82 typedef struct MachineThrAct
{
84 * pointer to process control block control blocks. Potentially
85 * one for each active facility context. They may point to the
88 savearea
*pcb
; /* The "normal" savearea */
89 savearea
*upcb
; /* The "normal" user savearea */
90 facility_context
*curctx
; /* Current facility context */
91 facility_context
*deferctx
; /* Deferred facility context */
92 facility_context facctx
; /* "Normal" facility context */
93 struct vmmCntrlEntry
*vmmCEntry
; /* Pointer current emulation context or 0 */
94 struct vmmCntrlTable
*vmmControl
; /* Pointer to virtual machine monitor control table */
95 uint64_t qactTimer
; /* Time thread needs to interrupt. This is a single-shot timer. Zero is unset */
96 unsigned int cioSpace
; /* Address space ID for in progress copyin/out */
97 #define cioSwitchAway 0x80000000 /* Context switched away from thread since MapUserAddressSpace */
98 #define cioSwitchAwayb 0
99 addr64_t cioRelo
; /* Relocation value for in progress copyin/out */
100 unsigned int ksp
; /* points to TOP OF STACK or zero */
101 unsigned int preemption_count
; /* preemption count */
102 unsigned int bbDescAddr
; /* Points to Blue Box Trap descriptor area in kernel (page aligned) */
103 unsigned int bbUserDA
; /* Points to Blue Box Trap descriptor area in user (page aligned) */
104 unsigned int bbTableStart
; /* Points to Blue Box Trap dispatch area in user */
105 unsigned int emPendRupts
; /* Number of pending emulated interruptions */
106 unsigned int bbTaskID
; /* Opaque task ID for Blue Box threads */
107 unsigned int bbTaskEnv
; /* Opaque task data reference for Blue Box threads */
108 unsigned int specFlags
; /* Special flags */
109 unsigned int pmcovfl
[8]; /* PMC overflow count */
110 unsigned int perfmonFlags
; /* Perfmon facility flags */
111 unsigned int bbTrap
; /* Blue Box trap vector */
112 unsigned int bbSysCall
; /* Blue Box syscall vector */
113 unsigned int bbInterrupt
; /* Blue Box interrupt vector */
114 unsigned int bbPending
; /* Blue Box pending interrupt vector */
116 /* special flags bits */
118 #define ignoreZeroFaultbit 0
119 #define floatUsedbit 1
120 #define vectorUsedbit 2
121 #define runningVMbit 4
122 #define floatCngbit 5
123 #define vectorCngbit 6
124 #define timerPopbit 7
125 #define userProtKeybit 8
126 #define FamVMenabit 11
127 #define FamVMmodebit 12
128 #define perfMonitorbit 13
130 /* NOTE: Do not move or assign bit 31 without changing exception vector ultra fast path code */
131 #define bbThreadbit 28
132 #define bbNoMachSCbit 29
133 #define bbPreemptivebit 30
134 #define spfReserved1 31 /* See note above */
136 #define ignoreZeroFault 0x80000000 /* (1<<(31-ignoreZeroFaultbit)) */
137 #define floatUsed 0x40000000 /* (1<<(31-floatUsedbit)) */
138 #define vectorUsed 0x20000000 /* (1<<(31-vectorUsedbit)) */
140 #define runningVM 0x08000000 /* (1<<(31-runningVMbit)) */
141 #define floatCng 0x04000000 /* (1<<(31-floatCngbit)) */
142 #define vectorCng 0x02000000 /* (1<<(31-vectorCngbit)) */
143 #define timerPop 0x01000000 /* (1<<(31-timerPopbit)) */
145 #define userProtKey 0x00800000 /* (1<<(31-userProtKeybit)) */
147 #define FamVMena 0x00100000 /* (1<<(31-FamVMenabit)) */
148 #define FamVMmode 0x00080000 /* (1<<(31-FamVMmodebit)) */
149 #define perfMonitor 0x00040000 /* (1<<(31-perfMonitorbit)) */
150 #define OnProc 0x00020000 /* (1<<(31-OnProcbit)) */
152 #define bbThread 0x00000008 /* (1<<(31-bbThreadbit)) */
153 #define bbNoMachSC 0x00000004 /* (1<<(31-bbNoMachSCbit)) */
154 #define bbPreemptive 0x00000002 /* (1<<(31-bbPreemptivebit)) */
157 #define fvChk 0x80000000
160 unsigned long cthread_self
; /* for use of cthread package */
163 } MachineThrAct
, *MachineThrAct_t
;
165 extern struct savearea
*find_user_regs(thread_act_t act
);
166 extern struct savearea
*get_user_regs(thread_act_t
);
167 extern struct savearea_fpu
*find_user_fpu(thread_act_t act
);
168 extern struct savearea_vec
*find_user_vec(thread_act_t act
);
169 extern struct savearea_vec
*find_user_vec_curr(void);
170 extern int thread_enable_fpe(thread_act_t act
, int onoff
);
172 extern struct savearea
*find_kern_regs(thread_act_t act
);
174 extern void *act_thread_csave(void);
175 extern void act_thread_catt(void *ctx
);
176 extern void act_thread_cfree(void *ctx
);
178 #define current_act_fast() current_act()
180 #endif /* _PPC_THREAD_ACT_H_ */