aboutsummaryrefslogtreecommitdiff
path: root/pk
diff options
context:
space:
mode:
authorAndrew Waterman <andrew@sifive.com>2017-02-20 21:43:09 -0800
committerAndrew Waterman <andrew@sifive.com>2017-02-20 21:43:09 -0800
commitf6bca6e35b66632afad68f6b7fb2b3203c8502fb (patch)
tree3f8d691713d96ef4e7f57b8504691e68cdcda6f7 /pk
parent59484c94e161b0f1870096cfb183533b20569669 (diff)
downloadpk-f6bca6e35b66632afad68f6b7fb2b3203c8502fb.zip
pk-f6bca6e35b66632afad68f6b7fb2b3203c8502fb.tar.gz
pk-f6bca6e35b66632afad68f6b7fb2b3203c8502fb.tar.bz2
Don't block for acks on console writes
Diffstat (limited to 'pk')
-rw-r--r--pk/mmap.c12
-rw-r--r--pk/mmap.h1
-rw-r--r--pk/pk.lds4
3 files changed, 9 insertions, 8 deletions
diff --git a/pk/mmap.c b/pk/mmap.c
index 9e9be57..33c3da2 100644
--- a/pk/mmap.c
+++ b/pk/mmap.c
@@ -20,6 +20,7 @@ typedef struct {
static spinlock_t vm_lock = SPINLOCK_INIT;
static vmr_t* vmrs;
+uintptr_t first_free_paddr;
static uintptr_t first_free_page;
static size_t next_free_page;
static size_t free_pages;
@@ -385,15 +386,14 @@ void populate_mapping(const void* start, size_t size, int prot)
uintptr_t pk_vm_init()
{
-#if __riscv_xlen == 32
- // We can't support more than 2 GiB of memory in RV32
+ // HTIF address signedness and va2pa macro both cap memory size to 2 GiB
mem_size = MIN(mem_size, 1U << 31);
-#endif
-
size_t mem_pages = mem_size >> RISCV_PGSHIFT;
free_pages = MAX(8, mem_pages >> (RISCV_PGLEVEL_BITS-1));
- first_free_page = first_free_paddr;
- first_free_paddr += free_pages * RISCV_PGSIZE;
+
+ extern char _end;
+ first_free_page = ROUNDUP((uintptr_t)&_end, RISCV_PGSIZE);
+ first_free_paddr = first_free_page + free_pages * RISCV_PGSIZE;
root_page_table = (void*)__page_alloc();
__map_kernel_range(DRAM_BASE, DRAM_BASE, first_free_paddr - DRAM_BASE, PROT_READ|PROT_WRITE|PROT_EXEC);
diff --git a/pk/mmap.h b/pk/mmap.h
index f4f39f5..efc7c1e 100644
--- a/pk/mmap.h
+++ b/pk/mmap.h
@@ -33,6 +33,7 @@ uintptr_t do_mprotect(uintptr_t addr, size_t length, int prot);
uintptr_t do_brk(uintptr_t addr);
#define va2pa(va) ({ uintptr_t __va = (uintptr_t)(va); \
+ extern uintptr_t first_free_paddr; \
__va >= DRAM_BASE ? __va : __va + first_free_paddr; })
#endif
diff --git a/pk/pk.lds b/pk/pk.lds
index 1bc9adf..5348635 100644
--- a/pk/pk.lds
+++ b/pk/pk.lds
@@ -44,9 +44,9 @@ SECTIONS
/* HTIF, isolated onto separate page */
/*--------------------------------------------------------------------*/
. = ALIGN(0x1000);
- htif :
+ .htif :
{
- *(htif)
+ *(.htif)
}
. = ALIGN(0x1000);