From: Kit Rhett Aultman Date: Mon, 2 Sep 2024 17:44:02 +0000 (-0400) Subject: main.rs: enable floating point X-Git-Url: https://git.kitaultman.com/?a=commitdiff_plain;h=934a8b734c89102ad02c39811aad55d22c66cc9e;p=riscv_baremetal.git main.rs: enable floating point The trap frame already handles the floating point registers, but floating point support was not enabled via the mstatus register. This didn't cause an issue on the Ubuntu 22.04 standard version of qemu, but one built from nightly source will issue an illegal instruction exception if floating point registers are accessed without the support being enabled. This commit fixes the issue by enabling floating point support from early initialization. --- diff --git a/src/main.rs b/src/main.rs index d25754e..76f3110 100644 --- a/src/main.rs +++ b/src/main.rs @@ -104,6 +104,9 @@ extern "C" fn entry() -> ! { // we can't use keywords other than const and sym unsafe { asm!( + // Turn on floating point support + "li t0, 1 << 13", + "csrw mstatus, t0", // Establish the stack frame reference in mscratch "csrw mscratch, {trap_frame}", "lla t2, m_trap_vector",