From 6fa3555cc501ab1dfb034061e991e065e2e54253 Mon Sep 17 00:00:00 2001 From: Andrew Waterman Date: Mon, 13 Jan 2020 12:14:04 -0800 Subject: Enable vector unit if present (continuation of 77a5df569451571d608650a34183d53df99790ec) --- machine/encoding.h | 1 + machine/minit.c | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) (limited to 'machine') diff --git a/machine/encoding.h b/machine/encoding.h index 20c44b9..1953f56 100644 --- a/machine/encoding.h +++ b/machine/encoding.h @@ -33,6 +33,7 @@ #define SSTATUS_UPIE 0x00000010 #define SSTATUS_SPIE 0x00000020 #define SSTATUS_SPP 0x00000100 +#define SSTATUS_VS 0x01800000 #define SSTATUS_FS 0x00006000 #define SSTATUS_XS 0x00018000 #define SSTATUS_SUM 0x00040000 diff --git a/machine/minit.c b/machine/minit.c index 8c98e2b..a1befd1 100644 --- a/machine/minit.c +++ b/machine/minit.c @@ -23,13 +23,17 @@ void* kernel_end; static void mstatus_init() { + uintptr_t mstatus = 0; + // Enable FPU if (supports_extension('F')) - write_csr(mstatus, MSTATUS_FS); + mstatus |= MSTATUS_FS; // Enable vector extension if (supports_extension('V')) - write_csr(mstatus, MSTATUS_VS); + mstatus |= MSTATUS_VS; + + write_csr(mstatus, mstatus); // Enable user/supervisor use of perf counters if (supports_extension('S')) -- cgit v1.1