7 #include <generated/csr.h>
8 #include <generated/mem.h>
13 static unsigned int log2(unsigned int v
)
21 static void membw_service(void)
23 static int last_event
;
24 unsigned long long int nr
, nw
;
25 unsigned long long int f
;
26 unsigned int rdb
, wrb
;
29 if(elapsed(&last_event
, identifier_frequency_read())) {
30 sdram_controller_bandwidth_update_write(1);
31 nr
= sdram_controller_bandwidth_nreads_read();
32 nw
= sdram_controller_bandwidth_nwrites_read();
33 f
= identifier_frequency_read();
34 dw
= sdram_controller_bandwidth_data_width_read();
35 rdb
= (nr
*f
>> (24 - log2(dw
)))/1000000ULL;
36 wrb
= (nw
*f
>> (24 - log2(dw
)))/1000000ULL;
37 printf("read:%5dMbps write:%5dMbps all:%5dMbps\n", rdb
, wrb
, rdb
+ wrb
);
43 static void memtest_service(void)
45 static unsigned int test_buffer
[(MAIN_RAM_SIZE
/2)/4] __attribute__((aligned(16)));
46 static unsigned char reading
;
47 static unsigned int err
, total_err
;
53 if(!memtest_w_busy_read()) {
57 printf("starting read\n");
59 printf("%08x", test_buffer
[i
]);
64 memtest_r_reset_write(1);
65 memtest_r_base_write((unsigned int)test_buffer
);
66 memtest_r_length_write(sizeof(test_buffer
));
67 memtest_r_shoot_write(1);
71 if(!memtest_r_busy_read()) {
72 err
= memtest_r_error_count_read();
74 printf("err=%d\t\ttotal=%d\n", err
, total_err
);
75 memtest_w_reset_write(1);
76 memtest_w_base_write((unsigned int)test_buffer
);
77 memtest_w_length_write(sizeof(test_buffer
));
78 memtest_w_shoot_write(1);
90 puts("Memory testing software built "__DATE__
" "__TIME__
"\n");
92 if((memtest_w_magic_read() != 0x361f) || (memtest_r_magic_read() != 0x361f)) {
93 printf("Memory test cores not detected\n");