xscale_test.c
来自「eCos操作系统源码」· C语言 代码 · 共 1,435 行 · 第 1/4 页
C
1,435 行
hex32out(end_addr); printf(".\n"); memTest(start_addr, end_addr); printf("\n"); printf ("\nMemory test done.\n"); printf ("Press return to continue.\n"); (void) hexIn();}/****************************************************************************** memory_tests - Basic Memory Tests ** Memory tests can be run one of two ways - with the cache turned OFF to test* physical memory, or with cache turned ON to test the caching*/static void memory_tests (MENU_ARG arg){ 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"); memTest(start_addr, end_addr); printf("\n"); printf ("\nMemory test done.\n"); printf ("Press return to continue.\n"); (void) xgetchar();}/****************************************************************************** repeat_mem_test - Repeating Memory Tests **/static void repeat_mem_test (MENU_ARG arg){ unsigned long start_addr, mem_size, end_addr; char cache_disable[10]; printf ("Turn off Data Cache? (y/n): "); sgets (cache_disable); printf ("\n"); 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); while (memTest (start_addr, end_addr)) ;}/* 02/02/01 jwf *//****************************************************************************** special_mem_test - Repeat-On-Fail Memory Test ** Memory tests can be run one of two ways - with the cache turned OFF to test* physical memory, or with cache turned ON to test the caching*/static void special_mem_test (MENU_ARG arg){ 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();}const unsigned char SevSegDecode[] = { ZERO, ONE, TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE, LETTER_A, LETTER_B, LETTER_C, LETTER_D, LETTER_E, LETTER_F, DECIMAL_POINT, DISPLAY_OFF};/* sequential test for LSD and MSD 7 segment Leds */void seven_segment_display (MENU_ARG arg){ int DisplaySequence; int SelectLed; *MSB_DISPLAY_REG = DISPLAY_OFF; /* blank MSD 7 segment LEDS */ *LSB_DISPLAY_REG = 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) { /* 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 . */ if (SelectLed) *MSB_DISPLAY_REG = SevSegDecode[DisplaySequence]; else *LSB_DISPLAY_REG = SevSegDecode[DisplaySequence]; delay_ms(400); } /* end for(DisplaySequence~) */ ++SelectLed; /* select next 7 segment LED */ } while (SelectLed < 2); /* tests a pair of 7 segment LEDs */ *MSB_DISPLAY_REG = LETTER_S; *LSB_DISPLAY_REG = LETTER_S;}/* 12/18/00 jwf *//* tests rotary switch status, S1 positions 0-3, a 2 bit output code */void rotary_switch (MENU_ARG arg){ const unsigned char MAX_SWITCH_SAMPLES = 9; unsigned char RotarySwitch[MAX_SWITCH_SAMPLES]; unsigned char index; /* index for Rotary Switch array */ unsigned char debounce; /* keeps tally of equal rotary switch data reads in a loop */ char ch; *MSB_DISPLAY_REG = DISPLAY_OFF; *MSB_DISPLAY_REG = DISPLAY_OFF; 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."); printf( "\n\nStrike <CR> to exit this test." ); do { do { /* debounce the switch contacts */ for (index = 0; index <= MAX_SWITCH_SAMPLES; index++) { /* read rotary switch code */ RotarySwitch[index] = *(volatile unsigned char *)0xfe8d0000; RotarySwitch[index] &= 0x0f; } debounce = 0; for (index = 1; index <= MAX_SWITCH_SAMPLES; index++) if (RotarySwitch[0] == RotarySwitch[index]) debounce++; /* exit when all rotary switch code readings are equal, when debounce = MAX_SWITCH_SAMPLES-1 */ } while (debounce < (MAX_SWITCH_SAMPLES - 1)); /* display the rotary switch position on the 7 segment LSD LED as: 0, 1, 2, 3 */ *LSB_DISPLAY_REG = SevSegDecode[RotarySwitch[0]]; } while (!xgetchar_timeout(&ch, 200) || ch != 0x0d); /* run until User types a <CR> to exit */ *MSB_DISPLAY_REG = LETTER_S; *LSB_DISPLAY_REG = LETTER_S;}/* test backplane detection, connector socket J19 pin 7 *//* BP_DET#=0, no backplane *//* BP_DET#=1, backplane installed *//* b0 <--> BP_DET# */void backplane_detection(MENU_ARG arg){ 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(MENU_ARG arg){ unsigned char BatteryStatus; BatteryStatus = *(unsigned char *)0xfe8f0000; /* read battery status port */ /* examine bit b0 BATT_PRES# */ if (BatteryStatus & 0x01) /* TestBit=!(BATT_PRES#=0)=1 */ printf("\nBATT_PRES#=0. A battery was detected.\n"); else printf("\nBATT_PRES#=1. No battery installed.\n"); /* examine bit b1 BATT_CHRG */ if (BatteryStatus & 0x02) /* BATT_CHRG=1 */ printf("\nBATT_CHRG=1. Battery is fully charged.\n"); else /* BATT_CHRG=0 */ printf("\nBATT_CHRG=0. Battery is charging.\n"); /* examine bit b2 BATT_DISCHRG */ if (BatteryStatus & 0x04) printf("\nBATT_DISCHRG=1. Battery is fully discharged.\n"); else 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 (MENU_ARG arg){ /*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."); /* 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 */ *( 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) printf("\nGPIO Output Data Register first write/read test PASSED."); else printf("\nGPIO Output Data Register first write/read test FAILED."); /* write output data pattern to GPIO Output Data Register at address 00001724h */ *( unsigned char * ) 0x00001724 = 0xaa; /* read output data pattern from GPIO Output Data Register at address 00001724h */ GpioOutputPort = *( unsigned char * ) 0x00001724; if (GpioOutputPort==0xaa) printf("\nGPIO Output Data Register second write/read test PASSED."); else printf("\nGPIO Output Data Register second write/read test FAILED."); printf("\n\nRemove output test socket from header J16, strike 'Enter' to continue" ); while(xgetchar()!=0x0d);}/* i82559 Ethernet test */void ether_test (MENU_ARG arg){ cyg_pci_device_id devid[6]; int unit = 0; int i, num_enet; for (i = 0, num_enet = 0; i < 6; i++, num_enet++) { if (i == 0) devid[0] = CYG_PCI_NULL_DEVID; else devid[i] = devid[i-1]; // start from last one found if (!cyg_pci_find_device(VENDOR_INTEL, I82557, &devid[i])) break; } for (; i < 6; i++, num_enet++) { if (i == 0) devid[0] = CYG_PCI_NULL_DEVID; else devid[i] = devid[i-1]; // start from last one found if (!cyg_pci_find_device(VENDOR_INTEL, I82559ER, &devid[i])) break; } if (num_enet == 0) { printf ("No supported Ethernet devices found\n");
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?