Skip to content

Instantly share code, notes, and snippets.

@z4yx
Created April 3, 2019 02:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save z4yx/6d61470c97c1c949f2212b757756b048 to your computer and use it in GitHub Desktop.
Save z4yx/6d61470c97c1c949f2212b757756b048 to your computer and use it in GitHub Desktop.
uint64_t mask = 0;
for(int i=0; i<2; i++){
volatile uint64_t *ptr = (volatile uint64_t*)0x80100000;
uint64_t rnd = 12345;
for(; (uint64_t)ptr < 0x80800000; ptr+=1)
{
*ptr = rnd^mask; // Write MEM
// if((uint64_t)ptr == 0x802a0d90){
// printHex(rnd^mask);
// sbi_ecall_console_putc('\n');
// printHex(*ptr);
// sbi_ecall_console_putc('\n');
// }
rnd = rnd * 1103515245 + 12345;
}
ptr = (void*)0x80100000;
rnd = 12345;
for(; (uint64_t)ptr < 0x80800000; ptr+=1)
{
if(*ptr != (rnd^mask)){ // Read MEM
sbi_ecall_console_puts("mem test fail @ 0x");
printHex((uint64_t)ptr);
sbi_ecall_console_puts("\n ");
printHex(*ptr);
sbi_ecall_console_puts(" != ");
printHex(rnd^mask);
sbi_ecall_console_putc('\n');
// while (1)
// wfi();
}
rnd = rnd * 1103515245 + 12345;
}
// sbi_ecall_console_puts("mem test ok\n");
mask = ~mask;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment