Commit b5bc5de5 authored by Thanassis Tsiodras's avatar Thanassis Tsiodras

Committed portable memchecking functionality used during RASTA tests

parent 375bea4b
Pipeline #226 skipped
...@@ -40,7 +40,8 @@ SRC= \ ...@@ -40,7 +40,8 @@ SRC= \
init.c \ init.c \
task1.c \ task1.c \
task2.c \ task2.c \
common.c common.c \
memcheck.c
SUFFIX=$(CFG).$(FPU_SUFFIX).$(LEON) SUFFIX=$(CFG).$(FPU_SUFFIX).$(LEON)
......
...@@ -18,6 +18,7 @@ rtems_task Init(rtems_task_argument argument) ...@@ -18,6 +18,7 @@ rtems_task Init(rtems_task_argument argument)
rtems_id Task_id[TASKS]; /* task ids */ rtems_id Task_id[TASKS]; /* task ids */
int i; int i;
memcheck();
g_init_task_id = rtems_task_self(); g_init_task_id = rtems_task_self();
for(i = 0; i < TASKS; i++) for(i = 0; i < TASKS; i++)
{ {
......
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include "system.h"
void memcheck()
{
uint32_t patterns[] = {
0x0,
0xFFFFFFFF,
0xAAAAAAAA,
0x55555555,
0xAA55AA55,
0x55AA55AA,
};
size_t space = 512*1024;
void *p = malloc(space);
int i;
printf("[MEMCHECK] Detecting memory available");
while(p) {
free(p);
printf(".");
fflush(stdout);
space += 1024*1024;
p = malloc(space);
}
space -= 1024*1024;
printf("\n[MEMCHECK] Memory available: %dK\n", space/1024);
p = malloc(space);
if (!p) {
puts("[MEMCHECK] Unexpected heap error. Aborting...");
fflush(stdout);
exit(1);
}
for(i=0; i<sizeof(patterns)/sizeof(patterns[0]); i++) {
printf("[MEMCHECK] Checking memory with pattern: 0x%x...\n", (unsigned) patterns[i]);
uint32_t *pw = p;
unsigned words = space/4;
// Writing the pattern
while(words--) {
*pw++ = patterns[i];
}
pw = p;
words = space/4;
// Verifying the pattern
while(words--) {
if (*pw != patterns[i]) {
printf(
"[MEMCHECK] Failed with pattern 0x%x at offset 0x%x\n",
(unsigned)patterns[i], (unsigned)pw);
fflush(stdout);
exit(1);
}
pw++;
}
}
free(p);
}
...@@ -8,6 +8,7 @@ rtems_task Task1_EntryPoint(rtems_task_argument argument); ...@@ -8,6 +8,7 @@ rtems_task Task1_EntryPoint(rtems_task_argument argument);
rtems_task Task2_EntryPoint(rtems_task_argument argument); rtems_task Task2_EntryPoint(rtems_task_argument argument);
void task_begin(int task_no); void task_begin(int task_no);
void task_end(int task_no); void task_end(int task_no);
void memcheck(void);
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
#define CONFIGURE_MAXIMUM_TASKS 64 #define CONFIGURE_MAXIMUM_TASKS 64
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment