⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sma_mem_test.c

📁 sharp的arm920t 7A400的评估板附带光盘Sharp KEVLH7A400 v0.3b Welcome to the SHARP KEV7A400 Evaluation board
💻 C
📖 第 1 页 / 共 3 页
字号:
 * 
 * Purpose: 
 *  verify the address range with a 32-bit pattern that increments
 *  one byte after each read
 * 
 * Processing: 
 *
 * Parameters: 
 *  start:      The start address
 *  end:        The end address
 *  pattern:    The fill pattern
 *  log:        An array of error data log[0:max_err - 1]
 *  max_err:    The maximum number of errors before abort.
 *  test_name:  The name of the test
 * 
 * Outputs: 
 *  writes to the log array the address, intended value and 
 *  value read back for each error
 * 
 * Returns: 
 *  the number of errors found. 0 indicates the test passed.
 *  
 * Notes: 
 *  If log is NULL, no errors will be logged.
 * 
 **********************************************************************/ 
UNS_32 mem_verify_modify32(UNS_32 * start, UNS_32 * end, UNS_32 pattern,
                           MEM_ERROR_T * log, UNS_32 max_err,
                           const CHAR * test_name)
{
    volatile UNS_32 * addr;
    volatile UNS_32 read;
    UNS_32 err_count = 0;
    
    for (addr = start, err_count = 0; 
         addr <= end && err_count < max_err; 
         addr++)
    {
        read = *addr;
        if (read != pattern)
        {
            if (log != NULL)
            {
                log[err_count].test_name = test_name;
                log[err_count].addr = addr;
                log[err_count].written = pattern;
                log[err_count].read = read;
            }
            err_count++;
        }
        // add 1 to each byte of the pattern in turn
        pattern += (1 << (((UNS_32)addr & 0xF) << 1));
    }

    return err_count;
}

/*********************************************************************** 
 * 
 * Function: mem_test8
 * 
 * Purpose: 
 *  Test the memory one byte at a time in the specified address range
 * 
 * Processing: 
 *
 * Parameters: 
 *  start:      The start address
 *  end:        The end address
 *  log:        An array of error data log[0:max_err - 1]
 *  max_err:    The maximum number of errors before abort.
 *  test_name:  The name of the test
 * 
 * Outputs: 
 *  writes to the log array the address, intended value and 
 *  value read back for each error
 * 
 * Returns: 
 *  the number of errors found. 0 indicates the test passed.
 *  
 * Notes: 
 *  If log is NULL, no errors will be logged.
 *  See SMA_mem_test.h for the MEM_TEST macro
 * 
 **********************************************************************/ 
UNS_32 mem_test8(UNS_8 * start, UNS_8 * end, 
                 MEM_ERROR_T * log, UNS_32 max_err)
{
    MEM_TEST(8,start,end,log,max_err);
}

/*********************************************************************** 
 * 
 * Function: mem_test16
 * 
 * Purpose: 
 *  Test the memory one halfword at a time in the 
 *  specified address range
 * 
 * Processing: 
 *
 * Parameters: 
 *  start:      The start address
 *  end:        The end address
 *  log:        An array of error data log[0:max_err - 1]
 *  max_err:    The maximum number of errors before abort.
 *  test_name:  The name of the test
 * 
 * Outputs: 
 *  writes to the log array the address, intended value and 
 *  value read back for each error
 * 
 * Returns: 
 *  the number of errors found. 0 indicates the test passed.
 *  
 * Notes: 
 *  If log is NULL, no errors will be logged.
 *  See SMA_mem_test.h for the MEM_TEST macro
 * 
 **********************************************************************/ 
UNS_32 mem_test16(UNS_16 * start, UNS_16 * end, 
                 MEM_ERROR_T * log, UNS_32 max_err)
{
    MEM_TEST(16,start,end,log,max_err);
}

/*********************************************************************** 
 * 
 * Function: mem_test32
 * 
 * Purpose: 
 *  Test the memory one word at a time in the specified address range
 * 
 * Processing: 
 *
 * Parameters: 
 *  start:      The start address
 *  end:        The end address
 *  log:        An array of error data log[0:max_err - 1]
 *  max_err:    The maximum number of errors before abort.
 *  test_name:  The name of the test
 * 
 * Outputs: 
 *  writes to the log array the address, intended value and 
 *  value read back for each error
 * 
 * Returns: 
 *  the number of errors found. 0 indicates the test passed.
 *  
 * Notes: 
 *  If log is NULL, no errors will be logged.
 *  See SMA_mem_test.h for the MEM_TEST macro
 * 
 **********************************************************************/ 
UNS_32 mem_test32(UNS_32 * start, UNS_32 * end, 
                 MEM_ERROR_T * log, UNS_32 max_err)
{
    MEM_TEST(32,start,end,log,max_err);
}


/*********************************************************************** 
 * 
 * Function: mem_test_data_bus8
 * 
 * Purpose: 
 *  Test the data bus one bit at a time at the specified address
 *  Use this test to verify that all pins of an off-chip data bus
 *  are wired to a memory device.
 * 
 * Processing: 
 *  See macro MEM_TEST_DATA_BUS in SMA_mem_test.h
 *
 * Parameters: 
 *  addr:  the address to access
 * 
 * Outputs: None
 * 
 * Returns: 
 *  0 if the test passed or _BIT(failed_bit) if the test failed
 *  
 * Notes: None
 * 
 **********************************************************************/ 
UNS_8 mem_test_data_bus8(UNS_8 * addr)
{
    MEM_TEST_DATA_BUS(8,addr);
}


/*********************************************************************** 
 * 
 * Function: mem_test_data_bus16
 * 
 * Purpose: 
 *  Test the data bus one bit at a time at the specified address
 *  Use this test to verify that all pins of an off-chip data bus
 *  are wired to a memory device.
 * 
 * Processing: 
 *  See macro MEM_TEST_DATA_BUS in SMA_mem_test.h
 *
 * Parameters: 
 *  addr:  the address to access
 * 
 * Outputs: None
 * 
 * Returns: 
 *  0 if the test passed or _BIT(failed_bit) if the test failed
 *  
 * Notes: None
 * 
 **********************************************************************/ 
UNS_16 mem_test_data_bus16(UNS_16 * addr)
{
    MEM_TEST_DATA_BUS(16,addr);
}

/*********************************************************************** 
 * 
 * Function: mem_test_data_bus32
 * 
 * Purpose: 
 *  Test the data bus one bit at a time at the specified address
 *  Use this test to verify that all pins of an off-chip data bus
 *  are wired to a memory device.
 * 
 * Processing: 
 *  See macro MEM_TEST_DATA_BUS in SMA_mem_test.h
 *
 * Parameters: 
 *  addr:  the address to access
 * 
 * Outputs: None
 * 
 * Returns: 
 *  0 if the test passed or _BIT(failed_bit) if the test failed
 *  
 * Notes: None
 * 
 **********************************************************************/ 
UNS_32 mem_test_data_bus32(UNS_32 * addr)
{
    MEM_TEST_DATA_BUS(32,addr);
}

/*********************************************************************** 
 * 
 * Function: mem_test_addr_bus8
 * 
 * Purpose: 
 *  Test the address bus one bit at a time starting at the the specified
 *  base address address over the range of nbytes. Use this test to
 *  verify that all pins of an off-chip address bus are wired to a
 *  memory device.
 * 
 * Processing: 
 *  See macro MEM_TEST_ADDR_BUS in SMA_mem_test.h
 *
 * Parameters: 
 *  addr:  the address to access
 * 
 * Outputs: None
 * 
 * Returns: 
 *  0 if the test passed or the failed address if the test failed
 *  
 * Notes: None
 * 
 **********************************************************************/ 
UNS_8 * mem_test_addr_bus8(UNS_8 * addr, UNS_32 nbytes)
{
    MEM_TEST_ADDR_BUS(8,addr,nbytes);
}

/*********************************************************************** 
 * 
 * Function: mem_test_addr_bus16
 * 
 * Purpose: 
 *  Test the address bus one bit at a time starting at the the specified
 *  base address address over the range of nbytes. Use this test to
 *  verify that all pins of an off-chip address bus are wired to a
 *  memory device.
 * 
 * Processing: 
 *  See macro MEM_TEST_ADDR_BUS in SMA_mem_test.h
 *
 * Parameters: 
 *  addr:  the address to access
 * 
 * Outputs: None
 * 
 * Returns: 
 *  0 if the test passed or the failed address if the test failed
 *  
 * Notes: None
 * 
 **********************************************************************/ 
UNS_16 * mem_test_addr_bus16(UNS_16 * addr, UNS_32 nbytes)
{
    MEM_TEST_ADDR_BUS(16,addr,nbytes);
}

/*********************************************************************** 
 * 
 * Function: mem_test_addr_bus32
 * 
 * Purpose: 
 *  Test the address bus one bit at a time starting at the the specified
 *  base address address over the range of nbytes. Use this test to
 *  verify that all pins of an off-chip address bus are wired to a
 *  memory device.
 * 
 * Processing: 
 *  See macro MEM_TEST_ADDR_BUS in SMA_mem_test.h
 *
 * Parameters: 
 *  addr:  the address to access
 * 
 * Outputs: None
 * 
 * Returns: 
 *  0 if the test passed or the failed address if the test failed
 *  
 * Notes: None
 * 
 **********************************************************************/ 
UNS_32 * mem_test_addr_bus32(UNS_32 * addr, UNS_32 nbytes)
{
    MEM_TEST_ADDR_BUS(32,addr,nbytes);
}


/*********************************************************************** 
 * 
 * Function: mem_test_random8
 * 
 * Purpose: 
 *  fill the memory with an 8-bit incremented pattern at a psuedo-
 *  randomly-generated address.
 * 
 * Processing: 
 *  See macro MEM_TEST_RANDOM processing description
 *
 * Parameters: 
 *  start:      The start address
 *  length:     The number of bytes to test
 *  log:        an array of MEM_TEST_T structures for logging errors
 *              or NULL if no logging is done
 *  max_err:    The maximum number of errors to catch before quiting
 *  test_name:  The identifier to place in the log.
 * 
 * Outputs: None. 
 * 
 * Returns: 
 *  _ERROR if parameters are out of range. Otherwise, returns
 * the number of errors. 0 means the test passed.
 *  
 * Notes: 
 *  This function works best if the address range is a power of 2.
 *  Use this as a test for address uniqueness. The probability of
 *  two memory locations at aliased addresses having the same
 *  value is very low.
 * 
 **********************************************************************/ 
INT_32 mem_test_random8(UNS_8 * start, UNS_32 length,
                           MEM_ERROR_T * log, UNS_32 max_err,
                           const CHAR * test_name)
{
    MEM_TEST_RANDOM(8,start,length,log,max_err, test_name);
}

/*********************************************************************** 
 * 
 * Function: mem_test_random16
 * 
 * Purpose: 
 *  fill the memory with an 16-bit incremented pattern at a psuedo-
 *  randomly-generated address.
 * 
 * Processing: 
 *  See macro MEM_TEST_RANDOM processing description
 *
 * Parameters: 
 *  start:      The start address
 *  length:     The number of halfwords to test
 *  log:        an array of MEM_TEST_T structures for logging errors
 *              or NULL if no logging is done
 *  max_err:    The maximum number of errors to catch before quiting
 *  test_name:  The identifier to place in the log.
 * 
 * Outputs: None. 
 * 
 * Returns: 
 *  _ERROR if parameters are out of range. Otherwise, returns
 * the number of errors. 0 means the test passed.
 *  
 * Notes: 
 *  This function works best if the address range is a power of 2.
 *  Use this as a test for address uniqueness. The probability of
 *  two memory locations at aliased addresses having the same
 *  value is very low.
 * 
 **********************************************************************/ 
INT_32 mem_test_random16(UNS_16 * start, UNS_32 length,
                           MEM_ERROR_T * log, UNS_32 max_err,
                           const CHAR * test_name)
{
    MEM_TEST_RANDOM(16,start,length,log,max_err, test_name);
}

/*********************************************************************** 
 * 
 * Function: mem_test_random32
 * 
 * Purpose: 
 *  fill the memory with an 32-bit incremented pattern at a psuedo-
 *  randomly-generated address.
 * 
 * Processing: 
 *  See macro MEM_TEST_RANDOM processing description
 *
 * Parameters: 
 *  start:      The start address
 *  length:     The number of words to test
 *  log:        an array of MEM_TEST_T structures for logging errors
 *              or NULL if no logging is done
 *  max_err:    The maximum number of errors to catch before quiting
 *  test_name:  The identifier to place in the log.
 * 
 * Outputs: None. 
 * 
 * Returns: 
 *  _ERROR if parameters are out of range. Otherwise, returns
 * the number of errors. 0 means the test passed.
 *  
 * Notes: 
 *  This function works best if the address range is a power of 2.
 *  Use this as a test for address uniqueness. The probability of
 *  two memory locations at aliased addresses having the same
 *  value is very low.
 * 
 **********************************************************************/ 
INT_32 mem_test_random32(UNS_32 * start, UNS_32 length,
                           MEM_ERROR_T * log, UNS_32 max_err,
                           const CHAR * test_name)
{
    MEM_TEST_RANDOM(32,start,length,log,max_err, test_name);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -