aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Waterman <waterman@cs.berkeley.edu>2013-12-14 01:59:48 -0800
committerAndrew Waterman <waterman@cs.berkeley.edu>2013-12-14 01:59:48 -0800
commit89a0cefd28cb7bdd33e0d17d43cfad5ae6d7e19f (patch)
treee73634ddd358d588b3c0a133207a89b7f9c53da0
parenta502c24732b1eb9f13c9addde81f2be536092fe1 (diff)
downloadpk-89a0cefd28cb7bdd33e0d17d43cfad5ae6d7e19f.zip
pk-89a0cefd28cb7bdd33e0d17d43cfad5ae6d7e19f.tar.gz
pk-89a0cefd28cb7bdd33e0d17d43cfad5ae6d7e19f.tar.bz2
Add -p flag: force physical memory addressing
-rw-r--r--pk/handlers.c5
-rw-r--r--pk/init.c9
-rw-r--r--pk/pk.h3
-rw-r--r--pk/vm.c10
4 files changed, 17 insertions, 10 deletions
diff --git a/pk/handlers.c b/pk/handlers.c
index 972a5dc..2c50ae6 100644
--- a/pk/handlers.c
+++ b/pk/handlers.c
@@ -4,10 +4,7 @@
#include "config.h"
#include "syscall.h"
#include "vm.h"
-
-int have_fp = 1; // initialized to 1 because it can't be in the .bss section!
-int have_accelerator = 1;
-
+
static void handle_accelerator_disabled(trapframe_t* tf)
{
if (have_accelerator)
diff --git a/pk/init.c b/pk/init.c
index 84b28f3..6ca3c49 100644
--- a/pk/init.c
+++ b/pk/init.c
@@ -9,6 +9,9 @@
#include <string.h>
elf_info current;
+int have_vm = 1; // unless -p flag is given
+int have_fp;
+int have_accelerator;
void init_tf(trapframe_t* tf, long pc, long sp, int user64)
{
@@ -26,10 +29,14 @@ static void handle_option(const char* s)
{
switch (s[1])
{
- case 's':
+ case 's': // print cycle count upon termination
current.t0 = rdcycle();
break;
+ case 'p': // physical memory mode
+ have_vm = 0;
+ break;
+
default:
panic("unrecognized option: `%c'", s[1]);
break;
diff --git a/pk/pk.h b/pk/pk.h
index 2be2069..282530c 100644
--- a/pk/pk.h
+++ b/pk/pk.h
@@ -34,7 +34,8 @@ extern "C" {
#endif
extern int have_fp;
-extern int have_vector;
+extern int have_accelerator;
+extern int have_vm;
extern uint32_t mem_mb;
int emulate_fp(trapframe_t*);
void init_fp(trapframe_t* tf);
diff --git a/pk/vm.c b/pk/vm.c
index d7371c5..6f02930 100644
--- a/pk/vm.c
+++ b/pk/vm.c
@@ -23,7 +23,6 @@ static pte_t* root_page_table;
static uintptr_t first_free_page;
static size_t next_free_page;
static size_t free_pages;
-static int have_vm;
static uintptr_t __page_alloc()
{
@@ -408,9 +407,12 @@ void vm_init()
__map_kernel_range(0, current.user_min, PROT_READ|PROT_WRITE|PROT_EXEC);
- write_csr(ptbr, root_page_table_paddr);
- set_csr(status, SR_VM);
- have_vm = clear_csr(status, SR_VM) & SR_VM;
+ if (have_vm)
+ {
+ write_csr(ptbr, root_page_table_paddr);
+ set_csr(status, SR_VM);
+ have_vm = clear_csr(status, SR_VM) & SR_VM;
+ }
size_t stack_size = RISCV_PGSIZE * stack_pages;
current.stack_top = MIN(first_free_page, 0x80000000); // for RV32 sanity