]> git.saurik.com Git - apple/xnu.git/blame - osfmk/ppc/thread_act.h
xnu-201.42.3.tar.gz
[apple/xnu.git] / osfmk / ppc / thread_act.h
CommitLineData
1c79356b
A
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 * @OSF_COPYRIGHT@
24 *
25 */
26
27#ifndef _PPC_THREAD_ACT_H_
28#define _PPC_THREAD_ACT_H_
29
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
1c79356b
A
37/*
38 * Kernel state structure
39 *
40 * This holds the kernel state that is saved and restored across context
0b4e3aa0 41 * switches.
1c79356b
A
42 */
43
44/*
45 * PPC process control block
46 *
47 * In the continuation model, the PCB holds the user context. It is used
48 * on entry to the kernel from user mode, either by system call or trap,
49 * to store the necessary user registers and other state.
50 *
51 * Note that this structure overlays a savearea. Make sure that these
52 * guys are updated in concert with that.
53 */
54struct pcb
55{
56 struct ppc_saved_state ss;
57 struct ppc_exception_state es;
58 struct ppc_float_state fs;
59 unsigned int gas1[6]; /* Force alignment with savearea */
60 struct ppc_vector_state vec;
61
62};
63
64typedef struct pcb *pcb_t;
65
66/*
67 * Maps state flavor to number of words in the state:
68 */
69extern unsigned int state_count[];
70
71#define USER_REGS(ThrAct) (&(ThrAct)->mact.pcb->ss)
72
73#define user_pc(ThrAct) ((ThrAct)->mact.pcb->ss.srr0)
74
75#define act_machine_state_ptr(ThrAct) (thread_state_t)USER_REGS(ThrAct)
76
77typedef struct MachineThrAct {
78 /*
79 * pointer to process control block control blocks. Potentially
80 * one for each active facility context. They may point to the
81 * same saveareas.
82 */
83 pcb_t pcb; /* The "normal" savearea */
84 pcb_t FPU_pcb; /* The floating point savearea */
85 pcb_t FPU_lvl; /* The floating point context level */
86 unsigned int FPU_cpu; /* The last processor to enable floating point */
87 pcb_t VMX_pcb; /* The VMX savearea */
88 pcb_t VMX_lvl; /* The VMX context level */
89 unsigned int VMX_cpu; /* The last processor to enable vector */
90 struct vmmCntrlEntry *vmmCEntry; /* Pointer current emulation context or 0 */
91 struct vmmCntrlTable *vmmControl; /* Pointer to virtual machine monitor control table */
0b4e3aa0 92 uint64_t qactTimer; /* Time thread needs to interrupt. This is a single-shot timer. Zero is unset */
1c79356b
A
93 unsigned int ksp; /* points to TOP OF STACK or zero */
94 unsigned int bbDescAddr; /* Points to Blue Box Trap descriptor area in kernel (page aligned) */
95 unsigned int bbUserDA; /* Points to Blue Box Trap descriptor area in user (page aligned) */
96 unsigned int bbTableStart; /* Points to Blue Box Trap dispatch area in user */
0b4e3aa0 97 unsigned int emPendRupts; /* Number of pending emulated interruptions */
1c79356b
A
98 unsigned int bbTaskID; /* Opaque task ID for Blue Box threads */
99 unsigned int bbTaskEnv; /* Opaque task data reference for Blue Box threads */
100 unsigned int specFlags; /* Special flags */
101
102/* special flags bits */
103
104#define ignoreZeroFaultbit 0
105#define floatUsedbit 1
106#define vectorUsedbit 2
1c79356b
A
107#define runningVMbit 4
108#define floatCngbit 5
109#define vectorCngbit 6
110#define timerPopbit 7
0b4e3aa0
A
111#define userProtKeybit 8
112/* NOTE: Do not move or assign bit 31 without changing exception vector ultra fast path code */
113#define bbThreadbit 28
114#define bbNoMachSCbit 29
115#define bbPreemptivebit 30
116#define spfReserved1 31 /* See note above */
1c79356b
A
117
118#define ignoreZeroFault (1<<(31-ignoreZeroFaultbit))
119#define floatUsed (1<<(31-floatUsedbit))
120#define vectorUsed (1<<(31-vectorUsedbit))
1c79356b
A
121#define runningVM (1<<(31-runningVMbit))
122#define floatCng (1<<(31-floatCngbit))
123#define vectorCng (1<<(31-vectorCngbit))
124#define timerPop (1<<(31-timerPopbit))
0b4e3aa0
A
125#define userProtKey (1<<(31-userProtKeybit))
126#define bbThread (1<<(31-bbThreadbit))
127#define bbNoMachSC (1<<(31-bbNoMachSCbit))
128#define bbPreemptive (1<<(31-bbPreemptivebit))
129
130#define fvChkb 0
131#define fvChk 0x80000000
1c79356b
A
132
133#ifdef MACH_BSD
134 unsigned long cthread_self; /* for use of cthread package */
135#endif
136
137} MachineThrAct, *MachineThrAct_t;
138
139extern struct ppc_saved_state * find_user_regs(thread_act_t act);
140extern struct ppc_float_state * find_user_fpu(thread_act_t act);
141
0b4e3aa0
A
142extern void *act_thread_csave(void);
143extern void act_thread_catt(void *ctx);
144extern void act_thread_cfree(void *ctx);
145
1c79356b 146#endif /* _PPC_THREAD_ACT_H_ */