Functions

xpal_extmem.c File Reference

interface to external SRAM (init, check) More...

#include "config.h"
#include "xpal_extmem.h"

Functions

hlog_extmem_info_textmem_test (uint8_t level)
 test external memory

Detailed Description

interface to external SRAM (init, check)


Function Documentation

hlog_extmem_info_t* extmem_test ( uint8_t  level  ) 

test external memory

At the moment, level is not used

We use the ((address+i) % 0xFF) as fill byte, this should detect the most common aliasing problems as well as dead cells

{
  uint8_t * p;
  uint8_t * end = xmem.xmem_end;
  uint8_t i; /* start byte */
  uint8_t b; /* fill byte */

  /* testing all possible byte values takes too long,
   * this takes approx. 0.5 seconds
   */
  for (i=7*31; i; i-=31) {
    uint8_t good_found = 0;
    /* fill memory */
    for (p = xmem.xmem_start, b = test_baseval (p, i);
         p != end+1;
         p++, b = fold_ff(b+1)) {
      *p = b;
    }
    /* check it */
    for (p = xmem.xmem_start, b = test_baseval (p, i);
         p != end+1;
         p++, b = fold_ff(b+1)) {
      if (*p == b) {
        good_found = 1;
      } else {
        if (good_found) {
          xmem.xmem_end = end = p;
          break; /* abort test */
        } else {
          xmem.xmem_start = p+1;
        }
      }
    }
  }
  return (xmem.xmem_start <= xmem.xmem_end) ? &xmem : NULL;
}