diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/main.c | 5 | ||||
| -rw-r--r-- | src/pmem.c | 4 | ||||
| -rw-r--r-- | src/proc.c | 9 | ||||
| -rw-r--r-- | src/regions.c | 5 | ||||
| -rw-r--r-- | src/tcb.c | 6 |
5 files changed, 19 insertions, 10 deletions
@@ -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(); } @@ -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); @@ -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; @@ -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); |
