aboutsummaryrefslogtreecommitdiff
path: root/pk/pk.c
diff options
context:
space:
mode:
authorAndrew Waterman <waterman@s144.Millennium.Berkeley.EDU>2011-11-11 03:40:24 -0800
committerAndrew Waterman <waterman@s144.Millennium.Berkeley.EDU>2011-11-11 03:40:24 -0800
commit8717517e048ff866167d6eee6c6d97225f0cd169 (patch)
treeab36a881f5f6700fb5d30e3abc5580be0c088002 /pk/pk.c
parent2f5776b244a4a2a8297fee9e0160c835430e1f06 (diff)
downloadriscv-pk-8717517e048ff866167d6eee6c6d97225f0cd169.zip
riscv-pk-8717517e048ff866167d6eee6c6d97225f0cd169.tar.gz
riscv-pk-8717517e048ff866167d6eee6c6d97225f0cd169.tar.bz2
Synced up PK with supervisor changes/asm syntax
You must upgrade to the latest compiler and ISA simulator to build and run this version of the PK.
Diffstat (limited to 'pk/pk.c')
-rw-r--r--pk/pk.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/pk/pk.c b/pk/pk.c
index 7260601..33b0bda 100644
--- a/pk/pk.c
+++ b/pk/pk.c
@@ -164,14 +164,20 @@ static void jump_usrstart(const char* fn, long sp)
pop_tf(&tf);
}
+uint32_t mem_mb;
+
void boot()
{
bss_init();
file_init();
- long stack_top = (mfpcr(PCR_MEMSIZE) << MEMSIZE_SHIFT);
- if(stack_top >= 0x80000000)
- stack_top = 0x80000000;
+ // word 0 of memory contains # of MB of memory
+ mem_mb = *(uint32_t*)0;
+
+ unsigned long stack_top = 0x80000000;
+ if (mem_mb < stack_top / (1024 * 1024))
+ stack_top = mem_mb * (1024 * 1024);
+
stack_top -= USER_MAINVARS_SIZE;
struct args* args = mainvars_init(stack_top);