From cd85da118c61e91a4e70407ee52725d799d3994b Mon Sep 17 00:00:00 2001 From: David Li Date: Sat, 9 Jan 2016 15:33:12 -0700 Subject: Remove old elfloader test --- src/lib.rs | 80 -------------------------------------------------------------- 1 file changed, 80 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index cec9d01..0b52b08 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -27,86 +27,6 @@ pub mod trap; pub use elfloader_lib as elfloader; -#[test] -fn test_elfloader() { - use std::io::prelude::*; - use std::fs::File; - use std::rc::Rc; - use std::cell::RefCell; - - use memory::MemoryInterface; - - struct SyscallHandler<'a> { - memory: memory::SharedMemory<'a>, - } - - impl<'a> syscall::SyscallHandler for SyscallHandler<'a> { - fn syscall(&mut self, registers: &mut register_file::RegisterFile) -> Option { - println!("Syscall number {}", registers.read_word(isa::Register::X10)); - let mut base = registers.read_word(isa::Register::X11); - let mut string = vec![]; - - loop { - let c = self.memory.borrow_mut().read_byte(base); - - if let Ok(0x00) = c { - break; - } - else if let Ok(c) = c { - string.push(c); - } - - base += 1; - } - - let result = std::str::from_utf8(&string); - if let Ok(string) = result { - println!("{}", string); - } - else { - println!("Error printing string: {:?}", result); - } - None - } - } - - let mut f = File::open("../riscv/kernel").unwrap(); - let mut buffer = Vec::new(); - - f.read_to_end(&mut buffer).unwrap(); - - let elf = elfloader::ElfBinary::new("test", &buffer).unwrap(); - let start = elf.file_header().entry as isa::Address; - - let mmu = memory::IdentityMmu::new(); - let mmu2 = memory::ReverseMmu::new(0x8000); - let mut memory = memory::Memory::new(0x10000); - - for p in elf.section_headers() { - let name = elf.section_name(p); - if name == ".text" || name == ".sdata" || name == ".rodata" { - println!("Loading {} section", name); - memory.write_segment(&mmu, elf.section_data(p), p.addr as usize); - memory.write_segment(&mmu2, elf.section_data(p), p.addr as usize); - } - } - - let memory_ref = Rc::new(RefCell::new(memory)); - let cache = memory::DirectMappedCache::new(4, 4, memory_ref.clone()); - let cache_ref = Rc::new(RefCell::new(cache)); - let core = simulator::Core::new( - start, 0x1000, - cache_ref.clone(), Box::new(mmu)); - let core2 = simulator::Core::new( - start, 0x3000, - cache_ref.clone(), Box::new(mmu2)); - let cores = vec![core, core2]; - - let system = SyscallHandler { memory: memory_ref.clone(), }; - let mut simulator = simulator::Simulator::new(cores, memory_ref.clone(), system); - simulator.run(); -} - #[cfg(test)] mod tests { #[test] -- cgit v1.2.3