aboutsummaryrefslogtreecommitdiff
path: root/pk
diff options
context:
space:
mode:
authorYunsup Lee <yunsup@cs.berkeley.edu>2010-10-17 14:08:12 -0700
committerYunsup Lee <yunsup@cs.berkeley.edu>2010-10-17 14:08:12 -0700
commit9297008e44254848cfa42726272640b641282665 (patch)
tree026813cd81b607994d156f399d5e725b7952bc7a /pk
parentb4fd490d689415205cf315c02f673b9386ece337 (diff)
downloadpk-9297008e44254848cfa42726272640b641282665.zip
pk-9297008e44254848cfa42726272640b641282665.tar.gz
pk-9297008e44254848cfa42726272640b641282665.tar.bz2
[pk] zero out fp regs
Diffstat (limited to 'pk')
-rw-r--r--pk/fp.c36
-rw-r--r--pk/pk.c13
-rw-r--r--pk/pk.h1
3 files changed, 50 insertions, 0 deletions
diff --git a/pk/fp.c b/pk/fp.c
index eff9b27..256c63f 100644
--- a/pk/fp.c
+++ b/pk/fp.c
@@ -183,6 +183,42 @@ int emulate_fp(trapframe_t* tf)
return 0;
}
+void init_fpregs()
+{
+ set_fp_reg(0, 1, 0);
+ set_fp_reg(1, 1, 0);
+ set_fp_reg(2, 1, 0);
+ set_fp_reg(3, 1, 0);
+ set_fp_reg(4, 1, 0);
+ set_fp_reg(5, 1, 0);
+ set_fp_reg(6, 1, 0);
+ set_fp_reg(7, 1, 0);
+ set_fp_reg(8, 1, 0);
+ set_fp_reg(9, 1, 0);
+ set_fp_reg(10, 1, 0);
+ set_fp_reg(11, 1, 0);
+ set_fp_reg(12, 1, 0);
+ set_fp_reg(13, 1, 0);
+ set_fp_reg(14, 1, 0);
+ set_fp_reg(15, 1, 0);
+ set_fp_reg(16, 1, 0);
+ set_fp_reg(17, 1, 0);
+ set_fp_reg(18, 1, 0);
+ set_fp_reg(19, 1, 0);
+ set_fp_reg(20, 1, 0);
+ set_fp_reg(21, 1, 0);
+ set_fp_reg(22, 1, 0);
+ set_fp_reg(23, 1, 0);
+ set_fp_reg(24, 1, 0);
+ set_fp_reg(25, 1, 0);
+ set_fp_reg(26, 1, 0);
+ set_fp_reg(27, 1, 0);
+ set_fp_reg(28, 1, 0);
+ set_fp_reg(29, 1, 0);
+ set_fp_reg(30, 1, 0);
+ set_fp_reg(31, 1, 0);
+}
+
#define STR(x) XSTR(x)
#define XSTR(x) #x
diff --git a/pk/pk.c b/pk/pk.c
index d3f12ff..3a3c85b 100644
--- a/pk/pk.c
+++ b/pk/pk.c
@@ -130,6 +130,18 @@ void init_tf(trapframe_t* tf, long pc, long sp)
tf->epc = USER_START;
}
+void init_fp()
+{
+ if (have_fp)
+ {
+ register long sr;
+ sr = mfpcr(PCR_SR);
+ mtpcr(sr | SR_EF, PCR_SR);
+ init_fpregs();
+ mtpcr(sr, PCR_SR);
+ }
+}
+
void bss_init()
{
extern char edata,end;
@@ -146,6 +158,7 @@ void mainvars_init()
void jump_usrstart()
{
+ init_fp();
trapframe_t tf;
init_tf(&tf, USER_START, USER_MEM_SIZE-USER_MAINVARS_SIZE);
pop_tf(&tf);
diff --git a/pk/pk.h b/pk/pk.h
index c98e2f9..65a92fc 100644
--- a/pk/pk.h
+++ b/pk/pk.h
@@ -25,6 +25,7 @@ extern "C" {
extern int have_fp;
int emulate_fp(trapframe_t*);
+void init_fpregs();
void printk(const char* s, ...);
void init_tf(trapframe_t*, long pc, long sp);