Skip to content

Commit

Permalink
CLEANUP
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Maslowski <info@orangecms.org>
  • Loading branch information
orangecms committed Jul 31, 2023
1 parent a405623 commit f43a6f1
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 302 deletions.
44 changes: 8 additions & 36 deletions src/arch/src/riscv64/sbi/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const ECALL_OREBOOT: usize = 0x0A023B00;
const EBREAK: u16 = 0x9002;

const DEBUG: bool = true;
const DEBUG_ECALL: bool = false;
const DEBUG_MTIMER: bool = true;
const DEBUG_EBREAK: bool = true;
const DEBUG_EMULATE: bool = false;
Expand Down Expand Up @@ -59,14 +60,15 @@ fn ore_sbi(method: usize, args: [usize; 6]) -> SbiRet {
}
}

fn putchar(method: usize, args: [usize; 6]) -> SbiRet {
// TODO: Check newer specs on out this should work
fn putchar(_method: usize, args: [usize; 6]) -> SbiRet {
let char = args[0] as u8 as char;
print!("{char}");
SbiRet { value: 0, error: 0 }
}

fn print_ecall_context(ctx: &mut SupervisorContext) {
if DEBUG {
if DEBUG && DEBUG_ECALL {
println!(
"[SBI] ecall a6: {:x}, a7: {:x}, a0-a5: {:x} {:x} {:x} {:x} {:x} {:x}",
ctx.a6, ctx.a7, ctx.a0, ctx.a1, ctx.a2, ctx.a3, ctx.a4, ctx.a5,
Expand Down Expand Up @@ -148,53 +150,23 @@ pub fn execute_supervisor(
}
}
GeneratorState::Yielded(MachineTrap::LoadMisaligned(_addr)) => {
if DEBUG_MISALIGNED {
if DEBUG && DEBUG_MISALIGNED {
println!("[SBI]: load misaligned");
}
/*
let ctx = rt.context_mut();
let trap = Trap::Exception(Exception::LoadMisaligned);
unsafe { feature::do_transfer_trap(ctx, trap) }
*/
}
GeneratorState::Yielded(MachineTrap::StoreMisaligned(addr)) => {
if DEBUG_MISALIGNED {
if DEBUG && DEBUG_MISALIGNED {
println!("[SBI]: store misaligned");
}
let ctx = rt.context_mut();
/*
let trap = if feature::is_page_fault(addr) {
Trap::Exception(Exception::StorePageFault)
} else {
Trap::Exception(Exception::StoreFault)
}
*/
let trap = Trap::Exception(Exception::StoreMisaligned);
unsafe { feature::do_transfer_trap(ctx, trap) }
}
// NOTE: These are all delegated.
GeneratorState::Yielded(MachineTrap::LoadFault(_addr)) => {}
GeneratorState::Yielded(MachineTrap::StoreFault(_addr)) => {}
GeneratorState::Yielded(MachineTrap::ExternalInterrupt()) => {}
GeneratorState::Yielded(MachineTrap::MachineSoft()) => {}
GeneratorState::Yielded(MachineTrap::InstructionFault(_addr)) => {}
GeneratorState::Yielded(MachineTrap::LoadPageFault(addr)) => {
let ctx = rt.context_mut();
let trap = Trap::Exception(Exception::LoadPageFault);
unsafe { feature::do_transfer_trap(ctx, trap) }
}
GeneratorState::Yielded(MachineTrap::StorePageFault(addr)) => {
let ctx = rt.context_mut();
/*
let trap = if feature::is_page_fault(addr) {
Trap::Exception(Exception::StorePageFault)
} else {
Trap::Exception(Exception::StoreFault)
};
*/
let trap = Trap::Exception(Exception::StoreFault);
unsafe { feature::do_transfer_trap(ctx, trap) }
}
GeneratorState::Yielded(MachineTrap::LoadPageFault(_addr)) => {}
GeneratorState::Yielded(MachineTrap::StorePageFault(_addr)) => {}
GeneratorState::Yielded(MachineTrap::InstructionPageFault(_addr)) => {}
GeneratorState::Complete(()) => unreachable!(),
}
Expand Down
199 changes: 0 additions & 199 deletions src/arch/src/riscv64/sbi/feature/delegate_page_fault.rs

This file was deleted.

2 changes: 0 additions & 2 deletions src/arch/src/riscv64/sbi/feature/mod.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
mod delegate_page_fault;
mod emulate_rdtime;
mod sfence_vma;
mod supervisor_interrupt;
mod transfer_trap;

pub use delegate_page_fault::is_page_fault;
pub use emulate_rdtime::emulate_rdtime;
pub use sfence_vma::emulate_sfence_vma;
pub use supervisor_interrupt::preprocess_supervisor_external;
Expand Down
Loading

0 comments on commit f43a6f1

Please sign in to comment.