mainssav.sav
来自「The Lite Evaluation/Demonstration Kit is」· SAV 代码 · 共 1,534 行 · 第 1/3 页
SAV
1,534 行
#Command Line: C:\Green\ccomppc.exe -X944 -X722 -X682 -X735 -X687 -X780 -X1165
# -X316 -X1042 -X405 -Z55 -Z70 -X371 -X1128 -X1311 -Z1031 -Z1032
# -X1177 -D__PROTOTYPES__ -D__STDC__=0 -D__ghs__ -D__ghs -Dghs
# -D__NoFloat -D__ELF -D__PowerPC -DPowerPC -D__ppc -Dppc
# -D__ppc860 -D__ghs_alignment=8 -D__BigEndian -DBigEndian
# -D__IeeeFloat -DIeeeFloat -D__Ptr_Is_Signed__
# -D__Char_Is_Unsigned__ -D__WChar_Is_Signed__ -D__WChar_Is_Long__
# -D__Int_Is_32 -D__Long_Is_32 -D__LL_Is_32 -D__Ptr_Is_32
# -D__Reg_Is_32 -U- -DEMBEDDED
# -IS:\Eng\3042\Software\DKTstng\860Lite -IC:\Green\ppc\include
# -IC:\Green\ansi -X698 -g -X1361 -X1293 -X1189 -X1116 -X614
# -DLANGUAGE_C -D__LANGUAGE_C -D__LANGUAGE_C__
# S:\Eng\3042\Software\DKTstng\860Lite\main.c main.s -sym=main.dbg
#Source File: S:\Eng\3042\Software\DKTstng\860Lite\main.c
#Directory: .
#Compile Date: Fri Jul 17 16:08:07 1998
#Host OS: Win32
#Version: C-POWERPC 1.8.8
#Revision Date: Wed Aug 27 14:43:20 1997
.nodebug
#1: /*****************************************************************************
#2: * MAIN.C
#3: *
#4: * For 3042 Testing...
#5: *
#6: * Copyright (c) 1997 Anchor Chips, Inc. See the license agreement for specific
#7: * details on the use of this source code. This code is intended to be used as
#8: * an example and is not guarenteed to be complete or correct.
#9: *****************************************************************************/
#12: #include "AN3042.h"
#14: // void aprintf( char *str, ... );
#16: const int NUMopr3042 = 8; // Number of records in the following table...
#18: struct reg_descrip_struct opRegs3042[NUMopr3042] =
#19: {
#20: // offset omask zmask text
#22: { 0x460, 0xFFFFe0f6, 0x00000000, "dahbase " },
#24: // Cannot do read/write test to 3 nv regs.
#26: { 0x4B0, 0x00003ffc, 0x00000000, "dmalbase" },
#27: { 0x4B4, 0xFFFFfffc, 0x00000000, "dmahbase" },
#28: { 0x4B8, 0x00003ffc, 0x00000000, "dmasize " },
#29: // Cannot do read/write test to dmactl reg.
#30:
#31: // Do not write the HCTL register in the testOpRegs !!! Cause the 3042 to go into Reset and
#32: // ignore further stimulus.
#33: // { 0x4E0, 0x00000003, "hctl " },
#34: { 0x4E4, 0x033B0018, 0x00000018, "hint " },
#35: { 0x4E8, 0x0000ffff, 0x00000000, "hldata " },
#37: { 0x4F4, 0x032B0000, 0x00000000, "lint " },
#38: { 0x4F8, 0x0000ffff, 0x00000000, "lhdata " },
#39: // { 0x4FC, 0x0000ff00, "lbuscfg " },
#40: };
#43: long * AN3042ptr = (long *) CS1_BASE;
#44: long * DAHBASEptr = (long *) (CS1_BASE + DAHBASEoffset);
#45: long * DAregion = (long *) (CS1_BASE + DAregionoffset) ;
#47: long * SRAMptr = (long *) CS2_BASE;
#48: long * LEDptr = (long *) CS3_BASE;
#49:
#51: long LEDvalue = 0; // A count up value used only in the LEDtest.
#54: struct _local_i2o_regs_struct * i2oregp = (struct _local_i2o_regs_struct *) CS1_BASE;
#55: struct op_regs_struct_42_t * regp = (struct op_regs_struct_42_t *) (CS1_BASE + OP_REGS_BASE_42);
#59: // Returns the IMMR (Internal Memory Map Register) of the 860
#60: long get_immr (void)
#61: {
.text
.globl ..bof.main..2E
..bof.main..2E:
.align 2
.long 0 # alloca=0;fmax=0;gmax=0;sp=lr=0;cr=fpscr=0
.globl get_immr
get_immr:
# .bf
#62: return (0); // Future: can do assembly language to actually read the IMMR.
# .bs
li r3, 0
#63: }
# .es
# .ef
blr
__ghs_eofn_get_immr::
.type get_immr,@function
.size get_immr,$-get_immr
.align 2
#function: get_immr
#stack frame size: 0
#
.data
.text
#66: void writeLED (long value, long limit)
#67: {
.align 2
.align 2
.align 2
.long 16444 # alloca=1;fmax=0;gmax=3;sp=lr=1;cr=fpscr=0
.globl writeLED
writeLED:
mflr r0
mr r11, sp
stwu sp, -24(sp)
bl _savegpr_29_l
mr r30, r3
# .bf
#68: ////////////////////////////////////////////////////////////////////////
#69: // The CS3# is connected to the LED strobe, so every time we write to
#70: // the CS3# addresses, we write to the LED (for the VBoard 0x300000)
#71: ////////////////////////////////////////////////////////////////////////
#72: long temp = value;
mr r31, r30
#74: if (limit)
# .bs
#75: if (temp > 0xF)
cmplwi r4, 0
beq .L17
#76: temp = 0xF; // Limit what we write to the LED to 0xF, but put the entire value onto the data bus.
cmpwi r31, 15
ble .L17
li r31, 15
#78: *( (short *) (get_immr() + PADAT) ) = (temp << 4) & 0xF0; // Put value to PA port (shifting left into PA 8-11) so we can strobe into LED next.
.L17:
bl get_immr
addi r10, r3, 2390
slwi r11, r31, 4
andi. r29, r11, 240
sth r29, 0(r10)
#79: *LEDptr = value; // Strobe the LED and puts value onto the data bus
lis r12, %hiadj(LEDptr)
lwz r11, %lo(LEDptr)(r12)
stw r30, 0(r11)
#80: // where we can conveniently look at value via a logic analyzer.
#81: // This is useful, since the LED only displays up to 0xF.
#82: /*
#83: Here's the assembly code to do approximately the same thing...
#85: ; Display value in r5 into the LED
#86: slwi r5,r5,4 ; Shift left into PA 8-11
#87: sth r5,PADAT(r4) ; Setup the A port data (goes to the LED)
#88: lis r3,CS3_HI_BASE
#89: ori r3,r3,0
#90: stw r5,0(r3) ; Strobe PA into the LED Display and other LEDs. For convenience, r5 is also strobed onto the data bus.
#91: */
#93: }
# .es
# .ef
addi r11, sp, 24
b _restgpr_29_l
__ghs_eofn_writeLED::
.type writeLED,@function
.size writeLED,$-writeLED
.align 2
#function: writeLED
#stack frame size: 24
#link area offset: 0
#local storage area offset: 12
#gpr save area offset: 12
#
#temp r31 local
#value r30 param
#limit r4 param
.section ".rodata","a"
.L34:# "dahbase "
.byte 100,97,104,98
.byte 97,115,101,32
.byte 0
.space 3
.L35:# "dmalbase"
.byte 100,109,97,108
.byte 98,97,115,101
.byte 0
.space 3
.L36:# "dmahbase"
.byte 100,109,97,104
.byte 98,97,115,101
.byte 0
.space 3
.L37:# "dmasize "
.byte 100,109,97,115
.byte 105,122,101,32
.byte 0
.space 3
.L38:# "hint "
.byte 104,105,110,116
.byte 32,32,32,32
.byte 0
.space 3
.L39:# "hldata "
.byte 104,108,100,97
.byte 116,97,32,32
.byte 0
.space 3
.L40:# "lint "
.byte 108,105,110,116
.byte 32,32,32,32
.byte 0
.space 3
.L41:# "lhdata "
.byte 108,104,100,97
.byte 116,97,32,32
.byte 0
.data
.text
#95: // Just a convenient place to trigger the logic analyzer if an error occurs.
#96: void errorHandler(long value, long limit)
#97: {
.align 2
.align 2
.long 16396 # alloca=1;fmax=0;gmax=0;sp=lr=1;cr=fpscr=0
.globl errorHandler
errorHandler:
mflr r0
stw r0, 4(sp)
stwu sp, -8(sp)
# .bf
#98: writeLED(value, limit);
# .bs
bl writeLED
#99: }
# .es
# .ef
lwz r0, 12(sp)
mtlr r0
addi sp, sp, 8
blr
__ghs_eofn_errorHandler::
.type errorHandler,@function
.size errorHandler,$-errorHandler
.align 2
#function: errorHandler
#stack frame size: 8
#link area offset: 0
#local storage area offset: 8
#
#value r3 param
#limit r4 param
.data
.text
#102: /* void setLED (LEDNum, newState)
#103: {
#104: short PAport;
#106: PAport = *( (short *) (get_immr() + PADAT) ); // Get current contents of PAport
#108: if (newState)
#109: *( (short *) (get_immr() + PADAT) ) = PAport | ;
#110: else
#111: *( (short *) (get_immr() + PADAT) ) = PAport | ;
#113: *LEDptr = PAport; // Strobe the LED and put new PAport value onto the data bus
#114: }
#117: long aliveLEDstate = OFF;
#118: #define ALIVE_LED 5
#120: void indicateAlive(void)
#121: {
#122: if (aliveLED)
#123: {
#124: aliveLEDstate = OFF;
#125: setLED (ALIVE_LED, OFF);
#126: }
#127: else
#128: {
#129: aliveLEDstate = ON;
#130: setLED (ALIVE_LED, ON);
#131: }
#133: // Wait loop
#134: for (count = 0; count < 10000; count ++)
#135: temp = 0x11223344;
#136: }
#137: */
#140: void waitDMAComplete(void)
#141: {
.align 2
.align 2
.long 16396 # alloca=1;fmax=0;gmax=0;sp=lr=1;cr=fpscr=0
.globl waitDMAComplete
waitDMAComplete:
mflr r0
stw r0, 4(sp)
stwu sp, -8(sp)
# .bf
#142: DWORD timeout, tempd;
#144: // Wait for the DMA complete bit to be set
#145: #define loopsPerByte 0x1000 // Number of times through this 'while' loop per byte of DMA.
#146: timeout = 0x1000 * loopsPerByte; // Give mucho time to complete.
# .bs
lis r8, 256
#147: while ( ((regp->lint & DMAcompleteBit) != DMAcompleteBit)
b .L60
.L61:
addi r8, r8, -1
#152: if (timeout == 0)
.L60:
#148: && timeout
#149: )
#150: timeout--;
lis r12, %hiadj(regp)
lwz r11, %lo(regp)(r12)
lwz r9, 148(r11)
andi. r10, r9, 32
cmplwi r10, 32
bne .L62
b .L59
.L62:
cmplwi r8, 0
bne .L61
.L59:
#153: {
cmplwi r8, 0
bne .L63
#154: errorHandler (0, FALSE);
li r3, 0
li r4, 0
bl errorHandler
#155: // printf ("Error: timed out before DMAcompleteBit set (DMA completed). Errs=%d\n", errorCnt);
#156: return;
b .L57
.L63:
#157: }
#159: tempd = regp->lint;
lis r12, %hiadj(regp)
lwz r8, %lo(regp)(r12)
lwz r11, 148(r8)
#160: regp->lint = DMAcompleteBit; // Clear the DMAcompleteBit. Is a Write One Clear bit !!!
lis r12, %hiadj(regp)
lwz r7, %lo(regp)(r12)
li r0, 32
stw r0, 148(r7)
#161: tempd = regp->lint;
lis r12, %hiadj(regp)
lwz r11, %lo(regp)(r12)
lwz r11, 148(r11)
#162: }
# .es
.L57:
# .ef
lwz r0, 12(sp)
mtlr r0
addi sp, sp, 8
blr
__ghs_eofn_waitDMAComplete::
.type waitDMAComplete,@function
.size waitDMAComplete,$-waitDMAComplete
.align 2
#function: waitDMAComplete
#stack frame size: 8
#link area offset: 0
#local storage area offset: 8
#
#timeout r8 local
#tempd r11 local
.data
.text
#166: //
#167: // testOpRegs
#168: //
#169: //
#170: void testOpRegs (void)
#171: {
.align 2
.align 2
.long 16508 # alloca=1;fmax=0;gmax=7;sp=lr=1;cr=fpscr=0
.globl testOpRegs
testOpRegs:
mflr r0
mr r11, sp
stwu sp, -40(sp)
bl _savegpr_25_l
# .bf
#172: int errorCnt = 0;
li r31, 0
#173: DWORD i;
#174: DWORD * regs = (DWORD *) CS1_BASE; // OpRegs are at 0 beyond CS1#
lis r26, 16
#176: unsigned char tempc, origLP;
#177: DWORD origDMACTL, tempd;
#180: for (i = 0 ; i < NUMopr3042 ; i++)
# .bs
li r30, 0
#181: {
b .L93
.L92:
#182: DWORD temp, orig;
#183: DWORD * theReg;
#184: DWORD theOMask = opRegs3042[i].omask; // Copy to temp variables to make the code more readable.
mr r11, r30
slwi r11, r11, 4
lis r9, %hiadj(opRegs3042)
addi r9, r9, %lo(opRegs3042)
add r10, r9, r11
lwz r6, 4(r10)
#185: DWORD theZMask = opRegs3042[i].zmask;
mr r8, r30
slwi r8, r8, 4
lis r11, %hiadj(opRegs3042)
addi r11, r11, %lo(opRegs3042)
add r7, r11, r8
lwz r25, 8(r7)
#186: char * theText = opRegs3042[i].text;
mr r10, r30
slwi r10, r10, 4
lis r8, %hiadj(opRegs3042)
addi r8, r8, %lo(opRegs3042)
add r9, r8, r10
lwz r11, 12(r9)
#187: DWORD theOffset = opRegs3042[i].offset;
mr r7, r30
slwi r7, r7, 4
lis r10, %hiadj(opRegs3042)
addi r10, r10, %lo(opRegs3042)
add r11, r10, r7
lwz r27, 0(r11)
#189: theReg = regs + (theOffset/4); // The /4 is to convert from byte offset
# .bs
srwi r9, r27, 2
mr r8, r9
slwi r8, r8, 2
add r29, r26, r8
#190: // (as coded in opRegs3042 table)
#191: // to a DWORD offset.
#192: orig = *theReg; // Get original.
lwz r28, 0(r29)
#193: // writeLED(orig, FALSE);
#195: *theReg = 0xFFFFffff; // Attempt to write all ones.
li r0, -1
stw r0, 0(r29)
#196: if ((temp = *theReg) != theOMask) // Read it back.
#197: {
lwz r11, 0(r29)
cmplw r11, r6
beq .L94
#198: errorCnt++;
addi r31, r31, 1
#199: errorHandler (errorCnt, FALSE);
mr r3, r31
li r4, 0
bl errorHandler
#200: // printf (" Bad %s: WR 0xFFFFffff RD %08x Should RD %08x Errs %d\n",
#201: // theText, temp, theMask, errorCnt);
#202: }
#204: *theReg = 0; // Attempt to write all zeros.
.L94:
li r0, 0
stw r0, 0(r29)
#205: if ((temp = *theReg) != theZMask) // Read it back.
#206: {
lwz r11, 0(r29)
cmplw r11, r25
beq .L96
#207: errorCnt++;
addi r31, r31, 1
#208: errorHandler (errorCnt, FALSE);
mr r3, r31
li r4, 0
bl errorHandler
#209: // printf (" Bad %s: WR 0 RD %08x Should RD 0 Errs %d\n",
#210: // theText, temp, errorCnt);
#211: }
#213: *theReg = orig; // Attempt to restore original.
.L96:
stw r28, 0(r29)
#214: if ((temp = *theReg) != orig) // Read it back.
#215: {
lwz r11, 0(r29)
cmplw r11, r28
beq .L98
#216: if (theOffset == 0x4E4) // Offset for the HINT. The restoration of the HINT is different from the original, because:
#217: // 1. We kicked off several DMAs below.
#218: // 2. The DMA completed (almost immediately), which set the DMA Complete bit in the HINT (0x20).
#219: // 3. Then, on the next entry to this test, the Write all Ones above cleared the DMA Complete bit.
#220: {
cmplwi r27, 1252
bne .L100
#221: if (temp != 0x00000018)
#222: {
cmplwi r11, 24
beq .L98
#223: errorCnt++;
addi r31, r31, 1
#224: errorHandler (errorCnt, FALSE);
mr r3, r31
li r4, 0
bl errorHandler
#225: // printf (" Bad %s: WR %08x RD %08x Should RD %08x Errs %d\n",
#226: // theText, orig, temp, orig, errorCnt);
#227: }
#228: }
b .L98
.L100:
#229: else
#230: {
#231: errorCnt++;
addi r31, r31, 1
#232: errorHandler (errorCnt, FALSE);
mr r3, r31
li r4, 0
bl errorHandler
#233: // printf (" Bad %s: WR %08x RD %08x Should RD %08x Errs %d\n",
#234: // theText, orig, temp, orig, errorCnt);
#235: }
#236: }
.L98:
#238: } // end for each record in opRegs3042 table
# .es
#240: // printf ("\n");
#242: // DMA test
#243: // Test arbitration bits.
#246: // Alternate test of LP bits:
#247: // DWORD write the DMACTL, but first set up the DMA so it is relatively
#248: // harmless when it gets kicked off.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?