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/POWERMAC/mp/MPPlugIn.h>
43 #include <ppc/exception.h>
44 #include <mach/machine/vm_param.h>
49 * Here we generate the table of supported firmware calls
55 .align 5 /* Line up on cache line */
61 .globl CutTrace /* Let everyone know 'bout it */
62 .set CutTrace,(.-EXT(FWtable))/4|0x80000000 /* Call number for CutTrace */
63 .long callUnimp /* This was already handled in lowmem_vectors */
65 #include <ppc/FirmwareCalls.h>
67 .set EXT(FirmwareCnt), (.-EXT(FWtable))/4 /* Get the top number */
72 #define NOTQUITEASSIMPLE 1
74 * This routine handles the firmware call routine. It must be entered with IR and DR off,
75 * interruptions disabled, and in supervisor state.
77 * When we enter, we expect R0 to have call number, and LR
78 * to point to the return. Also, all registers saved in savearea in R13.
79 * R3 is as passed in by the user. All others must be gotten from the save area
82 ENTRY(FirmwareCall, TAG_NO_FRAME_USED)
84 rlwinm r1,r0,2,1,29 /* Clear out bit 0 and multiply by 4 */
85 lis r12,HIGH_ADDR(EXT(FWtable)) /* Get the high part of the firmware call table */
86 cmplwi r1,EXT(FirmwareCnt)*4 /* Is it a valid firmware call number */
87 mflr r11 /* Save the return */
88 ori r12,r12,LOW_ADDR(EXT(FWtable)) /* Now the low part */
89 ble+ goodCall /* Yeah, it is... */
91 li r3,T_SYSTEM_CALL /* Tell the vector handler that we know nothing */
92 blr /* Return for errors... */
94 goodCall: mfsprg r10,0 /* Make sure about the per_proc block */
95 lwzx r1,r1,r12 /* Pick up the address of the routine */
96 lwz r4,saver4(r13) /* Pass in caller's R4 */
97 lwz r5,saver5(r13) /* Pass in caller's R5 */
98 rlwinm. r1,r1,0,0,29 /* Make sure the flag bits are clear */
99 stw r11,PP_TEMPWORK1(r10) /* Save our return point */
101 mtlr r1 /* Put it in the LR */
102 beq- callUnimp /* This one was unimplimented... */
104 blrl /* Call the routine... */
106 mfsprg r10,0 /* Make sure about the per_proc again */
107 stw r3,saver3(r13) /* Pass back the return code to caller */
108 lwz r11,PP_TEMPWORK1(r10) /* Get our return point */
109 li r3,T_IN_VAIN /* Tell the vector handler that we took care of it */
110 mtlr r11 /* Set the return */
111 blr /* Bye, dudes... */
113 callUnimp: lwz r11,PP_TEMPWORK1(r10) /* Restore the return address */
114 li r3,T_SYSTEM_CALL /* Tell the vector handler that we know nothing */
115 mtlr r11 /* Restore the LR */
116 blr /* Return for errors... */
119 * This routine is used to store using a real address. It stores parmeter1 at parameter2.
122 ENTRY(StoreReal, TAG_NO_FRAME_USED)
124 lis r0,HIGH_ADDR(StoreRealCall) /* Get the top part of the SC number */
125 ori r0,r0,LOW_ADDR(StoreRealCall) /* and the bottom part */
127 blr /* Bye bye, Birdie... */
129 ENTRY(StoreRealLL, TAG_NO_FRAME_USED)
131 stw r3,0(r4) /* Store the word */
135 * This routine is used to clear a range of physical pages.
138 ENTRY(ClearReal, TAG_NO_FRAME_USED)
140 lis r0,HIGH_ADDR(ClearRealCall) /* Get the top part of the SC number */
141 ori r0,r0,LOW_ADDR(ClearRealCall) /* and the bottom part */
143 blr /* Bye bye, Birdie... */
145 ENTRY(ClearRealLL, TAG_NO_FRAME_USED)
148 * We take the first parameter as a physical address. The second is the length in bytes.
149 * Being crazy, I'll round the address down, and the length up. We could end up clearing
150 * an extra page at the start and one at the end, but we don't really care. If someone
151 * is stupid enough to give me unaligned addresses and lengths, I am just arrogant enough
152 * to take them at their word and to hell with them.
155 neg r5,r3 /* Negate the address */
156 addi r4,r4,4095 /* Round length up */
157 rlwinm r5,r5,0,20,31 /* Save extra length */
158 rlwinm r3,r3,0,0,19 /* Round the page on down */
159 add r4,r4,r5 /* Add up all extra lengths */
160 li r6,32 /* Get a displacement */
161 rlwinm r4,r4,0,0,19 /* Round the length back down */
163 clrloop: subi r4,r4,32 /* Back off a cache line */
164 dcbz 0,r3 /* Do the even line */
165 sub. r4,r4,r6 /* Back off a second time (we only do this to generate a CR */
166 dcbz r6,r3 /* Clear the even line */
167 addi r3,r3,64 /* Move up to every other line */
168 bgt+ clrloop /* Go until we've done it all... */
172 * This routine will read in 32 byte of real storage.
175 ENTRY(ReadReal, TAG_NO_FRAME_USED)
177 mfmsr r0 /* Get the MSR */
178 rlwinm r5,r0,0,28,26 /* Clear DR bit */
179 rlwinm r5,r5,0,17,15 /* Clear EE bit */
180 mtmsr r5 /* Disable EE and DR */
181 isync /* Just make sure about it */
183 lwz r5,0(r3) /* Get word 0 */
184 lwz r6,4(r3) /* Get word 1 */
185 lwz r7,8(r3) /* Get word 2 */
186 lwz r8,12(r3) /* Get word 3 */
187 lwz r9,16(r3) /* Get word 4 */
188 lwz r10,20(r3) /* Get word 5 */
189 lwz r11,24(r3) /* Get word 6 */
190 lwz r12,28(r3) /* Get word 7 */
192 mtmsr r0 /* Restore original machine state */
193 isync /* Insure goodness */
195 stw r5,0(r4) /* Set word 0 */
196 stw r6,4(r4) /* Set word 1 */
197 stw r7,8(r4) /* Set word 2 */
198 stw r8,12(r4) /* Set word 3 */
199 stw r9,16(r4) /* Set word 4 */
200 stw r10,20(r4) /* Set word 5 */
201 stw r11,24(r4) /* Set word 6 */
202 stw r12,28(r4) /* Set word 7 */
208 * This routine is used to load all 4 DBATs.
211 ENTRY(LoadDBATs, TAG_NO_FRAME_USED)
213 lis r0,HIGH_ADDR(LoadDBATsCall) /* Top half of LoadDBATsCall firmware call number */
214 ori r0,r0,LOW_ADDR(LoadDBATsCall) /* Bottom half */
217 blr /* Bye bye, Birdie... */
219 ENTRY(xLoadDBATsLL, TAG_NO_FRAME_USED)
221 lwz r4,0(r3) /* Get DBAT 0 high */
222 lwz r5,4(r3) /* Get DBAT 0 low */
223 lwz r6,8(r3) /* Get DBAT 1 high */
224 lwz r7,12(r3) /* Get DBAT 1 low */
225 lwz r8,16(r3) /* Get DBAT 2 high */
226 lwz r9,20(r3) /* Get DBAT 2 low */
227 lwz r10,24(r3) /* Get DBAT 3 high */
228 lwz r11,28(r3) /* Get DBAT 3 low */
230 sync /* Common decency and the state law require you to wash your hands */
231 mtdbatu 0,r4 /* Load DBAT 0 high */
232 mtdbatl 0,r5 /* Load DBAT 0 low */
233 mtdbatu 1,r6 /* Load DBAT 1 high */
234 mtdbatl 1,r7 /* Load DBAT 1 low */
235 mtdbatu 2,r8 /* Load DBAT 2 high */
236 mtdbatl 2,r9 /* Load DBAT 2 low */
237 mtdbatu 3,r10 /* Load DBAT 3 high */
238 mtdbatl 3,r11 /* Load DBAT 3 low */
239 sync /* Make sure it's done */
240 isync /* Toss out anything new */
245 * This routine is used to load all 4 IBATs.
248 ENTRY(LoadIBATs, TAG_NO_FRAME_USED)
250 lis r0,HIGH_ADDR(LoadIBATsCall) /* Top half of CreateFakeIO firmware call number */
251 ori r0,r0,LOW_ADDR(LoadIBATsCall) /* Bottom half */
253 blr /* Bye bye, Birdie... */
255 ENTRY(xLoadIBATsLL, TAG_NO_FRAME_USED)
257 lwz r4,0(r3) /* Get IBAT 0 high */
258 lwz r5,4(r3) /* Get IBAT 0 low */
259 lwz r6,8(r3) /* Get IBAT 1 high */
260 lwz r7,12(r3) /* Get IBAT 1 low */
261 lwz r8,16(r3) /* Get IBAT 2 high */
262 lwz r9,20(r3) /* Get IBAT 2 low */
263 lwz r10,24(r3) /* Get IBAT 3 high */
264 lwz r11,28(r3) /* Get IBAT 3 low */
266 sync /* Common decency and the state law require you to wash your hands */
267 mtibatu 0,r4 /* Load IBAT 0 high */
268 mtibatl 0,r5 /* Load IBAT 0 low */
269 mtibatu 1,r6 /* Load IBAT 1 high */
270 mtibatl 1,r7 /* Load IBAT 1 low */
271 mtibatu 2,r8 /* Load IBAT 2 high */
272 mtibatl 2,r9 /* Load IBAT 2 low */
273 mtibatu 3,r10 /* Load IBAT 3 high */
274 mtibatl 3,r11 /* Load IBAT 3 low */
275 sync /* Make sure it's done */
276 isync /* Toss out anything new */
282 * This is the glue to call the CutTrace firmware call
285 ENTRY(dbgTrace, TAG_NO_FRAME_USED)
287 lis r0,HIGH_ADDR(CutTrace) /* Top half of CreateFakeIO firmware call number */
288 ori r0,r0,LOW_ADDR(CutTrace) /* Bottom half */
290 blr /* Bye bye, Birdie... */
293 * This is the glue to create a fake I/O interruption
296 ENTRY(CreateFakeIO, TAG_NO_FRAME_USED)
298 lis r0,HIGH_ADDR(CreateFakeIOCall) /* Top half of CreateFakeIO firmware call number */
299 ori r0,r0,LOW_ADDR(CreateFakeIOCall) /* Bottom half */
301 blr /* Bye bye, Birdie... */
304 * This is the glue to create a fake Dec interruption
307 ENTRY(CreateFakeDEC, TAG_NO_FRAME_USED)
309 lis r0,HIGH_ADDR(CreateFakeDECCall) /* Top half of CreateFakeDEC firmware call number */
310 ori r0,r0,LOW_ADDR(CreateFakeDECCall) /* Bottom half */
312 blr /* Bye bye, Birdie... */
316 * This is the glue to create a shutdown context
319 ENTRY(CreateShutdownCTX, TAG_NO_FRAME_USED)
321 lis r0,HIGH_ADDR(CreateShutdownCTXCall) /* Top half of CreateFakeIO firmware call number */
322 ori r0,r0,LOW_ADDR(CreateShutdownCTXCall) /* Bottom half */
324 blr /* Bye bye, Birdie... */
327 * This is the glue to choke system
330 ENTRY(ChokeSys, TAG_NO_FRAME_USED)
332 lis r0,HIGH_ADDR(Choke) /* Top half of Choke firmware call number */
333 ori r0,r0,LOW_ADDR(Choke) /* Bottom half */
335 blr /* Bye bye, Birdie... */
338 * Used to initialize the SCC for debugging output
342 ENTRY(fwSCCinit, TAG_NO_FRAME_USED)
344 mfmsr r8 /* Save the MSR */
345 mr. r3,r3 /* See if printer or modem */
346 rlwinm r12,r8,0,28,25 /* Turn off translation */
347 lis r10,0xF301 /* Set the top part */
348 rlwinm r12,r12,0,17,15 /* Turn off interruptions */
350 mtmsr r12 /* Smash the MSR */
351 isync /* Make it clean */
354 ori r10,r10,0x2000 /* Assume the printer (this is the normal one) */
355 beq+ fwSCCprnt /* It sure are... */
356 ori r10,r10,0x0002 /* Move it over to the modem port */
358 fwSCCprnt: dcbf 0,r10 /* Insure it is out */
361 dcbi 0,r10 /* Toss it */
365 li r7,0x09 /* Set the register */
366 stb r7,0(r10) /* Set the register */
367 dcbf 0,r10 /* Force it out */
368 sync /* Make sure it's out there */
372 li r7,0x80 /* Reset channel A */
373 stb r7,0(r10) /* Set the register */
374 dcbf 0,r10 /* Force it out */
375 sync /* Make sure it's out there */
379 li r7,0x04 /* Set the register */
380 stb r7,0(r10) /* Set the register */
381 dcbf 0,r10 /* Force it out */
382 sync /* Make sure it's out there */
386 li r7,0x44 /* x16 clock, 1 stop bit */
387 stb r7,0(r10) /* Set the register */
388 dcbf 0,r10 /* Force it out */
389 sync /* Make sure it's out there */
393 li r7,0x03 /* Set the register */
394 stb r7,0(r10) /* Set the register */
395 dcbf 0,r10 /* Force it out */
396 sync /* Make sure it's out there */
400 li r7,0xC0 /* 8 bits per char */
401 stb r7,0(r10) /* Set the register */
402 dcbf 0,r10 /* Force it out */
403 sync /* Make sure it's out there */
407 li r7,0x05 /* Set the register */
408 stb r7,0(r10) /* Set the register */
409 dcbf 0,r10 /* Force it out */
410 sync /* Make sure it's out there */
414 li r7,0xE2 /* DTR mode, 8bit/char */
415 stb r7,0(r10) /* Set the register */
416 dcbf 0,r10 /* Force it out */
417 sync /* Make sure it's out there */
421 li r7,0x02 /* Set the register */
422 stb r7,0(r10) /* Set the register */
423 dcbf 0,r10 /* Force it out */
424 sync /* Make sure it's out there */
428 li r7,0x00 /* Vector 0 */
429 stb r7,0(r10) /* Set the register */
430 dcbf 0,r10 /* Force it out */
431 sync /* Make sure it's out there */
435 li r7,0x0A /* Set the register */
436 stb r7,0(r10) /* Set the register */
437 dcbf 0,r10 /* Force it out */
438 sync /* Make sure it's out there */
442 li r7,0x00 /* Clear misc controls */
443 stb r7,0(r10) /* Set the register */
444 dcbf 0,r10 /* Force it out */
445 sync /* Make sure it's out there */
449 li r7,0x0B /* Set the register */
450 stb r7,0(r10) /* Set the register */
451 dcbf 0,r10 /* Force it out */
452 sync /* Make sure it's out there */
456 li r7,0x50 /* B/R gen T/R */
457 stb r7,0(r10) /* Set the register */
458 dcbf 0,r10 /* Force it out */
459 sync /* Make sure it's out there */
463 li r7,0x0C /* Set the register */
464 stb r7,0(r10) /* Set the register */
465 dcbf 0,r10 /* Force it out */
466 sync /* Make sure it's out there */
470 li r7,0x0A /* 9600 baud low */
471 stb r7,0(r10) /* Set the register */
472 dcbf 0,r10 /* Force it out */
473 sync /* Make sure it's out there */
477 li r7,0x0D /* Set the register */
478 stb r7,0(r10) /* Set the register */
479 dcbf 0,r10 /* Force it out */
480 sync /* Make sure it's out there */
484 li r7,0x00 /* 9600 baud high */
485 stb r7,0(r10) /* Set the register */
486 dcbf 0,r10 /* Force it out */
487 sync /* Make sure it's out there */
491 li r7,0x03 /* Set the register */
492 stb r7,0(r10) /* Set the register */
493 dcbf 0,r10 /* Force it out */
494 sync /* Make sure it's out there */
498 li r7,0xC1 /* 8 bits/char, Rx enable */
499 stb r7,0(r10) /* Set the register */
500 dcbf 0,r10 /* Force it out */
501 sync /* Make sure it's out there */
505 li r7,0x05 /* Set the register */
506 stb r7,0(r10) /* Set the register */
507 dcbf 0,r10 /* Force it out */
508 sync /* Make sure it's out there */
512 li r7,0xEA /* 8 bits/char, Tx enable */
513 stb r7,0(r10) /* Set the register */
514 dcbf 0,r10 /* Force it out */
515 sync /* Make sure it's out there */
519 li r7,0x0E /* Set the register */
520 stb r7,0(r10) /* Set the register */
521 dcbf 0,r10 /* Force it out */
522 sync /* Make sure it's out there */
526 li r7,0x01 /* BR rate gen enable */
527 stb r7,0(r10) /* Set the register */
528 dcbf 0,r10 /* Force it out */
529 sync /* Make sure it's out there */
533 li r7,0x0F /* Set the register */
534 stb r7,0(r10) /* Set the register */
535 dcbf 0,r10 /* Force it out */
536 sync /* Make sure it's out there */
540 li r7,0x00 /* ints off */
541 stb r7,0(r10) /* Set the register */
542 dcbf 0,r10 /* Force it out */
543 sync /* Make sure it's out there */
547 li r7,0x10 /* Reset ext/stat ints */
548 stb r7,0(r10) /* Set the register */
549 dcbf 0,r10 /* Force it out */
550 sync /* Make sure it's out there */
554 li r7,0x10 /* Reset ext/stat ints */
555 stb r7,0(r10) /* Set the register */
556 dcbf 0,r10 /* Force it out */
557 sync /* Make sure it's out there */
561 li r7,0x01 /* Set the register */
562 stb r7,0(r10) /* Set the register */
563 dcbf 0,r10 /* Force it out */
564 sync /* Make sure it's out there */
568 li r7,0x10 /* int on Rx, no Tx int enable */
569 stb r7,0(r10) /* Set the register */
570 dcbf 0,r10 /* Force it out */
571 sync /* Make sure it's out there */
575 li r7,0x09 /* Set the register */
576 stb r7,0(r10) /* Set the register */
577 dcbf 0,r10 /* Force it out */
578 sync /* Make sure it's out there */
582 li r7,0x0A /* int on Rx, Tx int enable */
583 stb r7,0(r10) /* Set the register */
584 dcbf 0,r10 /* Force it out */
585 sync /* Master enable, no vector */
589 li r7,0x09 /* Set the register */
590 stb r7,0(r10) /* Set the register */
591 dcbf 0,r10 /* Force it out */
592 sync /* Make sure it's out there */
596 li r7,0x02 /* No vector */
597 stb r7,0(r10) /* Set the register */
598 dcbf 0,r10 /* Force it out */
599 sync /* Master enable, no vector */
603 lbz r7,0(r10) /* Clear interrupts */
604 sync /* Master enable, no vector */
608 wSCCrdy: eieio /* Barricade it */
609 lbz r7,0(r10) /* Get current status */
612 andi. r7,r7,0x04 /* Is transmitter empty? */
613 beq wSCCrdy /* Nope... */
618 mtmsr r8 /* Restore 'rupts and TR */
624 * This routine is used to write debug output to either the modem or printer port.
625 * parm 1 is printer (0) or modem (1); parm 2 is ID (printed directly); parm 3 converted to hex
628 ENTRY(dbgDisp, TAG_NO_FRAME_USED)
630 mr r12,r0 /* Keep R0 pristene */
631 lis r0,HIGH_ADDR(dbgDispCall) /* Top half of dbgDispCall firmware call number */
632 ori r0,r0,LOW_ADDR(dbgDispCall) /* Bottom half */
634 sc /* Go display the stuff */
636 mr r0,r12 /* Restore R0 */
639 /* Here's the low-level part of dbgDisp */
641 ENTRY(dbgDispLL, TAG_NO_FRAME_USED)
643 dbgDispInt: mfmsr r8 /* Save the MSR */
646 lis r10,0xF301 /* (TEST/DEBUG) */
647 ori r10,r10,0x2002 /* (TEST/DEBUG) */
648 dcbf 0,r10 /* (TEST/DEBUG) */
649 sync /* (TEST/DEBUG) */
650 dcbi 0,r10 /* (TEST/DEBUG) */
651 eieio /* (TEST/DEBUG) */
652 li r7,0x35 /* (TEST/DEBUG) */
653 stb r7,4(r10) /* (TEST/DEBUG) */
655 lis r7,10 /* (TEST/DEBUG) */
656 spw6: addi r7,r7,-1 /* (TEST/DEBUG) */
657 mr. r7,r7 /* (TEST/DEBUG) */
658 bne- spw6 /* (TEST/DEBUG) */
659 dcbf 0,r10 /* (TEST/DEBUG) */
660 sync /* (TEST/DEBUG) */
661 dcbi 0,r10 /* (TEST/DEBUG) */
662 eieio /* (TEST/DEBUG) */
665 rlwinm r12,r8,0,28,25 /* Turn off translation */
666 rlwinm r12,r12,0,17,15 /* Turn off interruptions */
668 mflr r11 /* Save the link register */
671 mr r7,r12 /* (TEST/DEBUG) */
672 bl dumpr7 /* (TEST/DEBUG) */
675 mr. r3,r3 /* See if printer or modem */
676 lis r10,0xF301 /* Set the top part */
677 mr r3,r4 /* Copy the ID parameter */
680 mr r9,r12 /* (TEST/DEBUG) */
682 mtmsr r12 /* (TEST/DEBUG) */
683 isync /* (TEST/DEBUG) */
686 mtmsr r8 /* (TEST/DEBUG) */
687 isync /* (TEST/DEBUG) */
690 lis r12,0xF301 /* (TEST/DEBUG) */
691 ori r12,r12,0x2002 /* (TEST/DEBUG) */
693 dcbf 0,r12 /* (TEST/DEBUG) */
694 sync /* (TEST/DEBUG) */
695 dcbi 0,r12 /* (TEST/DEBUG) */
698 xqrw1: eieio /* (TEST/DEBUG) */
699 lbz r7,0(r12) /* (TEST/DEBUG) */
700 dcbi 0,r12 /* (TEST/DEBUG) */
701 sync /* (TEST/DEBUG) */
702 andi. r7,r7,0x04 /* (TEST/DEBUG) */
703 beq xqrw1 /* (TEST/DEBUG) */
705 eieio /* (TEST/DEBUG) */
706 li r7,0x36 /* (TEST/DEBUG) */
707 stb r7,4(r12) /* (TEST/DEBUG) */
709 dcbf 0,r12 /* (TEST/DEBUG) */
710 sync /* (TEST/DEBUG) */
711 dcbi 0,r12 /* (TEST/DEBUG) */
712 eieio /* (TEST/DEBUG) */
715 lis r7,10 /* (TEST/DEBUG) */
716 spw7: addi r7,r7,-1 /* (TEST/DEBUG) */
717 mr. r7,r7 /* (TEST/DEBUG) */
718 bne- spw7 /* (TEST/DEBUG) */
719 dcbf 0,r12 /* (TEST/DEBUG) */
720 sync /* (TEST/DEBUG) */
721 dcbi 0,r12 /* (TEST/DEBUG) */
722 eieio /* (TEST/DEBUG) */
723 mr r12,r9 /* (TEST/DEBUG) */
726 mtmsr r12 /* Smash the MSR */
727 isync /* Make it clean */
730 #if SIMPLESCC && !NOTQUITEASSIMPLE
731 ori r10,r10,0x3010 /* Assume the printer (this is the normal one) */
733 ori r10,r10,0x2000 /* Assume the printer (this is the normal one) */
735 beq+ dbgDprintr /* It sure are... */
736 #if SIMPLESCC && !NOTQUITEASSIMPLE
737 ori r10,r10,0x0020 /* Move it over to the modem port */
739 ori r10,r10,0x0002 /* Move it over to the modem port */
741 #if !NOTQUITEASSIMPLE
742 lis r7,0xF300 /* Address of SCC rounded to 128k */
743 ori r7,r7,0x0032 /* Make it cache inhibited */
744 mtdbatl 3,r7 /* Load DBAT 3 low */
745 lis r7,0xF300 /* Address of SCC rounded to 128k */
746 ori r7,r7,0x0002 /* Make it supervisor only */
747 mtdbatu 3,r7 /* Load DBAT 3 high */
748 ori r12,r12,0x0010 /* Turn on DR */
749 mtmsr r12 /* Smash the MSR */
750 isync /* Make it clean */
757 mr r7,r10 /* (TEST/DEBUG) */
758 bl dumpr7 /* (TEST/DEBUG) */
761 dcbi 0,r10 /* Toss it */
765 lis r12,0xF301 /* (TEST/DEBUG) */
766 ori r12,r12,0x2002 /* (TEST/DEBUG) */
767 dcbf 0,r12 /* (TEST/DEBUG) */
768 sync /* (TEST/DEBUG) */
769 dcbi 0,r12 /* (TEST/DEBUG) */
770 eieio /* (TEST/DEBUG) */
771 li r7,0x37 /* (TEST/DEBUG) */
772 stb r7,4(r12) /* (TEST/DEBUG) */
774 lis r7,12 /* (TEST/DEBUG) */
775 spw8: addi r7,r7,-1 /* (TEST/DEBUG) */
776 mr. r7,r7 /* (TEST/DEBUG) */
777 bne- spw8 /* (TEST/DEBUG) */
778 dcbf 0,r12 /* (TEST/DEBUG) */
779 sync /* (TEST/DEBUG) */
780 dcbi 0,r12 /* (TEST/DEBUG) */
781 eieio /* (TEST/DEBUG) */
785 /* Print the ID parameter */
787 lis r12,HIGH_ADDR(fwdisplock) /* Get the display locker outer */
788 ori r12,r12,LOW_ADDR(fwdisplock) /* Last part */
792 ddwait0: lwarx r7,0,r12 /* Get the lock */
793 mr. r7,r7 /* Is it locked? */
794 bne- ddwait0 /* Yup... */
795 stwcx. r12,0,r12 /* Try to get it */
796 bne- ddwait0 /* Nope, start all over... */
799 dcbf 0,r10 /* (TEST/DEBUG) */
800 sync /* (TEST/DEBUG) */
801 dcbi 0,r10 /* (TEST/DEBUG) */
802 eieio /* (TEST/DEBUG) */
803 li r7,0x38 /* (TEST/DEBUG) */
804 stb r7,6(r10) /* (TEST/DEBUG) */
806 lis r7,10 /* (TEST/DEBUG) */
807 spwa: addi r7,r7,-1 /* (TEST/DEBUG) */
808 mr. r7,r7 /* (TEST/DEBUG) */
809 bne- spwa /* (TEST/DEBUG) */
810 dcbf 0,r10 /* (TEST/DEBUG) */
811 sync /* (TEST/DEBUG) */
812 dcbi 0,r10 /* (TEST/DEBUG) */
813 eieio /* (TEST/DEBUG) */
816 rlwinm r3,r3,8,0,31 /* Get the first character */
817 bl dbgDchar /* Print it */
818 rlwinm r3,r3,8,0,31 /* Get the second character */
819 bl dbgDchar /* Print it */
820 rlwinm r3,r3,8,0,31 /* Get the third character */
821 bl dbgDchar /* Print it */
822 rlwinm r3,r3,8,0,31 /* Get the fourth character */
823 bl dbgDchar /* Print it */
825 li r3,0x20 /* Get a space for a separator */
826 bl dbgDchar /* Print it */
827 bl dbg4byte /* Print register 5 in hex */
829 li r3,0x0A /* Linefeed */
830 bl dbgDchar /* Send it */
831 li r3,0x0D /* Carriage return */
832 bl dbgDchar /* Send it */
834 mtlr r11 /* Get back the return */
835 #if !SIMPLESCC && !NOTQUITEASSIMPLE
836 li r7,0 /* Get a zero */
837 mtdbatu 3,r7 /* Invalidate DBAT 3 upper */
838 mtdbatl 3,r7 /* Invalidate DBAT 3 lower */
840 lis r12,HIGH_ADDR(fwdisplock) /* Get the display locker outer */
841 li r7,0 /* Get a zero */
842 ori r12,r12,LOW_ADDR(fwdisplock) /* Last part */
844 stw r7,0(r12) /* Release the display lock */
845 mtmsr r8 /* Restore the MSR */
846 isync /* Wait for it */
850 dbg4byte: mflr r12 /* Save the return */
852 lis r4,HIGH_ADDR(hexTab) /* Point to the top of table */
853 li r6,8 /* Set number of hex digits to dump */
854 ori r4,r4,LOW_ADDR(hexTab) /* Point to the bottom of table */
856 dbgDnext: rlwinm r5,r5,4,0,31 /* Rotate a nybble */
857 subi r6,r6,1 /* Back down the count */
858 rlwinm r3,r5,0,28,31 /* Isolate the last nybble */
859 lbzx r3,r4,r3 /* Convert to ascii */
860 bl dbgDchar /* Print it */
861 mr. r6,r6 /* Any more? */
862 bne+ dbgDnext /* Convert 'em all... */
864 li r3,0x20 /* Space */
865 bl dbgDchar /* Send it */
866 mtlr r12 /* Restore LR */
869 /* Write to whichever serial port. Try to leave it clean, but not too hard (this is a hack) */
872 #if SIMPLESCC && !NOTQUITEASSIMPLE
873 stb r3,0(r10) /* ? */
874 dcbf 0,r10 /* Force it out */
875 sync /* Make sure it's out there */
877 lis r7,3 /* Get enough for about 1ms */
879 dbgDchar0: addi r7,r7,-1 /* Count down */
880 mr. r7,r7 /* Waited long enough? */
881 bgt+ dbgDchar0 /* Nope... */
886 stb r7,0(r10) /* ? */
887 dcbf 0,r10 /* Force it out */
888 sync /* Make sure it's out there */
892 lbz r7,0(r10) /* ? */
893 dcbi 0,r10 /* Force it out */
894 sync /* kill it off */
898 stb r7,0(r10) /* ? */
899 dcbf 0,r10 /* Force it out */
900 sync /* Make sure it's out there */
904 lbz r7,0(r10) /* ? */
905 dcbi 0,r10 /* Force it out */
906 sync /* kill it off */
910 qrw1: eieio /* Barricade it */
911 lbz r7,0(r10) /* ? */
914 andi. r7,r7,0x04 /* ? */
915 beq qrw1 /* Nope... */
919 stb r3,4(r10) /* ? */
920 dcbf 0,r10 /* Force it out */
921 sync /* Make sure it's out there */
925 qrw2: eieio /* Barricade it */
926 lbz r7,0(r10) /* ? */
929 andi. r7,r7,0x04 /* ? */
930 beq qrw2 /* Nope... */
935 stb r7,0(r10) /* ? */
936 dcbf 0,r10 /* Force it out */
937 sync /* Make sure it's out there */
941 lbz r7,0(r10) /* ? */
942 dcbi 0,r10 /* Force it out */
943 sync /* kill it off */
947 lis r7,0x0080 /* ? */
948 lis r9,0xF300 /* ? */
949 ori r7,r7,0x010F /* ? */
950 stw r7,0x28(r9) /* ? */
951 dcbf 0,r10 /* Force it out */
952 sync /* Make sure it's out there */
957 #if !SIMPLESCC && !NOTQUITEASSIMPLE
958 rlwinm r9,r10,0,0,29 /* Get channel a */
959 eieio /* Barricade it */
963 eieio /* Barricade it */
967 eieio /* Barricade it */
970 dchrw1: eieio /* Barricade it */
971 lbz r7,0(r10) /* ? */
972 andi. r7,r7,0x04 /* ? */
973 beq dchrw1 /* Nope... */
975 stb r3,4(r10) /* ? */
976 sync /* Make sure it's there */
977 eieio /* Don't get confused */
979 dchrw2: eieio /* Barricade it */
980 lbz r7,0(r10) /* ? */
981 andi. r7,r7,0x04 /* ? */
982 beq dchrw2 /* Nope... */
984 eieio /* Avoid confusion */
985 lbz r7,0(r10) /* ? */
986 andi. r7,r7,0x40 /* ? */
987 beq+ nounder /* Nope... */
989 eieio /* Avoid confusion */
991 stb r7,0(r10) /* ? */
993 nounder: eieio /* Avoid confusion */
995 stb r7,0(r10) /* ? */
997 eieio /* Avoid confusion */
1001 eieio /* Avoid confusion */
1003 stb r7,0(r10) /* ? */
1005 eieio /* Avoid confusion */
1007 stb r7,0(r10) /* ? */
1008 eieio /* Avoid confusion */
1016 hexTab: STRINGD "0123456789ABCDEF" /* Convert hex numbers to printable hex */
1020 * Dumps all the registers in the savearea in R13
1024 ENTRY(dbgRegsLL, TAG_NO_FRAME_USED)
1027 bl dbgRegsCm /* Join on up... */
1030 * Note that we bypass the normal return 'cause we don't wanna mess up R3
1032 mfsprg r11,0 /* Get the per_proc */
1033 lwz r11,PP_TEMPWORK1(r11) /* Get our return point */
1034 li r3,T_IN_VAIN /* Tell the vector handler that we took care of it */
1035 mtlr r11 /* Set the return */
1036 blr /* Bye, dudes... */
1038 ENTRY(dbgRegs, TAG_NO_FRAME_USED)
1040 dbgRegsCm: mfmsr r8 /* Save the MSR */
1042 rlwinm r12,r8,0,28,25 /* Turn off translation */
1043 lis r10,0xF301 /* Set the top part */
1044 rlwinm r12,r12,0,17,15 /* Turn off interruptions */
1045 mtmsr r12 /* Smash the MSR */
1046 isync /* Make it clean */
1047 #if SIMPLESCC && !NOTQUITEASSIMPLE
1048 ori r10,r10,0x3010 /* ? */
1050 ori r10,r10,0x2000 /* ? */
1052 mflr r11 /* Save the link register */
1053 beq+ dbgDprints /* It sure are... */
1054 #if SIMPLESCC && !NOTQUITEASSIMPLE
1055 ori r10,r10,0x0020 /* ? */
1057 ori r10,r10,0x0002 /* ? */
1059 dcbf 0,r10 /* Insure it is out */
1061 dcbi 0,r10 /* Toss it */
1062 #if !NOTQUITEASSIMPLE
1063 lis r7,0xF300 /* ? */
1064 ori r7,r7,0x0032 /* ? */
1065 mtdbatl 3,r7 /* ? */
1066 lis r7,0xF300 /* ? */
1067 ori r7,r7,0x0002 /* ? */
1068 mtdbatu 3,r7 /* ? */
1069 ori r12,r12,0x0010 /* ? */
1076 lis r3,HIGH_ADDR(fwdisplock) /* Get the display locker outer */
1077 ori r3,r3,LOW_ADDR(fwdisplock) /* Last part */
1080 ddwait1: lwarx r5,0,r3 /* Get the lock */
1081 mr. r5,r5 /* Is it locked? */
1082 bne- ddwait1 /* Yup... */
1083 stwcx. r3,0,r3 /* Try to get it */
1084 bne- ddwait1 /* Nope, start all over... */
1086 li r3,0x52 /* Print eyecatcher */
1087 bl dbgDchar /* Send it */
1088 li r3,0x65 /* Print eyecatcher */
1089 bl dbgDchar /* Send it */
1090 li r3,0x67 /* Print eyecatcher */
1091 bl dbgDchar /* Send it */
1092 li r3,0x73 /* Print eyecatcher */
1093 bl dbgDchar /* Send it */
1094 li r3,0x20 /* Print eyecatcher */
1095 bl dbgDchar /* Send it */
1097 lwz r5,saver0(r13) /* Do register */
1098 bl dbg4byte /* Print */
1099 lwz r5,saver1(r13) /* Do register */
1100 bl dbg4byte /* Print */
1101 lwz r5,saver2(r13) /* Do register */
1102 bl dbg4byte /* Print */
1103 lwz r5,saver3(r13) /* Do register */
1104 bl dbg4byte /* Print */
1105 li r3,0x0A /* Linefeed */
1106 bl dbgDchar /* Send it */
1107 li r3,0x0D /* Carriage return */
1108 bl dbgDchar /* Send it */
1110 li r3,0x20 /* Print eyecatcher */
1111 bl dbgDchar /* Send it */
1112 li r3,0x20 /* Print eyecatcher */
1113 bl dbgDchar /* Send it */
1114 li r3,0x20 /* Print eyecatcher */
1115 bl dbgDchar /* Send it */
1116 li r3,0x20 /* Print eyecatcher */
1117 bl dbgDchar /* Send it */
1118 li r3,0x20 /* Print eyecatcher */
1119 bl dbgDchar /* Send it */
1120 lwz r5,saver4(r13) /* Do register */
1121 bl dbg4byte /* Print */
1122 lwz r5,saver5(r13) /* Do register */
1123 bl dbg4byte /* Print */
1124 lwz r5,saver6(r13) /* Do register */
1125 bl dbg4byte /* Print */
1126 lwz r5,saver7(r13) /* Do register */
1127 bl dbg4byte /* Print */
1128 li r3,0x0A /* Linefeed */
1129 bl dbgDchar /* Send it */
1130 li r3,0x0D /* Carriage return */
1131 bl dbgDchar /* Send it */
1133 li r3,0x20 /* Print eyecatcher */
1134 bl dbgDchar /* Send it */
1135 li r3,0x20 /* Print eyecatcher */
1136 bl dbgDchar /* Send it */
1137 li r3,0x20 /* Print eyecatcher */
1138 bl dbgDchar /* Send it */
1139 li r3,0x20 /* Print eyecatcher */
1140 bl dbgDchar /* Send it */
1141 li r3,0x20 /* Print eyecatcher */
1142 bl dbgDchar /* Send it */
1143 lwz r5,saver8(r13) /* Do register */
1144 bl dbg4byte /* Print */
1145 lwz r5,saver9(r13) /* Do register */
1146 bl dbg4byte /* Print */
1147 lwz r5,saver10(r13) /* Do register */
1148 bl dbg4byte /* Print */
1149 lwz r5,saver11(r13) /* Do register */
1150 bl dbg4byte /* Print */
1151 li r3,0x0A /* Linefeed */
1152 bl dbgDchar /* Send it */
1153 li r3,0x0D /* Carriage return */
1154 bl dbgDchar /* Send it */
1156 li r3,0x20 /* Print eyecatcher */
1157 bl dbgDchar /* Send it */
1158 li r3,0x20 /* Print eyecatcher */
1159 bl dbgDchar /* Send it */
1160 li r3,0x20 /* Print eyecatcher */
1161 bl dbgDchar /* Send it */
1162 li r3,0x20 /* Print eyecatcher */
1163 bl dbgDchar /* Send it */
1164 li r3,0x20 /* Print eyecatcher */
1165 bl dbgDchar /* Send it */
1166 lwz r5,saver12(r13) /* Do register */
1167 bl dbg4byte /* Print */
1168 lwz r5,saver13(r13) /* Do register */
1169 bl dbg4byte /* Print */
1170 lwz r5,saver14(r13) /* Do register */
1171 bl dbg4byte /* Print */
1172 lwz r5,saver15(r13) /* Do register */
1173 bl dbg4byte /* Print */
1174 li r3,0x0A /* Linefeed */
1175 bl dbgDchar /* Send it */
1176 li r3,0x0D /* Carriage return */
1177 bl dbgDchar /* Send it */
1179 li r3,0x20 /* Print eyecatcher */
1180 bl dbgDchar /* Send it */
1181 li r3,0x20 /* Print eyecatcher */
1182 bl dbgDchar /* Send it */
1183 li r3,0x20 /* Print eyecatcher */
1184 bl dbgDchar /* Send it */
1185 li r3,0x20 /* Print eyecatcher */
1186 bl dbgDchar /* Send it */
1187 li r3,0x20 /* Print eyecatcher */
1188 bl dbgDchar /* Send it */
1189 lwz r5,saver16(r13) /* Do register */
1190 bl dbg4byte /* Print */
1191 lwz r5,saver17(r13) /* Do register */
1192 bl dbg4byte /* Print */
1193 lwz r5,saver18(r13) /* Do register */
1194 bl dbg4byte /* Print */
1195 lwz r5,saver19(r13) /* Do register */
1196 bl dbg4byte /* Print */
1197 li r3,0x0A /* Linefeed */
1198 bl dbgDchar /* Send it */
1199 li r3,0x0D /* Carriage return */
1200 bl dbgDchar /* Send it */
1202 li r3,0x20 /* Print eyecatcher */
1203 bl dbgDchar /* Send it */
1204 li r3,0x20 /* Print eyecatcher */
1205 bl dbgDchar /* Send it */
1206 li r3,0x20 /* Print eyecatcher */
1207 bl dbgDchar /* Send it */
1208 li r3,0x20 /* Print eyecatcher */
1209 bl dbgDchar /* Send it */
1210 li r3,0x20 /* Print eyecatcher */
1211 bl dbgDchar /* Send it */
1212 lwz r5,saver20(r13) /* Do register */
1213 bl dbg4byte /* Print */
1214 lwz r5,saver21(r13) /* Do register */
1215 bl dbg4byte /* Print */
1216 lwz r5,saver22(r13) /* Do register */
1217 bl dbg4byte /* Print */
1218 lwz r5,saver23(r13) /* Do register */
1219 bl dbg4byte /* Print */
1220 li r3,0x0A /* Linefeed */
1221 bl dbgDchar /* Send it */
1222 li r3,0x0D /* Carriage return */
1223 bl dbgDchar /* Send it */
1225 li r3,0x20 /* Print eyecatcher */
1226 bl dbgDchar /* Send it */
1227 li r3,0x20 /* Print eyecatcher */
1228 bl dbgDchar /* Send it */
1229 li r3,0x20 /* Print eyecatcher */
1230 bl dbgDchar /* Send it */
1231 li r3,0x20 /* Print eyecatcher */
1232 bl dbgDchar /* Send it */
1233 li r3,0x20 /* Print eyecatcher */
1234 bl dbgDchar /* Send it */
1235 lwz r5,saver24(r13) /* Do register */
1236 bl dbg4byte /* Print */
1237 lwz r5,saver25(r13) /* Do register */
1238 bl dbg4byte /* Print */
1239 lwz r5,saver26(r13) /* Do register */
1240 bl dbg4byte /* Print */
1241 lwz r5,saver27(r13) /* Do register */
1242 bl dbg4byte /* Print */
1243 li r3,0x0A /* Linefeed */
1244 bl dbgDchar /* Send it */
1245 li r3,0x0D /* Carriage return */
1246 bl dbgDchar /* Send it */
1248 li r3,0x20 /* Print eyecatcher */
1249 bl dbgDchar /* Send it */
1250 li r3,0x20 /* Print eyecatcher */
1251 bl dbgDchar /* Send it */
1252 li r3,0x20 /* Print eyecatcher */
1253 bl dbgDchar /* Send it */
1254 li r3,0x20 /* Print eyecatcher */
1255 bl dbgDchar /* Send it */
1256 li r3,0x20 /* Print eyecatcher */
1257 bl dbgDchar /* Send it */
1258 lwz r5,saver28(r13) /* Do register */
1259 bl dbg4byte /* Print */
1260 lwz r5,saver29(r13) /* Do register */
1261 bl dbg4byte /* Print */
1262 lwz r5,saver30(r13) /* Do register */
1263 bl dbg4byte /* Print */
1264 lwz r5,saver31(r13) /* Do register */
1265 bl dbg4byte /* Print */
1266 li r3,0x0A /* Linefeed */
1267 bl dbgDchar /* Send it */
1268 li r3,0x0D /* Carriage return */
1269 bl dbgDchar /* Send it */
1271 /* Segment registers */
1273 li r3,0x53 /* Print eyecatcher */
1274 bl dbgDchar /* Send it */
1275 li r3,0x65 /* Print eyecatcher */
1276 bl dbgDchar /* Send it */
1277 li r3,0x67 /* Print eyecatcher */
1278 bl dbgDchar /* Send it */
1279 li r3,0x73 /* Print eyecatcher */
1280 bl dbgDchar /* Send it */
1281 li r3,0x20 /* Print eyecatcher */
1282 bl dbgDchar /* Send it */
1284 lwz r5,savesr0(r13) /* Do register */
1285 bl dbg4byte /* Print */
1286 lwz r5,savesr1(r13) /* Do register */
1287 bl dbg4byte /* Print */
1288 lwz r5,savesr2(r13) /* Do register */
1289 bl dbg4byte /* Print */
1290 lwz r5,savesr3(r13) /* Do register */
1291 bl dbg4byte /* Print */
1292 li r3,0x0A /* Linefeed */
1293 bl dbgDchar /* Send it */
1294 li r3,0x0D /* Carriage return */
1295 bl dbgDchar /* Send it */
1297 li r3,0x20 /* Print eyecatcher */
1298 bl dbgDchar /* Send it */
1299 li r3,0x20 /* Print eyecatcher */
1300 bl dbgDchar /* Send it */
1301 li r3,0x20 /* Print eyecatcher */
1302 bl dbgDchar /* Send it */
1303 li r3,0x20 /* Print eyecatcher */
1304 bl dbgDchar /* Send it */
1305 li r3,0x20 /* Print eyecatcher */
1306 bl dbgDchar /* Send it */
1307 lwz r5,savesr4(r13) /* Do register */
1308 bl dbg4byte /* Print */
1309 lwz r5,savesr5(r13) /* Do register */
1310 bl dbg4byte /* Print */
1311 lwz r5,savesr6(r13) /* Do register */
1312 bl dbg4byte /* Print */
1313 lwz r5,savesr7(r13) /* Do register */
1314 bl dbg4byte /* Print */
1315 li r3,0x0A /* Linefeed */
1316 bl dbgDchar /* Send it */
1317 li r3,0x0D /* Carriage return */
1318 bl dbgDchar /* Send it */
1320 li r3,0x20 /* Print eyecatcher */
1321 bl dbgDchar /* Send it */
1322 li r3,0x20 /* Print eyecatcher */
1323 bl dbgDchar /* Send it */
1324 li r3,0x20 /* Print eyecatcher */
1325 bl dbgDchar /* Send it */
1326 li r3,0x20 /* Print eyecatcher */
1327 bl dbgDchar /* Send it */
1328 li r3,0x20 /* Print eyecatcher */
1329 bl dbgDchar /* Send it */
1330 lwz r5,savesr8(r13) /* Do register */
1331 bl dbg4byte /* Print */
1332 lwz r5,savesr9(r13) /* Do register */
1333 bl dbg4byte /* Print */
1334 lwz r5,savesr10(r13) /* Do register */
1335 bl dbg4byte /* Print */
1336 lwz r5,savesr11(r13) /* Do register */
1337 bl dbg4byte /* Print */
1338 li r3,0x0A /* Linefeed */
1339 bl dbgDchar /* Send it */
1340 li r3,0x0D /* Carriage return */
1341 bl dbgDchar /* Send it */
1343 li r3,0x20 /* Print eyecatcher */
1344 bl dbgDchar /* Send it */
1345 li r3,0x20 /* Print eyecatcher */
1346 bl dbgDchar /* Send it */
1347 li r3,0x20 /* Print eyecatcher */
1348 bl dbgDchar /* Send it */
1349 li r3,0x20 /* Print eyecatcher */
1350 bl dbgDchar /* Send it */
1351 li r3,0x20 /* Print eyecatcher */
1352 bl dbgDchar /* Send it */
1353 lwz r5,savesr12(r13) /* Do register */
1354 bl dbg4byte /* Print */
1355 lwz r5,savesr13(r13) /* Do register */
1356 bl dbg4byte /* Print */
1357 lwz r5,savesr14(r13) /* Do register */
1358 bl dbg4byte /* Print */
1359 lwz r5,savesr15(r13) /* Do register */
1360 bl dbg4byte /* Print */
1361 li r3,0x0A /* Linefeed */
1362 bl dbgDchar /* Send it */
1363 li r3,0x0D /* Carriage return */
1364 bl dbgDchar /* Send it */
1366 li r3,0x30 /* Print eyecatcher */
1367 bl dbgDchar /* Send it */
1368 li r3,0x31 /* Print eyecatcher */
1369 bl dbgDchar /* Send it */
1370 li r3,0x64 /* Print eyecatcher */
1371 bl dbgDchar /* Send it */
1372 li r3,0x64 /* Print eyecatcher */
1373 bl dbgDchar /* Send it */
1374 li r3,0x20 /* Print eyecatcher */
1375 bl dbgDchar /* Send it */
1376 lwz r5,savesrr0(r13) /* Do register */
1377 bl dbg4byte /* Print */
1378 lwz r5,savesrr1(r13) /* Do register */
1379 bl dbg4byte /* Print */
1380 lwz r5,savedar(r13) /* Do register */
1381 bl dbg4byte /* Print */
1382 lwz r5,savedsisr(r13) /* Do register */
1383 bl dbg4byte /* Print */
1384 li r3,0x0A /* Linefeed */
1385 bl dbgDchar /* Send it */
1386 li r3,0x0D /* Carriage return */
1387 bl dbgDchar /* Send it */
1389 li r3,0x20 /* Print eyecatcher */
1390 bl dbgDchar /* Send it */
1391 li r3,0x6C /* Print eyecatcher */
1392 bl dbgDchar /* Send it */
1393 li r3,0x63 /* Print eyecatcher */
1394 bl dbgDchar /* Send it */
1395 li r3,0x63 /* Print eyecatcher */
1396 bl dbgDchar /* Send it */
1397 li r3,0x20 /* Print eyecatcher */
1398 bl dbgDchar /* Send it */
1399 lwz r5,savelr(r13) /* Do register */
1400 bl dbg4byte /* Print */
1401 lwz r5,savecr(r13) /* Do register */
1402 bl dbg4byte /* Print */
1403 lwz r5,savectr(r13) /* Do register */
1404 bl dbg4byte /* Print */
1405 li r3,0x0A /* Linefeed */
1406 bl dbgDchar /* Send it */
1407 li r3,0x0D /* Carriage return */
1408 bl dbgDchar /* Send it */
1409 mtlr r11 /* Get back the return */
1411 #if !SIMPLESCC && !NOTQUITEASSIMPLE
1412 li r7,0 /* Get a zero */
1413 mtdbatu 3,r7 /* Invalidate DBAT 3 upper */
1414 mtdbatl 3,r7 /* Invalidate DBAT 3 lower */
1416 lis r3,HIGH_ADDR(fwdisplock) /* Get the display locker outer */
1417 li r7,0 /* Get a zero */
1418 ori r3,r3,LOW_ADDR(fwdisplock) /* Last part */
1419 stw r7,0(r3) /* Clear display lock */
1420 mtmsr r8 /* Restore the MSR */
1421 isync /* Wait for it */
1426 * Used for debugging to leave stuff in 0x380-0x3FF (128 bytes).
1427 * Mapping is V=R. Stores and loads are real.
1430 ENTRY(dbgCkpt, TAG_NO_FRAME_USED)
1432 mr r12,r0 /* Keep R0 pristene */
1433 lis r0,HIGH_ADDR(dbgCkptCall) /* Top half of dbgCkptCall firmware call number */
1434 ori r0,r0,LOW_ADDR(dbgCkptCall) /* Bottom half */
1436 sc /* Go stash the stuff */
1438 mr r0,r12 /* Restore R0 */
1441 /* Here's the low-level part of dbgCkpt */
1443 ENTRY(dbgCkptLL, TAG_NO_FRAME_USED)
1445 li r12,0x380 /* Point to output area */
1446 li r1,32 /* Get line size */
1447 dcbz 0,r12 /* Make sure we don't fetch a cache line */
1449 lwz r4,0x00(r3) /* Load up storage to checkpoint */
1451 dcbt r1,r3 /* Start in the next line */
1453 lwz r5,0x04(r3) /* Load up storage to checkpoint */
1454 lwz r6,0x08(r3) /* Load up storage to checkpoint */
1455 lwz r7,0x0C(r3) /* Load up storage to checkpoint */
1456 lwz r8,0x10(r3) /* Load up storage to checkpoint */
1457 lwz r9,0x14(r3) /* Load up storage to checkpoint */
1458 lwz r10,0x18(r3) /* Load up storage to checkpoint */
1459 lwz r11,0x1C(r3) /* Load up storage to checkpoint */
1461 add r3,r3,r1 /* Bump input */
1463 stw r4,0x00(r12) /* Store it */
1464 stw r5,0x04(r12) /* Store it */
1465 stw r6,0x08(r12) /* Store it */
1466 stw r7,0x0C(r12) /* Store it */
1467 stw r8,0x10(r12) /* Store it */
1468 stw r9,0x14(r12) /* Store it */
1469 stw r10,0x18(r12) /* Store it */
1470 stw r11,0x1C(r12) /* Store it */
1472 dcbz r1,r12 /* Clear the next line */
1473 add r12,r12,r1 /* Point to next output line */
1475 lwz r4,0x00(r3) /* Load up storage to checkpoint */
1476 lwz r5,0x04(r3) /* Load up storage to checkpoint */
1477 lwz r6,0x08(r3) /* Load up storage to checkpoint */
1478 lwz r7,0x0C(r3) /* Load up storage to checkpoint */
1479 lwz r8,0x10(r3) /* Load up storage to checkpoint */
1480 lwz r9,0x14(r3) /* Load up storage to checkpoint */
1481 lwz r10,0x18(r3) /* Load up storage to checkpoint */
1482 lwz r11,0x1C(r3) /* Load up storage to checkpoint */
1484 dcbt r1,r3 /* Touch the next line */
1485 add r3,r3,r1 /* Point to next input line */
1487 stw r4,0x00(r12) /* Store it */
1488 stw r5,0x04(r12) /* Store it */
1489 stw r6,0x08(r12) /* Store it */
1490 stw r7,0x0C(r12) /* Store it */
1491 stw r8,0x10(r12) /* Store it */
1492 stw r9,0x14(r12) /* Store it */
1493 stw r10,0x18(r12) /* Store it */
1494 stw r11,0x1C(r12) /* Store it */
1496 dcbz r1,r12 /* Clear the next line */
1497 add r12,r12,r1 /* Point to next output line */
1499 lwz r4,0x00(r3) /* Load up storage to checkpoint */
1500 lwz r5,0x04(r3) /* Load up storage to checkpoint */
1501 lwz r6,0x08(r3) /* Load up storage to checkpoint */
1502 lwz r7,0x0C(r3) /* Load up storage to checkpoint */
1503 lwz r8,0x10(r3) /* Load up storage to checkpoint */
1504 lwz r9,0x14(r3) /* Load up storage to checkpoint */
1505 lwz r10,0x18(r3) /* Load up storage to checkpoint */
1506 lwz r11,0x1C(r3) /* Load up storage to checkpoint */
1508 dcbt r1,r3 /* Touch the next line */
1509 add r3,r3,r1 /* Point to next input line */
1511 stw r4,0x00(r12) /* Store it */
1512 stw r5,0x04(r12) /* Store it */
1513 stw r6,0x08(r12) /* Store it */
1514 stw r7,0x0C(r12) /* Store it */
1515 stw r8,0x10(r12) /* Store it */
1516 stw r9,0x14(r12) /* Store it */
1517 stw r10,0x18(r12) /* Store it */
1518 stw r11,0x1C(r12) /* Store it */
1520 dcbz r1,r12 /* Clear the next line */
1521 add r12,r12,r1 /* Point to next output line */
1523 lwz r4,0x00(r3) /* Load up storage to checkpoint */
1524 lwz r5,0x04(r3) /* Load up storage to checkpoint */
1525 lwz r6,0x08(r3) /* Load up storage to checkpoint */
1526 lwz r7,0x0C(r3) /* Load up storage to checkpoint */
1527 lwz r8,0x10(r3) /* Load up storage to checkpoint */
1528 lwz r9,0x14(r3) /* Load up storage to checkpoint */
1529 lwz r10,0x18(r3) /* Load up storage to checkpoint */
1530 lwz r11,0x1C(r3) /* Load up storage to checkpoint */
1532 stw r4,0x00(r12) /* Store it */
1533 stw r5,0x04(r12) /* Store it */
1534 stw r6,0x08(r12) /* Store it */
1535 stw r7,0x0C(r12) /* Store it */
1536 stw r8,0x10(r12) /* Store it */
1537 stw r9,0x14(r12) /* Store it */
1538 stw r10,0x18(r12) /* Store it */
1539 stw r11,0x1C(r12) /* Store it */
1545 * Do Preemption. Forces a T_PREEMPT trap to allow a preemption to occur.
1548 ENTRY(DoPreemptLL, TAG_NO_FRAME_USED)
1550 mfsprg r11,0 /* Get the per_proc address */
1551 lwz r11,PP_TEMPWORK1(r11) /* Restore the return address */
1552 li r3,T_PREEMPT /* Set preemption interrupt value */
1553 mtlr r11 /* Restore the LR */
1554 stw r3,saveexception(r13) /* Modify the exception type to preemption */
1555 blr /* Return to interrupt handler */
1559 * Force 'rupt handler to dispatch with new context
1560 * R3 at the call contains the new savearea.
1561 * R4 at the call contains a return code to pass back in R3.
1562 * Forces a T_CSWITCH
1565 ENTRY(SwitchContextLL, TAG_NO_FRAME_USED)
1567 mfsprg r11,0 /* Get the per_proc address */
1568 lwz r11,PP_TEMPWORK1(r11) /* Restore the return address */
1569 li r3,T_CSWITCH /* Set context switch value */
1570 mtlr r11 /* Restore the LR */
1571 stw r3,saveexception(r13) /* Modify the exception type to switch context */
1572 blr /* Return to interrupt handler */
1576 * Create a fake I/O 'rupt.
1577 * Forces a T_INTERRUPT trap to pretend that an actual I/O interrupt occurred.
1580 ENTRY(CreateFakeIOLL, TAG_NO_FRAME_USED)
1582 mfsprg r11,0 /* Get the per_proc address */
1583 lwz r11,PP_TEMPWORK1(r11) /* Restore the return address */
1584 li r3,T_INTERRUPT /* Set external interrupt value */
1585 mtlr r11 /* Restore the LR */
1586 stw r3,saveexception(r13) /* Modify the exception type to external */
1587 blr /* Return to interrupt handler */
1590 * Create a shutdown context
1591 * Forces a T_SHUTDOWN trap.
1594 ENTRY(CreateShutdownCTXLL, TAG_NO_FRAME_USED)
1596 mfsprg r11,0 /* Get the per_proc address */
1597 lwz r11,PP_TEMPWORK1(r11) /* Restore the return address */
1598 li r3,T_SHUTDOWN /* Set external interrupt value */
1599 mtlr r11 /* Restore the LR */
1600 stw r3,saveexception(r13) /* Modify the exception type to external */
1601 blr /* Return to interrupt handler */
1604 * Create a fake decrementer 'rupt.
1605 * Forces a T_DECREMENTER trap to pretend that an actual decrementer interrupt occurred.
1608 ENTRY(CreateFakeDECLL, TAG_NO_FRAME_USED)
1610 mfsprg r11,0 /* Get the per_proc address */
1611 lwz r11,PP_TEMPWORK1(r11) /* Restore the return address */
1612 li r3,T_DECREMENTER /* Set decrementer interrupt value */
1613 mtlr r11 /* Restore the LR */
1614 stw r3,saveexception(r13) /* Modify the exception type to external */
1615 blr /* Return to interrupt handler */
1621 ENTRY(DoChokeLL, TAG_NO_FRAME_USED)
1623 mfsprg r11,0 ; Get the per_proc address
1624 lwz r11,PP_TEMPWORK1(r11) ; Restore the return address
1625 li r3,T_CHOKE ; Set external interrupt value
1626 mtlr r11 ; Restore the LR
1627 stw r3,saveexception(r13) ; Modify the exception type to external
1628 blr ; Return to interrupt handler
1631 * Set the low level trace flags
1634 ENTRY(LLTraceSet, TAG_NO_FRAME_USED)
1636 mfsprg r6,2 ; Get feature flags
1637 mfmsr r12 /* Get the MSR */
1638 mr r4,r3 /* Save the new value */
1639 andi. r3,r12,0x01C0 /* Clear interrupts and translation */
1640 mtcrf 0x04,r6 ; Set the features
1641 bt pfNoMSRirb,ltsNoMSR ; Use MSR...
1643 mtmsr r3 ; Translation and all off
1644 isync ; Toss prefetch
1647 ltsNoMSR: li r0,loadMSR ; Get the MSR setter SC
1652 lis r5,hi16(EXT(trcWork)) ; Get trace area
1653 ori r5,r5,lo16(EXT(trcWork)) ; again
1655 lwz r3,traceMask(r5) /* Get the old trace flags to pass back */
1656 stw r4,traceMask(r5) /* Replace with the new ones */
1658 mtmsr r12 /* Restore the MSR */
1666 ; ***************************************************************************
1668 ; ----------------- Grateful Deb ----------------
1670 ; Debugging: direct draw into main screen menu bar
1672 ; Takes R4 value, converts it to hex characters and displays it.
1674 ; Gotta make sure the DCBST is done to force the pixels from the cache.
1676 ; Position is taken as column, row (0 based) from R3.
1677 ; Characters are from hexfont, and are 16x16 pixels.
1679 ; Only works with two processors so far
1682 ; ***************************************************************************
1685 #define GDfromright 20
1686 #define GDfontsize 16
1688 ENTRY(GratefulDeb,TAG_NO_FRAME_USED)
1689 mfspr r6,pir /* Get the PIR */
1690 lis r5,HIGH_ADDR(EXT(GratefulDebWork)) /* Point to our work area */
1691 rlwinm r6,r6,8,23,23 /* Get part of the offset to our processors area */
1692 ori r5,r5,LOW_ADDR(EXT(GratefulDebWork)) /* Start building the address */
1693 rlwimi r6,r6,2,21,21 /* Get the rest of the offset to our processors area */
1694 add r6,r6,r5 /* Point at our CPU's work area */
1695 mfmsr r5 /* Get that MSR */
1696 stmw r0,GDsave(r6) /* Save all registers */
1697 lwz r10,GDready(r6) /* See if we're all ready to go */
1698 ori r0,r5,0x2000 /* Turn on the floating point */
1699 mr r31,r6 /* Get a more sane base register */
1700 mr. r10,r10 /* Are we all set? */
1701 mtmsr r0 /* Enable floating point */
1704 stfd f0,GDfp0(r31) /* Save FP */
1705 stfd f1,GDfp1(r31) /* Save FP */
1706 stfd f2,GDfp2(r31) /* Save FP */
1707 stfd f3,GDfp3(r31) /* Save FP */
1709 beq- GDbailout /* Go and bail... */
1711 rlwinm r25,r3,0,16,31 /* Isolate just the row number */
1712 lwz r28,GDtopleft(r31) /* Get the physical address of our line 0 */
1713 rlwinm r3,r3,16,16,31 /* Isolate the column number */
1714 lwz r27,GDrowbytes(r31) /* Get the number of bytes per row */
1715 lwz r9,GDrowchar(r31) /* Get the number of bytes per row of full leaded charactrers */
1716 lwz r26,GDdepth(r31) /* Get the bit depth */
1717 mullw r25,r25,r9 /* get offset to the row to write in bytes */
1718 lwz r24,GDcollgn(r31) /* Get the size of columns in bytes */
1719 add r25,r28,r25 /* Physical address of row */
1720 mullw r3,r3,r24 /* Get byte offset to first output column */
1722 li r9,32 /* Get the initial shift calc */
1724 lis r20,HIGH_ADDR(hexfont) /* Point to the font */
1726 li r18,GDfontsize /* Get the number of rows in the font */
1727 ori r20,r20,LOW_ADDR(hexfont) /* Point to the low part */
1728 add r21,r25,r3 /* Physical address of top left output pixel */
1729 sub r9,r9,r26 /* Get right shift justifier for pixel size */
1730 li r7,32 /* Number of bits per word */
1733 la r6,GDrowbuf1(r31) /* Point to the row buffer */
1734 li r19,8 /* Get the number of characters in a row */
1736 getNybble: rlwinm r10,r4,9,23,26 /* Get the top nybble * 32 */
1737 rlwinm r4,r4,4,0,31 /* Rotate a nybble */
1738 add r10,r20,r10 /* Point to the character in the font */
1740 rlwinm r16,r26,4,0,27 /* Width of row in actual bits */
1741 lhz r15,0(r10) /* Get the next row of the font */
1743 rendrow: rlwinm r17,r15,16,0,0 /* Get the next font pixel in the row */
1744 rlwinm r15,r15,1,16,31 /* Move in the next font pixel */
1745 srawi r17,r17,31 /* Fill with 1s if black and 0s if white (reversed) */
1747 slw r14,r14,r26 /* Make room for our pixel in a register */
1748 srw r17,r17,r9 /* Isolate one pixels worth of black or white */
1749 sub. r7,r7,r26 /* See how may bits are left */
1750 sub r16,r16,r26 /* Count how many bits are left to store for this row */
1751 or r14,r14,r17 /* Put in the pixel */
1752 bne+ notfull /* Finish rendering this word */
1754 not r14,r14 /* Invert to black on white */
1755 stw r14,0(r6) /* Write out the word */
1756 li r7,32 /* Bit per word count */
1757 addi r6,r6,4 /* Point to the next word */
1759 notfull: mr. r16,r16 /* Have we finished the whole character row? */
1760 bne+ rendrow /* Finish rendering the row */
1762 addic. r19,r19,-1 /* Are we finished with a whole display row yet? */
1763 bne+ getNybble /* Not yet... */
1765 la r6,GDrowbuf1(r31) /* Point to the row buffer */
1766 rlwinm r19,r26,31,0,29 /* Number of cache lines (depth/2) */
1767 mr r14,r21 /* Get the frame buffer address */
1771 blitrow: lfd f0,0(r6) /* Load a line */
1776 stfd f0,0(r14) /* Blit a line */
1781 addi r6,r6,32 /* Next buffered line */
1783 dcbst 0,r14 /* Force the line to the screen */
1784 sync /* Make sure the line is on it's way */
1785 eieio /* Make sure we beat the invalidate */
1786 dcbi 0,r14 /* Make sure we leave no paradox */
1788 addic. r19,r19,-1 /* Done all lines yet? */
1789 addi r14,r14,32 /* Point to the next output */
1790 bne+ blitrow /* Nope, do it some more... */
1792 addic. r18,r18,-1 /* Have we done all the rows in character yet? */
1793 addi r20,r20,2 /* Offset the font to the next row */
1794 add r21,r21,r27 /* Point to start of next row */
1795 bne+ startNybble /* Nope, go through the word one more time... */
1797 GDbailout: mr r1,r31 /* Move the workarea base */
1799 lfd f0,GDfp0(r31) /* Restore FP */
1800 lfd f1,GDfp1(r31) /* Restore FP */
1801 lfd f2,GDfp2(r31) /* Restore FP */
1802 lfd f3,GDfp3(r31) /* Restore FP */
1804 mtmsr r5 /* Disable floating point */
1807 lmw r3,GDsave+12(r1) /* Restore most registers */
1808 lwz r0,GDsave(r1) /* Restore R0 */
1809 lwz r1,GDsave+4(r1) /* Finally, R1 */
1814 * void GratefulDebDisp(unsigned int coord, unsigned int data);
1818 ENTRY(GratefulDebDisp,TAG_NO_FRAME_USED)
1820 mfmsr r9 /* Save the current MSR */
1821 mflr r7 /* Save the return */
1822 andi. r8,r9,0x7FCF /* Clear interrupt and translation */
1823 mtmsr r8 /* Turn 'em really off */
1824 isync /* Make sure about the translation part */
1825 bl EXT(GratefulDeb) /* Display it */
1826 mtmsr r9 /* Restore interrupt and translation */
1827 mtlr r7 /* Restore return */
1828 isync /* Make sure */
1835 * void checkNMI(void);
1839 ENTRY(checkNMI,TAG_NO_FRAME_USED)
1841 mfmsr r9 /* Save it */
1842 andi. r8,r9,0x7FCF /* Clear it */
1843 mtmsr r8 /* Disable it */
1844 isync /* Fence it */
1845 lis r7,0xF300 /* Find it */
1846 ori r7,r7,0x0020 /* Find it */
1847 dcbi 0,r7 /* Toss it */
1850 lwz r6,0x000C(r7) /* Check it */
1851 eieio /* Fence it */
1852 dcbi 0,r7 /* Toss it */
1853 rlwinm. r4,r6,0,19,19 /* Check it */
1854 rlwinm r6,r6,0,20,18 /* Clear it */
1856 eieio /* Fence it */
1857 beq+ xnonmi /* Branch on it */
1859 stw r6,0x0008(r7) /* Reset it */
1861 dcbi 0,r6 /* Toss it */
1862 eieio /* Fence it */
1864 mtmsr r9 /* Restore it */
1867 BREAKPOINT_TRAP /* Kill it */
1868 blr /* Return from it */
1870 xnonmi: /* Label it */
1871 mtmsr r9 /* Restore it */
1873 blr /* Return from it */
1880 dumpr7: lis r9,HIGH_ADDR(hexTab) /* (TEST/DEBUG) */
1881 li r5,8 /* (TEST/DEBUG) */
1882 ori r9,r9,LOW_ADDR(hexTab) /* (TEST/DEBUG) */
1884 dumpr7n: rlwinm r7,r7,4,0,31 /* (TEST/DEBUG) */
1885 mr r6,r7 /* (TEST/DEBUG) */
1886 andi. r6,r6,15 /* (TEST/DEBUG) */
1887 lbzx r6,r9,r6 /* (TEST/DEBUG) */
1888 lis r10,0xF301 /* (TEST/DEBUG) */
1889 ori r10,r10,0x2000 /* (TEST/DEBUG) */
1892 xqrw2: eieio /* (TEST/DEBUG) */
1893 lbz r7,0(r10) /* (TEST/DEBUG) */
1894 dcbi 0,r10 /* (TEST/DEBUG) */
1895 sync /* (TEST/DEBUG) */
1896 andi. r7,r7,0x04 /* (TEST/DEBUG) */
1897 beq xqrw2 /* (TEST/DEBUG) */
1900 dcbf 0,r10 /* (TEST/DEBUG) */
1901 sync /* (TEST/DEBUG) */
1902 dcbi 0,r10 /* (TEST/DEBUG) */
1903 eieio /* (TEST/DEBUG) */
1904 stb r6,4(r10) /* (TEST/DEBUG) */
1906 lis r6,10 /* (TEST/DEBUG) */
1907 dumpr7d: addi r6,r6,-1 /* (TEST/DEBUG) */
1908 mr. r6,r6 /* (TEST/DEBUG) */
1909 bne- dumpr7d /* (TEST/DEBUG) */
1910 dcbf 0,r10 /* (TEST/DEBUG) */
1911 sync /* (TEST/DEBUG) */
1912 dcbi 0,r10 /* (TEST/DEBUG) */
1913 eieio /* (TEST/DEBUG) */
1915 addic. r5,r5,-1 /* (TEST/DEBUG) */
1916 bne+ dumpr7n /* (TEST/DEBUG) */
1918 blr /* (TEST/DEBUG) */
1921 ; Log a special entry in physical memory.
1922 ; This assumes that memory size has been significantly lowered using
1923 ; the maxmem boot option. The buffer starts just after the end of mem_size.
1925 ; This is absolutely for special tracing cases. Do not ever leave in...
1928 ENTRY(dbgLog,TAG_NO_FRAME_USED)
1930 li r11,0 ; Clear callers callers callers return
1931 li r10,0 ; Clear callers callers callers callers return
1932 li r9,0 ; Clear callers callers callers callers callers return
1933 lwz r2,0(r1) ; Get callers callers stack frame
1934 lis r0,0x4000 ; First invalid address
1935 lwz r12,8(r2) ; Get our callers return
1936 lwz r2,0(r2) ; Back chain
1938 mr. r2,r2 ; End of chain?
1939 cmplw cr1,r2,r0 ; Valid kernel address?
1940 beq- nosavehere ; Yes, end of chain...
1941 bge- cr1,nosavehere ; No...
1942 lwz r11,8(r2) ; Get our callers return
1943 lwz r2,0(r2) ; Back chain
1945 mr. r2,r2 ; End of chain?
1946 cmplw cr1,r2,r0 ; Valid kernel address?
1947 beq- nosavehere ; Yes, end of chain...
1948 bge- cr1,nosavehere ; No...
1949 lwz r10,8(r2) ; Get our callers return
1950 lwz r2,0(r2) ; Back chain
1952 mr. r2,r2 ; End of chain?
1953 cmplw cr1,r2,r0 ; Valid kernel address?
1954 beq- nosavehere ; Yes, end of chain...
1955 bge- cr1,nosavehere ; No...
1956 lwz r9,8(r2) ; Get our callers return
1958 nosavehere: mfmsr r8 ; Get the MSR
1959 lis r2,hi16(EXT(DebugWork)) ; High part of area
1960 lis r7,hi16(EXT(mem_actual)) ; High part of actual
1961 andi. r0,r8,0x7FCF ; Interrupts and translation off
1962 ori r2,r2,lo16(EXT(DebugWork)) ; Get the entry
1963 mtmsr r0 ; Turn stuff off
1964 ori r7,r7,lo16(EXT(mem_actual)) ; Get the actual
1967 lwz r0,4(r2) ; Get the flag
1968 mr. r0,r0 ; Should we log?
1969 lwz r0,0(r7) ; Get the end of memory
1970 lwz r7,0(r2) ; Get the position
1971 bne- waytoofar ; No logging...
1972 mr. r7,r7 ; Is this the first?
1973 bne+ gotspot ; Nope...
1975 lis r7,hi16(EXT(mem_size)) ; High part of defined memory
1976 ori r7,r7,lo16(EXT(mem_size)) ; Low part of defined memory
1977 lwz r7,0(r7) ; Make it end of defined
1979 gotspot: cmplw r7,r0 ; Do we fit in memory
1980 addi r0,r7,0x0020 ; Next slot
1981 bge- waytoofar ; No fit...
1983 stw r0,0(r2) ; Set next time slot
1986 stw r3,0(r7) ; First data
1987 li r3,32 ; Disp to next line
1988 stw r4,4(r7) ; Second data
1990 stw r5,8(r7) ; Third data
1991 stw r6,12(r7) ; Fourth data
1993 stw r12,16(r7) ; Callers callers
1994 stw r11,20(r7) ; Callers callers caller
1995 stw r10,24(r7) ; Callers callers callers caller
1996 stw r9,28(r7) ; Callers callers callers callers caller
1998 waytoofar: mtmsr r8 ; Back to normal
2003 ; Same as the other, but no traceback and 16 byte entry
2004 ; Trashes R0, R2, R10, R12
2013 mfmsr r10 ; Get the MSR
2014 lis r2,hi16(EXT(DebugWork)) ; High part of area
2015 lis r12,hi16(EXT(mem_actual)) ; High part of actual
2016 andi. r0,r10,0x7FCF ; Interrupts and translation off
2017 ori r2,r2,lo16(EXT(DebugWork)) ; Get the entry
2018 mtmsr r0 ; Turn stuff off
2019 ori r12,r12,lo16(EXT(mem_actual)) ; Get the actual
2022 lwz r0,4(r2) ; Get the flag
2023 mr. r0,r0 ; Should we log?
2024 lwz r0,0(r12) ; Get the end of memory
2025 lwz r12,0(r2) ; Get the position
2026 bne- waytoofar2 ; No logging...
2027 mr. r12,r12 ; Is this the first?
2028 bne+ gotspot2 ; Nope...
2030 lis r12,hi16(EXT(mem_size)) ; High part of defined memory
2031 ori r12,r12,lo16(EXT(mem_size)) ; Low part of defined memory
2032 lwz r12,0(r12) ; Make it end of defined
2034 gotspot2: cmplw cr1,r12,r0 ; Do we fit in memory
2035 rlwinm. r0,r12,0,27,27 ; Are we on a new line?
2036 bge- cr1,waytoofar2 ; No fit...
2037 addi r0,r12,0x0010 ; Next slot
2039 bne+ nonewline ; Not on a new line...
2040 dcbz br0,r12 ; Clear it so we do not fetch it
2042 nonewline: cmplwi r3,68 ; Special place for time stamp?
2044 stw r0,0(r2) ; Set next time slot
2045 bne+ nospcts ; Nope...
2047 lwz r0,0x17C(br0) ; Get special saved time stamp
2050 nospcts: mftb r0 ; Get the current time
2052 nospctt: stw r3,4(r12) ; First data
2053 stw r4,8(r12) ; Second data
2054 stw r5,12(r12) ; Third data
2055 stw r0,0(r12) ; Time stamp
2057 waytoofar2: mtmsr r10 ; Back to normal
2063 ; Saves floating point registers
2071 mfmsr r0 ; Save the MSR
2072 rlwinm r4,r0,0,MSR_EE_BIT,MSR_EE_BIT ; Turn off interruptions
2073 ori r4,r4,lo16(MASK(MSR_FP)) ; Enable floating point
2118 ; Saves vector registers. Returns 0 if non-Altivec machine.
2122 .globl EXT(stVectors)
2127 mfpvr r6 ; Get machine type
2128 mr r5,r3 ; Save area address
2129 rlwinm r6,r6,16,17,31 ; Rotate on it
2130 li r3,0 ; Assume failure
2131 cmplwi r6,PROCESSOR_VERSION_7400 ; Do we have Altivec?
2134 mfmsr r0 ; Save the MSR
2135 rlwinm r4,r0,0,MSR_EE_BIT,MSR_EE_BIT ; Turn off interruptions
2136 oris r4,r4,hi16(MASK(MSR_VEC)) ; Enable vectors
2216 ; Saves yet more registers
2220 .globl EXT(stSpecrs)
2225 mfmsr r0 ; Save the MSR
2226 rlwinm r4,r0,0,MSR_EE_BIT,MSR_EE_BIT ; Turn off interruptions
2232 rlwinm r12,r12,16,16,31
2283 stSnsr: mfsrin r6,r5
2290 cmplwi cr1,r12,PROCESSOR_VERSION_604e
2291 cmplwi cr5,r12,PROCESSOR_VERSION_604ev
2292 cror cr1_eq,cr1_eq,cr5_eq ; Set if 604 type
2293 cmplwi r12,PROCESSOR_VERSION_750
2309 before750: stw r4,(40*4)(r3)
2318 isis750: stw r4,0(r3)
2332 b4750: stw r4,(44*4)(r3)
2338 cmplwi r12,PROCESSOR_VERSION_7400
2342 rlwinm r5,r5,0,16,31
2348 gnmax: mfspr r4,1016
2350 nnmax: stw r4,(48*4)(r3)