aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Waterman <waterman@s141.Millennium.Berkeley.EDU>2011-01-10 16:35:20 -0800
committerAndrew Waterman <waterman@s141.Millennium.Berkeley.EDU>2011-01-10 16:35:20 -0800
commit0cf0242c3bb3fbd9aba37ca21325ea4d11b83f1b (patch)
tree38d355d9b28f003ab682e9b75c7552366f37cca8
parentb83d64df0179835678c54401ec88bd37e03e19ba (diff)
downloadpk-0cf0242c3bb3fbd9aba37ca21325ea4d11b83f1b.zip
pk-0cf0242c3bb3fbd9aba37ca21325ea4d11b83f1b.tar.gz
pk-0cf0242c3bb3fbd9aba37ca21325ea4d11b83f1b.tar.bz2
[pk] added --disable-fp-emulation option for code size
-rw-r--r--config.h.in3
-rwxr-xr-xconfigure15
-rw-r--r--pk/fp.c14
-rw-r--r--pk/handlers.c6
-rw-r--r--pk/pk.ac5
5 files changed, 38 insertions, 5 deletions
diff --git a/config.h.in b/config.h.in
index dce08f0..409162a 100644
--- a/config.h.in
+++ b/config.h.in
@@ -21,6 +21,9 @@
/* Define if subproject MCPPBS_SPROJ_NORM is enabled */
#undef PK_ENABLED
+/* Define if floating-point emulation is enabled */
+#undef PK_ENABLE_FP_EMULATION
+
/* Define if the kernel runs in 64-bit mode */
#undef PK_ENABLE_KERNEL_64BIT
diff --git a/configure b/configure
index f1d154a..7cd367b 100755
--- a/configure
+++ b/configure
@@ -638,6 +638,7 @@ enable_optional_subprojects
enable_vm
enable_kernel_64bit
enable_user_64bit
+enable_fp_emulation
'
ac_precious_vars='build_alias
host_alias
@@ -1273,6 +1274,7 @@ Optional Features:
--disable-vm Disable virtual memory
--disable-kernel-64bit Disable 64-bit kernel operation
--disable-user-64bit Disable 64-bit user operation
+ --disable-fp-emulation Disable floating-point emulation
Some influential environment variables:
CC C compiler command
@@ -4019,6 +4021,19 @@ $as_echo "#define PK_ENABLE_USER_64BIT /**/" >>confdefs.h
fi
+# Check whether --enable-fp-emulation was given.
+if test "${enable_fp_emulation+set}" = set; then :
+ enableval=$enable_fp_emulation;
+fi
+
+if test "x$enable_fp_emulation" != "xno"; then :
+
+
+$as_echo "#define PK_ENABLE_FP_EMULATION /**/" >>confdefs.h
+
+
+fi
+
diff --git a/pk/fp.c b/pk/fp.c
index ffe6173..d9eb427 100644
--- a/pk/fp.c
+++ b/pk/fp.c
@@ -1,8 +1,13 @@
+#include "pk.h"
#include "pcr.h"
+#include "fp.h"
+
+static fp_state_t fp_state;
+
+#ifdef PK_ENABLE_FP_EMULATION
+
#include "softfloat.h"
#include "riscv-opc.h"
-#include "pk.h"
-#include "fp.h"
#include <stdint.h>
#define noisy 0
@@ -10,8 +15,6 @@
static void set_fp_reg(unsigned int which, unsigned int dp, uint64_t val);
static uint64_t get_fp_reg(unsigned int which, unsigned int dp);
-static fp_state_t fp_state;
-
static inline void
validate_address(trapframe_t* tf, long addr, int size, int store)
{
@@ -252,6 +255,8 @@ get_fp_reg(unsigned int which, unsigned int dp)
return val;
}
+#endif
+
void init_fp_regs()
{
long sr = mfpcr(PCR_SR);
@@ -259,4 +264,3 @@ void init_fp_regs()
put_fp_state(fp_state.fpr,fp_state.fsr);
mtpcr(sr, PCR_SR);
}
-
diff --git a/pk/handlers.c b/pk/handlers.c
index 25005c8..2947903 100644
--- a/pk/handlers.c
+++ b/pk/handlers.c
@@ -19,11 +19,15 @@ void handle_fp_disabled(trapframe_t* tf)
}
else
{
+#ifdef PK_ENABLE_FP_EMULATION
if(emulate_fp(tf) != 0)
{
dump_tf(tf);
panic("FPU emulation failed!");
}
+#else
+ panic("FPU emulation disabled! pc %lx, insn %x",tf->epc,(uint32_t)tf->insn);
+#endif
}
}
@@ -41,8 +45,10 @@ void handle_privileged_instruction(trapframe_t* tf)
void handle_illegal_instruction(trapframe_t* tf)
{
+#ifdef PK_ENABLE_FP_EMULATION
if(emulate_fp(tf) == 0)
return;
+#endif
dump_tf(tf);
panic("An illegal instruction was executed!");
diff --git a/pk/pk.ac b/pk/pk.ac
index 94fb63a..c53c2c2 100644
--- a/pk/pk.ac
+++ b/pk/pk.ac
@@ -15,3 +15,8 @@ AC_ARG_ENABLE([user-64bit], AS_HELP_STRING([--disable-user-64bit], [Disable 64-b
AS_IF([test "x$enable_user_64bit" != "xno"], [
AC_DEFINE([PK_ENABLE_USER_64BIT],,[Define if the user runs in 64-bit mode])
])
+
+AC_ARG_ENABLE([fp-emulation], AS_HELP_STRING([--disable-fp-emulation], [Disable floating-point emulation]))
+AS_IF([test "x$enable_fp_emulation" != "xno"], [
+ AC_DEFINE([PK_ENABLE_FP_EMULATION],,[Define if floating-point emulation is enabled])
+])