aboutsummaryrefslogtreecommitdiff
path: root/pk/int.c
diff options
context:
space:
mode:
authorAndrew Waterman <waterman@cs.berkeley.edu>2015-03-12 17:38:04 -0700
committerAndrew Waterman <waterman@cs.berkeley.edu>2015-03-12 17:38:04 -0700
commit6517fe26a2a0c89c3112f4a383c601572c71d64a (patch)
treed37eea7ae6f3e15eee94afb5c9c749a4cd800577 /pk/int.c
parenta4ae7da6ef0c09c2616a0b82f7f569e4e134f75c (diff)
downloadpk-6517fe26a2a0c89c3112f4a383c601572c71d64a.zip
pk-6517fe26a2a0c89c3112f4a383c601572c71d64a.tar.gz
pk-6517fe26a2a0c89c3112f4a383c601572c71d64a.tar.bz2
Update to new privileged spec
Diffstat (limited to 'pk/int.c')
-rw-r--r--pk/int.c89
1 files changed, 0 insertions, 89 deletions
diff --git a/pk/int.c b/pk/int.c
deleted file mode 100644
index 38cc7f0..0000000
--- a/pk/int.c
+++ /dev/null
@@ -1,89 +0,0 @@
-// See LICENSE for license details.
-
-#include "pk.h"
-
-
-#include "softint.h"
-#include <stdint.h>
-
-#define noisy 0
-
-
-int emulate_int(trapframe_t* tf)
-{
- if(noisy)
- printk("Int emulation at pc %lx, insn %x\n",tf->epc,(uint32_t)tf->insn);
-
- #define RS1 ((tf->insn >> 15) & 0x1F)
- #define RS2 ((tf->insn >> 20) & 0x1F)
- #define RD ((tf->insn >> 7) & 0x1F)
-
-// #define XRS1 (tf->gpr[RS1])
-// #define XRS2 (tf->gpr[RS2])
- #define XRD (tf->gpr[RD])
-
- unsigned long xrs1 = tf->gpr[RS1];
- unsigned long xrs2 = tf->gpr[RS2];
-
- #define IS_INSN(x) ((tf->insn & MASK_ ## x) == MATCH_ ## x)
-
- if(IS_INSN(DIV))
- {
- if(noisy)
- printk("emulating div\n");
-
- int num_negative = 0;
-
- if ((signed long) xrs1 < 0)
- {
- xrs1 = -xrs1;
- num_negative++;
- }
-
- if ((signed long) xrs2 < 0)
- {
- xrs2 = -xrs2;
- num_negative++;
- }
-
- unsigned long res = softint_udivrem(xrs1, xrs2, 0);
- if (num_negative == 1)
- XRD = -res;
- else
- XRD = res;
- }
- else if(IS_INSN(DIVU))
- {
- if(noisy)
- printk("emulating divu\n");
- XRD = softint_udivrem( xrs1, xrs2, 0);
- }
- else if(IS_INSN(MUL))
- {
- if(noisy)
- printk("emulating mul\n");
- XRD = softint_mul(xrs1, xrs2);
- }
- else if(IS_INSN(REM))
- {
- if(noisy)
- printk("emulating rem\n");
-
- if ((signed long) xrs1 < 0) {xrs1 = -xrs1;}
- if ((signed long) xrs2 < 0) {xrs2 = -xrs2;}
-
- XRD = softint_udivrem(xrs1, xrs2, 1);
- }
- else if(IS_INSN(REMU))
- {
- if(noisy)
- printk("emulating remu\n");
- XRD = softint_udivrem(xrs1, xrs2, 1);
- }
- else
- return -1;
-
- return 0;
-}
-
-