From 2f355158d19b0a34c46df5c3dd181c4975342637 Mon Sep 17 00:00:00 2001 From: ElicMagus Date: Thu, 9 Feb 2023 21:26:12 +0300 Subject: [PATCH] Tested Dram --- src/dram/mod.rs | 46 ++++++++++++++++++++++++++++++++++++++++++++-- src/main.rs | 20 ++++++++++---------- 2 files changed, 54 insertions(+), 12 deletions(-) diff --git a/src/dram/mod.rs b/src/dram/mod.rs index b34b39a..ef662dd 100644 --- a/src/dram/mod.rs +++ b/src/dram/mod.rs @@ -1768,7 +1768,49 @@ impl DramPara_t { sdelay(10); } - fn simple_wr_test(mut self, mem_size: u32, test: u32) -> u32 { - 0u32 + fn simple_wr_test(mut self, mem_size_mb: u32, len: u32) -> u32 { + let offs = (mem_size_mb >> 1) << 18; // half of memory size + let patt1 = 0x01234567; + let patt2 = 0xfedcba98; + let mut addr=0; + let mut v1=0; + let mut v2=0; + let mut i=0; + print!("WR Test {:X}\r\n",offs); + addr = RAM_BASE; + i=0; + // let mut val = 0xDEADC0DEu32; + // write32(addr, val); + // val = read32(addr); + // print!("DC = {:X}\r\n",val); + while i != len { + // print!("WR Test {:?}\r\n",i); + write32(addr, patt1 + i); + write32(addr + offs, patt2 + i); + addr+=4; + i+=4; + } + print!("Writed\r\n"); + addr = RAM_BASE; + i=0; + while i != len { + v1 = read32(addr + i); + v2 = patt1 + i; + if v1 != v2 { + print!("DRAM simple test FAIL.\r\n"); + print!("{:X} != {:X} at address {:X}\r\n", v1, v2, addr + i); + return 1; + } + v1 = read32(addr + offs + i); + v2 = patt2 + i; + if v1 != v2 { + print!("DRAM simple test FAIL.\r\n"); + print!("{:X} != {:X} at address {:X}\r\n", v1, v2, addr + offs + i); + return 1; + } + i+=4; + } + print!("DRAM simple test OK.\r\n"); + return 0; } } diff --git a/src/main.rs b/src/main.rs index 466d462..45ce1bc 100644 --- a/src/main.rs +++ b/src/main.rs @@ -81,16 +81,16 @@ fn delay() { #[panic_handler] fn panic(info: &PanicInfo<'_>) -> ! { - // let (location, line, column) = match info.location() { - // Some(loc) => (loc.file(), loc.line(), loc.column()), - // _ => ("???", 0, 0), - // }; - // print!( - // "Kernel panic!\n\n\ - // Panic location:\n File '{}', line {}, column {}\n\n\ - // ", - // location, line, column, - // ); + let (location, line, column) = match info.location() { + Some(loc) => (loc.file(), loc.line(), loc.column()), + _ => ("???", 0, 0), + }; + print!( + "Kernel panic!\n\n\ + Panic location:\n File '{}', line {}, column {}\n\n\ + ", + location, line, column, + ); cpu::wfe(); loop {} }