aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.c5
-rw-r--r--src/pmem.c4
-rw-r--r--src/proc.c9
-rw-r--r--src/regions.c5
-rw-r--r--src/tcb.c6
5 files changed, 19 insertions, 10 deletions
diff --git a/src/main.c b/src/main.c
index aaf4cde..b51c519 100644
--- a/src/main.c
+++ b/src/main.c
@@ -114,9 +114,8 @@ __noreturn void main(unsigned long hart, void *fdt, uintptr_t load_addr)
init_mem(fdt);
- struct vmem *d = direct_mapping();
-
- to_kernelspace(fdt, load_addr, d, ram_base, VM_DMAP);
+ struct vmem *d = init_mapping();
+ to_kernelspace(fdt, load_addr, d, ram_base);
unreachable();
}
diff --git a/src/pmem.c b/src/pmem.c
index fac7731..5516d30 100644
--- a/src/pmem.c
+++ b/src/pmem.c
@@ -397,8 +397,10 @@ static pm_t __maybe_populate_bucket(size_t n, pm_t cont, enum mm_order order,
if (n) {
struct mm_bmap *bmap = (struct mm_bmap *)cont;
- if (populate)
+ if (populate) {
+ memset(bmap, 0, set_size);
bmap->size = n;
+ }
if (first && populate)
__attach_set(bucket, bmap);
diff --git a/src/proc.c b/src/proc.c
index eff962a..93e3aa5 100644
--- a/src/proc.c
+++ b/src/proc.c
@@ -59,17 +59,22 @@ stat_t init_proc(void *fdt, vm_t *proc_fdt, vm_t *proc_initrd)
/* allocate stacks etc after ELF file to make sure nothing of importance
* clashes */
prepare_proc(t, get_init_base(fdt), 0);
+
+ /** In the init process, can the entry be the callback? Is that too
+ * unergonomic? */
+ t->callback = t->exec;
+
/** \todo start one thread per core, with special handling for init in
* that each thread starts at the entry point of init? */
*proc_fdt = map_fixed_uvmem(t,
(pm_t)fdt, fdt_totalsize(fdt),
- VM_V | VM_R | VM_U);
+ MR_SHARED | VM_V | VM_R | VM_U);
pm_t initrd = (pm_t)__va(get_initrdbase(fdt));
*proc_initrd = map_fixed_uvmem(t,
initrd, get_initrdsize(fdt),
- VM_V | VM_R | VM_U);
+ MR_SHARED | VM_V | VM_R | VM_U);
info("mapped fdt at %lx\n", *proc_fdt);
info("mapped initrd at %lx\n", *proc_initrd);
diff --git a/src/regions.c b/src/regions.c
index 66ee546..f098f4f 100644
--- a/src/regions.c
+++ b/src/regions.c
@@ -316,7 +316,10 @@ struct mem_region *find_free_region(struct mem_region_root *r, size_t size,
vm_t start = align_up(t->start, offset);
size_t qsize = t->end - t->start;
- size_t bsize = t->end - start;
+
+ size_t bsize = 0;
+ if (t->end >= start)
+ bsize = t->end - start;
if (!quick_best && size <= qsize)
quick_best = t;
diff --git a/src/tcb.c b/src/tcb.c
index 27256e9..6915676 100644
--- a/src/tcb.c
+++ b/src/tcb.c
@@ -120,14 +120,14 @@ void free_stack(struct tcb *t)
struct tcb *create_thread(struct tcb *p)
{
- hard_assert(tcbs, 0);
+ assert(tcbs);
vm_t bottom = alloc_page(KERNEL_STACK_PAGE_ORDER);
/* move tcb to top of kernel stack, keeping alignment in check
* (hopefully) */
/** \todo check alignment */
- struct tcb *t = (struct tcb *)align_down(
- bottom + order_size(MM_O0) - sizeof(struct tcb), sizeof(long));
+ bottom = bottom + order_size(MM_O0) - sizeof(struct tcb);
+ struct tcb *t = (struct tcb *)align_down(bottom, sizeof(long));
memset(t, 0, sizeof(struct tcb));
id_t tid = __alloc_tid(t);