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@
23 * @OSF_FREE_COPYRIGHT@
26 * @APPLE_FREE_COPYRIGHT@
32 Handle things that should be treated as an extension of the hardware
34 Lovingly crafted by Bill Angell using traditional methods and only natural or recycled materials.
35 No animal products are used other than rendered otter bile and deep fried pork lard.
41 #include <ppc/proc_reg.h>
42 #include <ppc/spec_reg.h>
43 #include <ppc/POWERMAC/mp/MPPlugIn.h>
44 #include <ppc/exception.h>
45 #include <mach/machine/vm_param.h>
50 * Here we generate the table of supported firmware calls
56 .align 5 /* Line up on cache line */
62 .globl CutTrace /* Let everyone know 'bout it */
63 .set CutTrace,(.-EXT(FWtable))/4|0x80000000 /* Call number for CutTrace */
64 .long callUnimp /* This was already handled in lowmem_vectors */
66 #include <ppc/FirmwareCalls.h>
68 .set EXT(FirmwareCnt), (.-EXT(FWtable))/4 /* Get the top number */
73 #define NOTQUITEASSIMPLE 1
75 * This routine handles the firmware call routine. It must be entered with IR and DR off,
76 * interruptions disabled, and in supervisor state.
78 * When we enter, we expect R0 to have call number, and LR
79 * to point to the return. Also, all registers saved in savearea in R13.
80 * R3 is as passed in by the user. All others must be gotten from the save area
83 ENTRY(FirmwareCall, TAG_NO_FRAME_USED)
85 rlwinm r1,r0,2,1,29 /* Clear out bit 0 and multiply by 4 */
86 lis r12,HIGH_ADDR(EXT(FWtable)) /* Get the high part of the firmware call table */
87 cmplwi r1,EXT(FirmwareCnt)*4 /* Is it a valid firmware call number */
88 mflr r11 /* Save the return */
89 ori r12,r12,LOW_ADDR(EXT(FWtable)) /* Now the low part */
90 ble+ goodCall /* Yeah, it is... */
92 li r3,T_SYSTEM_CALL /* Tell the vector handler that we know nothing */
93 blr /* Return for errors... */
95 goodCall: mfsprg r10,0 /* Make sure about the per_proc block */
96 lwzx r1,r1,r12 /* Pick up the address of the routine */
97 lwz r4,saver4(r13) /* Pass in caller's R4 */
98 lwz r5,saver5(r13) /* Pass in caller's R5 */
99 rlwinm. r1,r1,0,0,29 /* Make sure the flag bits are clear */
100 stw r11,PP_TEMPWORK1(r10) /* Save our return point */
102 mtlr r1 /* Put it in the LR */
103 beq- callUnimp /* This one was unimplimented... */
105 blrl /* Call the routine... */
107 mfsprg r10,0 /* Make sure about the per_proc again */
108 stw r3,saver3(r13) /* Pass back the return code to caller */
109 lwz r11,PP_TEMPWORK1(r10) /* Get our return point */
110 li r3,T_IN_VAIN /* Tell the vector handler that we took care of it */
111 mtlr r11 /* Set the return */
112 blr /* Bye, dudes... */
114 callUnimp: lwz r11,PP_TEMPWORK1(r10) /* Restore the return address */
115 li r3,T_SYSTEM_CALL /* Tell the vector handler that we know nothing */
116 mtlr r11 /* Restore the LR */
117 blr /* Return for errors... */
120 * This routine is used to store using a real address. It stores parmeter1 at parameter2.
123 ENTRY(StoreReal, TAG_NO_FRAME_USED)
125 lis r0,HIGH_ADDR(StoreRealCall) /* Get the top part of the SC number */
126 ori r0,r0,LOW_ADDR(StoreRealCall) /* and the bottom part */
128 blr /* Bye bye, Birdie... */
130 ENTRY(StoreRealLL, TAG_NO_FRAME_USED)
132 stw r3,0(r4) /* Store the word */
136 * This routine is used to clear a range of physical pages.
139 ENTRY(ClearReal, TAG_NO_FRAME_USED)
141 lis r0,HIGH_ADDR(ClearRealCall) /* Get the top part of the SC number */
142 ori r0,r0,LOW_ADDR(ClearRealCall) /* and the bottom part */
144 blr /* Bye bye, Birdie... */
146 ENTRY(ClearRealLL, TAG_NO_FRAME_USED)
149 * We take the first parameter as a physical address. The second is the length in bytes.
150 * Being crazy, I'll round the address down, and the length up. We could end up clearing
151 * an extra page at the start and one at the end, but we don't really care. If someone
152 * is stupid enough to give me unaligned addresses and lengths, I am just arrogant enough
153 * to take them at their word and to hell with them.
156 neg r5,r3 /* Negate the address */
157 addi r4,r4,4095 /* Round length up */
158 rlwinm r5,r5,0,20,31 /* Save extra length */
159 rlwinm r3,r3,0,0,19 /* Round the page on down */
160 add r4,r4,r5 /* Add up all extra lengths */
161 li r6,32 /* Get a displacement */
162 rlwinm r4,r4,0,0,19 /* Round the length back down */
164 clrloop: subi r4,r4,32 /* Back off a cache line */
165 dcbz 0,r3 /* Do the even line */
166 sub. r4,r4,r6 /* Back off a second time (we only do this to generate a CR */
167 dcbz r6,r3 /* Clear the even line */
168 addi r3,r3,64 /* Move up to every other line */
169 bgt+ clrloop /* Go until we've done it all... */
173 * This routine will read in 32 byte of real storage.
176 ENTRY(ReadReal, TAG_NO_FRAME_USED)
178 mfmsr r0 /* Get the MSR */
179 rlwinm r5,r0,0,28,26 /* Clear DR bit */
180 rlwinm r5,r5,0,17,15 /* Clear EE bit */
181 mtmsr r5 /* Disable EE and DR */
182 isync /* Just make sure about it */
184 lwz r5,0(r3) /* Get word 0 */
185 lwz r6,4(r3) /* Get word 1 */
186 lwz r7,8(r3) /* Get word 2 */
187 lwz r8,12(r3) /* Get word 3 */
188 rlwinm r0,r0,0,MSR_FP_BIT+1,MSR_FP_BIT-1 ; Force floating point off
189 lwz r9,16(r3) /* Get word 4 */
190 lwz r10,20(r3) /* Get word 5 */
191 rlwinm r0,r0,0,MSR_VEC_BIT+1,MSR_VEC_BIT-1 ; Force vectors off
192 lwz r11,24(r3) /* Get word 6 */
193 lwz r12,28(r3) /* Get word 7 */
195 mtmsr r0 /* Restore original machine state */
196 isync /* Insure goodness */
198 stw r5,0(r4) /* Set word 0 */
199 stw r6,4(r4) /* Set word 1 */
200 stw r7,8(r4) /* Set word 2 */
201 stw r8,12(r4) /* Set word 3 */
202 stw r9,16(r4) /* Set word 4 */
203 stw r10,20(r4) /* Set word 5 */
204 stw r11,24(r4) /* Set word 6 */
205 stw r12,28(r4) /* Set word 7 */
211 * This routine is used to load all 4 DBATs.
214 ENTRY(LoadDBATs, TAG_NO_FRAME_USED)
216 lis r0,HIGH_ADDR(LoadDBATsCall) /* Top half of LoadDBATsCall firmware call number */
217 ori r0,r0,LOW_ADDR(LoadDBATsCall) /* Bottom half */
220 blr /* Bye bye, Birdie... */
222 ENTRY(xLoadDBATsLL, TAG_NO_FRAME_USED)
224 lwz r4,0(r3) /* Get DBAT 0 high */
225 lwz r5,4(r3) /* Get DBAT 0 low */
226 lwz r6,8(r3) /* Get DBAT 1 high */
227 lwz r7,12(r3) /* Get DBAT 1 low */
228 lwz r8,16(r3) /* Get DBAT 2 high */
229 lwz r9,20(r3) /* Get DBAT 2 low */
230 lwz r10,24(r3) /* Get DBAT 3 high */
231 lwz r11,28(r3) /* Get DBAT 3 low */
233 sync /* Common decency and the state law require that you wash your hands */
234 mtdbatu 0,r4 /* Load DBAT 0 high */
235 mtdbatl 0,r5 /* Load DBAT 0 low */
236 mtdbatu 1,r6 /* Load DBAT 1 high */
237 mtdbatl 1,r7 /* Load DBAT 1 low */
238 mtdbatu 2,r8 /* Load DBAT 2 high */
239 mtdbatl 2,r9 /* Load DBAT 2 low */
240 mtdbatu 3,r10 /* Load DBAT 3 high */
241 mtdbatl 3,r11 /* Load DBAT 3 low */
242 sync /* Make sure it's done */
243 isync /* Toss out anything new */
248 * This routine is used to load all 4 IBATs.
251 ENTRY(LoadIBATs, TAG_NO_FRAME_USED)
253 lis r0,HIGH_ADDR(LoadIBATsCall) /* Top half of LoadIBATsCall firmware call number */
254 ori r0,r0,LOW_ADDR(LoadIBATsCall) /* Bottom half */
256 blr /* Bye bye, Birdie... */
258 ENTRY(xLoadIBATsLL, TAG_NO_FRAME_USED)
260 lwz r4,0(r3) /* Get IBAT 0 high */
261 lwz r5,4(r3) /* Get IBAT 0 low */
262 lwz r6,8(r3) /* Get IBAT 1 high */
263 lwz r7,12(r3) /* Get IBAT 1 low */
264 lwz r8,16(r3) /* Get IBAT 2 high */
265 lwz r9,20(r3) /* Get IBAT 2 low */
266 lwz r10,24(r3) /* Get IBAT 3 high */
267 lwz r11,28(r3) /* Get IBAT 3 low */
269 sync /* Common decency and the state law require that you wash your hands */
270 mtibatu 0,r4 /* Load IBAT 0 high */
271 mtibatl 0,r5 /* Load IBAT 0 low */
272 mtibatu 1,r6 /* Load IBAT 1 high */
273 mtibatl 1,r7 /* Load IBAT 1 low */
274 mtibatu 2,r8 /* Load IBAT 2 high */
275 mtibatl 2,r9 /* Load IBAT 2 low */
276 mtibatu 3,r10 /* Load IBAT 3 high */
277 mtibatl 3,r11 /* Load IBAT 3 low */
278 sync /* Make sure it's done */
279 isync /* Toss out anything new */
285 * This is the glue to call the CutTrace firmware call
288 ENTRY(dbgTrace, TAG_NO_FRAME_USED)
290 lis r0,HIGH_ADDR(CutTrace) /* Top half of CreateFakeIO firmware call number */
291 ori r0,r0,LOW_ADDR(CutTrace) /* Bottom half */
293 blr /* Bye bye, Birdie... */
296 * This is the glue to create a fake I/O interruption
299 ENTRY(CreateFakeIO, TAG_NO_FRAME_USED)
301 lis r0,HIGH_ADDR(CreateFakeIOCall) /* Top half of CreateFakeIO firmware call number */
302 ori r0,r0,LOW_ADDR(CreateFakeIOCall) /* Bottom half */
304 blr /* Bye bye, Birdie... */
307 * This is the glue to create a fake Dec interruption
310 ENTRY(CreateFakeDEC, TAG_NO_FRAME_USED)
313 mflr r4 ; (TEST/DEBUG)
314 bl EXT(ml_sense_nmi) ; (TEST/DEBUG)
315 mtlr r4 ; (TEST/DEBUG)
317 lis r0,HIGH_ADDR(CreateFakeDECCall) /* Top half of CreateFakeDEC firmware call number */
318 ori r0,r0,LOW_ADDR(CreateFakeDECCall) /* Bottom half */
320 blr /* Bye bye, Birdie... */
324 * This is the glue to create a shutdown context
327 ENTRY(CreateShutdownCTX, TAG_NO_FRAME_USED)
329 lis r0,HIGH_ADDR(CreateShutdownCTXCall) /* Top half of CreateFakeIO firmware call number */
330 ori r0,r0,LOW_ADDR(CreateShutdownCTXCall) /* Bottom half */
332 blr /* Bye bye, Birdie... */
335 * This is the glue to choke system
338 ENTRY(ChokeSys, TAG_NO_FRAME_USED)
340 lis r0,HIGH_ADDR(Choke) /* Top half of Choke firmware call number */
341 ori r0,r0,LOW_ADDR(Choke) /* Bottom half */
343 blr /* Bye bye, Birdie... */
346 * Used to initialize the SCC for debugging output
350 ENTRY(fwSCCinit, TAG_NO_FRAME_USED)
352 mfmsr r8 /* Save the MSR */
353 mr. r3,r3 /* See if printer or modem */
354 rlwinm r12,r8,0,28,25 /* Turn off translation */
355 lis r10,0xF301 /* Set the top part */
356 rlwinm r12,r12,0,17,15 /* Turn off interruptions */
358 mtmsr r12 /* Smash the MSR */
359 isync /* Make it clean */
362 ori r10,r10,0x2000 /* Assume the printer (this is the normal one) */
363 beq+ fwSCCprnt /* It sure are... */
364 ori r10,r10,0x0002 /* Move it over to the modem port */
366 fwSCCprnt: dcbf 0,r10 /* Insure it is out */
369 dcbi 0,r10 /* Toss it */
373 li r7,0x09 /* Set the register */
374 stb r7,0(r10) /* Set the register */
375 dcbf 0,r10 /* Force it out */
376 sync /* Make sure it's out there */
380 li r7,0x80 /* Reset channel A */
381 stb r7,0(r10) /* Set the register */
382 dcbf 0,r10 /* Force it out */
383 sync /* Make sure it's out there */
387 li r7,0x04 /* Set the register */
388 stb r7,0(r10) /* Set the register */
389 dcbf 0,r10 /* Force it out */
390 sync /* Make sure it's out there */
394 li r7,0x44 /* x16 clock, 1 stop bit */
395 stb r7,0(r10) /* Set the register */
396 dcbf 0,r10 /* Force it out */
397 sync /* Make sure it's out there */
401 li r7,0x03 /* Set the register */
402 stb r7,0(r10) /* Set the register */
403 dcbf 0,r10 /* Force it out */
404 sync /* Make sure it's out there */
408 li r7,0xC0 /* 8 bits per char */
409 stb r7,0(r10) /* Set the register */
410 dcbf 0,r10 /* Force it out */
411 sync /* Make sure it's out there */
415 li r7,0x05 /* Set the register */
416 stb r7,0(r10) /* Set the register */
417 dcbf 0,r10 /* Force it out */
418 sync /* Make sure it's out there */
422 li r7,0xE2 /* DTR mode, 8bit/char */
423 stb r7,0(r10) /* Set the register */
424 dcbf 0,r10 /* Force it out */
425 sync /* Make sure it's out there */
429 li r7,0x02 /* Set the register */
430 stb r7,0(r10) /* Set the register */
431 dcbf 0,r10 /* Force it out */
432 sync /* Make sure it's out there */
436 li r7,0x00 /* Vector 0 */
437 stb r7,0(r10) /* Set the register */
438 dcbf 0,r10 /* Force it out */
439 sync /* Make sure it's out there */
443 li r7,0x0A /* Set the register */
444 stb r7,0(r10) /* Set the register */
445 dcbf 0,r10 /* Force it out */
446 sync /* Make sure it's out there */
450 li r7,0x00 /* Clear misc controls */
451 stb r7,0(r10) /* Set the register */
452 dcbf 0,r10 /* Force it out */
453 sync /* Make sure it's out there */
457 li r7,0x0B /* Set the register */
458 stb r7,0(r10) /* Set the register */
459 dcbf 0,r10 /* Force it out */
460 sync /* Make sure it's out there */
464 li r7,0x50 /* B/R gen T/R */
465 stb r7,0(r10) /* Set the register */
466 dcbf 0,r10 /* Force it out */
467 sync /* Make sure it's out there */
471 li r7,0x0C /* Set the register */
472 stb r7,0(r10) /* Set the register */
473 dcbf 0,r10 /* Force it out */
474 sync /* Make sure it's out there */
478 li r7,0x0A /* 9600 baud low */
479 stb r7,0(r10) /* Set the register */
480 dcbf 0,r10 /* Force it out */
481 sync /* Make sure it's out there */
485 li r7,0x0D /* Set the register */
486 stb r7,0(r10) /* Set the register */
487 dcbf 0,r10 /* Force it out */
488 sync /* Make sure it's out there */
492 li r7,0x00 /* 9600 baud high */
493 stb r7,0(r10) /* Set the register */
494 dcbf 0,r10 /* Force it out */
495 sync /* Make sure it's out there */
499 li r7,0x03 /* Set the register */
500 stb r7,0(r10) /* Set the register */
501 dcbf 0,r10 /* Force it out */
502 sync /* Make sure it's out there */
506 li r7,0xC1 /* 8 bits/char, Rx enable */
507 stb r7,0(r10) /* Set the register */
508 dcbf 0,r10 /* Force it out */
509 sync /* Make sure it's out there */
513 li r7,0x05 /* Set the register */
514 stb r7,0(r10) /* Set the register */
515 dcbf 0,r10 /* Force it out */
516 sync /* Make sure it's out there */
520 li r7,0xEA /* 8 bits/char, Tx enable */
521 stb r7,0(r10) /* Set the register */
522 dcbf 0,r10 /* Force it out */
523 sync /* Make sure it's out there */
527 li r7,0x0E /* Set the register */
528 stb r7,0(r10) /* Set the register */
529 dcbf 0,r10 /* Force it out */
530 sync /* Make sure it's out there */
534 li r7,0x01 /* BR rate gen enable */
535 stb r7,0(r10) /* Set the register */
536 dcbf 0,r10 /* Force it out */
537 sync /* Make sure it's out there */
541 li r7,0x0F /* Set the register */
542 stb r7,0(r10) /* Set the register */
543 dcbf 0,r10 /* Force it out */
544 sync /* Make sure it's out there */
548 li r7,0x00 /* ints off */
549 stb r7,0(r10) /* Set the register */
550 dcbf 0,r10 /* Force it out */
551 sync /* Make sure it's out there */
555 li r7,0x10 /* Reset ext/stat ints */
556 stb r7,0(r10) /* Set the register */
557 dcbf 0,r10 /* Force it out */
558 sync /* Make sure it's out there */
562 li r7,0x10 /* Reset ext/stat ints */
563 stb r7,0(r10) /* Set the register */
564 dcbf 0,r10 /* Force it out */
565 sync /* Make sure it's out there */
569 li r7,0x01 /* Set the register */
570 stb r7,0(r10) /* Set the register */
571 dcbf 0,r10 /* Force it out */
572 sync /* Make sure it's out there */
576 li r7,0x10 /* int on Rx, no Tx int enable */
577 stb r7,0(r10) /* Set the register */
578 dcbf 0,r10 /* Force it out */
579 sync /* Make sure it's out there */
583 li r7,0x09 /* Set the register */
584 stb r7,0(r10) /* Set the register */
585 dcbf 0,r10 /* Force it out */
586 sync /* Make sure it's out there */
590 li r7,0x0A /* int on Rx, Tx int enable */
591 stb r7,0(r10) /* Set the register */
592 dcbf 0,r10 /* Force it out */
593 sync /* Master enable, no vector */
597 li r7,0x09 /* Set the register */
598 stb r7,0(r10) /* Set the register */
599 dcbf 0,r10 /* Force it out */
600 sync /* Make sure it's out there */
604 li r7,0x02 /* No vector */
605 stb r7,0(r10) /* Set the register */
606 dcbf 0,r10 /* Force it out */
607 sync /* Master enable, no vector */
611 lbz r7,0(r10) /* Clear interrupts */
612 sync /* Master enable, no vector */
616 wSCCrdy: eieio /* Barricade it */
617 lbz r7,0(r10) /* Get current status */
620 andi. r7,r7,0x04 /* Is transmitter empty? */
621 beq wSCCrdy /* Nope... */
626 mtmsr r8 /* Restore 'rupts and TR */
632 * This routine is used to write debug output to either the modem or printer port.
633 * parm 1 is printer (0) or modem (1); parm 2 is ID (printed directly); parm 3 converted to hex
636 ENTRY(dbgDisp, TAG_NO_FRAME_USED)
638 mr r12,r0 /* Keep R0 pristene */
639 lis r0,HIGH_ADDR(dbgDispCall) /* Top half of dbgDispCall firmware call number */
640 ori r0,r0,LOW_ADDR(dbgDispCall) /* Bottom half */
642 sc /* Go display the stuff */
644 mr r0,r12 /* Restore R0 */
647 /* Here's the low-level part of dbgDisp */
649 ENTRY(dbgDispLL, TAG_NO_FRAME_USED)
651 dbgDispInt: mfmsr r8 /* Save the MSR */
654 lis r10,0xF301 /* (TEST/DEBUG) */
655 ori r10,r10,0x2002 /* (TEST/DEBUG) */
656 dcbf 0,r10 /* (TEST/DEBUG) */
657 sync /* (TEST/DEBUG) */
658 dcbi 0,r10 /* (TEST/DEBUG) */
659 eieio /* (TEST/DEBUG) */
660 li r7,0x35 /* (TEST/DEBUG) */
661 stb r7,4(r10) /* (TEST/DEBUG) */
663 lis r7,10 /* (TEST/DEBUG) */
664 spw6: addi r7,r7,-1 /* (TEST/DEBUG) */
665 mr. r7,r7 /* (TEST/DEBUG) */
666 bne- spw6 /* (TEST/DEBUG) */
667 dcbf 0,r10 /* (TEST/DEBUG) */
668 sync /* (TEST/DEBUG) */
669 dcbi 0,r10 /* (TEST/DEBUG) */
670 eieio /* (TEST/DEBUG) */
673 rlwinm r12,r8,0,28,25 /* Turn off translation */
674 rlwinm r12,r12,0,17,15 /* Turn off interruptions */
676 mflr r11 /* Save the link register */
679 mr r7,r12 /* (TEST/DEBUG) */
680 bl dumpr7 /* (TEST/DEBUG) */
683 mr. r3,r3 /* See if printer or modem */
684 lis r10,0xF301 /* Set the top part */
685 mr r3,r4 /* Copy the ID parameter */
688 mr r9,r12 /* (TEST/DEBUG) */
690 mtmsr r12 /* (TEST/DEBUG) */
691 isync /* (TEST/DEBUG) */
694 mtmsr r8 /* (TEST/DEBUG) */
695 isync /* (TEST/DEBUG) */
698 lis r12,0xF301 /* (TEST/DEBUG) */
699 ori r12,r12,0x2002 /* (TEST/DEBUG) */
701 dcbf 0,r12 /* (TEST/DEBUG) */
702 sync /* (TEST/DEBUG) */
703 dcbi 0,r12 /* (TEST/DEBUG) */
706 xqrw1: eieio /* (TEST/DEBUG) */
707 lbz r7,0(r12) /* (TEST/DEBUG) */
708 dcbi 0,r12 /* (TEST/DEBUG) */
709 sync /* (TEST/DEBUG) */
710 andi. r7,r7,0x04 /* (TEST/DEBUG) */
711 beq xqrw1 /* (TEST/DEBUG) */
713 eieio /* (TEST/DEBUG) */
714 li r7,0x36 /* (TEST/DEBUG) */
715 stb r7,4(r12) /* (TEST/DEBUG) */
717 dcbf 0,r12 /* (TEST/DEBUG) */
718 sync /* (TEST/DEBUG) */
719 dcbi 0,r12 /* (TEST/DEBUG) */
720 eieio /* (TEST/DEBUG) */
723 lis r7,10 /* (TEST/DEBUG) */
724 spw7: addi r7,r7,-1 /* (TEST/DEBUG) */
725 mr. r7,r7 /* (TEST/DEBUG) */
726 bne- spw7 /* (TEST/DEBUG) */
727 dcbf 0,r12 /* (TEST/DEBUG) */
728 sync /* (TEST/DEBUG) */
729 dcbi 0,r12 /* (TEST/DEBUG) */
730 eieio /* (TEST/DEBUG) */
731 mr r12,r9 /* (TEST/DEBUG) */
734 mtmsr r12 /* Smash the MSR */
735 isync /* Make it clean */
738 #if SIMPLESCC && !NOTQUITEASSIMPLE
739 ori r10,r10,0x3010 /* Assume the printer (this is the normal one) */
741 ori r10,r10,0x2000 /* Assume the printer (this is the normal one) */
743 beq+ dbgDprintr /* It sure are... */
744 #if SIMPLESCC && !NOTQUITEASSIMPLE
745 ori r10,r10,0x0020 /* Move it over to the modem port */
747 ori r10,r10,0x0002 /* Move it over to the modem port */
749 #if !NOTQUITEASSIMPLE
750 lis r7,0xF300 /* Address of SCC rounded to 128k */
751 ori r7,r7,0x0032 /* Make it cache inhibited */
752 mtdbatl 3,r7 /* Load DBAT 3 low */
753 lis r7,0xF300 /* Address of SCC rounded to 128k */
754 ori r7,r7,0x0002 /* Make it supervisor only */
755 mtdbatu 3,r7 /* Load DBAT 3 high */
756 ori r12,r12,0x0010 /* Turn on DR */
757 mtmsr r12 /* Smash the MSR */
758 isync /* Make it clean */
765 mr r7,r10 /* (TEST/DEBUG) */
766 bl dumpr7 /* (TEST/DEBUG) */
769 dcbi 0,r10 /* Toss it */
773 lis r12,0xF301 /* (TEST/DEBUG) */
774 ori r12,r12,0x2002 /* (TEST/DEBUG) */
775 dcbf 0,r12 /* (TEST/DEBUG) */
776 sync /* (TEST/DEBUG) */
777 dcbi 0,r12 /* (TEST/DEBUG) */
778 eieio /* (TEST/DEBUG) */
779 li r7,0x37 /* (TEST/DEBUG) */
780 stb r7,4(r12) /* (TEST/DEBUG) */
782 lis r7,12 /* (TEST/DEBUG) */
783 spw8: addi r7,r7,-1 /* (TEST/DEBUG) */
784 mr. r7,r7 /* (TEST/DEBUG) */
785 bne- spw8 /* (TEST/DEBUG) */
786 dcbf 0,r12 /* (TEST/DEBUG) */
787 sync /* (TEST/DEBUG) */
788 dcbi 0,r12 /* (TEST/DEBUG) */
789 eieio /* (TEST/DEBUG) */
793 /* Print the ID parameter */
795 lis r12,HIGH_ADDR(fwdisplock) /* Get the display locker outer */
796 ori r12,r12,LOW_ADDR(fwdisplock) /* Last part */
800 ddwait0: lwarx r7,0,r12 /* Get the lock */
801 mr. r7,r7 /* Is it locked? */
802 bne- ddwait0 /* Yup... */
803 stwcx. r12,0,r12 /* Try to get it */
804 bne- ddwait0 /* Nope, start all over... */
807 dcbf 0,r10 /* (TEST/DEBUG) */
808 sync /* (TEST/DEBUG) */
809 dcbi 0,r10 /* (TEST/DEBUG) */
810 eieio /* (TEST/DEBUG) */
811 li r7,0x38 /* (TEST/DEBUG) */
812 stb r7,6(r10) /* (TEST/DEBUG) */
814 lis r7,10 /* (TEST/DEBUG) */
815 spwa: addi r7,r7,-1 /* (TEST/DEBUG) */
816 mr. r7,r7 /* (TEST/DEBUG) */
817 bne- spwa /* (TEST/DEBUG) */
818 dcbf 0,r10 /* (TEST/DEBUG) */
819 sync /* (TEST/DEBUG) */
820 dcbi 0,r10 /* (TEST/DEBUG) */
821 eieio /* (TEST/DEBUG) */
824 rlwinm r3,r3,8,0,31 /* Get the first character */
825 bl dbgDchar /* Print it */
826 rlwinm r3,r3,8,0,31 /* Get the second character */
827 bl dbgDchar /* Print it */
828 rlwinm r3,r3,8,0,31 /* Get the third character */
829 bl dbgDchar /* Print it */
830 rlwinm r3,r3,8,0,31 /* Get the fourth character */
831 bl dbgDchar /* Print it */
833 li r3,0x20 /* Get a space for a separator */
834 bl dbgDchar /* Print it */
835 bl dbg4byte /* Print register 5 in hex */
837 li r3,0x0A /* Linefeed */
838 bl dbgDchar /* Send it */
839 li r3,0x0D /* Carriage return */
840 bl dbgDchar /* Send it */
842 mtlr r11 /* Get back the return */
843 #if !SIMPLESCC && !NOTQUITEASSIMPLE
844 li r7,0 /* Get a zero */
845 mtdbatu 3,r7 /* Invalidate DBAT 3 upper */
846 mtdbatl 3,r7 /* Invalidate DBAT 3 lower */
848 lis r12,HIGH_ADDR(fwdisplock) /* Get the display locker outer */
849 li r7,0 /* Get a zero */
850 ori r12,r12,LOW_ADDR(fwdisplock) /* Last part */
852 stw r7,0(r12) /* Release the display lock */
853 mtmsr r8 /* Restore the MSR */
854 isync /* Wait for it */
858 dbg4byte: mflr r12 /* Save the return */
860 lis r4,HIGH_ADDR(hexTab) /* Point to the top of table */
861 li r6,8 /* Set number of hex digits to dump */
862 ori r4,r4,LOW_ADDR(hexTab) /* Point to the bottom of table */
864 dbgDnext: rlwinm r5,r5,4,0,31 /* Rotate a nybble */
865 subi r6,r6,1 /* Back down the count */
866 rlwinm r3,r5,0,28,31 /* Isolate the last nybble */
867 lbzx r3,r4,r3 /* Convert to ascii */
868 bl dbgDchar /* Print it */
869 mr. r6,r6 /* Any more? */
870 bne+ dbgDnext /* Convert 'em all... */
872 li r3,0x20 /* Space */
873 bl dbgDchar /* Send it */
874 mtlr r12 /* Restore LR */
877 /* Write to whichever serial port. Try to leave it clean, but not too hard (this is a hack) */
880 #if SIMPLESCC && !NOTQUITEASSIMPLE
881 stb r3,0(r10) /* ? */
882 dcbf 0,r10 /* Force it out */
883 sync /* Make sure it's out there */
885 lis r7,3 /* Get enough for about 1ms */
887 dbgDchar0: addi r7,r7,-1 /* Count down */
888 mr. r7,r7 /* Waited long enough? */
889 bgt+ dbgDchar0 /* Nope... */
894 stb r7,0(r10) /* ? */
895 dcbf 0,r10 /* Force it out */
896 sync /* Make sure it's out there */
900 lbz r7,0(r10) /* ? */
901 dcbi 0,r10 /* Force it out */
902 sync /* kill it off */
906 stb r7,0(r10) /* ? */
907 dcbf 0,r10 /* Force it out */
908 sync /* Make sure it's out there */
912 lbz r7,0(r10) /* ? */
913 dcbi 0,r10 /* Force it out */
914 sync /* kill it off */
918 qrw1: eieio /* Barricade it */
919 lbz r7,0(r10) /* ? */
922 andi. r7,r7,0x04 /* ? */
923 beq qrw1 /* Nope... */
927 stb r3,4(r10) /* ? */
928 dcbf 0,r10 /* Force it out */
929 sync /* Make sure it's out there */
933 qrw2: eieio /* Barricade it */
934 lbz r7,0(r10) /* ? */
937 andi. r7,r7,0x04 /* ? */
938 beq qrw2 /* Nope... */
943 stb r7,0(r10) /* ? */
944 dcbf 0,r10 /* Force it out */
945 sync /* Make sure it's out there */
949 lbz r7,0(r10) /* ? */
950 dcbi 0,r10 /* Force it out */
951 sync /* kill it off */
955 lis r7,0x0080 /* ? */
956 lis r9,0xF300 /* ? */
957 ori r7,r7,0x010F /* ? */
958 stw r7,0x28(r9) /* ? */
959 dcbf 0,r10 /* Force it out */
960 sync /* Make sure it's out there */
965 #if !SIMPLESCC && !NOTQUITEASSIMPLE
966 rlwinm r9,r10,0,0,29 /* Get channel a */
967 eieio /* Barricade it */
971 eieio /* Barricade it */
975 eieio /* Barricade it */
978 dchrw1: eieio /* Barricade it */
979 lbz r7,0(r10) /* ? */
980 andi. r7,r7,0x04 /* ? */
981 beq dchrw1 /* Nope... */
983 stb r3,4(r10) /* ? */
984 sync /* Make sure it's there */
985 eieio /* Don't get confused */
987 dchrw2: eieio /* Barricade it */
988 lbz r7,0(r10) /* ? */
989 andi. r7,r7,0x04 /* ? */
990 beq dchrw2 /* Nope... */
992 eieio /* Avoid confusion */
993 lbz r7,0(r10) /* ? */
994 andi. r7,r7,0x40 /* ? */
995 beq+ nounder /* Nope... */
997 eieio /* Avoid confusion */
999 stb r7,0(r10) /* ? */
1001 nounder: eieio /* Avoid confusion */
1003 stb r7,0(r10) /* ? */
1005 eieio /* Avoid confusion */
1007 stb r7,0(r9) /* ? */
1009 eieio /* Avoid confusion */
1011 stb r7,0(r10) /* ? */
1013 eieio /* Avoid confusion */
1015 stb r7,0(r10) /* ? */
1016 eieio /* Avoid confusion */
1024 hexTab: STRINGD "0123456789ABCDEF" /* Convert hex numbers to printable hex */
1028 * Dumps all the registers in the savearea in R13
1032 ENTRY(dbgRegsLL, TAG_NO_FRAME_USED)
1035 bl dbgRegsCm /* Join on up... */
1038 * Note that we bypass the normal return 'cause we don't wanna mess up R3
1040 mfsprg r11,0 /* Get the per_proc */
1041 lwz r11,PP_TEMPWORK1(r11) /* Get our return point */
1042 li r3,T_IN_VAIN /* Tell the vector handler that we took care of it */
1043 mtlr r11 /* Set the return */
1044 blr /* Bye, dudes... */
1046 ENTRY(dbgRegs, TAG_NO_FRAME_USED)
1048 dbgRegsCm: mfmsr r8 /* Save the MSR */
1050 rlwinm r12,r8,0,28,25 /* Turn off translation */
1051 lis r10,0xF301 /* Set the top part */
1052 rlwinm r12,r12,0,17,15 /* Turn off interruptions */
1053 mtmsr r12 /* Smash the MSR */
1054 isync /* Make it clean */
1055 #if SIMPLESCC && !NOTQUITEASSIMPLE
1056 ori r10,r10,0x3010 /* ? */
1058 ori r10,r10,0x2000 /* ? */
1060 mflr r11 /* Save the link register */
1061 beq+ dbgDprints /* It sure are... */
1062 #if SIMPLESCC && !NOTQUITEASSIMPLE
1063 ori r10,r10,0x0020 /* ? */
1065 ori r10,r10,0x0002 /* ? */
1067 dcbf 0,r10 /* Insure it is out */
1069 dcbi 0,r10 /* Toss it */
1070 #if !NOTQUITEASSIMPLE
1071 lis r7,0xF300 /* ? */
1072 ori r7,r7,0x0032 /* ? */
1073 mtdbatl 3,r7 /* ? */
1074 lis r7,0xF300 /* ? */
1075 ori r7,r7,0x0002 /* ? */
1076 mtdbatu 3,r7 /* ? */
1077 ori r12,r12,0x0010 /* ? */
1084 lis r3,HIGH_ADDR(fwdisplock) /* Get the display locker outer */
1085 ori r3,r3,LOW_ADDR(fwdisplock) /* Last part */
1088 ddwait1: lwarx r5,0,r3 /* Get the lock */
1089 mr. r5,r5 /* Is it locked? */
1090 bne- ddwait1 /* Yup... */
1091 stwcx. r3,0,r3 /* Try to get it */
1092 bne- ddwait1 /* Nope, start all over... */
1094 li r3,0x52 /* Print eyecatcher */
1095 bl dbgDchar /* Send it */
1096 li r3,0x65 /* Print eyecatcher */
1097 bl dbgDchar /* Send it */
1098 li r3,0x67 /* Print eyecatcher */
1099 bl dbgDchar /* Send it */
1100 li r3,0x73 /* Print eyecatcher */
1101 bl dbgDchar /* Send it */
1102 li r3,0x20 /* Print eyecatcher */
1103 bl dbgDchar /* Send it */
1105 lwz r5,saver0(r13) /* Do register */
1106 bl dbg4byte /* Print */
1107 lwz r5,saver1(r13) /* Do register */
1108 bl dbg4byte /* Print */
1109 lwz r5,saver2(r13) /* Do register */
1110 bl dbg4byte /* Print */
1111 lwz r5,saver3(r13) /* Do register */
1112 bl dbg4byte /* Print */
1113 li r3,0x0A /* Linefeed */
1114 bl dbgDchar /* Send it */
1115 li r3,0x0D /* Carriage return */
1116 bl dbgDchar /* Send it */
1118 li r3,0x20 /* Print eyecatcher */
1119 bl dbgDchar /* Send it */
1120 li r3,0x20 /* Print eyecatcher */
1121 bl dbgDchar /* Send it */
1122 li r3,0x20 /* Print eyecatcher */
1123 bl dbgDchar /* Send it */
1124 li r3,0x20 /* Print eyecatcher */
1125 bl dbgDchar /* Send it */
1126 li r3,0x20 /* Print eyecatcher */
1127 bl dbgDchar /* Send it */
1128 lwz r5,saver4(r13) /* Do register */
1129 bl dbg4byte /* Print */
1130 lwz r5,saver5(r13) /* Do register */
1131 bl dbg4byte /* Print */
1132 lwz r5,saver6(r13) /* Do register */
1133 bl dbg4byte /* Print */
1134 lwz r5,saver7(r13) /* Do register */
1135 bl dbg4byte /* Print */
1136 li r3,0x0A /* Linefeed */
1137 bl dbgDchar /* Send it */
1138 li r3,0x0D /* Carriage return */
1139 bl dbgDchar /* Send it */
1141 li r3,0x20 /* Print eyecatcher */
1142 bl dbgDchar /* Send it */
1143 li r3,0x20 /* Print eyecatcher */
1144 bl dbgDchar /* Send it */
1145 li r3,0x20 /* Print eyecatcher */
1146 bl dbgDchar /* Send it */
1147 li r3,0x20 /* Print eyecatcher */
1148 bl dbgDchar /* Send it */
1149 li r3,0x20 /* Print eyecatcher */
1150 bl dbgDchar /* Send it */
1151 lwz r5,saver8(r13) /* Do register */
1152 bl dbg4byte /* Print */
1153 lwz r5,saver9(r13) /* Do register */
1154 bl dbg4byte /* Print */
1155 lwz r5,saver10(r13) /* Do register */
1156 bl dbg4byte /* Print */
1157 lwz r5,saver11(r13) /* Do register */
1158 bl dbg4byte /* Print */
1159 li r3,0x0A /* Linefeed */
1160 bl dbgDchar /* Send it */
1161 li r3,0x0D /* Carriage return */
1162 bl dbgDchar /* Send it */
1164 li r3,0x20 /* Print eyecatcher */
1165 bl dbgDchar /* Send it */
1166 li r3,0x20 /* Print eyecatcher */
1167 bl dbgDchar /* Send it */
1168 li r3,0x20 /* Print eyecatcher */
1169 bl dbgDchar /* Send it */
1170 li r3,0x20 /* Print eyecatcher */
1171 bl dbgDchar /* Send it */
1172 li r3,0x20 /* Print eyecatcher */
1173 bl dbgDchar /* Send it */
1174 lwz r5,saver12(r13) /* Do register */
1175 bl dbg4byte /* Print */
1176 lwz r5,saver13(r13) /* Do register */
1177 bl dbg4byte /* Print */
1178 lwz r5,saver14(r13) /* Do register */
1179 bl dbg4byte /* Print */
1180 lwz r5,saver15(r13) /* Do register */
1181 bl dbg4byte /* Print */
1182 li r3,0x0A /* Linefeed */
1183 bl dbgDchar /* Send it */
1184 li r3,0x0D /* Carriage return */
1185 bl dbgDchar /* Send it */
1187 li r3,0x20 /* Print eyecatcher */
1188 bl dbgDchar /* Send it */
1189 li r3,0x20 /* Print eyecatcher */
1190 bl dbgDchar /* Send it */
1191 li r3,0x20 /* Print eyecatcher */
1192 bl dbgDchar /* Send it */
1193 li r3,0x20 /* Print eyecatcher */
1194 bl dbgDchar /* Send it */
1195 li r3,0x20 /* Print eyecatcher */
1196 bl dbgDchar /* Send it */
1197 lwz r5,saver16(r13) /* Do register */
1198 bl dbg4byte /* Print */
1199 lwz r5,saver17(r13) /* Do register */
1200 bl dbg4byte /* Print */
1201 lwz r5,saver18(r13) /* Do register */
1202 bl dbg4byte /* Print */
1203 lwz r5,saver19(r13) /* Do register */
1204 bl dbg4byte /* Print */
1205 li r3,0x0A /* Linefeed */
1206 bl dbgDchar /* Send it */
1207 li r3,0x0D /* Carriage return */
1208 bl dbgDchar /* Send it */
1210 li r3,0x20 /* Print eyecatcher */
1211 bl dbgDchar /* Send it */
1212 li r3,0x20 /* Print eyecatcher */
1213 bl dbgDchar /* Send it */
1214 li r3,0x20 /* Print eyecatcher */
1215 bl dbgDchar /* Send it */
1216 li r3,0x20 /* Print eyecatcher */
1217 bl dbgDchar /* Send it */
1218 li r3,0x20 /* Print eyecatcher */
1219 bl dbgDchar /* Send it */
1220 lwz r5,saver20(r13) /* Do register */
1221 bl dbg4byte /* Print */
1222 lwz r5,saver21(r13) /* Do register */
1223 bl dbg4byte /* Print */
1224 lwz r5,saver22(r13) /* Do register */
1225 bl dbg4byte /* Print */
1226 lwz r5,saver23(r13) /* Do register */
1227 bl dbg4byte /* Print */
1228 li r3,0x0A /* Linefeed */
1229 bl dbgDchar /* Send it */
1230 li r3,0x0D /* Carriage return */
1231 bl dbgDchar /* Send it */
1233 li r3,0x20 /* Print eyecatcher */
1234 bl dbgDchar /* Send it */
1235 li r3,0x20 /* Print eyecatcher */
1236 bl dbgDchar /* Send it */
1237 li r3,0x20 /* Print eyecatcher */
1238 bl dbgDchar /* Send it */
1239 li r3,0x20 /* Print eyecatcher */
1240 bl dbgDchar /* Send it */
1241 li r3,0x20 /* Print eyecatcher */
1242 bl dbgDchar /* Send it */
1243 lwz r5,saver24(r13) /* Do register */
1244 bl dbg4byte /* Print */
1245 lwz r5,saver25(r13) /* Do register */
1246 bl dbg4byte /* Print */
1247 lwz r5,saver26(r13) /* Do register */
1248 bl dbg4byte /* Print */
1249 lwz r5,saver27(r13) /* Do register */
1250 bl dbg4byte /* Print */
1251 li r3,0x0A /* Linefeed */
1252 bl dbgDchar /* Send it */
1253 li r3,0x0D /* Carriage return */
1254 bl dbgDchar /* Send it */
1256 li r3,0x20 /* Print eyecatcher */
1257 bl dbgDchar /* Send it */
1258 li r3,0x20 /* Print eyecatcher */
1259 bl dbgDchar /* Send it */
1260 li r3,0x20 /* Print eyecatcher */
1261 bl dbgDchar /* Send it */
1262 li r3,0x20 /* Print eyecatcher */
1263 bl dbgDchar /* Send it */
1264 li r3,0x20 /* Print eyecatcher */
1265 bl dbgDchar /* Send it */
1266 lwz r5,saver28(r13) /* Do register */
1267 bl dbg4byte /* Print */
1268 lwz r5,saver29(r13) /* Do register */
1269 bl dbg4byte /* Print */
1270 lwz r5,saver30(r13) /* Do register */
1271 bl dbg4byte /* Print */
1272 lwz r5,saver31(r13) /* Do register */
1273 bl dbg4byte /* Print */
1274 li r3,0x0A /* Linefeed */
1275 bl dbgDchar /* Send it */
1276 li r3,0x0D /* Carriage return */
1277 bl dbgDchar /* Send it */
1279 /* Segment registers */
1281 li r3,0x53 /* Print eyecatcher */
1282 bl dbgDchar /* Send it */
1283 li r3,0x65 /* Print eyecatcher */
1284 bl dbgDchar /* Send it */
1285 li r3,0x67 /* Print eyecatcher */
1286 bl dbgDchar /* Send it */
1287 li r3,0x73 /* Print eyecatcher */
1288 bl dbgDchar /* Send it */
1289 li r3,0x20 /* Print eyecatcher */
1290 bl dbgDchar /* Send it */
1292 lwz r5,savesr0(r13) /* Do register */
1293 bl dbg4byte /* Print */
1294 lwz r5,savesr1(r13) /* Do register */
1295 bl dbg4byte /* Print */
1296 lwz r5,savesr2(r13) /* Do register */
1297 bl dbg4byte /* Print */
1298 lwz r5,savesr3(r13) /* Do register */
1299 bl dbg4byte /* Print */
1300 li r3,0x0A /* Linefeed */
1301 bl dbgDchar /* Send it */
1302 li r3,0x0D /* Carriage return */
1303 bl dbgDchar /* Send it */
1305 li r3,0x20 /* Print eyecatcher */
1306 bl dbgDchar /* Send it */
1307 li r3,0x20 /* Print eyecatcher */
1308 bl dbgDchar /* Send it */
1309 li r3,0x20 /* Print eyecatcher */
1310 bl dbgDchar /* Send it */
1311 li r3,0x20 /* Print eyecatcher */
1312 bl dbgDchar /* Send it */
1313 li r3,0x20 /* Print eyecatcher */
1314 bl dbgDchar /* Send it */
1315 lwz r5,savesr4(r13) /* Do register */
1316 bl dbg4byte /* Print */
1317 lwz r5,savesr5(r13) /* Do register */
1318 bl dbg4byte /* Print */
1319 lwz r5,savesr6(r13) /* Do register */
1320 bl dbg4byte /* Print */
1321 lwz r5,savesr7(r13) /* Do register */
1322 bl dbg4byte /* Print */
1323 li r3,0x0A /* Linefeed */
1324 bl dbgDchar /* Send it */
1325 li r3,0x0D /* Carriage return */
1326 bl dbgDchar /* Send it */
1328 li r3,0x20 /* Print eyecatcher */
1329 bl dbgDchar /* Send it */
1330 li r3,0x20 /* Print eyecatcher */
1331 bl dbgDchar /* Send it */
1332 li r3,0x20 /* Print eyecatcher */
1333 bl dbgDchar /* Send it */
1334 li r3,0x20 /* Print eyecatcher */
1335 bl dbgDchar /* Send it */
1336 li r3,0x20 /* Print eyecatcher */
1337 bl dbgDchar /* Send it */
1338 lwz r5,savesr8(r13) /* Do register */
1339 bl dbg4byte /* Print */
1340 lwz r5,savesr9(r13) /* Do register */
1341 bl dbg4byte /* Print */
1342 lwz r5,savesr10(r13) /* Do register */
1343 bl dbg4byte /* Print */
1344 lwz r5,savesr11(r13) /* Do register */
1345 bl dbg4byte /* Print */
1346 li r3,0x0A /* Linefeed */
1347 bl dbgDchar /* Send it */
1348 li r3,0x0D /* Carriage return */
1349 bl dbgDchar /* Send it */
1351 li r3,0x20 /* Print eyecatcher */
1352 bl dbgDchar /* Send it */
1353 li r3,0x20 /* Print eyecatcher */
1354 bl dbgDchar /* Send it */
1355 li r3,0x20 /* Print eyecatcher */
1356 bl dbgDchar /* Send it */
1357 li r3,0x20 /* Print eyecatcher */
1358 bl dbgDchar /* Send it */
1359 li r3,0x20 /* Print eyecatcher */
1360 bl dbgDchar /* Send it */
1361 lwz r5,savesr12(r13) /* Do register */
1362 bl dbg4byte /* Print */
1363 lwz r5,savesr13(r13) /* Do register */
1364 bl dbg4byte /* Print */
1365 lwz r5,savesr14(r13) /* Do register */
1366 bl dbg4byte /* Print */
1367 lwz r5,savesr15(r13) /* Do register */
1368 bl dbg4byte /* Print */
1369 li r3,0x0A /* Linefeed */
1370 bl dbgDchar /* Send it */
1371 li r3,0x0D /* Carriage return */
1372 bl dbgDchar /* Send it */
1374 li r3,0x30 /* Print eyecatcher */
1375 bl dbgDchar /* Send it */
1376 li r3,0x31 /* Print eyecatcher */
1377 bl dbgDchar /* Send it */
1378 li r3,0x64 /* Print eyecatcher */
1379 bl dbgDchar /* Send it */
1380 li r3,0x64 /* Print eyecatcher */
1381 bl dbgDchar /* Send it */
1382 li r3,0x20 /* Print eyecatcher */
1383 bl dbgDchar /* Send it */
1384 lwz r5,savesrr0(r13) /* Do register */
1385 bl dbg4byte /* Print */
1386 lwz r5,savesrr1(r13) /* Do register */
1387 bl dbg4byte /* Print */
1388 lwz r5,savedar(r13) /* Do register */
1389 bl dbg4byte /* Print */
1390 lwz r5,savedsisr(r13) /* Do register */
1391 bl dbg4byte /* Print */
1392 li r3,0x0A /* Linefeed */
1393 bl dbgDchar /* Send it */
1394 li r3,0x0D /* Carriage return */
1395 bl dbgDchar /* Send it */
1397 li r3,0x20 /* Print eyecatcher */
1398 bl dbgDchar /* Send it */
1399 li r3,0x6C /* Print eyecatcher */
1400 bl dbgDchar /* Send it */
1401 li r3,0x63 /* Print eyecatcher */
1402 bl dbgDchar /* Send it */
1403 li r3,0x63 /* Print eyecatcher */
1404 bl dbgDchar /* Send it */
1405 li r3,0x20 /* Print eyecatcher */
1406 bl dbgDchar /* Send it */
1407 lwz r5,savelr(r13) /* Do register */
1408 bl dbg4byte /* Print */
1409 lwz r5,savecr(r13) /* Do register */
1410 bl dbg4byte /* Print */
1411 lwz r5,savectr(r13) /* Do register */
1412 bl dbg4byte /* Print */
1413 li r3,0x0A /* Linefeed */
1414 bl dbgDchar /* Send it */
1415 li r3,0x0D /* Carriage return */
1416 bl dbgDchar /* Send it */
1417 mtlr r11 /* Get back the return */
1419 #if !SIMPLESCC && !NOTQUITEASSIMPLE
1420 li r7,0 /* Get a zero */
1421 mtdbatu 3,r7 /* Invalidate DBAT 3 upper */
1422 mtdbatl 3,r7 /* Invalidate DBAT 3 lower */
1424 lis r3,HIGH_ADDR(fwdisplock) /* Get the display locker outer */
1425 li r7,0 /* Get a zero */
1426 ori r3,r3,LOW_ADDR(fwdisplock) /* Last part */
1427 stw r7,0(r3) /* Clear display lock */
1428 mtmsr r8 /* Restore the MSR */
1429 isync /* Wait for it */
1434 * Used for debugging to leave stuff in 0x380-0x3FF (128 bytes).
1435 * Mapping is V=R. Stores and loads are real.
1438 ENTRY(dbgCkpt, TAG_NO_FRAME_USED)
1440 mr r12,r0 /* Keep R0 pristene */
1441 lis r0,HIGH_ADDR(dbgCkptCall) /* Top half of dbgCkptCall firmware call number */
1442 ori r0,r0,LOW_ADDR(dbgCkptCall) /* Bottom half */
1444 sc /* Go stash the stuff */
1446 mr r0,r12 /* Restore R0 */
1449 /* Here's the low-level part of dbgCkpt */
1451 ENTRY(dbgCkptLL, TAG_NO_FRAME_USED)
1453 li r12,0x380 /* Point to output area */
1454 li r1,32 /* Get line size */
1455 dcbz 0,r12 /* Make sure we don't fetch a cache line */
1457 lwz r4,0x00(r3) /* Load up storage to checkpoint */
1459 dcbt r1,r3 /* Start in the next line */
1461 lwz r5,0x04(r3) /* Load up storage to checkpoint */
1462 lwz r6,0x08(r3) /* Load up storage to checkpoint */
1463 lwz r7,0x0C(r3) /* Load up storage to checkpoint */
1464 lwz r8,0x10(r3) /* Load up storage to checkpoint */
1465 lwz r9,0x14(r3) /* Load up storage to checkpoint */
1466 lwz r10,0x18(r3) /* Load up storage to checkpoint */
1467 lwz r11,0x1C(r3) /* Load up storage to checkpoint */
1469 add r3,r3,r1 /* Bump input */
1471 stw r4,0x00(r12) /* Store it */
1472 stw r5,0x04(r12) /* Store it */
1473 stw r6,0x08(r12) /* Store it */
1474 stw r7,0x0C(r12) /* Store it */
1475 stw r8,0x10(r12) /* Store it */
1476 stw r9,0x14(r12) /* Store it */
1477 stw r10,0x18(r12) /* Store it */
1478 stw r11,0x1C(r12) /* Store it */
1480 dcbz r1,r12 /* Clear the next line */
1481 add r12,r12,r1 /* Point to next output line */
1483 lwz r4,0x00(r3) /* Load up storage to checkpoint */
1484 lwz r5,0x04(r3) /* Load up storage to checkpoint */
1485 lwz r6,0x08(r3) /* Load up storage to checkpoint */
1486 lwz r7,0x0C(r3) /* Load up storage to checkpoint */
1487 lwz r8,0x10(r3) /* Load up storage to checkpoint */
1488 lwz r9,0x14(r3) /* Load up storage to checkpoint */
1489 lwz r10,0x18(r3) /* Load up storage to checkpoint */
1490 lwz r11,0x1C(r3) /* Load up storage to checkpoint */
1492 dcbt r1,r3 /* Touch the next line */
1493 add r3,r3,r1 /* Point to next input line */
1495 stw r4,0x00(r12) /* Store it */
1496 stw r5,0x04(r12) /* Store it */
1497 stw r6,0x08(r12) /* Store it */
1498 stw r7,0x0C(r12) /* Store it */
1499 stw r8,0x10(r12) /* Store it */
1500 stw r9,0x14(r12) /* Store it */
1501 stw r10,0x18(r12) /* Store it */
1502 stw r11,0x1C(r12) /* Store it */
1504 dcbz r1,r12 /* Clear the next line */
1505 add r12,r12,r1 /* Point to next output line */
1507 lwz r4,0x00(r3) /* Load up storage to checkpoint */
1508 lwz r5,0x04(r3) /* Load up storage to checkpoint */
1509 lwz r6,0x08(r3) /* Load up storage to checkpoint */
1510 lwz r7,0x0C(r3) /* Load up storage to checkpoint */
1511 lwz r8,0x10(r3) /* Load up storage to checkpoint */
1512 lwz r9,0x14(r3) /* Load up storage to checkpoint */
1513 lwz r10,0x18(r3) /* Load up storage to checkpoint */
1514 lwz r11,0x1C(r3) /* Load up storage to checkpoint */
1516 dcbt r1,r3 /* Touch the next line */
1517 add r3,r3,r1 /* Point to next input line */
1519 stw r4,0x00(r12) /* Store it */
1520 stw r5,0x04(r12) /* Store it */
1521 stw r6,0x08(r12) /* Store it */
1522 stw r7,0x0C(r12) /* Store it */
1523 stw r8,0x10(r12) /* Store it */
1524 stw r9,0x14(r12) /* Store it */
1525 stw r10,0x18(r12) /* Store it */
1526 stw r11,0x1C(r12) /* Store it */
1528 dcbz r1,r12 /* Clear the next line */
1529 add r12,r12,r1 /* Point to next output line */
1531 lwz r4,0x00(r3) /* Load up storage to checkpoint */
1532 lwz r5,0x04(r3) /* Load up storage to checkpoint */
1533 lwz r6,0x08(r3) /* Load up storage to checkpoint */
1534 lwz r7,0x0C(r3) /* Load up storage to checkpoint */
1535 lwz r8,0x10(r3) /* Load up storage to checkpoint */
1536 lwz r9,0x14(r3) /* Load up storage to checkpoint */
1537 lwz r10,0x18(r3) /* Load up storage to checkpoint */
1538 lwz r11,0x1C(r3) /* Load up storage to checkpoint */
1540 stw r4,0x00(r12) /* Store it */
1541 stw r5,0x04(r12) /* Store it */
1542 stw r6,0x08(r12) /* Store it */
1543 stw r7,0x0C(r12) /* Store it */
1544 stw r8,0x10(r12) /* Store it */
1545 stw r9,0x14(r12) /* Store it */
1546 stw r10,0x18(r12) /* Store it */
1547 stw r11,0x1C(r12) /* Store it */
1553 * Do Preemption. Forces a T_PREEMPT trap to allow a preemption to occur.
1556 ENTRY(DoPreemptLL, TAG_NO_FRAME_USED)
1558 mfsprg r11,0 /* Get the per_proc address */
1559 lwz r11,PP_TEMPWORK1(r11) /* Restore the return address */
1560 li r3,T_PREEMPT /* Set preemption interrupt value */
1561 mtlr r11 /* Restore the LR */
1562 stw r3,saveexception(r13) /* Modify the exception type to preemption */
1563 blr /* Return to interrupt handler */
1567 * Force 'rupt handler to dispatch with new context
1568 * R3 at the call contains the new savearea.
1569 * R4 at the call contains a return code to pass back in R3.
1570 * Forces a T_CSWITCH
1573 ENTRY(SwitchContextLL, TAG_NO_FRAME_USED)
1575 mfsprg r11,0 /* Get the per_proc address */
1576 lwz r11,PP_TEMPWORK1(r11) /* Restore the return address */
1577 li r3,T_CSWITCH /* Set context switch value */
1578 mtlr r11 /* Restore the LR */
1579 stw r3,saveexception(r13) /* Modify the exception type to switch context */
1580 blr /* Return to interrupt handler */
1584 * Create a fake I/O 'rupt.
1585 * Forces a T_INTERRUPT trap to pretend that an actual I/O interrupt occurred.
1588 ENTRY(CreateFakeIOLL, TAG_NO_FRAME_USED)
1590 mfsprg r11,0 /* Get the per_proc address */
1591 lwz r11,PP_TEMPWORK1(r11) /* Restore the return address */
1592 li r3,T_INTERRUPT /* Set external interrupt value */
1593 mtlr r11 /* Restore the LR */
1594 stw r3,saveexception(r13) /* Modify the exception type to external */
1595 blr /* Return to interrupt handler */
1598 * Create a shutdown context
1599 * Forces a T_SHUTDOWN trap.
1602 ENTRY(CreateShutdownCTXLL, TAG_NO_FRAME_USED)
1604 mfsprg r11,0 /* Get the per_proc address */
1605 lwz r11,PP_TEMPWORK1(r11) /* Restore the return address */
1606 li r3,T_SHUTDOWN /* Set external interrupt value */
1607 mtlr r11 /* Restore the LR */
1608 stw r3,saveexception(r13) /* Modify the exception type to external */
1609 blr /* Return to interrupt handler */
1612 * Create a fake decrementer 'rupt.
1613 * Forces a T_DECREMENTER trap to pretend that an actual decrementer interrupt occurred.
1616 ENTRY(CreateFakeDECLL, TAG_NO_FRAME_USED)
1618 mfsprg r11,0 /* Get the per_proc address */
1619 lwz r11,PP_TEMPWORK1(r11) /* Restore the return address */
1620 li r3,T_DECREMENTER /* Set decrementer interrupt value */
1621 mtlr r11 /* Restore the LR */
1622 stw r3,saveexception(r13) /* Modify the exception type to external */
1623 blr /* Return to interrupt handler */
1629 ENTRY(DoChokeLL, TAG_NO_FRAME_USED)
1631 mfsprg r11,0 ; Get the per_proc address
1632 lwz r11,PP_TEMPWORK1(r11) ; Restore the return address
1633 li r3,T_CHOKE ; Set external interrupt value
1634 mtlr r11 ; Restore the LR
1635 stw r3,saveexception(r13) ; Modify the exception type to external
1636 blr ; Return to interrupt handler
1639 * Set the low level trace flags
1642 ENTRY(LLTraceSet, TAG_NO_FRAME_USED)
1644 mfsprg r6,2 ; Get feature flags
1645 mfmsr r12 /* Get the MSR */
1646 mr r4,r3 /* Save the new value */
1647 andi. r3,r12,0x01C0 /* Clear interrupts and translation */
1648 mtcrf 0x04,r6 ; Set the features
1649 bt pfNoMSRirb,ltsNoMSR ; Use MSR...
1651 mtmsr r3 ; Translation and all off
1652 isync ; Toss prefetch
1655 ltsNoMSR: li r0,loadMSR ; Get the MSR setter SC
1660 lis r5,hi16(EXT(trcWork)) ; Get trace area
1661 rlwinm r12,r12,0,MSR_FP_BIT+1,MSR_FP_BIT-1 ; Force floating point off
1662 ori r5,r5,lo16(EXT(trcWork)) ; again
1664 lwz r3,traceMask(r5) /* Get the old trace flags to pass back */
1665 rlwinm r12,r12,0,MSR_VEC_BIT+1,MSR_VEC_BIT-1 ; Force vectors off
1666 stw r4,traceMask(r5) /* Replace with the new ones */
1668 mtmsr r12 /* Restore the MSR */
1676 ; ***************************************************************************
1678 ; ----------------- Grateful Deb ----------------
1680 ; Debugging: direct draw into main screen menu bar
1682 ; Takes R4 value, converts it to hex characters and displays it.
1684 ; Gotta make sure the DCBST is done to force the pixels from the cache.
1686 ; Position is taken as column, row (0 based) from R3.
1687 ; Characters are from hexfont, and are 16x16 pixels.
1689 ; Only works with two processors so far
1692 ; ***************************************************************************
1695 #define GDfromright 20
1696 #define GDfontsize 16
1698 ENTRY(GratefulDeb,TAG_NO_FRAME_USED)
1699 mfspr r6,pir /* Get the PIR */
1700 lis r5,HIGH_ADDR(EXT(GratefulDebWork)) /* Point to our work area */
1701 rlwinm r6,r6,8,23,23 /* Get part of the offset to our processors area */
1702 ori r5,r5,LOW_ADDR(EXT(GratefulDebWork)) /* Start building the address */
1703 rlwimi r6,r6,2,21,21 /* Get the rest of the offset to our processors area */
1704 add r6,r6,r5 /* Point at our CPU's work area */
1705 mfmsr r5 /* Get that MSR */
1706 stmw r0,GDsave(r6) /* Save all registers */
1707 lwz r10,GDready(r6) /* See if we're all ready to go */
1708 ori r0,r5,0x2000 /* Turn on the floating point */
1709 mr r31,r6 /* Get a more sane base register */
1710 mr. r10,r10 /* Are we all set? */
1711 mtmsr r0 /* Enable floating point */
1714 stfd f0,GDfp0(r31) /* Save FP */
1715 stfd f1,GDfp1(r31) /* Save FP */
1716 stfd f2,GDfp2(r31) /* Save FP */
1717 stfd f3,GDfp3(r31) /* Save FP */
1719 beq- GDbailout /* Go and bail... */
1721 rlwinm r25,r3,0,16,31 /* Isolate just the row number */
1722 lwz r28,GDtopleft(r31) /* Get the physical address of our line 0 */
1723 rlwinm r3,r3,16,16,31 /* Isolate the column number */
1724 lwz r27,GDrowbytes(r31) /* Get the number of bytes per row */
1725 lwz r9,GDrowchar(r31) /* Get the number of bytes per row of full leaded charactrers */
1726 lwz r26,GDdepth(r31) /* Get the bit depth */
1727 mullw r25,r25,r9 /* get offset to the row to write in bytes */
1728 lwz r24,GDcollgn(r31) /* Get the size of columns in bytes */
1729 add r25,r28,r25 /* Physical address of row */
1730 mullw r3,r3,r24 /* Get byte offset to first output column */
1732 li r9,32 /* Get the initial shift calc */
1734 lis r20,HIGH_ADDR(hexfont) /* Point to the font */
1736 li r18,GDfontsize /* Get the number of rows in the font */
1737 ori r20,r20,LOW_ADDR(hexfont) /* Point to the low part */
1738 add r21,r25,r3 /* Physical address of top left output pixel */
1739 sub r9,r9,r26 /* Get right shift justifier for pixel size */
1740 li r7,32 /* Number of bits per word */
1743 la r6,GDrowbuf1(r31) /* Point to the row buffer */
1744 li r19,8 /* Get the number of characters in a row */
1746 getNybble: rlwinm r10,r4,9,23,26 /* Get the top nybble * 32 */
1747 rlwinm r4,r4,4,0,31 /* Rotate a nybble */
1748 add r10,r20,r10 /* Point to the character in the font */
1750 rlwinm r16,r26,4,0,27 /* Width of row in actual bits */
1751 lhz r15,0(r10) /* Get the next row of the font */
1753 rendrow: rlwinm r17,r15,16,0,0 /* Get the next font pixel in the row */
1754 rlwinm r15,r15,1,16,31 /* Move in the next font pixel */
1755 srawi r17,r17,31 /* Fill with 1s if black and 0s if white (reversed) */
1757 slw r14,r14,r26 /* Make room for our pixel in a register */
1758 srw r17,r17,r9 /* Isolate one pixels worth of black or white */
1759 sub. r7,r7,r26 /* See how may bits are left */
1760 sub r16,r16,r26 /* Count how many bits are left to store for this row */
1761 or r14,r14,r17 /* Put in the pixel */
1762 bne+ notfull /* Finish rendering this word */
1764 not r14,r14 /* Invert to black on white */
1765 stw r14,0(r6) /* Write out the word */
1766 li r7,32 /* Bit per word count */
1767 addi r6,r6,4 /* Point to the next word */
1769 notfull: mr. r16,r16 /* Have we finished the whole character row? */
1770 bne+ rendrow /* Finish rendering the row */
1772 addic. r19,r19,-1 /* Are we finished with a whole display row yet? */
1773 bne+ getNybble /* Not yet... */
1775 la r6,GDrowbuf1(r31) /* Point to the row buffer */
1776 rlwinm r19,r26,31,0,29 /* Number of cache lines (depth/2) */
1777 mr r14,r21 /* Get the frame buffer address */
1781 blitrow: lfd f0,0(r6) /* Load a line */
1786 stfd f0,0(r14) /* Blit a line */
1791 addi r6,r6,32 /* Next buffered line */
1793 dcbst 0,r14 /* Force the line to the screen */
1794 sync /* Make sure the line is on it's way */
1795 eieio /* Make sure we beat the invalidate */
1796 dcbi 0,r14 /* Make sure we leave no paradox */
1798 addic. r19,r19,-1 /* Done all lines yet? */
1799 addi r14,r14,32 /* Point to the next output */
1800 bne+ blitrow /* Nope, do it some more... */
1802 addic. r18,r18,-1 /* Have we done all the rows in character yet? */
1803 addi r20,r20,2 /* Offset the font to the next row */
1804 add r21,r21,r27 /* Point to start of next row */
1805 bne+ startNybble /* Nope, go through the word one more time... */
1807 GDbailout: mr r1,r31 /* Move the workarea base */
1809 lfd f0,GDfp0(r31) /* Restore FP */
1810 lfd f1,GDfp1(r31) /* Restore FP */
1811 lfd f2,GDfp2(r31) /* Restore FP */
1812 lfd f3,GDfp3(r31) /* Restore FP */
1814 mtmsr r5 /* Disable floating point */
1817 lmw r3,GDsave+12(r1) /* Restore most registers */
1818 lwz r0,GDsave(r1) /* Restore R0 */
1819 lwz r1,GDsave+4(r1) /* Finally, R1 */
1824 * void GratefulDebDisp(unsigned int coord, unsigned int data);
1828 ENTRY(GratefulDebDisp,TAG_NO_FRAME_USED)
1830 mfmsr r9 /* Save the current MSR */
1831 mflr r7 /* Save the return */
1832 andi. r8,r9,0x7FCF /* Clear interrupt and translation */
1833 mtmsr r8 /* Turn 'em really off */
1834 isync /* Make sure about the translation part */
1835 bl EXT(GratefulDeb) /* Display it */
1836 mtmsr r9 /* Restore interrupt and translation */
1837 mtlr r7 /* Restore return */
1838 isync /* Make sure */
1845 * void checkNMI(void);
1849 ENTRY(checkNMI,TAG_NO_FRAME_USED)
1851 mfmsr r9 /* Save it */
1852 andi. r8,r9,0x7FCF /* Clear it */
1853 mtmsr r8 /* Disable it */
1854 isync /* Fence it */
1855 lis r7,0xF300 /* Find it */
1856 ori r7,r7,0x0020 /* Find it */
1857 dcbi 0,r7 /* Toss it */
1859 rlwinm r9,r9,0,MSR_FP_BIT+1,MSR_FP_BIT-1 ; Force floating point off
1861 lwz r6,0x000C(r7) /* Check it */
1862 eieio /* Fence it */
1863 dcbi 0,r7 /* Toss it */
1864 rlwinm r9,r9,0,MSR_VEC_BIT+1,MSR_VEC_BIT-1 ; Force vectors off
1865 rlwinm. r4,r6,0,19,19 /* Check it */
1866 rlwinm r6,r6,0,20,18 /* Clear it */
1868 eieio /* Fence it */
1869 beq+ xnonmi /* Branch on it */
1871 stw r6,0x0008(r7) /* Reset it */
1873 dcbi 0,r6 /* Toss it */
1874 eieio /* Fence it */
1876 mtmsr r9 /* Restore it */
1879 BREAKPOINT_TRAP /* Kill it */
1880 blr /* Return from it */
1882 xnonmi: /* Label it */
1883 mtmsr r9 /* Restore it */
1885 blr /* Return from it */
1892 dumpr7: lis r9,HIGH_ADDR(hexTab) /* (TEST/DEBUG) */
1893 li r5,8 /* (TEST/DEBUG) */
1894 ori r9,r9,LOW_ADDR(hexTab) /* (TEST/DEBUG) */
1896 dumpr7n: rlwinm r7,r7,4,0,31 /* (TEST/DEBUG) */
1897 mr r6,r7 /* (TEST/DEBUG) */
1898 andi. r6,r6,15 /* (TEST/DEBUG) */
1899 lbzx r6,r9,r6 /* (TEST/DEBUG) */
1900 lis r10,0xF301 /* (TEST/DEBUG) */
1901 ori r10,r10,0x2000 /* (TEST/DEBUG) */
1904 xqrw2: eieio /* (TEST/DEBUG) */
1905 lbz r7,0(r10) /* (TEST/DEBUG) */
1906 dcbi 0,r10 /* (TEST/DEBUG) */
1907 sync /* (TEST/DEBUG) */
1908 andi. r7,r7,0x04 /* (TEST/DEBUG) */
1909 beq xqrw2 /* (TEST/DEBUG) */
1912 dcbf 0,r10 /* (TEST/DEBUG) */
1913 sync /* (TEST/DEBUG) */
1914 dcbi 0,r10 /* (TEST/DEBUG) */
1915 eieio /* (TEST/DEBUG) */
1916 stb r6,4(r10) /* (TEST/DEBUG) */
1918 lis r6,10 /* (TEST/DEBUG) */
1919 dumpr7d: addi r6,r6,-1 /* (TEST/DEBUG) */
1920 mr. r6,r6 /* (TEST/DEBUG) */
1921 bne- dumpr7d /* (TEST/DEBUG) */
1922 dcbf 0,r10 /* (TEST/DEBUG) */
1923 sync /* (TEST/DEBUG) */
1924 dcbi 0,r10 /* (TEST/DEBUG) */
1925 eieio /* (TEST/DEBUG) */
1927 addic. r5,r5,-1 /* (TEST/DEBUG) */
1928 bne+ dumpr7n /* (TEST/DEBUG) */
1930 blr /* (TEST/DEBUG) */
1933 ; Log a special entry in physical memory.
1934 ; This assumes that memory size has been significantly lowered using
1935 ; the maxmem boot option. The buffer starts just after the end of mem_size.
1937 ; This is absolutely for special tracing cases. Do not ever leave in...
1940 ENTRY(dbgLog,TAG_NO_FRAME_USED)
1942 li r11,0 ; Clear callers callers callers return
1943 li r10,0 ; Clear callers callers callers callers return
1944 li r9,0 ; Clear callers callers callers callers callers return
1945 lwz r2,0(r1) ; Get callers callers stack frame
1946 lis r0,0x4000 ; First invalid address
1947 lwz r12,8(r2) ; Get our callers return
1948 lwz r2,0(r2) ; Back chain
1950 mr. r2,r2 ; End of chain?
1951 cmplw cr1,r2,r0 ; Valid kernel address?
1952 beq- nosavehere ; Yes, end of chain...
1953 bge- cr1,nosavehere ; No...
1954 lwz r11,8(r2) ; Get our callers return
1955 lwz r2,0(r2) ; Back chain
1957 mr. r2,r2 ; End of chain?
1958 cmplw cr1,r2,r0 ; Valid kernel address?
1959 beq- nosavehere ; Yes, end of chain...
1960 bge- cr1,nosavehere ; No...
1961 lwz r10,8(r2) ; Get our callers return
1962 lwz r2,0(r2) ; Back chain
1964 mr. r2,r2 ; End of chain?
1965 cmplw cr1,r2,r0 ; Valid kernel address?
1966 beq- nosavehere ; Yes, end of chain...
1967 bge- cr1,nosavehere ; No...
1968 lwz r9,8(r2) ; Get our callers return
1970 nosavehere: mfmsr r8 ; Get the MSR
1971 lis r2,hi16(EXT(DebugWork)) ; High part of area
1972 lis r7,hi16(EXT(mem_actual)) ; High part of actual
1973 andi. r0,r8,0x7FCF ; Interrupts and translation off
1974 ori r2,r2,lo16(EXT(DebugWork)) ; Get the entry
1975 mtmsr r0 ; Turn stuff off
1976 ori r7,r7,lo16(EXT(mem_actual)) ; Get the actual
1979 lwz r0,4(r2) ; Get the flag
1980 mr. r0,r0 ; Should we log?
1981 lwz r0,0(r7) ; Get the end of memory
1982 lwz r7,0(r2) ; Get the position
1983 bne- waytoofar ; No logging...
1984 mr. r7,r7 ; Is this the first?
1985 bne+ gotspot ; Nope...
1987 lis r7,hi16(EXT(mem_size)) ; High part of defined memory
1988 ori r7,r7,lo16(EXT(mem_size)) ; Low part of defined memory
1989 lwz r7,0(r7) ; Make it end of defined
1991 gotspot: cmplw r7,r0 ; Do we fit in memory
1992 addi r0,r7,0x0020 ; Next slot
1993 bge- waytoofar ; No fit...
1995 stw r0,0(r2) ; Set next time slot
1998 stw r3,0(r7) ; First data
1999 li r3,32 ; Disp to next line
2000 stw r4,4(r7) ; Second data
2002 stw r5,8(r7) ; Third data
2003 stw r6,12(r7) ; Fourth data
2005 stw r12,16(r7) ; Callers callers
2006 stw r11,20(r7) ; Callers callers caller
2007 stw r10,24(r7) ; Callers callers callers caller
2008 stw r9,28(r7) ; Callers callers callers callers caller
2010 waytoofar: mtmsr r8 ; Back to normal
2015 ; Same as the other, but no traceback and 16 byte entry
2016 ; Trashes R0, R2, R10, R12
2025 mfmsr r10 ; Get the MSR
2026 lis r2,hi16(EXT(DebugWork)) ; High part of area
2027 lis r12,hi16(EXT(mem_actual)) ; High part of actual
2028 andi. r0,r10,0x7FCF ; Interrupts and translation off
2029 ori r2,r2,lo16(EXT(DebugWork)) ; Get the entry
2030 mtmsr r0 ; Turn stuff off
2031 ori r12,r12,lo16(EXT(mem_actual)) ; Get the actual
2034 lwz r0,4(r2) ; Get the flag
2035 mr. r0,r0 ; Should we log?
2036 lwz r0,0(r12) ; Get the end of memory
2037 lwz r12,0(r2) ; Get the position
2038 bne- waytoofar2 ; No logging...
2039 mr. r12,r12 ; Is this the first?
2040 bne+ gotspot2 ; Nope...
2042 lis r12,hi16(EXT(mem_size)) ; High part of defined memory
2043 ori r12,r12,lo16(EXT(mem_size)) ; Low part of defined memory
2044 lwz r12,0(r12) ; Make it end of defined
2046 gotspot2: cmplw cr1,r12,r0 ; Do we fit in memory
2047 rlwinm. r0,r12,0,27,27 ; Are we on a new line?
2048 bge- cr1,waytoofar2 ; No fit...
2049 addi r0,r12,0x0010 ; Next slot
2051 bne+ nonewline ; Not on a new line...
2052 dcbz br0,r12 ; Clear it so we do not fetch it
2054 nonewline: cmplwi r3,68 ; Special place for time stamp?
2056 stw r0,0(r2) ; Set next time slot
2057 bne+ nospcts ; Nope...
2059 lwz r0,0x17C(br0) ; Get special saved time stamp
2062 nospcts: mftb r0 ; Get the current time
2064 nospctt: stw r3,4(r12) ; First data
2065 stw r4,8(r12) ; Second data
2066 stw r5,12(r12) ; Third data
2067 stw r0,0(r12) ; Time stamp
2069 waytoofar2: mtmsr r10 ; Back to normal
2075 ; Saves floating point registers
2083 mfmsr r0 ; Save the MSR
2084 rlwinm r0,r0,0,MSR_FP_BIT+1,MSR_FP_BIT-1 ; Force floating point off
2085 rlwinm r0,r0,0,MSR_VEC_BIT+1,MSR_VEC_BIT-1 ; Force vectors off
2086 rlwinm r4,r0,0,MSR_EE_BIT,MSR_EE_BIT ; Turn off interruptions
2087 ori r4,r4,lo16(MASK(MSR_FP)) ; Enable floating point
2132 ; Saves vector registers. Returns 0 if non-Altivec machine.
2136 .globl EXT(stVectors)
2141 mfsprg r6,2 ; Get features
2142 mr r5,r3 ; Save area address
2143 rlwinm. r6,r6,0,pfAltivecb,pfAltivecb ; Do we have Altivec?
2144 li r3,0 ; Assume failure
2147 mfmsr r0 ; Save the MSR
2148 rlwinm r0,r0,0,MSR_FP_BIT+1,MSR_FP_BIT-1 ; Force floating point off
2149 rlwinm r0,r0,0,MSR_VEC_BIT+1,MSR_VEC_BIT-1 ; Force vectors off
2150 rlwinm r4,r0,0,MSR_EE_BIT,MSR_EE_BIT ; Turn off interruptions
2151 oris r4,r4,hi16(MASK(MSR_VEC)) ; Enable vectors
2230 ; Saves yet more registers
2234 .globl EXT(stSpecrs)
2238 mfmsr r0 ; Save the MSR
2239 rlwinm r0,r0,0,MSR_FP_BIT+1,MSR_FP_BIT-1 ; Force floating point off
2240 rlwinm r0,r0,0,MSR_VEC_BIT+1,MSR_VEC_BIT-1 ; Force vectors off
2241 rlwinm r4,r0,0,MSR_EE_BIT,MSR_EE_BIT ; Turn off interruptions
2247 rlwinm r12,r12,16,16,31
2298 stSnsr: mfsrin r6,r5
2305 cmplwi cr1,r12,PROCESSOR_VERSION_604e
2306 cmplwi cr5,r12,PROCESSOR_VERSION_604ev
2307 cror cr1_eq,cr1_eq,cr5_eq ; Set if 604 type
2308 cmplwi r12,PROCESSOR_VERSION_750
2324 before750: stw r4,(40*4)(r3)
2333 isis750: stw r4,0(r3)
2347 b4750: stw r4,(44*4)(r3)
2353 cmplwi r12,PROCESSOR_VERSION_7400
2357 rlwinm r5,r5,0,16,31
2363 gnmax: mfspr r4,1016
2365 nnmax: stw r4,(48*4)(r3)