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