2013-07-11 13:03:45 -04:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#include <irq.h>
|
|
|
|
#include <uart.h>
|
|
|
|
#include <time.h>
|
2013-11-24 13:50:17 -05:00
|
|
|
#include <generated/csr.h>
|
2013-07-11 13:03:45 -04:00
|
|
|
#include <hw/flags.h>
|
|
|
|
#include <console.h>
|
2013-11-24 07:59:45 -05:00
|
|
|
#include <system.h>
|
2013-07-11 13:03:45 -04:00
|
|
|
|
|
|
|
static void membw_service(void)
|
|
|
|
{
|
|
|
|
static int last_event;
|
|
|
|
unsigned long long int nr, nw;
|
|
|
|
unsigned long long int f;
|
|
|
|
unsigned int rdb, wrb;
|
|
|
|
|
|
|
|
if(elapsed(&last_event, identifier_frequency_read())) {
|
2015-03-25 12:25:20 -04:00
|
|
|
sdram_controller_bandwidth_update_write(1);
|
|
|
|
nr = sdram_controller_bandwidth_nreads_read();
|
|
|
|
nw = sdram_controller_bandwidth_nwrites_read();
|
2013-07-11 13:03:45 -04:00
|
|
|
f = identifier_frequency_read();
|
2013-07-17 07:08:40 -04:00
|
|
|
rdb = (nr*f >> (24 - 7))/1000000ULL;
|
|
|
|
wrb = (nw*f >> (24 - 7))/1000000ULL;
|
|
|
|
printf("read:%5dMbps write:%5dMbps all:%5dMbps\n", rdb, wrb, rdb + wrb);
|
2013-07-11 13:03:45 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-24 07:59:45 -05:00
|
|
|
//#define DEBUG
|
|
|
|
|
2013-07-13 11:31:46 -04:00
|
|
|
static void memtest_service(void)
|
|
|
|
{
|
|
|
|
static unsigned int test_buffer[64*1024*1024/4] __attribute__((aligned(16)));
|
|
|
|
static unsigned char reading;
|
2013-11-24 07:59:45 -05:00
|
|
|
static unsigned int err, total_err;
|
|
|
|
#ifdef DEBUG
|
|
|
|
int i;
|
|
|
|
#endif
|
2013-07-13 11:31:46 -04:00
|
|
|
|
|
|
|
if(reading) {
|
|
|
|
if(!memtest_w_busy_read()) {
|
2013-11-24 07:59:45 -05:00
|
|
|
#ifdef DEBUG
|
|
|
|
flush_l2_cache();
|
|
|
|
flush_cpu_dcache();
|
|
|
|
printf("starting read\n");
|
|
|
|
for(i=0;i<64;i++) {
|
2013-07-13 11:31:46 -04:00
|
|
|
printf("%08x", test_buffer[i]);
|
|
|
|
if((i % 4) == 3)
|
|
|
|
printf("\n");
|
2013-11-24 07:59:45 -05:00
|
|
|
}
|
|
|
|
#endif
|
2013-07-13 11:31:46 -04:00
|
|
|
memtest_r_reset_write(1);
|
|
|
|
memtest_r_base_write((unsigned int)test_buffer);
|
|
|
|
memtest_r_length_write(sizeof(test_buffer));
|
|
|
|
memtest_r_shoot_write(1);
|
|
|
|
reading = 0;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if(!memtest_r_busy_read()) {
|
2013-11-24 07:59:45 -05:00
|
|
|
err = memtest_r_error_count_read();
|
|
|
|
total_err += err;
|
|
|
|
printf("err=%d\t\ttotal=%d\n", err, total_err);
|
2013-07-13 11:31:46 -04:00
|
|
|
memtest_w_reset_write(1);
|
|
|
|
memtest_w_base_write((unsigned int)test_buffer);
|
|
|
|
memtest_w_length_write(sizeof(test_buffer));
|
|
|
|
memtest_w_shoot_write(1);
|
|
|
|
reading = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-11 13:03:45 -04:00
|
|
|
int main(void)
|
|
|
|
{
|
|
|
|
irq_setmask(0);
|
|
|
|
irq_setie(1);
|
|
|
|
uart_init();
|
2015-03-25 12:25:20 -04:00
|
|
|
|
2013-07-11 13:03:45 -04:00
|
|
|
puts("Memory testing software built "__DATE__" "__TIME__"\n");
|
2013-07-13 11:31:46 -04:00
|
|
|
|
|
|
|
if((memtest_w_magic_read() != 0x361f) || (memtest_r_magic_read() != 0x361f)) {
|
|
|
|
printf("Memory test cores not detected\n");
|
|
|
|
while(1);
|
|
|
|
}
|
2015-03-25 12:25:20 -04:00
|
|
|
|
2013-07-11 13:03:45 -04:00
|
|
|
time_init();
|
|
|
|
|
2013-11-24 07:59:45 -05:00
|
|
|
flush_l2_cache();
|
2013-07-11 13:03:45 -04:00
|
|
|
while(1) {
|
2013-07-13 11:31:46 -04:00
|
|
|
memtest_service();
|
2013-07-11 13:03:45 -04:00
|
|
|
membw_service();
|
|
|
|
}
|
2015-03-25 12:25:20 -04:00
|
|
|
|
2013-07-11 13:03:45 -04:00
|
|
|
return 0;
|
|
|
|
}
|