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.
40 #include <ppc/proc_reg.h>
41 #include <ppc/spec_reg.h>
42 #include <ppc/exception.h>
43 #include <mach/machine/vm_param.h>
48 * Here we generate the table of supported firmware calls
54 .align 5 /* Line up on cache line */
60 .globl CutTrace /* Let everyone know 'bout it */
61 .set CutTrace,(.-EXT(FWtable))/4|0x80000000 /* Call number for CutTrace */
62 .long callUnimp /* This was already handled in lowmem_vectors */
64 #include <ppc/FirmwareCalls.h>
66 .set EXT(FirmwareCnt), (.-EXT(FWtable))/4 /* Get the top number */
71 #define NOTQUITEASSIMPLE 1
73 * This routine handles the firmware call routine. It must be entered with IR and DR off,
74 * interruptions disabled, and in supervisor state.
76 * When we enter, we expect R0 to have call number, and LR
77 * to point to the return. Also, all registers saved in savearea in R13.
78 * R3 is as passed in by the user. All others must be gotten from the save area
83 .globl EXT(FirmwareCall)
87 rlwinm r1,r0,2,1,29 /* Clear out bit 0 and multiply by 4 */
88 lis r12,HIGH_ADDR(EXT(FWtable)) /* Get the high part of the firmware call table */
89 cmplwi r1,EXT(FirmwareCnt)*4 /* Is it a valid firmware call number */
90 ori r12,r12,LOW_ADDR(EXT(FWtable)) /* Now the low part */
91 ble+ goodCall /* Yeah, it is... */
93 li r3,T_SYSTEM_CALL /* Tell the vector handler that we know nothing */
94 b EXT(FCReturn) ; Bye dudes...
96 goodCall: mfsprg r10,0 /* Make sure about the per_proc block */
97 lwzx r1,r1,r12 /* Pick up the address of the routine */
98 lwz r4,saver4+4(r13) /* Pass in caller's R4 */
99 lwz r5,saver5+4(r13) /* Pass in caller's R5 */
100 rlwinm. r1,r1,0,0,29 /* Make sure the flag bits are clear */
102 mtlr r1 /* Put it in the LR */
103 beq- callUnimp /* This one was unimplimented... */
105 blrl /* Call the routine... */
107 stw r3,saver3+4(r13) /* Pass back the return code to caller */
108 li r3,T_IN_VAIN /* Tell the vector handler that we took care of it */
109 b EXT(FCReturn) ; Bye dudes...
111 callUnimp: li r3,T_SYSTEM_CALL /* Tell the vector handler that we know nothing */
112 b EXT(FCReturn) ; Bye dudes...
115 * This routine is used to store using a real address. It stores parmeter1 at parameter2.
119 .globl EXT(StoreReal)
123 lis r0,HIGH_ADDR(StoreRealCall) /* Get the top part of the SC number */
124 ori r0,r0,LOW_ADDR(StoreRealCall) /* and the bottom part */
126 blr /* Bye bye, Birdie... */
129 .globl EXT(StoreRealLL)
133 stw r3,0(r4) /* Store the word */
137 * This routine is used to clear a range of physical pages.
141 .globl EXT(ClearReal)
145 lis r0,HIGH_ADDR(ClearRealCall) /* Get the top part of the SC number */
146 ori r0,r0,LOW_ADDR(ClearRealCall) /* and the bottom part */
148 blr /* Bye bye, Birdie... */
152 .globl EXT(ClearRealLL)
157 * We take the first parameter as a physical address. The second is the length in bytes.
158 * Being crazy, I'll round the address down, and the length up. We could end up clearing
159 * an extra page at the start and one at the end, but we don't really care. If someone
160 * is stupid enough to give me unaligned addresses and lengths, I am just arrogant enough
161 * to take them at their word and to hell with them.
164 neg r5,r3 /* Negate the address */
165 addi r4,r4,4095 /* Round length up */
166 rlwinm r5,r5,0,20,31 /* Save extra length */
167 rlwinm r3,r3,0,0,19 /* Round the page on down */
168 add r4,r4,r5 /* Add up all extra lengths */
169 li r6,32 /* Get a displacement */
170 rlwinm r4,r4,0,0,19 /* Round the length back down */
172 clrloop: subi r4,r4,32 /* Back off a cache line */
173 dcbz 0,r3 /* Do the even line */
174 sub. r4,r4,r6 /* Back off a second time (we only do this to generate a CR */
175 dcbz r6,r3 /* Clear the even line */
176 addi r3,r3,64 /* Move up to every other line */
177 bgt+ clrloop /* Go until we've done it all... */
181 * This routine will read in 32 byte of real storage.
189 mfsprg r9,2 ; Get the features
190 mfmsr r0 ; Get the MSR
191 li r8,lo16(MASK(MSR_DR)) ; Get the DR bit
192 rlwinm. r9,r9,0,pf64Bitb,pf64Bitb ; Are we 64-bit?
193 ori r8,r8,lo16(MASK(MSR_EE)) ; Add in the EE bit
194 li r7,1 ; Get set for it
195 andc r8,r0,r8 ; Turn off EE and DR
196 bt-- cr0_eq,rr32a ; Yes, we are...
198 rldimi r8,r7,63,MSR_SF_BIT ; Set SF bit (bit 0)
199 sldi r3,r3,32 ; Slide on over for true 64-bit address
202 or r3,r3,r4 ; Join top and bottom of address
203 mr r4,r5 ; Set destination address
204 b rrJoina ; Join on up...
206 rr32a: mr r3,r4 ; Position bottom of long long
207 mr r4,r5 ; Set destination address
208 mtmsr r8 /* Disable EE and DR */
209 isync /* Just make sure about it */
211 rrJoina: lwz r5,0(r3) /* Get word 0 */
212 lwz r6,4(r3) /* Get word 1 */
213 lwz r7,8(r3) /* Get word 2 */
214 lwz r8,12(r3) /* Get word 3 */
215 lis r2,hi16(MASK(MSR_VEC)) ; Get the vector enable
216 lwz r9,16(r3) /* Get word 4 */
217 ori r2,r2,lo16(MASK(MSR_FP)) ; Get the FP enable
218 lwz r10,20(r3) /* Get word 5 */
219 andc r0,r0,r2 ; Clear VEC and FP enables
220 lwz r11,24(r3) /* Get word 6 */
221 lwz r12,28(r3) /* Get word 7 */
223 bt-- cr0_eq,rr32b ; We are not 64-bit...
227 b rrJoinb ; Join on up...
229 rr32b: mtmsr r0 /* Restore original machine state */
230 isync /* Insure goodness */
232 rrJoinb: stw r5,0(r4) /* Set word 0 */
233 stw r6,4(r4) /* Set word 1 */
234 stw r7,8(r4) /* Set word 2 */
235 stw r8,12(r4) /* Set word 3 */
236 stw r9,16(r4) /* Set word 4 */
237 stw r10,20(r4) /* Set word 5 */
238 stw r11,24(r4) /* Set word 6 */
239 stw r12,28(r4) /* Set word 7 */
245 * This routine is used to load all 4 DBATs.
249 .globl EXT(LoadDBATs)
254 lis r0,HIGH_ADDR(LoadDBATsCall) /* Top half of LoadDBATsCall firmware call number */
255 ori r0,r0,LOW_ADDR(LoadDBATsCall) /* Bottom half */
258 blr /* Bye bye, Birdie... */
262 .globl EXT(xLoadDBATsLL)
266 lwz r4,0(r3) /* Get DBAT 0 high */
267 lwz r5,4(r3) /* Get DBAT 0 low */
268 lwz r6,8(r3) /* Get DBAT 1 high */
269 lwz r7,12(r3) /* Get DBAT 1 low */
270 lwz r8,16(r3) /* Get DBAT 2 high */
271 lwz r9,20(r3) /* Get DBAT 2 low */
272 lwz r10,24(r3) /* Get DBAT 3 high */
273 lwz r11,28(r3) /* Get DBAT 3 low */
275 sync /* Common decency and the state law require that you wash your hands */
276 mtdbatu 0,r4 /* Load DBAT 0 high */
277 mtdbatl 0,r5 /* Load DBAT 0 low */
278 mtdbatu 1,r6 /* Load DBAT 1 high */
279 mtdbatl 1,r7 /* Load DBAT 1 low */
280 mtdbatu 2,r8 /* Load DBAT 2 high */
281 mtdbatl 2,r9 /* Load DBAT 2 low */
282 mtdbatu 3,r10 /* Load DBAT 3 high */
283 mtdbatl 3,r11 /* Load DBAT 3 low */
284 sync /* Make sure it's done */
285 isync /* Toss out anything new */
290 * This routine is used to load all 4 IBATs.
294 .globl EXT(LoadIBATs)
299 lis r0,HIGH_ADDR(LoadIBATsCall) /* Top half of LoadIBATsCall firmware call number */
300 ori r0,r0,LOW_ADDR(LoadIBATsCall) /* Bottom half */
302 blr /* Bye bye, Birdie... */
305 .globl EXT(xLoadIBATsLL)
309 lwz r4,0(r3) /* Get IBAT 0 high */
310 lwz r5,4(r3) /* Get IBAT 0 low */
311 lwz r6,8(r3) /* Get IBAT 1 high */
312 lwz r7,12(r3) /* Get IBAT 1 low */
313 lwz r8,16(r3) /* Get IBAT 2 high */
314 lwz r9,20(r3) /* Get IBAT 2 low */
315 lwz r10,24(r3) /* Get IBAT 3 high */
316 lwz r11,28(r3) /* Get IBAT 3 low */
318 sync /* Common decency and the state law require that you wash your hands */
319 mtibatu 0,r4 /* Load IBAT 0 high */
320 mtibatl 0,r5 /* Load IBAT 0 low */
321 mtibatu 1,r6 /* Load IBAT 1 high */
322 mtibatl 1,r7 /* Load IBAT 1 low */
323 mtibatu 2,r8 /* Load IBAT 2 high */
324 mtibatl 2,r9 /* Load IBAT 2 low */
325 mtibatu 3,r10 /* Load IBAT 3 high */
326 mtibatl 3,r11 /* Load IBAT 3 low */
327 sync /* Make sure it's done */
328 isync /* Toss out anything new */
334 * This is the glue to call the CutTrace firmware call
342 lis r0,HIGH_ADDR(CutTrace) /* Top half of CreateFakeIO firmware call number */
343 ori r0,r0,LOW_ADDR(CutTrace) /* Bottom half */
345 blr /* Bye bye, Birdie... */
348 * This is the glue to create a fake I/O interruption
352 .globl EXT(CreateFakeIO)
356 lis r0,HIGH_ADDR(CreateFakeIOCall) /* Top half of CreateFakeIO firmware call number */
357 ori r0,r0,LOW_ADDR(CreateFakeIOCall) /* Bottom half */
359 blr /* Bye bye, Birdie... */
362 * This is the glue to create a fake Dec interruption
366 .globl EXT(CreateFakeDEC)
371 mflr r4 ; (TEST/DEBUG)
372 bl EXT(ml_sense_nmi) ; (TEST/DEBUG)
373 mtlr r4 ; (TEST/DEBUG)
376 lis r0,HIGH_ADDR(CreateFakeDECCall) /* Top half of CreateFakeDEC firmware call number */
377 ori r0,r0,LOW_ADDR(CreateFakeDECCall) /* Bottom half */
379 blr /* Bye bye, Birdie... */
383 * This is the glue to create a shutdown context
387 .globl EXT(CreateShutdownCTX)
389 LEXT(CreateShutdownCTX)
391 lis r0,HIGH_ADDR(CreateShutdownCTXCall) /* Top half of CreateFakeIO firmware call number */
392 ori r0,r0,LOW_ADDR(CreateShutdownCTXCall) /* Bottom half */
394 blr /* Bye bye, Birdie... */
397 * This is the glue to choke system
405 lis r0,HIGH_ADDR(Choke) /* Top half of Choke firmware call number */
406 ori r0,r0,LOW_ADDR(Choke) /* Bottom half */
408 blr /* Bye bye, Birdie... */
411 * Used to initialize the SCC for debugging output
416 .globl EXT(fwSCCinit)
420 mfmsr r8 /* Save the MSR */
421 mr. r3,r3 /* See if printer or modem */
422 rlwinm r12,r8,0,28,25 /* Turn off translation */
423 lis r10,0xF301 /* Set the top part */
424 rlwinm r12,r12,0,17,15 /* Turn off interruptions */
426 mtmsr r12 /* Smash the MSR */
427 isync /* Make it clean */
430 ori r10,r10,0x2000 /* Assume the printer (this is the normal one) */
431 beq+ fwSCCprnt /* It sure are... */
432 ori r10,r10,0x0002 /* Move it over to the modem port */
434 fwSCCprnt: dcbf 0,r10 /* Insure it is out */
437 dcbi 0,r10 /* Toss it */
441 li r7,0x09 /* Set the register */
442 stb r7,0(r10) /* Set the register */
443 dcbf 0,r10 /* Force it out */
444 sync /* Make sure it's out there */
448 li r7,0x80 /* Reset channel A */
449 stb r7,0(r10) /* Set the register */
450 dcbf 0,r10 /* Force it out */
451 sync /* Make sure it's out there */
455 li r7,0x04 /* Set the register */
456 stb r7,0(r10) /* Set the register */
457 dcbf 0,r10 /* Force it out */
458 sync /* Make sure it's out there */
462 li r7,0x44 /* x16 clock, 1 stop bit */
463 stb r7,0(r10) /* Set the register */
464 dcbf 0,r10 /* Force it out */
465 sync /* Make sure it's out there */
469 li r7,0x03 /* Set the register */
470 stb r7,0(r10) /* Set the register */
471 dcbf 0,r10 /* Force it out */
472 sync /* Make sure it's out there */
476 li r7,0xC0 /* 8 bits per char */
477 stb r7,0(r10) /* Set the register */
478 dcbf 0,r10 /* Force it out */
479 sync /* Make sure it's out there */
483 li r7,0x05 /* Set the register */
484 stb r7,0(r10) /* Set the register */
485 dcbf 0,r10 /* Force it out */
486 sync /* Make sure it's out there */
490 li r7,0xE2 /* DTR mode, 8bit/char */
491 stb r7,0(r10) /* Set the register */
492 dcbf 0,r10 /* Force it out */
493 sync /* Make sure it's out there */
497 li r7,0x02 /* Set the register */
498 stb r7,0(r10) /* Set the register */
499 dcbf 0,r10 /* Force it out */
500 sync /* Make sure it's out there */
504 li r7,0x00 /* Vector 0 */
505 stb r7,0(r10) /* Set the register */
506 dcbf 0,r10 /* Force it out */
507 sync /* Make sure it's out there */
511 li r7,0x0A /* Set the register */
512 stb r7,0(r10) /* Set the register */
513 dcbf 0,r10 /* Force it out */
514 sync /* Make sure it's out there */
518 li r7,0x00 /* Clear misc controls */
519 stb r7,0(r10) /* Set the register */
520 dcbf 0,r10 /* Force it out */
521 sync /* Make sure it's out there */
525 li r7,0x0B /* Set the register */
526 stb r7,0(r10) /* Set the register */
527 dcbf 0,r10 /* Force it out */
528 sync /* Make sure it's out there */
532 li r7,0x50 /* B/R gen T/R */
533 stb r7,0(r10) /* Set the register */
534 dcbf 0,r10 /* Force it out */
535 sync /* Make sure it's out there */
539 li r7,0x0C /* Set the register */
540 stb r7,0(r10) /* Set the register */
541 dcbf 0,r10 /* Force it out */
542 sync /* Make sure it's out there */
546 li r7,0x0A /* 9600 baud low */
547 stb r7,0(r10) /* Set the register */
548 dcbf 0,r10 /* Force it out */
549 sync /* Make sure it's out there */
553 li r7,0x0D /* Set the register */
554 stb r7,0(r10) /* Set the register */
555 dcbf 0,r10 /* Force it out */
556 sync /* Make sure it's out there */
560 li r7,0x00 /* 9600 baud high */
561 stb r7,0(r10) /* Set the register */
562 dcbf 0,r10 /* Force it out */
563 sync /* Make sure it's out there */
567 li r7,0x03 /* Set the register */
568 stb r7,0(r10) /* Set the register */
569 dcbf 0,r10 /* Force it out */
570 sync /* Make sure it's out there */
574 li r7,0xC1 /* 8 bits/char, Rx enable */
575 stb r7,0(r10) /* Set the register */
576 dcbf 0,r10 /* Force it out */
577 sync /* Make sure it's out there */
581 li r7,0x05 /* Set the register */
582 stb r7,0(r10) /* Set the register */
583 dcbf 0,r10 /* Force it out */
584 sync /* Make sure it's out there */
588 li r7,0xEA /* 8 bits/char, Tx enable */
589 stb r7,0(r10) /* Set the register */
590 dcbf 0,r10 /* Force it out */
591 sync /* Make sure it's out there */
595 li r7,0x0E /* Set the register */
596 stb r7,0(r10) /* Set the register */
597 dcbf 0,r10 /* Force it out */
598 sync /* Make sure it's out there */
602 li r7,0x01 /* BR rate gen enable */
603 stb r7,0(r10) /* Set the register */
604 dcbf 0,r10 /* Force it out */
605 sync /* Make sure it's out there */
609 li r7,0x0F /* Set the register */
610 stb r7,0(r10) /* Set the register */
611 dcbf 0,r10 /* Force it out */
612 sync /* Make sure it's out there */
616 li r7,0x00 /* ints off */
617 stb r7,0(r10) /* Set the register */
618 dcbf 0,r10 /* Force it out */
619 sync /* Make sure it's out there */
623 li r7,0x10 /* Reset ext/stat ints */
624 stb r7,0(r10) /* Set the register */
625 dcbf 0,r10 /* Force it out */
626 sync /* Make sure it's out there */
630 li r7,0x10 /* Reset ext/stat ints */
631 stb r7,0(r10) /* Set the register */
632 dcbf 0,r10 /* Force it out */
633 sync /* Make sure it's out there */
637 li r7,0x01 /* Set the register */
638 stb r7,0(r10) /* Set the register */
639 dcbf 0,r10 /* Force it out */
640 sync /* Make sure it's out there */
644 li r7,0x10 /* int on Rx, no Tx int enable */
645 stb r7,0(r10) /* Set the register */
646 dcbf 0,r10 /* Force it out */
647 sync /* Make sure it's out there */
651 li r7,0x09 /* Set the register */
652 stb r7,0(r10) /* Set the register */
653 dcbf 0,r10 /* Force it out */
654 sync /* Make sure it's out there */
658 li r7,0x0A /* int on Rx, Tx int enable */
659 stb r7,0(r10) /* Set the register */
660 dcbf 0,r10 /* Force it out */
661 sync /* Master enable, no vector */
665 li r7,0x09 /* Set the register */
666 stb r7,0(r10) /* Set the register */
667 dcbf 0,r10 /* Force it out */
668 sync /* Make sure it's out there */
672 li r7,0x02 /* No vector */
673 stb r7,0(r10) /* Set the register */
674 dcbf 0,r10 /* Force it out */
675 sync /* Master enable, no vector */
679 lbz r7,0(r10) /* Clear interrupts */
680 sync /* Master enable, no vector */
684 wSCCrdy: eieio /* Barricade it */
685 lbz r7,0(r10) /* Get current status */
688 andi. r7,r7,0x04 /* Is transmitter empty? */
689 beq wSCCrdy /* Nope... */
694 mtmsr r8 /* Restore 'rupts and TR */
700 * This routine is used to write debug output to either the modem or printer port.
701 * parm 1 is printer (0) or modem (1); parm 2 is ID (printed directly); parm 3 converted to hex
709 mr r12,r0 /* Keep R0 pristene */
710 lis r0,HIGH_ADDR(dbgDispCall) /* Top half of dbgDispCall firmware call number */
711 ori r0,r0,LOW_ADDR(dbgDispCall) /* Bottom half */
713 sc /* Go display the stuff */
715 mr r0,r12 /* Restore R0 */
718 /* Here's the low-level part of dbgDisp */
721 .globl EXT(dbgDispLL)
725 dbgDispInt: mfmsr r8 /* Save the MSR */
728 lis r10,0xF301 /* (TEST/DEBUG) */
729 ori r10,r10,0x2002 /* (TEST/DEBUG) */
730 dcbf 0,r10 /* (TEST/DEBUG) */
731 sync /* (TEST/DEBUG) */
732 dcbi 0,r10 /* (TEST/DEBUG) */
733 eieio /* (TEST/DEBUG) */
734 li r7,0x35 /* (TEST/DEBUG) */
735 stb r7,4(r10) /* (TEST/DEBUG) */
737 lis r7,10 /* (TEST/DEBUG) */
738 spw6: addi r7,r7,-1 /* (TEST/DEBUG) */
739 mr. r7,r7 /* (TEST/DEBUG) */
740 bne- spw6 /* (TEST/DEBUG) */
741 dcbf 0,r10 /* (TEST/DEBUG) */
742 sync /* (TEST/DEBUG) */
743 dcbi 0,r10 /* (TEST/DEBUG) */
744 eieio /* (TEST/DEBUG) */
747 rlwinm r12,r8,0,28,25 /* Turn off translation */
748 rlwinm r12,r12,0,17,15 /* Turn off interruptions */
750 mflr r11 /* Save the link register */
753 mr r7,r12 /* (TEST/DEBUG) */
754 bl dumpr7 /* (TEST/DEBUG) */
757 mr. r3,r3 /* See if printer or modem */
758 lis r10,0xF301 /* Set the top part */
759 mr r3,r4 /* Copy the ID parameter */
762 mr r9,r12 /* (TEST/DEBUG) */
764 mtmsr r12 /* (TEST/DEBUG) */
765 isync /* (TEST/DEBUG) */
768 mtmsr r8 /* (TEST/DEBUG) */
769 isync /* (TEST/DEBUG) */
772 lis r12,0xF301 /* (TEST/DEBUG) */
773 ori r12,r12,0x2002 /* (TEST/DEBUG) */
775 dcbf 0,r12 /* (TEST/DEBUG) */
776 sync /* (TEST/DEBUG) */
777 dcbi 0,r12 /* (TEST/DEBUG) */
780 xqrw1: eieio /* (TEST/DEBUG) */
781 lbz r7,0(r12) /* (TEST/DEBUG) */
782 dcbi 0,r12 /* (TEST/DEBUG) */
783 sync /* (TEST/DEBUG) */
784 andi. r7,r7,0x04 /* (TEST/DEBUG) */
785 beq xqrw1 /* (TEST/DEBUG) */
787 eieio /* (TEST/DEBUG) */
788 li r7,0x36 /* (TEST/DEBUG) */
789 stb r7,4(r12) /* (TEST/DEBUG) */
791 dcbf 0,r12 /* (TEST/DEBUG) */
792 sync /* (TEST/DEBUG) */
793 dcbi 0,r12 /* (TEST/DEBUG) */
794 eieio /* (TEST/DEBUG) */
797 lis r7,10 /* (TEST/DEBUG) */
798 spw7: addi r7,r7,-1 /* (TEST/DEBUG) */
799 mr. r7,r7 /* (TEST/DEBUG) */
800 bne- spw7 /* (TEST/DEBUG) */
801 dcbf 0,r12 /* (TEST/DEBUG) */
802 sync /* (TEST/DEBUG) */
803 dcbi 0,r12 /* (TEST/DEBUG) */
804 eieio /* (TEST/DEBUG) */
805 mr r12,r9 /* (TEST/DEBUG) */
808 mtmsr r12 /* Smash the MSR */
809 isync /* Make it clean */
812 #if SIMPLESCC && !NOTQUITEASSIMPLE
813 ori r10,r10,0x3010 /* Assume the printer (this is the normal one) */
815 ori r10,r10,0x2000 /* Assume the printer (this is the normal one) */
817 beq+ dbgDprintr /* It sure are... */
818 #if SIMPLESCC && !NOTQUITEASSIMPLE
819 ori r10,r10,0x0020 /* Move it over to the modem port */
821 ori r10,r10,0x0002 /* Move it over to the modem port */
823 #if !NOTQUITEASSIMPLE
824 lis r7,0xF300 /* Address of SCC rounded to 128k */
825 ori r7,r7,0x0032 /* Make it cache inhibited */
826 mtdbatl 3,r7 /* Load DBAT 3 low */
827 lis r7,0xF300 /* Address of SCC rounded to 128k */
828 ori r7,r7,0x0002 /* Make it supervisor only */
829 mtdbatu 3,r7 /* Load DBAT 3 high */
830 ori r12,r12,0x0010 /* Turn on DR */
831 mtmsr r12 /* Smash the MSR */
832 isync /* Make it clean */
839 mr r7,r10 /* (TEST/DEBUG) */
840 bl dumpr7 /* (TEST/DEBUG) */
843 dcbi 0,r10 /* Toss it */
847 lis r12,0xF301 /* (TEST/DEBUG) */
848 ori r12,r12,0x2002 /* (TEST/DEBUG) */
849 dcbf 0,r12 /* (TEST/DEBUG) */
850 sync /* (TEST/DEBUG) */
851 dcbi 0,r12 /* (TEST/DEBUG) */
852 eieio /* (TEST/DEBUG) */
853 li r7,0x37 /* (TEST/DEBUG) */
854 stb r7,4(r12) /* (TEST/DEBUG) */
856 lis r7,12 /* (TEST/DEBUG) */
857 spw8: addi r7,r7,-1 /* (TEST/DEBUG) */
858 mr. r7,r7 /* (TEST/DEBUG) */
859 bne- spw8 /* (TEST/DEBUG) */
860 dcbf 0,r12 /* (TEST/DEBUG) */
861 sync /* (TEST/DEBUG) */
862 dcbi 0,r12 /* (TEST/DEBUG) */
863 eieio /* (TEST/DEBUG) */
867 /* Print the ID parameter */
869 lis r12,HIGH_ADDR(fwdisplock) /* Get the display locker outer */
870 ori r12,r12,LOW_ADDR(fwdisplock) /* Last part */
874 ddwait0: lwarx r7,0,r12 /* Get the lock */
875 mr. r7,r7 /* Is it locked? */
876 bne- ddwait0 /* Yup... */
877 stwcx. r12,0,r12 /* Try to get it */
878 bne- ddwait0 /* Nope, start all over... */
881 dcbf 0,r10 /* (TEST/DEBUG) */
882 sync /* (TEST/DEBUG) */
883 dcbi 0,r10 /* (TEST/DEBUG) */
884 eieio /* (TEST/DEBUG) */
885 li r7,0x38 /* (TEST/DEBUG) */
886 stb r7,6(r10) /* (TEST/DEBUG) */
888 lis r7,10 /* (TEST/DEBUG) */
889 spwa: addi r7,r7,-1 /* (TEST/DEBUG) */
890 mr. r7,r7 /* (TEST/DEBUG) */
891 bne- spwa /* (TEST/DEBUG) */
892 dcbf 0,r10 /* (TEST/DEBUG) */
893 sync /* (TEST/DEBUG) */
894 dcbi 0,r10 /* (TEST/DEBUG) */
895 eieio /* (TEST/DEBUG) */
898 rlwinm r3,r3,8,0,31 /* Get the first character */
899 bl dbgDchar /* Print it */
900 rlwinm r3,r3,8,0,31 /* Get the second character */
901 bl dbgDchar /* Print it */
902 rlwinm r3,r3,8,0,31 /* Get the third character */
903 bl dbgDchar /* Print it */
904 rlwinm r3,r3,8,0,31 /* Get the fourth character */
905 bl dbgDchar /* Print it */
907 li r3,0x20 /* Get a space for a separator */
908 bl dbgDchar /* Print it */
909 bl dbg4byte /* Print register 5 in hex */
911 li r3,0x0A /* Linefeed */
912 bl dbgDchar /* Send it */
913 li r3,0x0D /* Carriage return */
914 bl dbgDchar /* Send it */
916 mtlr r11 /* Get back the return */
917 #if !SIMPLESCC && !NOTQUITEASSIMPLE
918 li r7,0 /* Get a zero */
919 mtdbatu 3,r7 /* Invalidate DBAT 3 upper */
920 mtdbatl 3,r7 /* Invalidate DBAT 3 lower */
922 lis r12,HIGH_ADDR(fwdisplock) /* Get the display locker outer */
923 li r7,0 /* Get a zero */
924 ori r12,r12,LOW_ADDR(fwdisplock) /* Last part */
926 stw r7,0(r12) /* Release the display lock */
927 mtmsr r8 /* Restore the MSR */
928 isync /* Wait for it */
932 dbg4byte: mflr r12 /* Save the return */
934 lis r4,HIGH_ADDR(hexTab) /* Point to the top of table */
935 li r6,8 /* Set number of hex digits to dump */
936 ori r4,r4,LOW_ADDR(hexTab) /* Point to the bottom of table */
938 dbgDnext: rlwinm r5,r5,4,0,31 /* Rotate a nybble */
939 subi r6,r6,1 /* Back down the count */
940 rlwinm r3,r5,0,28,31 /* Isolate the last nybble */
941 lbzx r3,r4,r3 /* Convert to ascii */
942 bl dbgDchar /* Print it */
943 mr. r6,r6 /* Any more? */
944 bne+ dbgDnext /* Convert 'em all... */
946 li r3,0x20 /* Space */
947 bl dbgDchar /* Send it */
948 mtlr r12 /* Restore LR */
951 /* Write to whichever serial port. Try to leave it clean, but not too hard (this is a hack) */
954 #if SIMPLESCC && !NOTQUITEASSIMPLE
955 stb r3,0(r10) /* ? */
956 dcbf 0,r10 /* Force it out */
957 sync /* Make sure it's out there */
959 lis r7,3 /* Get enough for about 1ms */
961 dbgDchar0: addi r7,r7,-1 /* Count down */
962 mr. r7,r7 /* Waited long enough? */
963 bgt+ dbgDchar0 /* Nope... */
968 stb r7,0(r10) /* ? */
969 dcbf 0,r10 /* Force it out */
970 sync /* Make sure it's out there */
974 lbz r7,0(r10) /* ? */
975 dcbi 0,r10 /* Force it out */
976 sync /* kill it off */
980 stb r7,0(r10) /* ? */
981 dcbf 0,r10 /* Force it out */
982 sync /* Make sure it's out there */
986 lbz r7,0(r10) /* ? */
987 dcbi 0,r10 /* Force it out */
988 sync /* kill it off */
992 qrw1: eieio /* Barricade it */
993 lbz r7,0(r10) /* ? */
996 andi. r7,r7,0x04 /* ? */
997 beq qrw1 /* Nope... */
1001 stb r3,4(r10) /* ? */
1002 dcbf 0,r10 /* Force it out */
1003 sync /* Make sure it's out there */
1007 qrw2: eieio /* Barricade it */
1008 lbz r7,0(r10) /* ? */
1011 andi. r7,r7,0x04 /* ? */
1012 beq qrw2 /* Nope... */
1017 stb r7,0(r10) /* ? */
1018 dcbf 0,r10 /* Force it out */
1019 sync /* Make sure it's out there */
1023 lbz r7,0(r10) /* ? */
1024 dcbi 0,r10 /* Force it out */
1025 sync /* kill it off */
1029 lis r7,0x0080 /* ? */
1030 lis r9,0xF300 /* ? */
1031 ori r7,r7,0x010F /* ? */
1032 stw r7,0x28(r9) /* ? */
1033 dcbf 0,r10 /* Force it out */
1034 sync /* Make sure it's out there */
1039 #if !SIMPLESCC && !NOTQUITEASSIMPLE
1040 rlwinm r9,r10,0,0,29 /* Get channel a */
1041 eieio /* Barricade it */
1044 stb r7,0(r9) /* ? */
1045 eieio /* Barricade it */
1047 lbz r7,0(r9) /* ? */
1049 eieio /* Barricade it */
1050 lbz r7,0(r9) /* ? */
1052 dchrw1: eieio /* Barricade it */
1053 lbz r7,0(r10) /* ? */
1054 andi. r7,r7,0x04 /* ? */
1055 beq dchrw1 /* Nope... */
1057 stb r3,4(r10) /* ? */
1058 sync /* Make sure it's there */
1059 eieio /* Don't get confused */
1061 dchrw2: eieio /* Barricade it */
1062 lbz r7,0(r10) /* ? */
1063 andi. r7,r7,0x04 /* ? */
1064 beq dchrw2 /* Nope... */
1066 eieio /* Avoid confusion */
1067 lbz r7,0(r10) /* ? */
1068 andi. r7,r7,0x40 /* ? */
1069 beq+ nounder /* Nope... */
1071 eieio /* Avoid confusion */
1073 stb r7,0(r10) /* ? */
1075 nounder: eieio /* Avoid confusion */
1077 stb r7,0(r10) /* ? */
1079 eieio /* Avoid confusion */
1081 stb r7,0(r9) /* ? */
1083 eieio /* Avoid confusion */
1085 stb r7,0(r10) /* ? */
1087 eieio /* Avoid confusion */
1089 stb r7,0(r10) /* ? */
1090 eieio /* Avoid confusion */
1098 hexTab: STRINGD "0123456789ABCDEF" /* Convert hex numbers to printable hex */
1102 * Dumps all the registers in the savearea in R13
1107 .globl EXT(dbgRegsLL)
1111 b EXT(FCReturn) ; Bye dudes...
1114 bl dbgRegsCm /* Join on up... */
1115 b EXT(FCReturn) ; Bye dudes...
1123 dbgRegsCm: mfmsr r8 /* Save the MSR */
1125 rlwinm r12,r8,0,28,25 /* Turn off translation */
1126 lis r10,0xF301 /* Set the top part */
1127 rlwinm r12,r12,0,17,15 /* Turn off interruptions */
1128 mtmsr r12 /* Smash the MSR */
1129 isync /* Make it clean */
1130 #if SIMPLESCC && !NOTQUITEASSIMPLE
1131 ori r10,r10,0x3010 /* ? */
1133 ori r10,r10,0x2000 /* ? */
1135 mflr r11 /* Save the link register */
1136 beq+ dbgDprints /* It sure are... */
1137 #if SIMPLESCC && !NOTQUITEASSIMPLE
1138 ori r10,r10,0x0020 /* ? */
1140 ori r10,r10,0x0002 /* ? */
1142 dcbf 0,r10 /* Insure it is out */
1144 dcbi 0,r10 /* Toss it */
1145 #if !NOTQUITEASSIMPLE
1146 lis r7,0xF300 /* ? */
1147 ori r7,r7,0x0032 /* ? */
1148 mtdbatl 3,r7 /* ? */
1149 lis r7,0xF300 /* ? */
1150 ori r7,r7,0x0002 /* ? */
1151 mtdbatu 3,r7 /* ? */
1152 ori r12,r12,0x0010 /* ? */
1159 lis r3,HIGH_ADDR(fwdisplock) /* Get the display locker outer */
1160 ori r3,r3,LOW_ADDR(fwdisplock) /* Last part */
1163 ddwait1: lwarx r5,0,r3 /* Get the lock */
1164 mr. r5,r5 /* Is it locked? */
1165 bne- ddwait1 /* Yup... */
1166 stwcx. r3,0,r3 /* Try to get it */
1167 bne- ddwait1 /* Nope, start all over... */
1169 li r3,0x52 /* Print eyecatcher */
1170 bl dbgDchar /* Send it */
1171 li r3,0x65 /* Print eyecatcher */
1172 bl dbgDchar /* Send it */
1173 li r3,0x67 /* Print eyecatcher */
1174 bl dbgDchar /* Send it */
1175 li r3,0x73 /* Print eyecatcher */
1176 bl dbgDchar /* Send it */
1177 li r3,0x20 /* Print eyecatcher */
1178 bl dbgDchar /* Send it */
1180 lwz r5,saver0(r13) /* Do register */
1181 bl dbg4byte /* Print */
1182 lwz r5,saver1(r13) /* Do register */
1183 bl dbg4byte /* Print */
1184 lwz r5,saver2(r13) /* Do register */
1185 bl dbg4byte /* Print */
1186 lwz r5,saver3(r13) /* Do register */
1187 bl dbg4byte /* Print */
1188 li r3,0x0A /* Linefeed */
1189 bl dbgDchar /* Send it */
1190 li r3,0x0D /* Carriage return */
1191 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 li r3,0x20 /* Print eyecatcher */
1198 bl dbgDchar /* Send it */
1199 li r3,0x20 /* Print eyecatcher */
1200 bl dbgDchar /* Send it */
1201 li r3,0x20 /* Print eyecatcher */
1202 bl dbgDchar /* Send it */
1203 lwz r5,saver4(r13) /* Do register */
1204 bl dbg4byte /* Print */
1205 lwz r5,saver5(r13) /* Do register */
1206 bl dbg4byte /* Print */
1207 lwz r5,saver6(r13) /* Do register */
1208 bl dbg4byte /* Print */
1209 lwz r5,saver7(r13) /* Do register */
1210 bl dbg4byte /* Print */
1211 li r3,0x0A /* Linefeed */
1212 bl dbgDchar /* Send it */
1213 li r3,0x0D /* Carriage return */
1214 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 li r3,0x20 /* Print eyecatcher */
1221 bl dbgDchar /* Send it */
1222 li r3,0x20 /* Print eyecatcher */
1223 bl dbgDchar /* Send it */
1224 li r3,0x20 /* Print eyecatcher */
1225 bl dbgDchar /* Send it */
1226 lwz r5,saver8(r13) /* Do register */
1227 bl dbg4byte /* Print */
1228 lwz r5,saver9(r13) /* Do register */
1229 bl dbg4byte /* Print */
1230 lwz r5,saver10(r13) /* Do register */
1231 bl dbg4byte /* Print */
1232 lwz r5,saver11(r13) /* Do register */
1233 bl dbg4byte /* Print */
1234 li r3,0x0A /* Linefeed */
1235 bl dbgDchar /* Send it */
1236 li r3,0x0D /* Carriage return */
1237 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 li r3,0x20 /* Print eyecatcher */
1244 bl dbgDchar /* Send it */
1245 li r3,0x20 /* Print eyecatcher */
1246 bl dbgDchar /* Send it */
1247 li r3,0x20 /* Print eyecatcher */
1248 bl dbgDchar /* Send it */
1249 lwz r5,saver12(r13) /* Do register */
1250 bl dbg4byte /* Print */
1251 lwz r5,saver13(r13) /* Do register */
1252 bl dbg4byte /* Print */
1253 lwz r5,saver14(r13) /* Do register */
1254 bl dbg4byte /* Print */
1255 lwz r5,saver15(r13) /* Do register */
1256 bl dbg4byte /* Print */
1257 li r3,0x0A /* Linefeed */
1258 bl dbgDchar /* Send it */
1259 li r3,0x0D /* Carriage return */
1260 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 li r3,0x20 /* Print eyecatcher */
1267 bl dbgDchar /* Send it */
1268 li r3,0x20 /* Print eyecatcher */
1269 bl dbgDchar /* Send it */
1270 li r3,0x20 /* Print eyecatcher */
1271 bl dbgDchar /* Send it */
1272 lwz r5,saver16(r13) /* Do register */
1273 bl dbg4byte /* Print */
1274 lwz r5,saver17(r13) /* Do register */
1275 bl dbg4byte /* Print */
1276 lwz r5,saver18(r13) /* Do register */
1277 bl dbg4byte /* Print */
1278 lwz r5,saver19(r13) /* Do register */
1279 bl dbg4byte /* Print */
1280 li r3,0x0A /* Linefeed */
1281 bl dbgDchar /* Send it */
1282 li r3,0x0D /* Carriage return */
1283 bl dbgDchar /* Send it */
1285 li r3,0x20 /* Print eyecatcher */
1286 bl dbgDchar /* Send it */
1287 li r3,0x20 /* Print eyecatcher */
1288 bl dbgDchar /* Send it */
1289 li r3,0x20 /* Print eyecatcher */
1290 bl dbgDchar /* Send it */
1291 li r3,0x20 /* Print eyecatcher */
1292 bl dbgDchar /* Send it */
1293 li r3,0x20 /* Print eyecatcher */
1294 bl dbgDchar /* Send it */
1295 lwz r5,saver20(r13) /* Do register */
1296 bl dbg4byte /* Print */
1297 lwz r5,saver21(r13) /* Do register */
1298 bl dbg4byte /* Print */
1299 lwz r5,saver22(r13) /* Do register */
1300 bl dbg4byte /* Print */
1301 lwz r5,saver23(r13) /* Do register */
1302 bl dbg4byte /* Print */
1303 li r3,0x0A /* Linefeed */
1304 bl dbgDchar /* Send it */
1305 li r3,0x0D /* Carriage return */
1306 bl dbgDchar /* Send it */
1308 li r3,0x20 /* Print eyecatcher */
1309 bl dbgDchar /* Send it */
1310 li r3,0x20 /* Print eyecatcher */
1311 bl dbgDchar /* Send it */
1312 li r3,0x20 /* Print eyecatcher */
1313 bl dbgDchar /* Send it */
1314 li r3,0x20 /* Print eyecatcher */
1315 bl dbgDchar /* Send it */
1316 li r3,0x20 /* Print eyecatcher */
1317 bl dbgDchar /* Send it */
1318 lwz r5,saver24(r13) /* Do register */
1319 bl dbg4byte /* Print */
1320 lwz r5,saver25(r13) /* Do register */
1321 bl dbg4byte /* Print */
1322 lwz r5,saver26(r13) /* Do register */
1323 bl dbg4byte /* Print */
1324 lwz r5,saver27(r13) /* Do register */
1325 bl dbg4byte /* Print */
1326 li r3,0x0A /* Linefeed */
1327 bl dbgDchar /* Send it */
1328 li r3,0x0D /* Carriage return */
1329 bl dbgDchar /* Send it */
1331 li r3,0x20 /* Print eyecatcher */
1332 bl dbgDchar /* Send it */
1333 li r3,0x20 /* Print eyecatcher */
1334 bl dbgDchar /* Send it */
1335 li r3,0x20 /* Print eyecatcher */
1336 bl dbgDchar /* Send it */
1337 li r3,0x20 /* Print eyecatcher */
1338 bl dbgDchar /* Send it */
1339 li r3,0x20 /* Print eyecatcher */
1340 bl dbgDchar /* Send it */
1341 lwz r5,saver28(r13) /* Do register */
1342 bl dbg4byte /* Print */
1343 lwz r5,saver29(r13) /* Do register */
1344 bl dbg4byte /* Print */
1345 lwz r5,saver30(r13) /* Do register */
1346 bl dbg4byte /* Print */
1347 lwz r5,saver31(r13) /* Do register */
1348 bl dbg4byte /* Print */
1349 li r3,0x0A /* Linefeed */
1350 bl dbgDchar /* Send it */
1351 li r3,0x0D /* Carriage return */
1352 bl dbgDchar /* Send it */
1354 /* Segment registers */
1356 li r3,0x53 /* Print eyecatcher */
1357 bl dbgDchar /* Send it */
1358 li r3,0x65 /* Print eyecatcher */
1359 bl dbgDchar /* Send it */
1360 li r3,0x67 /* Print eyecatcher */
1361 bl dbgDchar /* Send it */
1362 li r3,0x73 /* Print eyecatcher */
1363 bl dbgDchar /* Send it */
1364 li r3,0x20 /* Print eyecatcher */
1365 bl dbgDchar /* Send it */
1367 lwz r5,savesr0(r13) /* Do register */
1368 bl dbg4byte /* Print */
1369 lwz r5,savesr1(r13) /* Do register */
1370 bl dbg4byte /* Print */
1371 lwz r5,savesr2(r13) /* Do register */
1372 bl dbg4byte /* Print */
1373 lwz r5,savesr3(r13) /* Do register */
1374 bl dbg4byte /* Print */
1375 li r3,0x0A /* Linefeed */
1376 bl dbgDchar /* Send it */
1377 li r3,0x0D /* Carriage return */
1378 bl dbgDchar /* Send it */
1380 li r3,0x20 /* Print eyecatcher */
1381 bl dbgDchar /* Send it */
1382 li r3,0x20 /* Print eyecatcher */
1383 bl dbgDchar /* Send it */
1384 li r3,0x20 /* Print eyecatcher */
1385 bl dbgDchar /* Send it */
1386 li r3,0x20 /* Print eyecatcher */
1387 bl dbgDchar /* Send it */
1388 li r3,0x20 /* Print eyecatcher */
1389 bl dbgDchar /* Send it */
1390 lwz r5,savesr4(r13) /* Do register */
1391 bl dbg4byte /* Print */
1392 lwz r5,savesr5(r13) /* Do register */
1393 bl dbg4byte /* Print */
1394 lwz r5,savesr6(r13) /* Do register */
1395 bl dbg4byte /* Print */
1396 lwz r5,savesr7(r13) /* Do register */
1397 bl dbg4byte /* Print */
1398 li r3,0x0A /* Linefeed */
1399 bl dbgDchar /* Send it */
1400 li r3,0x0D /* Carriage return */
1401 bl dbgDchar /* Send it */
1403 li r3,0x20 /* Print eyecatcher */
1404 bl dbgDchar /* Send it */
1405 li r3,0x20 /* Print eyecatcher */
1406 bl dbgDchar /* Send it */
1407 li r3,0x20 /* Print eyecatcher */
1408 bl dbgDchar /* Send it */
1409 li r3,0x20 /* Print eyecatcher */
1410 bl dbgDchar /* Send it */
1411 li r3,0x20 /* Print eyecatcher */
1412 bl dbgDchar /* Send it */
1413 lwz r5,savesr8(r13) /* Do register */
1414 bl dbg4byte /* Print */
1415 lwz r5,savesr9(r13) /* Do register */
1416 bl dbg4byte /* Print */
1417 lwz r5,savesr10(r13) /* Do register */
1418 bl dbg4byte /* Print */
1419 lwz r5,savesr11(r13) /* Do register */
1420 bl dbg4byte /* Print */
1421 li r3,0x0A /* Linefeed */
1422 bl dbgDchar /* Send it */
1423 li r3,0x0D /* Carriage return */
1424 bl dbgDchar /* Send it */
1426 li r3,0x20 /* Print eyecatcher */
1427 bl dbgDchar /* Send it */
1428 li r3,0x20 /* Print eyecatcher */
1429 bl dbgDchar /* Send it */
1430 li r3,0x20 /* Print eyecatcher */
1431 bl dbgDchar /* Send it */
1432 li r3,0x20 /* Print eyecatcher */
1433 bl dbgDchar /* Send it */
1434 li r3,0x20 /* Print eyecatcher */
1435 bl dbgDchar /* Send it */
1436 lwz r5,savesr12(r13) /* Do register */
1437 bl dbg4byte /* Print */
1438 lwz r5,savesr13(r13) /* Do register */
1439 bl dbg4byte /* Print */
1440 lwz r5,savesr14(r13) /* Do register */
1441 bl dbg4byte /* Print */
1442 lwz r5,savesr15(r13) /* Do register */
1443 bl dbg4byte /* Print */
1444 li r3,0x0A /* Linefeed */
1445 bl dbgDchar /* Send it */
1446 li r3,0x0D /* Carriage return */
1447 bl dbgDchar /* Send it */
1449 li r3,0x30 /* Print eyecatcher */
1450 bl dbgDchar /* Send it */
1451 li r3,0x31 /* Print eyecatcher */
1452 bl dbgDchar /* Send it */
1453 li r3,0x64 /* Print eyecatcher */
1454 bl dbgDchar /* Send it */
1455 li r3,0x64 /* Print eyecatcher */
1456 bl dbgDchar /* Send it */
1457 li r3,0x20 /* Print eyecatcher */
1458 bl dbgDchar /* Send it */
1459 lwz r5,savesrr0(r13) /* Do register */
1460 bl dbg4byte /* Print */
1461 lwz r5,savesrr1(r13) /* Do register */
1462 bl dbg4byte /* Print */
1463 lwz r5,savedar(r13) /* Do register */
1464 bl dbg4byte /* Print */
1465 lwz r5,savedsisr(r13) /* Do register */
1466 bl dbg4byte /* Print */
1467 li r3,0x0A /* Linefeed */
1468 bl dbgDchar /* Send it */
1469 li r3,0x0D /* Carriage return */
1470 bl dbgDchar /* Send it */
1472 li r3,0x20 /* Print eyecatcher */
1473 bl dbgDchar /* Send it */
1474 li r3,0x6C /* Print eyecatcher */
1475 bl dbgDchar /* Send it */
1476 li r3,0x63 /* Print eyecatcher */
1477 bl dbgDchar /* Send it */
1478 li r3,0x63 /* Print eyecatcher */
1479 bl dbgDchar /* Send it */
1480 li r3,0x20 /* Print eyecatcher */
1481 bl dbgDchar /* Send it */
1482 lwz r5,savelr(r13) /* Do register */
1483 bl dbg4byte /* Print */
1484 lwz r5,savecr(r13) /* Do register */
1485 bl dbg4byte /* Print */
1486 lwz r5,savectr(r13) /* Do register */
1487 bl dbg4byte /* Print */
1488 li r3,0x0A /* Linefeed */
1489 bl dbgDchar /* Send it */
1490 li r3,0x0D /* Carriage return */
1491 bl dbgDchar /* Send it */
1492 mtlr r11 /* Get back the return */
1494 #if !SIMPLESCC && !NOTQUITEASSIMPLE
1495 li r7,0 /* Get a zero */
1496 mtdbatu 3,r7 /* Invalidate DBAT 3 upper */
1497 mtdbatl 3,r7 /* Invalidate DBAT 3 lower */
1499 lis r3,HIGH_ADDR(fwdisplock) /* Get the display locker outer */
1500 li r7,0 /* Get a zero */
1501 ori r3,r3,LOW_ADDR(fwdisplock) /* Last part */
1502 stw r7,0(r3) /* Clear display lock */
1503 mtmsr r8 /* Restore the MSR */
1504 isync /* Wait for it */
1509 * Used for debugging to leave stuff in 0x380-0x3FF (128 bytes).
1510 * Mapping is V=R. Stores and loads are real.
1518 mr r12,r0 /* Keep R0 pristene */
1519 lis r0,HIGH_ADDR(dbgCkptCall) /* Top half of dbgCkptCall firmware call number */
1520 ori r0,r0,LOW_ADDR(dbgCkptCall) /* Bottom half */
1522 sc /* Go stash the stuff */
1524 mr r0,r12 /* Restore R0 */
1527 /* Here's the low-level part of dbgCkpt */
1530 .globl EXT(dbgCkptLL)
1535 li r12,0x380 /* Point to output area */
1536 li r1,32 /* Get line size */
1537 dcbz 0,r12 /* Make sure we don't fetch a cache line */
1539 lwz r4,0x00(r3) /* Load up storage to checkpoint */
1541 dcbt r1,r3 /* Start in the next line */
1543 lwz r5,0x04(r3) /* Load up storage to checkpoint */
1544 lwz r6,0x08(r3) /* Load up storage to checkpoint */
1545 lwz r7,0x0C(r3) /* Load up storage to checkpoint */
1546 lwz r8,0x10(r3) /* Load up storage to checkpoint */
1547 lwz r9,0x14(r3) /* Load up storage to checkpoint */
1548 lwz r10,0x18(r3) /* Load up storage to checkpoint */
1549 lwz r11,0x1C(r3) /* Load up storage to checkpoint */
1551 add r3,r3,r1 /* Bump input */
1553 stw r4,0x00(r12) /* Store it */
1554 stw r5,0x04(r12) /* Store it */
1555 stw r6,0x08(r12) /* Store it */
1556 stw r7,0x0C(r12) /* Store it */
1557 stw r8,0x10(r12) /* Store it */
1558 stw r9,0x14(r12) /* Store it */
1559 stw r10,0x18(r12) /* Store it */
1560 stw r11,0x1C(r12) /* Store it */
1562 dcbz r1,r12 /* Clear the next line */
1563 add r12,r12,r1 /* Point to next output line */
1565 lwz r4,0x00(r3) /* Load up storage to checkpoint */
1566 lwz r5,0x04(r3) /* Load up storage to checkpoint */
1567 lwz r6,0x08(r3) /* Load up storage to checkpoint */
1568 lwz r7,0x0C(r3) /* Load up storage to checkpoint */
1569 lwz r8,0x10(r3) /* Load up storage to checkpoint */
1570 lwz r9,0x14(r3) /* Load up storage to checkpoint */
1571 lwz r10,0x18(r3) /* Load up storage to checkpoint */
1572 lwz r11,0x1C(r3) /* Load up storage to checkpoint */
1574 dcbt r1,r3 /* Touch the next line */
1575 add r3,r3,r1 /* Point to next input line */
1577 stw r4,0x00(r12) /* Store it */
1578 stw r5,0x04(r12) /* Store it */
1579 stw r6,0x08(r12) /* Store it */
1580 stw r7,0x0C(r12) /* Store it */
1581 stw r8,0x10(r12) /* Store it */
1582 stw r9,0x14(r12) /* Store it */
1583 stw r10,0x18(r12) /* Store it */
1584 stw r11,0x1C(r12) /* Store it */
1586 dcbz r1,r12 /* Clear the next line */
1587 add r12,r12,r1 /* Point to next output line */
1589 lwz r4,0x00(r3) /* Load up storage to checkpoint */
1590 lwz r5,0x04(r3) /* Load up storage to checkpoint */
1591 lwz r6,0x08(r3) /* Load up storage to checkpoint */
1592 lwz r7,0x0C(r3) /* Load up storage to checkpoint */
1593 lwz r8,0x10(r3) /* Load up storage to checkpoint */
1594 lwz r9,0x14(r3) /* Load up storage to checkpoint */
1595 lwz r10,0x18(r3) /* Load up storage to checkpoint */
1596 lwz r11,0x1C(r3) /* Load up storage to checkpoint */
1598 dcbt r1,r3 /* Touch the next line */
1599 add r3,r3,r1 /* Point to next input line */
1601 stw r4,0x00(r12) /* Store it */
1602 stw r5,0x04(r12) /* Store it */
1603 stw r6,0x08(r12) /* Store it */
1604 stw r7,0x0C(r12) /* Store it */
1605 stw r8,0x10(r12) /* Store it */
1606 stw r9,0x14(r12) /* Store it */
1607 stw r10,0x18(r12) /* Store it */
1608 stw r11,0x1C(r12) /* Store it */
1610 dcbz r1,r12 /* Clear the next line */
1611 add r12,r12,r1 /* Point to next output line */
1613 lwz r4,0x00(r3) /* Load up storage to checkpoint */
1614 lwz r5,0x04(r3) /* Load up storage to checkpoint */
1615 lwz r6,0x08(r3) /* Load up storage to checkpoint */
1616 lwz r7,0x0C(r3) /* Load up storage to checkpoint */
1617 lwz r8,0x10(r3) /* Load up storage to checkpoint */
1618 lwz r9,0x14(r3) /* Load up storage to checkpoint */
1619 lwz r10,0x18(r3) /* Load up storage to checkpoint */
1620 lwz r11,0x1C(r3) /* Load up storage to checkpoint */
1622 stw r4,0x00(r12) /* Store it */
1623 stw r5,0x04(r12) /* Store it */
1624 stw r6,0x08(r12) /* Store it */
1625 stw r7,0x0C(r12) /* Store it */
1626 stw r8,0x10(r12) /* Store it */
1627 stw r9,0x14(r12) /* Store it */
1628 stw r10,0x18(r12) /* Store it */
1629 stw r11,0x1C(r12) /* Store it */
1635 * Do Preemption. Forces a T_PREEMPT trap to allow a preemption to occur.
1639 .globl EXT(DoPreemptLL)
1643 li r3,T_PREEMPT /* Set preemption interrupt value */
1644 stw r3,saveexception(r13) /* Modify the exception type to preemption */
1645 b EXT(FCReturn) ; Bye dudes...
1649 * Force 'rupt handler to dispatch with new context
1650 * R3 at the call contains the new savearea.
1651 * R4 at the call contains a return code to pass back in R3.
1652 * Forces a T_CSWITCH
1656 .globl EXT(SwitchContextLL)
1658 LEXT(SwitchContextLL)
1660 li r3,T_CSWITCH /* Set context switch value */
1661 stw r3,saveexception(r13) /* Modify the exception type to switch context */
1662 b EXT(FCReturn) ; Bye dudes...
1666 * Create a fake I/O 'rupt.
1667 * Forces a T_INTERRUPT trap to pretend that an actual I/O interrupt occurred.
1671 .globl EXT(CreateFakeIOLL)
1673 LEXT(CreateFakeIOLL)
1675 li r3,T_INTERRUPT /* Set external interrupt value */
1676 stw r3,saveexception(r13) /* Modify the exception type to external */
1677 b EXT(FCReturn) ; Bye dudes...
1680 * Create a shutdown context
1681 * Forces a T_SHUTDOWN trap.
1685 .globl EXT(CreateShutdownCTXLL)
1687 LEXT(CreateShutdownCTXLL)
1689 li r3,T_SHUTDOWN /* Set external interrupt value */
1690 stw r3,saveexception(r13) /* Modify the exception type to external */
1691 b EXT(FCReturn) ; Bye dudes...
1694 * Create a fake decrementer 'rupt.
1695 * Forces a T_DECREMENTER trap to pretend that an actual decrementer interrupt occurred.
1699 .globl EXT(CreateFakeDECLL)
1701 LEXT(CreateFakeDECLL)
1703 li r3,T_DECREMENTER /* Set decrementer interrupt value */
1704 stw r3,saveexception(r13) /* Modify the exception type to external */
1705 b EXT(FCReturn) ; Bye dudes...
1712 .globl EXT(DoChokeLL)
1716 li r3,T_CHOKE ; Set external interrupt value
1717 stw r3,saveexception(r13) ; Modify the exception type to external
1718 b EXT(FCReturn) ; Bye dudes...
1721 * Null firmware call
1729 li r3,T_IN_VAIN ; Set to just ignore this one
1730 b EXT(FCReturn) ; Bye dudes...
1733 ; Null firmware call
1741 mfspr r4,pmc1 ; Get stamp
1742 stw r4,0x6100+(9*16)+0x0(0) ; Save it
1744 mfspr r4,pmc2 ; Get stamp
1745 stw r4,0x6100+(9*16)+0x4(0) ; Save it
1746 mfspr r4,pmc3 ; Get stamp
1747 stw r4,0x6100+(9*16)+0x8(0) ; Save it
1748 mfspr r4,pmc4 ; Get stamp
1749 stw r4,0x6100+(9*16)+0xC(0) ; Save it
1751 li r3,T_IN_VAIN ; Set to just ignore this one
1752 b EXT(FCReturn) ; Bye dudes...
1755 ; Set the low level trace flags
1759 .globl EXT(LLTraceSet)
1763 mr r4,r3 ; Save the new value
1765 lwz r3,traceMask(0) ; Get the old trace flags to pass back
1766 stw r4,traceMask(0) ; Replace with the new ones
1772 ; ***************************************************************************
1774 ; ----------------- Grateful Deb ----------------
1776 ; Debugging: direct draw into main screen menu bar
1778 ; Takes R4 value, converts it to hex characters and displays it.
1780 ; Gotta make sure the DCBST is done to force the pixels from the cache.
1782 ; Position is taken as column, row (0 based) from R3.
1783 ; Characters are from hexfont, and are 16x16 pixels.
1785 ; Only works with two processors so far
1788 ; ***************************************************************************
1791 #define GDfromright 20
1792 #define GDfontsize 16
1795 .globl EXT(GratefulDeb)
1799 mfspr r6,pir /* Get the PIR */
1800 lis r5,HIGH_ADDR(EXT(GratefulDebWork)) /* Point to our work area */
1801 rlwinm r6,r6,8,23,23 /* Get part of the offset to our processors area */
1802 ori r5,r5,LOW_ADDR(EXT(GratefulDebWork)) /* Start building the address */
1803 rlwimi r6,r6,2,21,21 /* Get the rest of the offset to our processors area */
1804 add r6,r6,r5 /* Point at our CPU's work area */
1805 mfmsr r5 /* Get that MSR */
1806 stmw r0,GDsave(r6) /* Save all registers */
1807 lwz r10,GDready(r6) /* See if we're all ready to go */
1808 ori r0,r5,0x2000 /* Turn on the floating point */
1809 mr r31,r6 /* Get a more sane base register */
1810 mr. r10,r10 /* Are we all set? */
1811 mtmsr r0 /* Enable floating point */
1814 stfd f0,GDfp0(r31) /* Save FP */
1815 stfd f1,GDfp1(r31) /* Save FP */
1816 stfd f2,GDfp2(r31) /* Save FP */
1817 stfd f3,GDfp3(r31) /* Save FP */
1819 beq- GDbailout /* Go and bail... */
1821 rlwinm r25,r3,0,16,31 /* Isolate just the row number */
1822 lwz r28,GDtopleft(r31) /* Get the physical address of our line 0 */
1823 rlwinm r3,r3,16,16,31 /* Isolate the column number */
1824 lwz r27,GDrowbytes(r31) /* Get the number of bytes per row */
1825 lwz r9,GDrowchar(r31) /* Get the number of bytes per row of full leaded charactrers */
1826 lwz r26,GDdepth(r31) /* Get the bit depth */
1827 mullw r25,r25,r9 /* get offset to the row to write in bytes */
1828 lwz r24,GDcollgn(r31) /* Get the size of columns in bytes */
1829 add r25,r28,r25 /* Physical address of row */
1830 mullw r3,r3,r24 /* Get byte offset to first output column */
1832 li r9,32 /* Get the initial shift calc */
1834 lis r20,HIGH_ADDR(hexfont) /* Point to the font */
1836 li r18,GDfontsize /* Get the number of rows in the font */
1837 ori r20,r20,LOW_ADDR(hexfont) /* Point to the low part */
1838 add r21,r25,r3 /* Physical address of top left output pixel */
1839 sub r9,r9,r26 /* Get right shift justifier for pixel size */
1840 li r7,32 /* Number of bits per word */
1843 la r6,GDrowbuf1(r31) /* Point to the row buffer */
1844 li r19,8 /* Get the number of characters in a row */
1846 getNybble: rlwinm r10,r4,9,23,26 /* Get the top nybble * 32 */
1847 rlwinm r4,r4,4,0,31 /* Rotate a nybble */
1848 add r10,r20,r10 /* Point to the character in the font */
1850 rlwinm r16,r26,4,0,27 /* Width of row in actual bits */
1851 lhz r15,0(r10) /* Get the next row of the font */
1853 rendrow: rlwinm r17,r15,16,0,0 /* Get the next font pixel in the row */
1854 rlwinm r15,r15,1,16,31 /* Move in the next font pixel */
1855 srawi r17,r17,31 /* Fill with 1s if black and 0s if white (reversed) */
1857 slw r14,r14,r26 /* Make room for our pixel in a register */
1858 srw r17,r17,r9 /* Isolate one pixels worth of black or white */
1859 sub. r7,r7,r26 /* See how may bits are left */
1860 sub r16,r16,r26 /* Count how many bits are left to store for this row */
1861 or r14,r14,r17 /* Put in the pixel */
1862 bne+ notfull /* Finish rendering this word */
1864 not r14,r14 /* Invert to black on white */
1865 stw r14,0(r6) /* Write out the word */
1866 li r7,32 /* Bit per word count */
1867 addi r6,r6,4 /* Point to the next word */
1869 notfull: mr. r16,r16 /* Have we finished the whole character row? */
1870 bne+ rendrow /* Finish rendering the row */
1872 addic. r19,r19,-1 /* Are we finished with a whole display row yet? */
1873 bne+ getNybble /* Not yet... */
1875 la r6,GDrowbuf1(r31) /* Point to the row buffer */
1876 rlwinm r19,r26,31,0,29 /* Number of cache lines (depth/2) */
1877 mr r14,r21 /* Get the frame buffer address */
1881 blitrow: lfd f0,0(r6) /* Load a line */
1886 stfd f0,0(r14) /* Blit a line */
1891 addi r6,r6,32 /* Next buffered line */
1893 dcbst 0,r14 /* Force the line to the screen */
1894 sync /* Make sure the line is on it's way */
1895 eieio /* Make sure we beat the invalidate */
1896 dcbi 0,r14 /* Make sure we leave no paradox */
1898 addic. r19,r19,-1 /* Done all lines yet? */
1899 addi r14,r14,32 /* Point to the next output */
1900 bne+ blitrow /* Nope, do it some more... */
1902 addic. r18,r18,-1 /* Have we done all the rows in character yet? */
1903 addi r20,r20,2 /* Offset the font to the next row */
1904 add r21,r21,r27 /* Point to start of next row */
1905 bne+ startNybble /* Nope, go through the word one more time... */
1907 GDbailout: mr r1,r31 /* Move the workarea base */
1909 lfd f0,GDfp0(r31) /* Restore FP */
1910 lfd f1,GDfp1(r31) /* Restore FP */
1911 lfd f2,GDfp2(r31) /* Restore FP */
1912 lfd f3,GDfp3(r31) /* Restore FP */
1914 mtmsr r5 /* Disable floating point */
1917 lmw r3,GDsave+12(r1) /* Restore most registers */
1918 lwz r0,GDsave(r1) /* Restore R0 */
1919 lwz r1,GDsave+4(r1) /* Finally, R1 */
1924 * void GratefulDebDisp(unsigned int coord, unsigned int data);
1929 .globl EXT(GratefulDebDisp)
1931 LEXT(GratefulDebDisp)
1933 mfmsr r9 /* Save the current MSR */
1934 mflr r7 /* Save the return */
1935 andi. r8,r9,0x7FCF /* Clear interrupt and translation */
1936 mtmsr r8 /* Turn 'em really off */
1937 isync /* Make sure about the translation part */
1938 bl EXT(GratefulDeb) /* Display it */
1939 mtmsr r9 /* Restore interrupt and translation */
1940 mtlr r7 /* Restore return */
1941 isync /* Make sure */
1948 * void checkNMI(void);
1953 .globl EXT(checkNMI)
1957 mfmsr r9 /* Save it */
1958 andi. r8,r9,0x7FCF /* Clear it */
1959 mtmsr r8 /* Disable it */
1960 isync /* Fence it */
1961 lis r7,0xF300 /* Find it */
1962 lis r2,hi16(MASK(MSR_VEC)) ; Get the vector enable
1963 ori r7,r7,0x0020 /* Find it */
1964 ori r2,r2,lo16(MASK(MSR_FP)) ; Get the FP enable
1965 dcbi 0,r7 /* Toss it */
1967 andc r9,r9,r2 ; Clear VEC and FP enables
1969 lwz r6,0x000C(r7) /* Check it */
1970 eieio /* Fence it */
1971 dcbi 0,r7 /* Toss it */
1972 rlwinm. r4,r6,0,19,19 /* Check it */
1973 rlwinm r6,r6,0,20,18 /* Clear it */
1975 eieio /* Fence it */
1976 beq+ xnonmi /* Branch on it */
1978 stw r6,0x0008(r7) /* Reset it */
1980 dcbi 0,r6 /* Toss it */
1981 eieio /* Fence it */
1983 mtmsr r9 /* Restore it */
1986 BREAKPOINT_TRAP /* Kill it */
1987 blr /* Return from it */
1989 xnonmi: /* Label it */
1990 mtmsr r9 /* Restore it */
1992 blr /* Return from it */
1995 ; Saves floating point registers
2003 lis r2,hi16(MASK(MSR_VEC)) ; Get the vector enable
2005 ori r2,r2,lo16(MASK(MSR_FP)) ; Get the FP enable
2006 ori r4,r4,lo16(MASK(MSR_EE)) ; Get the EE bit
2008 mfmsr r0 ; Save the MSR
2010 andc r4,r0,r4 ; Clear EE
2011 ori r4,r4,lo16(MASK(MSR_FP)) ; Enable floating point
2015 andc r0,r0,r2 ; Clear VEC and FP enables
2058 ; Saves vector registers. Returns 0 if non-Altivec machine.
2062 .globl EXT(stVectors)
2066 lis r2,hi16(MASK(MSR_VEC)) ; Get the vector enable
2068 ori r2,r2,lo16(MASK(MSR_FP)) ; Get the FP enable
2069 ori r4,r4,lo16(MASK(MSR_EE)) ; Get the EE bit
2071 mfsprg r6,2 ; Get features
2072 mr r5,r3 ; Save area address
2073 rlwinm. r6,r6,0,pfAltivecb,pfAltivecb ; Do we have Altivec?
2074 li r3,0 ; Assume failure
2077 mfmsr r0 ; Save the MSR
2079 andc r4,r0,r4 ; Clear EE
2081 oris r4,r4,hi16(MASK(MSR_VEC)) ; Enable vectors
2085 andc r0,r0,r2 ; Clear FP and VEC
2162 ; Saves yet more registers
2166 .globl EXT(stSpecrs)
2171 lis r2,hi16(MASK(MSR_VEC)) ; Get the vector enable
2173 ori r2,r2,lo16(MASK(MSR_FP)) ; Get the FP enable
2174 ori r4,r4,lo16(MASK(MSR_EE)) ; Get the EE bit
2176 mfsprg r9,2 ; Get feature flags
2177 mtcrf 0x02,r9 ; move pf64Bit cr6
2179 mfmsr r0 ; Save the MSR
2180 andc r0,r0,r2 ; Turn off VEC and FP
2181 andc r4,r0,r4 ; And EE
2187 rlwinm r12,r12,16,16,31
2189 bt++ pf64Bitb,stsSF1 ; skip if 64-bit (only they take the hint)
2240 stSnsr: mfsrin r6,r5
2247 cmplwi r12,PROCESSOR_VERSION_750
2270 isis750: stw r4,0(r3)
2283 b4750: stw r4,(44*4)(r3)
2290 cmplwi r12,PROCESSOR_VERSION_7400
2295 rlwinm r5,r5,0,16,31
2301 gnmax: mfspr r4,1016
2303 nnmax: stw r4,(48*4)(r3)
2336 stsslbm: slbmfee r6,r5
2352 ; fwEmMck - this forces the hardware to emulate machine checks
2353 ; Only valid on 64-bit machines
2354 ; Note: we want interruptions disabled here
2364 rlwinm r3,r3,0,1,0 ; Copy low of high high - scomd
2365 rlwinm r5,r5,0,1,0 ; Copy low of high high - hid1
2366 rlwinm r7,r7,0,1,0 ; Copy low of high high - hid4
2367 rlwimi r3,r4,0,0,31 ; Copy low of low low
2368 rlwimi r5,r6,0,0,31 ; Copy low of low low
2369 rlwimi r7,r8,0,0,31 ; Copy low of low low
2371 lis r9,3 ; Start forming hid1 error inject mask
2372 lis r10,hi16(0x01084083) ; Start formaing hid4 error inject mask
2373 ori r9,r9,0xC000 ; Next bit
2374 ori r10,r10,lo16(0x01084083) ; Next part
2375 sldi r9,r9,32 ; Shift up high
2376 sldi r10,r10,8 ; Shift into position
2378 mfspr r0,hid1 ; Get hid1
2379 mfspr r2,hid4 ; and hid4
2381 and r5,r5,r9 ; Keep only error inject controls - hid1
2382 and r7,r7,r10 ; Keep only error inject controls - hid4
2384 andc r0,r0,r9 ; Clear error inject controls hid1
2385 andc r2,r2,r10 ; Clear error inject controls hid4
2387 or r0,r0,r5 ; Add in the new controls hid1
2388 or r2,r2,r7 ; Add in the new controls hid4
2392 lis r12,CoreErrI ; Get the error inject controls
2395 mtspr scomd,r3 ; Set the error inject controls
2396 mtspr scomc,r12 ; Request error inject
2397 mfspr r11,scomc ; Get back the status (we just ignore it)
2402 mtspr hid1,r0 ; Move in hid1 controls
2403 mtspr hid1,r0 ; We need to do it twice
2407 mtspr hid4,r2 ; Move in hid4 controls
2413 ; fwSCOMrd - read/write SCOM
2420 lhz r12,scomfunc(r3) ; Get the function
2421 lwz r4,scomreg(r3) ; Get the register
2422 rldicr r4,r4,8,47 ; Position for SCOM
2424 mr. r12,r12 ; See if read or write
2425 bne fwSCwrite ; Go do a write
2427 mfsprg r0,2 ; Get the feature flags
2428 ori r4,r4,0x8000 ; Set to read data
2429 rlwinm. r0,r0,pfSCOMFixUpb+1,31,31 ; Set shift if we need a fix me up
2432 mtspr scomc,r4 ; Request the register
2433 mfspr r11,scomd ; Get the register contents
2434 mfspr r10,scomc ; Get back the status
2438 sld r11,r11,r0 ; Fix up if needed
2440 std r11,scomdata(r3) ; Save result
2442 std r10,scomstat(r3) ; Save status
2446 fwSCwrite: ld r5,scomdata(r3) ; Get the data
2450 mtspr scomd,r5 ; Set the data
2451 mtspr scomc,r4 ; Set it
2452 mfspr r10,scomc ; Get back the status
2456 std r10,scomstat(r3) ; Save status
2461 ; diagTrap - this is used to trigger checks from user space
2462 ; any "twi 31,r31,0xFFFx" will come here (x = 0 to F).
2463 ; On entry R3 points to savearea.
2464 ; R4 is the "x" from instruction;
2465 ; Pass back 1 to no-op twi and return to user
2466 ; Pass back 0 to treat as normal twi.
2469 .globl EXT(diagTrap)
2475 li r3,1 ; Ignore TWI
2482 ; setPmon - this is used to manipulate MMCR0 and MMCR1
2492 mtspr mmcr0,r0 ; Clear MMCR0
2493 mtspr mmcr1,r0 ; Clear MMCR1
2501 mtspr mmcr0,r3 ; Set MMCR0
2502 mtspr mmcr1,r4 ; Set MMCR1