]> git.saurik.com Git - apple/xnu.git/blame - osfmk/ppc/thread.h
xnu-792.25.20.tar.gz
[apple/xnu.git] / osfmk / ppc / thread.h
CommitLineData
1c79356b 1/*
91447636 2 * Copyright (c) 2000-2005 Apple Computer, Inc. All rights reserved.
1c79356b 3 *
6601e61a 4 * @APPLE_LICENSE_HEADER_START@
1c79356b 5 *
6601e61a
A
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.
8f6c56a5 11 *
6601e61a
A
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
8f6c56a5
A
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
6601e61a
A
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.
8f6c56a5 19 *
6601e61a 20 * @APPLE_LICENSE_HEADER_END@
1c79356b
A
21 */
22/*
23 * @OSF_COPYRIGHT@
24 */
25
26/*
27 * File: machine/thread.h
28 *
29 * This file contains the structure definitions for the thread
30 * state as applied to PPC processors.
31 */
32
33#ifndef _PPC_THREAD_H_
34#define _PPC_THREAD_H_
35
91447636
A
36#include <mach/boolean.h>
37#include <mach/ppc/vm_types.h>
38#include <mach/thread_status.h>
39#include <kern/lock.h>
40#include <kern/clock.h>
41#include <ppc/savearea.h>
42
43/*
44 * Kernel state structure
45 *
46 * This holds the kernel state that is saved and restored across context
47 * switches.
48 */
49
50/*
51 * PPC process control block
52 *
53 * The PCB holds normal context. It does not contain vector or floating point
54 * registers.
55 *
56 */
57
58typedef struct savearea pcb;
59typedef struct savearea *pcb_t;
60
61struct facility_context {
62
63 savearea_fpu *FPUsave; /* The floating point savearea */
64 savearea *FPUlevel; /* The floating point context level */
65 unsigned int FPUcpu; /* The last processor to enable floating point */
66 unsigned int FPUsync; /* Sync lock */
67 savearea_vec *VMXsave; /* The VMX savearea */
68 savearea *VMXlevel; /* The VMX context level */
69 unsigned int VMXcpu; /* The last processor to enable vector */
70 unsigned int VMXsync; /* Sync lock */
71 struct thread *facAct;
72};
73
74typedef struct facility_context facility_context;
75
76/*
77 * Maps state flavor to number of words in the state:
78 */
79__private_extern__ unsigned int _MachineStateCount[];
80
81#define USER_REGS(ThrAct) ((ThrAct)->machine.pcb)
82
83#define user_pc(ThrAct) ((ThrAct)->machine.pcb->save_srr0)
84
85#define act_machine_state_ptr(ThrAct) (thread_state_t)USER_REGS(ThrAct)
86
87struct machine_thread {
88 /*
89 * pointer to process control block control blocks. Potentially
90 * one for each active facility context. They may point to the
91 * same saveareas.
92 */
93 savearea *pcb; /* The "normal" savearea */
94 savearea *upcb; /* The "normal" user savearea */
95 facility_context *curctx; /* Current facility context */
96 facility_context *deferctx; /* Deferred facility context */
97 facility_context facctx; /* "Normal" facility context */
98 struct vmmCntrlEntry *vmmCEntry; /* Pointer current emulation context or 0 */
99 struct vmmCntrlTable *vmmControl; /* Pointer to virtual machine monitor control table */
100 uint64_t qactTimer; /* Time thread needs to interrupt. This is a single-shot timer. Zero is unset */
101 unsigned int umwSpace; /* Address space ID for user memory window */
102#define umwSwitchAway 0x80000000 /* Context switched away from thread since MapUserAddressWindow */
103#define umwSwitchAwayb 0
104 addr64_t umwRelo; /* Relocation value for user memory window */
105 unsigned int ksp; /* points to TOP OF STACK or zero */
106 unsigned int preemption_count; /* preemption count */
107 struct per_proc_info *PerProc; /* current per processor data */
108 unsigned int bbDescAddr; /* Points to Blue Box Trap descriptor area in kernel (page aligned) */
109 unsigned int bbUserDA; /* Points to Blue Box Trap descriptor area in user (page aligned) */
110 unsigned int bbTableStart; /* Points to Blue Box Trap dispatch area in user */
111 unsigned int emPendRupts; /* Number of pending emulated interruptions */
112 unsigned int bbTaskID; /* Opaque task ID for Blue Box threads */
113 unsigned int bbTaskEnv; /* Opaque task data reference for Blue Box threads */
114 unsigned int specFlags; /* Special flags */
115 unsigned int pmcovfl[8]; /* PMC overflow count */
116 unsigned int perfmonFlags; /* Perfmon facility flags */
117 unsigned int bbTrap; /* Blue Box trap vector */
118 unsigned int bbSysCall; /* Blue Box syscall vector */
119 unsigned int bbInterrupt; /* Blue Box interrupt vector */
120 unsigned int bbPending; /* Blue Box pending interrupt vector */
121
122/* special flags bits */
123
124#define ignoreZeroFaultbit 0
125#define floatUsedbit 1
126#define vectorUsedbit 2
127#define runningVMbit 4
128#define floatCngbit 5
129#define vectorCngbit 6
130#define timerPopbit 7
131#define userProtKeybit 8
132#define FamVMenabit 11
133#define FamVMmodebit 12
134#define perfMonitorbit 13
135#define OnProcbit 14
136/* NOTE: Do not move or assign bit 31 without changing exception vector ultra fast path code */
137#define bbThreadbit 28
138#define bbNoMachSCbit 29
139#define bbPreemptivebit 30
140#define spfReserved1 31 /* See note above */
141
142#define ignoreZeroFault 0x80000000 /* (1<<(31-ignoreZeroFaultbit)) */
143#define floatUsed 0x40000000 /* (1<<(31-floatUsedbit)) */
144#define vectorUsed 0x20000000 /* (1<<(31-vectorUsedbit)) */
145
146#define runningVM 0x08000000 /* (1<<(31-runningVMbit)) */
147#define floatCng 0x04000000 /* (1<<(31-floatCngbit)) */
148#define vectorCng 0x02000000 /* (1<<(31-vectorCngbit)) */
149#define timerPop 0x01000000 /* (1<<(31-timerPopbit)) */
150
151#define userProtKey 0x00800000 /* (1<<(31-userProtKeybit)) */
152
153#define FamVMena 0x00100000 /* (1<<(31-FamVMenabit)) */
154#define FamVMmode 0x00080000 /* (1<<(31-FamVMmodebit)) */
155#define perfMonitor 0x00040000 /* (1<<(31-perfMonitorbit)) */
156#define OnProc 0x00020000 /* (1<<(31-OnProcbit)) */
157
158#define bbThread 0x00000008 /* (1<<(31-bbThreadbit)) */
159#define bbNoMachSC 0x00000004 /* (1<<(31-bbNoMachSCbit)) */
160#define bbPreemptive 0x00000002 /* (1<<(31-bbPreemptivebit)) */
161
162#define fvChkb 0
163#define fvChk 0x80000000
164
165#ifdef MACH_BSD
166 uint64_t cthread_self; /* for use of cthread package */
167#endif
168
169};
170
171extern struct savearea *find_user_regs(thread_t);
172extern struct savearea *get_user_regs(thread_t);
173extern struct savearea_fpu *find_user_fpu(thread_t);
174extern struct savearea_vec *find_user_vec(thread_t);
175extern struct savearea_vec *find_user_vec_curr(void);
176extern int thread_enable_fpe(thread_t act, int onoff);
177
178extern struct savearea *find_kern_regs(thread_t);
179
180extern void *act_thread_csave(void);
181extern void act_thread_catt(void *ctx);
182extern void act_thread_cfree(void *ctx);
1c79356b
A
183
184/*
185 * Return address of the function that called current function, given
186 * address of the first parameter of current function. We can't
187 * do it this way, since parameter was copied from a register
188 * into a local variable. Call an assembly sub-function to
189 * return this.
190 */
191
192extern vm_offset_t getrpc(void);
193#define GET_RETURN_PC(addr) getrpc()
194
195#define STACK_IKS(stack) \
196 ((vm_offset_t)(((vm_offset_t)stack)+KERNEL_STACK_SIZE)-FM_SIZE)
197
1c79356b
A
198/*
199 * Defining this indicates that MD code will supply an exception()
200 * routine, conformant with kern/exception.c (dependency alert!)
201 * but which does wonderfully fast, machine-dependent magic.
202 */
203
204#define MACHINE_FAST_EXCEPTION 1
205
206#endif /* _PPC_THREAD_H_ */