📄 xscale_test.c
字号:
* physical memory, or with cache turned ON to test the caching*/static void special_mem_test (void){ long start_addr; long mem_size; long end_addr; printf ("Base address of memory to test (in hex): "); start_addr = hexIn(); printf("\n"); printf ("Size of memory to test (in hex): "); mem_size = hexIn(); printf("\n"); end_addr = start_addr + mem_size; printf("Testing memory from $"); hex32out(start_addr); printf(" to $"); hex32out(end_addr); printf(".\n"); LoopMemTest(start_addr, end_addr); printf("\n"); printf ("\nMemory test done.\n"); printf ("Press return to continue.\n"); (void) xgetchar();}/* sequential test for LSD and MSD 7 segment Leds */void seven_segment_display (void){ unsigned char SevSegDecode; int DisplaySequence; int SelectLed;/* 02/07/01 jwf *//* const unsigned long TIME_OUT=6000000;*//* 02/02/01 jwf *//* unsigned long Dwell;*//* volatile unsigned long Dwell;*/ *( unsigned char * ) 0xfe840000 = DISPLAY_OFF; /* blank MSD 7 segment LEDS */ *( unsigned char * ) 0xfe850000 = DISPLAY_OFF; /* blank LSD 7 segment LEDS */ SelectLed=0; /* initialize 7 segment LED selection */ do { /* run test data sequence for a 7 segment LED */ for (DisplaySequence = 0; DisplaySequence <= 17; ++DisplaySequence ) { /* fetch 7 segment decode byte */ switch( DisplaySequence ) { case 0: SevSegDecode = ZERO; break; case 1: SevSegDecode = ONE; break; case 2: SevSegDecode = TWO; break; case 3: SevSegDecode = THREE; break; case 4: SevSegDecode = FOUR; break; case 5: SevSegDecode = FIVE; break; case 6: SevSegDecode = SIX; break; case 7: SevSegDecode = SEVEN; break; case 8: SevSegDecode = EIGHT; break; case 9: SevSegDecode = NINE; break; case 10: SevSegDecode = LETTER_A; break; case 11: SevSegDecode = LETTER_B; break; case 12: SevSegDecode = LETTER_C; break; case 13: SevSegDecode = LETTER_D; break; case 14: SevSegDecode = LETTER_E; break; case 15: SevSegDecode = LETTER_F; break; case 16: SevSegDecode = DECIMAL_POINT; break; case 17: SevSegDecode = DISPLAY_OFF; default: break; } /* end switch( DisplaySequence ) */ /* display test data on selected 7 segment LED */ /* the test data sequence for a 7 segment led will be seen as:*/ /* 0 1 2 3 4 5 6 7 8 9 A b C d e F . */ switch( SelectLed ) { case 0: *( unsigned char * ) 0xfe850000 = SevSegDecode; /* write value on 7 segment LSD LED display */; break; case 1: *( unsigned char * ) 0xfe840000 = SevSegDecode; /* write value on 7 segment MSD LED display */; break; default: break; } /* end switch( SelectLed ) *//* 02/07/01 jwf */ /* time delay, allows user enough time to read a value on display *//* for (Dwell=TIME_OUT; Dwell > 0; --Dwell );*/ time_delay (0x325aa0, 4);/* Delay 0.4 second. Load counter with a 100ms count down (3300000)d per timer interrupt, 5 timer interrupts */ } /* end for(DisplaySequence~) */ ++SelectLed; /* select next 7 segment LED */ } while (SelectLed < 2); /* tests a pair of 7 segment LEDs */ *( unsigned char * ) 0xfe840000 = LETTER_S; /* show S on the 7 segment MSD LED */ *( unsigned char * ) 0xfe850000 = LETTER_S; /* show S on the 7 segment LSD LED */} /* end seven_segment_display() *//* 12/18/00 jwf *//* tests rotary switch status, S1 positions 0-3, a 2 bit output code */void rotary_switch (void){ /* CYGMON serial port J9 */ unsigned char recv_data; /* RHR */ unsigned char recv_lsr; /* LSR */ const unsigned char MAX_SWITCH_SAMPLES = 9; unsigned char RotarySwitch[MAX_SWITCH_SAMPLES]; /* holds multiple samples of a 4 bit switch code */ unsigned char index; /* index for Rotary Switch array */ unsigned char debounce; /* keeps tally of equal rotary switch data reads in a loop */ unsigned char SevSegDecode; /* holds decode data for a 7 segment LED display */ char board_rev; /* holds a Board Revision number *//* 02/07/01 jwf *//* const unsigned long TIME_OUT = 4000000;*//* 02/02/01 jwf *//* volatile unsigned int Dwell;*/ *( unsigned char * ) 0xfe840000 = DISPLAY_OFF; /* turn off the 7 segment MSD LED */ *( unsigned char * ) 0xfe850000 = DISPLAY_OFF; /* turn off the 7 segment LSD LED */ board_rev= board_revision (); /* Determine Board Revision Number */ if (board_rev >= BOARD_REV_E) /* Board Rev is at E or higher */ { printf("\n\nThe 7-Segment LSD LED shows the Rotary Switch position selected, i.e., 0-F."); printf("\n\nSlowly dial the Rotary Switch through each position 0-F and confirm reading."); } else /* Unknown Board Revision, might be D or B or A. */ { printf("\n\nThe 7-Segment LSD LED shows the Rotary Switch position selected, i.e., 0-3."); printf("\n\nSlowly dial the Rotary Switch through each position 0-3 and confirm reading."); } printf( "\n\nStrike <CR> to exit this test." ); while ( recv_data != 0x0d ) /* run until User types a <CR> to exit */ { do /* debounce the switch contacts */ { for(index = 0; index <= MAX_SWITCH_SAMPLES; index++) /* sample rotary switch code */ { RotarySwitch[index] = *( unsigned char * ) 0xfe8d0000; /* read rotary switch code */ RotarySwitch[index] &= 0x0f; /* mask out bits b7-b4, preserve bits b0-b3 */ } debounce = 0; for(index = 1; index <= MAX_SWITCH_SAMPLES; index++) /* test rotary switch code samples */ { if (RotarySwitch[0] == RotarySwitch[index]) debounce++; /* keep tally of equal rotary switch code samples */ } } while ( debounce < (MAX_SWITCH_SAMPLES - 1) ); /* exit when all rotary switch code readings are equal, when debounce = MAX_SWITCH_SAMPLES-1 */ /* decipher state of rotary switch position */ switch( RotarySwitch[0] ) /* examine rotary switch position then display its position number on the 7 segment LSD LED */ { case 0x00: SevSegDecode = ZERO; break; case 0x01: SevSegDecode = ONE; break; case 0x02: SevSegDecode = TWO; break; case 0x03: SevSegDecode = THREE; break; case 0x4: SevSegDecode = FOUR; break; case 0x5: SevSegDecode = FIVE; break; case 0x6: SevSegDecode = SIX; break; case 0x7: SevSegDecode = SEVEN; break; case 0x8: SevSegDecode = EIGHT; break; case 0x9: SevSegDecode = NINE; break; case 0xa: SevSegDecode = LETTER_A; break; case 0xb: SevSegDecode = LETTER_B; break; case 0xc: SevSegDecode = LETTER_C; break; case 0xd: SevSegDecode = LETTER_D; break; case 0xe: SevSegDecode = LETTER_E; break; case 0xf: SevSegDecode = LETTER_F; break; default: SevSegDecode = DECIMAL_POINT; break; } *( unsigned char * ) 0xfe850000 = SevSegDecode; /* display the rotary switch position on the 7 segment LSD LED as: 0, 1, 2, 3 */ recv_lsr = *(volatile unsigned char *) 0xfe810005; /* read J9 serial port LSR */ recv_lsr &= 0x1; if ( recv_lsr == 0x1) /* a character is ready in receiver buffer */ { recv_data = *(volatile unsigned char *) 0xfe810000; /* read character from J9 serial port receiver buffer */ }/* 02/07/01 jwf *//* for (Dwell=TIME_OUT; Dwell > 0; --Dwell );*/ time_delay (0x325aa0, 2);/* Delay 0.2 second. Load counter with a 100ms count down (3300000)d per timer interrupt, 2 timer interrupts */ } *( unsigned char * ) 0xfe840000 = LETTER_S; /* show S on the 7 segment MSD LED */ *( unsigned char * ) 0xfe850000 = LETTER_S; /* show S on the 7 segment LSD LED */} /* end rotary_switch() *//* test backplane detection, connector socket J19 pin 7 *//* BP_DET#=0, no backplane *//* BP_DET#=1, backplane installed *//* b0 <--> BP_DET# */void backplane_detection(void){ unsigned char BpDetStatus; /* L = pci700 board installed on backplane */ BpDetStatus = *( unsigned char * ) 0xfe870000; /* read backplane detection status port */ BpDetStatus &= 0x01; /* isolate bit b0 */ /* examine bit 0 */ switch( BpDetStatus ) { case 0x00: /* BpDetStatus = !(BP_DET#=1) = 0 */ printf("\nBackplane detection bit read Low, no backplane installed\n"); printf("\nPlace a jumper across J19.7 to J19.1, then run this test again.\n"); break; case 0x01: /* BpDetStatus = !(BP_DET#=0) = 1 */ printf("\nBackplane detection bit read High, 1 backplane detected.\n"); printf("\nRemove jumper from J19\n"); break; default: break; }/* 12/18/00 jwf */ printf ("\n\nStrike <CR> to exit this test.\n\n"); hexIn();}/* test battery status *//* b0 - !(BATT_PRES#=0). A battery is installed.*//* b1 - BATT_CHRG=1. The battery is fully charged. *//* b2 - BATT_DISCHRG=1. The battery is fully discharged. */void battery_status(void){ unsigned char BatteryStatus; unsigned char TestBit; BatteryStatus = *( unsigned char * ) 0xfe8f0000; /* read battery status port */ BatteryStatus &= 0x07; /* isolate bits b0, b1, and b2 */ TestBit = BatteryStatus; /* examine bit b0 BATT_PRES# */ TestBit &= 0x01; if (TestBit == 0x01) /* TestBit=!(BATT_PRES#=0)=1 */ { printf("\nBATT_PRES#=0. A battery was detected.\n"); } else /* TestBit=!(BATT_PRES#=1)=0 */ { printf("\nBATT_PRES#=1. No battery installed.\n"); /* skip testing bits b2 and b3 (BATT_CHRG and BATT_DISCHRG) here since no battery is installed yet */ } /* examine bit b1 BATT_CHRG */ TestBit |= BatteryStatus; TestBit &= 0x02; if (TestBit == 0x02) /* BATT_CHRG=1 */ /* Assume V_BATT float=4.2V, then 1.2V<V(U20.5)<=1.33V so V_BATT>3.78V,*/ printf("\nBATT_CHRG=1. Battery is fully charged.\n"); else /* BATT_CHRG=0 */ /* Assume V_BATT float=4.2V, then V(U20.5)<=1.2V so V_BATT<=3.78V */ printf("\nBATT_CHRG=0. Battery is charging.\n"); /* examine bit b2 BATT_DISCHRG */ TestBit |= BatteryStatus; TestBit &= 0x04; if (TestBit == 0x04) /* BATT_DISCHRG=1 */ /* Assume V_BATT float=4.2V, then V(U30.2)=<1.2V so V_BATT<=3.0V */ printf("\nBATT_DISCHRG=1. Battery is fully discharged.\n"); else /* BATT_DISCHRG=0 */ /* Assume V_BATT float=4.2V, then 1.2V<V(U30.2)=<1.68V so V_BATT>3.0V */ printf("\nBATT_DISCHRG=0. Battery voltage measures with in normal operating range.\n"); printf ("\n\nStrike <CR> to exit this test.\n\n"); hexIn();}/* GPIO test *//* Header J16 pin out is: J16.1=b0, J16.3=b1, J16.5=b2, J16.7=b3, J16.9=b4, J16.11=b5, J16.13=b6, J16.15=b7 *//* This test will require use of 2 special test sockets wired as follows for the output and input tests. *//* Intel specifies that each GPIO pin must be pulled down after P_RST# deasserts to swamp out their weak internal active pull up *//* Note that the internal weak active pull up tends to have more of an affect on the GPIO input port rather than the output port *//* Therefore for the input test, jumper J16 pins: 1-2, 3-4, 5-6, 7-8, 9-10, 11-12, 13-14, 15-16, and (TBD) provide an input source for each bit *//* For the output test, jumper J16 pins: 1-2, 3-4, 5-6, 7-8, 9-10, 11-12, 13-14, 15-16 *//* each jumpered pin connects a weak pull down resistor, resident on board, to each GPIO pin */void gpio_test (void){ /*unsigned char GpioInputPort;*/ unsigned char GpioOutputPort; unsigned char GpioOutputEnablePort; /* GPIO output port test */ printf("\n\nPlug output test socket into header J16, strike 'Enter' to continue" ); while(xgetchar()!=0x0d); /* write test data pattern to GPIO Output Enable Register at address 0x0000171c */ *( unsigned char * ) 0x0000171c = 0x55; /* read GPIO Output Enable Register from address 0x0000171c */ GpioOutputEnablePort = *( unsigned char * ) 0x0000171c; if (GpioOutputEnablePort==0x55) printf("\nGPIO Output Enable first write/read test PASSED."); else printf("\nGPIO Output Enable first write/read test FAILED.");/* printf("\n\nStrike Enter to continue" ); printf("\n0x55" ); while(xgetchar()!=0x0d);*/ /* write test data pattern to GPIO Output Enable Register at address 0x0000171c */ *( unsigned char * ) 0x0000171c = 0xaa; /* read GPIO Output Enable Register from address 0x0000171c */ GpioOutputEnablePort = *( unsigned char * ) 0x0000171c; if (GpioOutputEnablePort==0xaa) printf("\nGPIO Output Enable second write/read test PASSED."); else printf("\nGPIO Output Enable second write/read test FAILED."); /* enable output bits b0-b7, write test pattern to GPIO Output Enable Register at address 0x0000171c */ *( unsigned char * ) 0x0000171c = 0x00; /* write test data pattern to GPIO Output Data Register at address 00001724h */ *( unsigned char * ) 0x00001724 = 0x55; /* read test data pattern from GPIO Output Data Register at address 00001724h */ GpioOutputPort = *( unsigned char * ) 0x00001724; if (GpioOutputPort==0x55)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -