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

📄 sma_mem_test.c

📁 sharp的arm920t 7A400的评估板附带光盘Sharp KEVLH7A400 v0.3b Welcome to the SHARP KEV7A400 Evaluation board
💻 C
📖 第 1 页 / 共 3 页
字号:
 *  start:      The start address
 *  end:        The end address
 *  pattern:    The fill pattern
 * 
 * Outputs: None. 
 * 
 * Returns: Nothing
 *  
 * Notes: None
 * 
 **********************************************************************/ 
void mem_fill8(UNS_8 * start, UNS_8 * end, UNS_8 pattern)
{
    volatile UNS_8 * addr;
    
    for (addr = start; addr <= end; addr++)
        *addr = pattern;
}

/*********************************************************************** 
 * 
 * Function: mem_fill16
 * 
 * Purpose: 
 *  fill the address range with a 16-bit pattern
 * 
 * Processing: 
 *
 * Parameters: 
 *  start:      The start address
 *  end:        The end address
 *  pattern:    The fill pattern
 * 
 * Outputs: None. 
 * 
 * Returns: Nothing
 *  
 * Notes: None
 * 
 **********************************************************************/ 
void mem_fill16(UNS_16 * start, UNS_16 * end, UNS_16 pattern)
{
    volatile UNS_16 * addr;
    
    for (addr = start; addr <= end; addr++)
        *addr = pattern;
}

/*********************************************************************** 
 * 
 * Function: mem_fill32
 * 
 * Purpose: 
 *  fill the address range with a 32-bit pattern
 * 
 * Processing: 
 *
 * Parameters: 
 *  start:      The start address
 *  end:        The end address
 *  pattern:    The fill pattern
 * 
 * Outputs: None. 
 * 
 * Returns: Nothing
 *  
 * Notes: None
 * 
 **********************************************************************/ 
void mem_fill32(UNS_32 * start, UNS_32 * end, UNS_32 pattern)
{
    volatile UNS_32 * addr;
    
    for (addr = start; addr <= end; addr++)
        *addr = pattern;
}

/*********************************************************************** 
 * 
 * Function: mem_fill_modify8
 * 
 * Purpose: 
 *  fill the address range with an 8-bit pattern
 * 
 * Processing: 
 *
 * Parameters: 
 *  start:      The start address
 *  end:        The end address
 *  pattern:    The fill pattern
 * 
 * Outputs: None. 
 * 
 * Returns: Nothing
 *  
 * Notes: None
 * 
 **********************************************************************/ 
void mem_fill_modify8(UNS_8 * start, UNS_8 * end, UNS_8 pattern)
{
    volatile UNS_8 * addr;
    
    for (addr = start; addr <= end; addr++)
    {
        *addr = pattern;
        pattern++;
    }
}

/*********************************************************************** 
 * 
 * Function: mem_fill_modify16
 * 
 * Purpose: 
 *  fill the address range with a 16-bit pattern
 * 
 * Processing: 
 *
 * Parameters: 
 *  start:      The start address
 *  end:        The end address
 *  pattern:    The fill pattern
 * 
 * Outputs: None. 
 * 
 * Returns: Nothing
 *  
 * Notes: None
 * 
 **********************************************************************/ 
void mem_fill_modify16(UNS_16 * start, UNS_16 * end, UNS_16 pattern)
{
    volatile UNS_16 * addr;
    
    for (addr = start; addr <= end; addr++)
    {
        *addr = pattern;
        // add 1 to each byte of the pattern in turn
        pattern += (1 << (((UNS_32)addr & 2) * 4));
    }
}

/*********************************************************************** 
 * 
 * Function: mem_fill_modify32
 * 
 * Purpose: 
 *  fill the address range with a 32-bit pattern
 * 
 * Processing: 
 *
 * Parameters: 
 *  start:      The start address
 *  end:        The end address
 *  pattern:    The fill pattern
 * 
 * Outputs: None. 
 * 
 * Returns: Nothing
 *  
 * Notes: None
 * 
 **********************************************************************/ 
void mem_fill_modify32(UNS_32 * start, UNS_32 * end, UNS_32 pattern)
{
    volatile UNS_32 * addr;
    
    for (addr = start; addr <= end; addr++)
    {
        *addr = pattern;
        // add 1 to each byte of the pattern in turn
        pattern += (1 << (((UNS_32)addr & 0xF) << 1));
    }
}

/*********************************************************************** 
 * 
 * Function: mem_verify8
 * 
 * Purpose: 
 *  verify the address range with an 8-bit pattern
 * 
 * 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_verify8(UNS_8 * start, UNS_8 * end, UNS_8 pattern,
                           MEM_ERROR_T * log, UNS_32 max_err,
                           const CHAR * test_name)
{
    volatile UNS_8 * addr;
    volatile UNS_8 read;
    UNS_32 err_count = 0;
    
    for (addr = start; addr <= end; 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++;
        }
    }
    return err_count;
}

/*********************************************************************** 
 * 
 * Function: mem_verify16
 * 
 * Purpose: 
 *  verify the address range with a 16-bit pattern
 * 
 * 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_verify16(UNS_16 * start, UNS_16 * end, UNS_16 pattern,
                           MEM_ERROR_T * log, UNS_32 max_err,
                           const CHAR * test_name)
{
    volatile UNS_16 * addr;
    volatile UNS_16 read;
    UNS_32 err_count = 0;
    
    for (addr = start; addr <= end; 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++;
        }
    }
    return err_count;
}

/*********************************************************************** 
 * 
 * Function: mem_verify32
 * 
 * Purpose: 
 *  verify the address range with a 32-bit pattern
 * 
 * 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.
 * 
 **********************************************************************/ 
UNS_32 mem_verify32(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; addr <= end; 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++;
        }
    }
    return err_count;
}

/*********************************************************************** 
 * 
 * Function: mem_verify_modify8
 * 
 * Purpose: 
 *  verify the address range with an 8-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_modify8(UNS_8 * start, UNS_8 * end, UNS_8 pattern,
                           MEM_ERROR_T * log, UNS_32 max_err,
                           const CHAR * test_name)
{
    volatile UNS_8 * addr;
    volatile UNS_8 read;
    volatile UNS_32 err_count = 0;
    
    for (addr = start; addr <= end; 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++;
        }
        pattern++;
    }
    return err_count;
}

/*********************************************************************** 
 * 
 * Function: mem_verify_modify16
 * 
 * Purpose: 
 *  verify the address range with a 16-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_modify16(UNS_16 * start, UNS_16 * end, UNS_16 pattern,
                           MEM_ERROR_T * log, UNS_32 max_err,
                           const CHAR * test_name)
{
    volatile UNS_16 * addr;
    volatile UNS_16 read;
    UNS_32 err_count = 0;
    
    for (addr = start; addr <= end; 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 & 2) * 4));
    }
    return err_count;
}

/*********************************************************************** 
 * 
 * Function: mem_verify_modify32

⌨️ 快捷键说明

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