]> git.saurik.com Git - apple/xnu.git/blob - osfmk/ppc/POWERMAC/mp/MPPlugIn.h
xnu-344.23.tar.gz
[apple/xnu.git] / osfmk / ppc / POWERMAC / mp / MPPlugIn.h
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_FREE_COPYRIGHT@
24 */
25 /*
26 * @APPLE_FREE_COPYRIGHT@
27 */
28
29 /*
30 MPPlugIn.h
31
32 Herein we find all the global MP plugin stuff
33
34 Lovingly crafted by Bill Angell using traditional methods
35
36 */
37
38
39 /*
40 * External hook completion codes
41 *
42 * The MP plugin's external interrupt hook returns one of these codes
43 */
44
45 #define kMPVainInterrupt 0 /* Interruption in vain -- ignore it */
46 #define kMPIOInterruptPending 1 /* This is an I/O interruption -- handle it */
47 #define kMPSignalPending 2 /* This is a pending signal -- handle it */
48
49
50 /* ***********************************************************************
51 * Entry point jump table entry numbers
52 * *********************************************************************** */
53
54 #define kCountProcessors 0
55 #define kStartProcessor 1 /* ->cpu address, ->start address, ->pass-thru parm */
56 #define kResumeProcessor 2 /* ->cpu address */
57 #define kStopProcessor 3 /* ->cpu address */
58 #define kResetProcessor 4 /* ->cpu address */
59 #define kSignalProcessor 5 /* ->cpu address */
60 #define kStoreProcessorStatus 6 /* ->cpu address, ->status area address */
61 #define kSynchClock 7 /* ->cpu address */
62 #define kExternalHook 8 /* no parms */
63 #define kProcessorState 9 /* ->cpu address */
64 #define kRunSIGPRun 10 /* no parms */
65 #define kPhoneyFirmware 11 /* Dummy kernel for alternate processors */
66
67 #define kMPPlugInMaxCall 11 /* set MPPlugInMaxCall to the highest-numbered call */
68
69
70 /* ***********************************************************************
71 * MP Plug-In specification
72 *
73 * The address of this area is passed to the MP plugin by the initialization code. If the
74 * version ID and the installed hardware match the MP plugin, it returns its memory
75 * requirements and a table of offsets to its entry points.
76 * *********************************************************************** */
77
78 #define kMPPlugInVersionID 1
79
80 #define kSIGPUninitializedState 0
81 #define kSIGPResetState 1
82 #define kSIGPStoppedState 2
83 #define kSIGPOperatingState 3
84 #define kSIGPErrorState 4
85
86 #define kSIGPnoErr 0
87 #define kSIGPInvalidStateErr -3999
88 #define kSIGPInterfaceBusyErr -3998
89 #define kSIGPPrivilegeErr -3997
90 #define kSIGPNoPlugInErr -3996
91 #define kTimeBaseSynchronizationErr -3995
92 #define kSIGPTargetAddrErr -3994
93 #define kSIGPInvalidStatusErr -3993
94
95 #define kMPPlugInInstallFailed -4999
96 #define kMPPlugInInternalError -4998
97
98 /*
99 * ***********************************************************************
100 * Signal processor request codes
101 * ***********************************************************************
102 */
103
104 #define SIGPast 0 /* Requests an ast on target processor */
105 #define SIGPptlb 1 /* Requests a total purge of the TLB */
106 #define SIGPkdb 2 /* Requests a KDB entry */
107
108 /*
109 * ***********************************************************************
110 * Temporary debugging error codes (well, at least as temporary as the income tax)
111 * ***********************************************************************
112 */
113 #define kMPPHairyPalms -10002
114 #define kMPPOffline -10003
115 #define kMPPBadState -10004
116 #define kMPPInvalCPU -10005
117 #define kMPPCantLock -10006
118 #define kMPPNotReady -10007
119 #define kMPPNotStopped -10008
120 #define kMPPBadCPU -10009
121 #define kMPPOnly1CPU -10010
122 #define kMPPBadVers -10011
123 #define kMPPNotRunning -10012
124 #define kMPPTimeOut -10013
125 #define kMPPInitTO1 -10014
126 #define kMPPInitTO2 -10015
127 #define kMPPInitTO3 -10016
128
129
130 /*
131 * ***********************************************************************
132 * Let's define some hardware stuff
133 * ***********************************************************************
134 */
135
136 #define Bandit1 0xF2000000
137 #define PCI1AdrReg 0xF2800000
138 #define GrandCentral 0xF3000000
139 #define EtherNetROM 0xF3019000
140 #define HammerHead 0xF8000000
141 #define ArbConfig 0x0090
142 #define TwoCPU 0x02
143 #define WhoAmI 0x00B0
144 #define PriCPU 0x10
145 #define SecCPU 0x08
146 #define IntReg 0x00C0
147 #define SecInt 0x80
148
149
150 /*
151 * ***********************************************************************
152 * Let's define the flags for MPPInterface
153 * ***********************************************************************
154 */
155
156 #define SpinTimeOut 30000000
157
158 #define MPPICmsgp 0xc0000000 /* Message pending (busy + pass) */
159 #define MPPICBusy 0x80000000 /* Processor area busy, i.e., locked */
160 #define MPPICPass 0x40000000 /* Busy lock passed to receiving processor */
161 #define MPPICOnline 0x20000000 /* Processor is online */
162 #define MPPICReady 0x10000000 /* Processor is ready, i.e., started, not reset */
163 #define MPPICStop 0x08000000 /* Processor is stopped */
164 #define MPPICBset 0x000000FF /* Processor that owns busy, i.e., the ID of */
165 /* whomever set busy. When a busy is passed, */
166 /* this is the requestor of the function. */
167 #define MPPICfunc 0x0000FF00 /* Current function */
168 #define MPPICfIdle 0x00 /* No function pending */
169 #define MPPICfStrt 0x01 /* Start the processor, physical address in */
170 /* MPPIParm0 */
171 #define MPPICfResm 0x02 /* Resume a stopped processor */
172 #define MPPICfStop 0x03 /* Stop a processor */
173 #define MPPICfSigp 0x04 /* Signal a processor */
174 #define MPPICfStat 0x05 /* Store the processor machine state - */
175 /* physical address of response in MPPIParm0 */
176 #define MPPICfTBsy 0x06 /* Synchronize timebase - */
177 /* TB image in MPPIParm0 and MPPIParm1 */
178 #define MPPICfReset 0x07 /* Reset the processor */
179 #define MPPICfTBsy1 0x81 /* TB sync, phase 1 */
180 #define MPPICfTBsy2 0x82 /* TB sync, phase 2 */
181 #define MPPICSigp 0x80000000 /* Processor has signal pending (keep signal status when stopped) */
182 #define MPPICXRun 0x40000000 /* Explicit SIGP run call */
183
184
185
186 #ifndef __ASSEMBLER__
187
188 typedef unsigned char CPUState;
189 typedef unsigned int CPUNotification;
190
191 struct MPPlugInSpec { /* This is MPSxxxx for assembler */
192 unsigned int versionID; /* Version ID, must match */
193 unsigned int *areaAddr; /* Virtual address of area to be */
194 /* relocated to physical memory */
195 unsigned int areaSize; /* Size of area to be relocated */
196 unsigned int *offsetTableAddr; /* Virtual address of table of entry offsets */
197 unsigned int *baseAddr; /* Common base area - used for debugging */
198 unsigned int *dataArea; /* Pointer to the MP workarea - used for debugging */
199 unsigned int *CPUArea; /* Pointer to the CPU workarea - used for debugging */
200 unsigned int *SIGPhandler; /* Physical address of signal interrupt filter */
201 };
202
203 typedef struct MPPlugInSpec MPPlugInSpec;
204 typedef MPPlugInSpec *MPPlugInSpecPtr;
205
206 struct MPEntryPts {
207 unsigned int EntAddr[kMPPlugInMaxCall+1]; /* Real addresses of all plugin entry points */
208 };
209
210 typedef struct MPEntryPts MPEntryPts;
211
212 struct SystemRegister {
213 unsigned int regno;
214 unsigned int contents;
215 };
216
217 typedef struct SystemRegister SystemRegister;
218
219 typedef struct FPRegs {
220 unsigned int lo;
221 unsigned int hi;
222 } FPRegs;
223
224 struct BATregs {
225 unsigned int upper;
226 unsigned int lower;
227 };
228
229 typedef struct BATregs BATregs;
230
231
232 #define kSysRegCount 16
233
234 struct CPUStatusArea { /* 0000 This is CSAxxxxx for assembler */
235
236 /*
237 * Note that this guy always has to be in one-to-one mapped area contiguously
238 */
239
240 CPUState state; /* 0000 */
241 unsigned char regsAreValid; /* 0001 */
242 unsigned char filler[2]; /* 0002 */
243 unsigned int gpr[32]; /* 0004 */
244 FPRegs fpr[32]; /* 0084 */
245 unsigned int cr; /* 0184 */
246 unsigned int fpscr; /* 0188 */
247 unsigned int xer; /* 018C */
248 unsigned int lr; /* 0190 */
249 unsigned int ctr; /* 0194 */
250 unsigned int tbu; /* 0198 This is rtcu on 601. */
251 unsigned int tbl; /* 019C This is rtcl on 601. */
252 unsigned int pvr; /* 01A0 */
253 BATregs ibat[4]; /* 01A4 */
254 BATregs dbat[4]; /* 01E4 */
255 unsigned int sdr1; /* 0224 */
256 unsigned int sr[16]; /* 0228 */
257 unsigned int dar; /* 0268 */
258 unsigned int dsisr; /* 026C */
259 unsigned int sprg[4]; /* 0270 */
260 unsigned int srr0; /* 0280 */
261 unsigned int srr1; /* 0284 */
262 unsigned int dec; /* 0288 */
263 unsigned int dabr; /* 028C */
264 unsigned int iabr; /* 0290 */
265 unsigned int ear; /* 0294 */
266 unsigned int hid[16]; /* 0298 */
267 unsigned int mmcr[2]; /* 02D8 */
268 unsigned int pmc[4]; /* 02E0 */
269 unsigned int pir; /* 02F0 */
270 unsigned int sda; /* 02F4 */
271 unsigned int sia; /* 02F8 */
272 unsigned int mq; /* 02FC */
273
274 unsigned int msr; /* 0300 */
275 unsigned int pc; /* 0304 */
276
277 SystemRegister sysregs[kSysRegCount]; /* 0308 */
278
279 unsigned int filler2[6]; /* 0388 Always pad up to 32-byte boundary */
280 /* 03A0 */
281 };
282
283 typedef struct CPUStatusArea CPUStatusArea;
284 typedef CPUStatusArea *CPUStatusAreaPtr;
285
286 extern CPUStatusArea CSA[NCPUS];
287
288 struct SenseInfo {
289 CPUNotification notification;
290 CPUState state;
291 };
292
293 typedef struct SenseInfo SenseInfo;
294 typedef SenseInfo *SenseInfoPtr;
295
296
297 struct MPPInterface {
298
299 unsigned int MPPICStat; /* Processor status (interlocked update for this one) */
300 unsigned int MPPICParm0; /* SIGP parm 0 */
301 unsigned int MPPICParm1; /* SIGP parm 1 */
302 unsigned int MPPICParm2; /* SIGP parm 2 */
303 unsigned int MPPICspare0; /* unused */
304 unsigned int MPPICspare1; /* unused */
305 unsigned int MPPICParm0BU; /* Parm 0 backed up here at 'rupt time for safe keeping */
306 unsigned int MPPICPriv; /* Processor status (interlocked update for this one) */
307 };
308
309 typedef struct MPPInterface MPPInterface;
310 typedef MPPInterface *MPPInterfacePtr;
311
312 extern MPPInterface MPPICPUs[];
313
314
315 /* ***********************************************************************
316 * Function prototypes and data areas
317 * *********************************************************************** */
318
319 extern unsigned int MPgetProcCount (void);
320 extern unsigned int MPstart (unsigned int cpu, unsigned int sadr, unsigned int parm);
321 extern unsigned int MPexternalHook (void);
322 extern unsigned int MPsignal (unsigned int cpu, unsigned int SIGPparm);
323 extern unsigned int MPstop (unsigned int cpu);
324 #if 0
325 extern unsigned int MPCPUAddress (void);
326 extern unsigned int MPresume (unsigned int cpu);
327 extern unsigned int MPreset (unsigned int cpu);
328 extern unsigned int MPSense (unsigned int cpu, unsigned int *info);
329 extern unsigned int MPstoreStatus (unsigned int cpu, unsigned int *statusArea);
330 extern unsigned int MPSetStatus (unsigned int cpu, unsigned int *statusArea);
331 extern unsigned int MPgetSignal (void);
332 extern unsigned int MPsyncTB (void);
333 extern unsigned int MPcheckPending (void);
334 #endif
335 extern int MPinstall (unsigned int physAddr, unsigned int band1, unsigned int hammerh, unsigned int grandc,
336 unsigned int pci1ar, unsigned int enetr);
337 extern unsigned int MPprobe (MPPlugInSpecPtr spec, unsigned int hammerh);
338
339 extern void start_secondary (void);
340 extern void mp_intr (void);
341
342
343 extern MPPlugInSpec MPspec; /* An area for the MP interfaces */
344 extern MPEntryPts MPEntries; /* Real addresses of plugin routines */
345
346 #endif /* ndef __ASSEMBLER */