void bmk_multiboot(struct multiboot_info *mbi) { unsigned long cmdlinelen; char *cmdline; bmk_printf_init(bmk_cons_putc, NULL); bmk_core_init(BMK_THREAD_STACK_PAGE_ORDER, PAGE_SIZE); bmk_printf("rump kernel bare metal multibootstrap\n\n"); /* save the command line before something overwrites it */ cmdline = (char *)(uintptr_t)mbi->cmdline; cmdlinelen = bmk_strlen(cmdline); if (cmdlinelen >= BMK_MULTIBOOT_CMDLINE_SIZE) bmk_platform_halt("command line too long, " "increase BMK_MULTIBOOT_CMDLINE_SIZE"); bmk_strcpy(bmk_multiboot_cmdline, cmdline); if ((mbi->flags & MULTIBOOT_MEMORY_INFO) == 0) bmk_platform_halt("multiboot memory info not available\n"); if (parsemem(mbi->mmap_addr, mbi->mmap_length) != 0) bmk_platform_halt("multiboot memory parse failed"); bmk_intr_init(); }
static int parsemem(uint32_t addr, uint32_t len) { struct multiboot_mmap_entry *mbm; unsigned long osend; extern char _end[]; uint32_t off; /* * Look for our memory. We assume it's just in one chunk * starting at MEMSTART. */ for (off = 0; off < len; off += mbm->size + sizeof(mbm->size)) { mbm = (void *)(uintptr_t)(addr + off); if (mbm->addr == MEMSTART && mbm->type == MULTIBOOT_MEMORY_AVAILABLE) { break; } } if (!(off < len)) bmk_platform_halt("multiboot memory chunk not found"); osend = round_page((unsigned long)_end); bmk_assert(osend > mbm->addr && osend < mbm->addr + mbm->len); bmk_pgalloc_loadmem(osend, mbm->addr + mbm->len); bmk_memsize = mbm->addr + mbm->len - osend; return 0; }
/* * Allocate a 2^n chunk of pages, aligned at 2^n. This is currently * for the benefit of thread stack allocation, and should be going * away in some time when the migration to TLS is complete. */ static void * alignedpgalloc(int shift) { struct stackcache *sc; int align = 1<<shift; size_t alignedoff; void *rv; if (shift == BMK_THREAD_STACK_PAGE_ORDER && (sc = LIST_FIRST(&cacheofstacks)) != NULL) { LIST_REMOVE(sc, sc_entries); return sc; } if (align > MAXPAGEALIGN) align = MAXPAGEALIGN; /* need to leave this much space until the next aligned alloc */ alignedoff = (bmk_membase + currentpg*PAGE_SIZE) % (align*PAGE_SIZE); if (alignedoff) currentpg += align - (alignedoff>>PAGE_SHIFT); rv = bmk_allocpg(1<<shift); if (((unsigned long)rv & (align*PAGE_SIZE-1)) != 0) { bmk_printf("wanted %d aligned, got memory at %p\n", align, rv); bmk_platform_halt("fail"); } return rv; }
static char * jsonordie(void) { if (hardcoded_jsoncfg[0] == '\0') bmk_platform_halt("could not get configuration"); bmk_printf("using hardcoded_jsoncfg\n"); return hardcoded_jsoncfg; }
void rumpuser_mutex_enter_nowrap(struct rumpuser_mtx *mtx) { int rv; rv = rumpuser_mutex_tryenter(mtx); /* one VCPU supported, no preemption => must succeed */ if (rv != 0) { bmk_platform_halt("rumpuser mutex error"); } }
/* * INITIAL C ENTRY POINT. */ void _minios_start_kernel(start_info_t *si) { bmk_printf_init(minios_putc, NULL); bmk_core_init(STACK_SIZE_PAGE_ORDER, PAGE_SHIFT); arch_init(si); trap_init(); bmk_sched_init(); /* print out some useful information */ minios_printk(" start_info: %p(VA)\n", si); minios_printk(" nr_pages: 0x%lx\n", si->nr_pages); minios_printk(" shared_inf: 0x%08lx(MA)\n", si->shared_info); minios_printk(" pt_base: %p(VA)\n", (void *)si->pt_base); minios_printk("nr_pt_frames: 0x%lx\n", si->nr_pt_frames); minios_printk(" mfn_list: %p(VA)\n", (void *)si->mfn_list); minios_printk(" mod_start: 0x%lx(VA)\n", si->mod_start); minios_printk(" mod_len: %lu\n", si->mod_len); minios_printk(" flags: 0x%x\n", (unsigned int)si->flags); minios_printk(" cmd_line: %s\n", si->cmd_line ? (const char *)si->cmd_line : "NULL"); /* Set up events. */ init_events(); /* ENABLE EVENT DELIVERY. This is disabled at start of day. */ __sti(); arch_print_info(); setup_xen_features(); /* Init memory management. */ init_mm(); /* Init time and timers. */ init_time(); /* Init the console driver. */ init_console(); /* Init grant tables */ init_gnttab(); /* Init XenBus */ init_xenbus(); /* Init scheduler. */ bmk_sched_startmain(_app_main, &start_info); bmk_platform_halt("unreachable"); }
int rumpuser_init(int version, const struct rumpuser_hyperup *hyp) { if (version != RUMPHYPER_MYVERSION) { bmk_platform_halt("rump kernel hypercall revision mismatch\n"); /* NOTREACHED */ } rumpuser__hyp = *hyp; return rumprun_platform_rumpuser_init(); }
int rumpuser_mutex_tryenter(struct rumpuser_mtx *mtx) { struct lwp *l = rumpuser_curlwp(); if (mtx->bmk_o == bmk_current) { bmk_platform_halt("rumpuser mutex: locking against myself"); } if (mtx->v) return BMK_EBUSY; mtx->v = 1; mtx->o = l; mtx->bmk_o = bmk_current; return 0; }
void rumpuser_exit(int value) { bmk_platform_halt(value == RUMPUSER_PANIC ? "rumpuser panic" : NULL); }