aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Waterman <waterman@cs.berkeley.edu>2015-11-12 17:18:48 -0800
committerAndrew Waterman <waterman@cs.berkeley.edu>2015-11-12 17:48:48 -0800
commit9cc6732d806b4a7e4842528606fa1390e7ab0a90 (patch)
tree634de3e94b0c52f5822c3d96dabe4ff2443aa90c
parentfa1b72958119abad2c6e1659ab6db914bf30059f (diff)
downloadpk-9cc6732d806b4a7e4842528606fa1390e7ab0a90.zip
pk-9cc6732d806b4a7e4842528606fa1390e7ab0a90.tar.gz
pk-9cc6732d806b4a7e4842528606fa1390e7ab0a90.tar.bz2
print PC of failed assertions
-rw-r--r--pk/console.c3
-rw-r--r--pk/device.c86
2 files changed, 2 insertions, 87 deletions
diff --git a/pk/console.c b/pk/console.c
index 3920a51..5808d77 100644
--- a/pk/console.c
+++ b/pk/console.c
@@ -145,5 +145,6 @@ void do_panic(const char* s, ...)
void kassert_fail(const char* s)
{
- do_panic("assertion failed: %s\n", s);
+ register uintptr_t ra asm ("ra");
+ do_panic("assertion failed @ %p: %s\n", ra, s);
}
diff --git a/pk/device.c b/pk/device.c
deleted file mode 100644
index f8b39ca..0000000
--- a/pk/device.c
+++ /dev/null
@@ -1,86 +0,0 @@
-#include "pk.h"
-#include "frontend.h"
-#include <string.h>
-#include <stdlib.h>
-
-void enumerate_devices()
-{
- char buf[64] __attribute__((aligned(64)));
-
- for (int dev = 0; dev < 256; dev++)
- {
- tohost_sync(dev, 0xFF, (uintptr_t)buf << 8 | 0xFF);
- if (buf[0])
- {
- printk("device %d: %s\n", dev, buf);
-
- for (int cmd = 0; cmd < 255; cmd++)
- {
- tohost_sync(dev, 0xFF, (uintptr_t)buf << 8 | cmd);
- if (buf[0])
- printk(" command %d: %s\n", cmd, buf);
- }
- }
- }
-}
-
-void disk_test()
-{
- struct disk_req {
- uint64_t addr;
- uint64_t offset;
- uint64_t size;
- uint64_t tag;
- };
-
- // find disk
- const char* disk_str = "disk size=";
- char buf[64] __attribute__((aligned(64)));
-
- for (int dev = 0; dev < 256; dev++)
- {
- tohost_sync(dev, 0xFF, (uintptr_t)buf << 8 | 0xFF);
- if (strncmp(buf, disk_str, strlen(disk_str)) == 0)
- {
- long size = atol(buf + strlen(disk_str));
- printk("found disk device %d, size %ld\n", dev, size);
-
- long sec_size = 512;
- char buf[sec_size] __attribute__((aligned(64)));
-
- // read block 3
- struct disk_req req = { (uintptr_t)buf, 3*sec_size, sec_size, 0 };
- tohost_sync(dev, 0, (uintptr_t)&req);
- // copy block 3 to block 5
- req.offset = 5*sec_size;
- tohost_sync(dev, 1, (uintptr_t)&req);
-
- printk("copied block 3 to block 5\n");
- }
- }
-}
-
-void rfb_test()
-{
- char buf[64] __attribute__((aligned(64)));
-
- int bpp = 16;
- int width = 32;
- int height = 32;
- uint16_t fb[width * height] __attribute__((aligned(64)));
-
- for (int dev = 0; dev < 256; dev++)
- {
- tohost_sync(dev, 0xFF, (uintptr_t)buf << 8 | 0xFF);
- if (strcmp(buf, "rfb") == 0)
- {
-
- tohost_sync(dev, 0, width | height << 16 | (uint64_t)bpp << 32);
- tohost_sync(dev, 1, (uintptr_t)fb);
-
- for (int pixel = 0; ; )
- for (int i = 0, value = 0; i < width * height; i++, pixel++)
- fb[i] = pixel;
- }
- }
-}