Example #1
0
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();
}
Example #2
0
static ssize_t
writestr(int fd, const char *str)
{
	return rump_sys_write(fd, str, bmk_strlen(str));
}
Example #3
0
static void xenbus_thread_func(void *ign)
{
    struct xsd_sockmsg msg;
    unsigned prod = xenstore_buf->rsp_prod;

    for (;;) 
    {
        minios_wait_event(xb_waitq, prod != xenstore_buf->rsp_prod);
        while (1) 
        {
            prod = xenstore_buf->rsp_prod;
            DEBUG("Rsp_cons %d, rsp_prod %d.\n", xenstore_buf->rsp_cons,
                    xenstore_buf->rsp_prod);
            if (xenstore_buf->rsp_prod - xenstore_buf->rsp_cons < sizeof(msg)) {
                minios_notify_remote_via_evtchn(start_info.store_evtchn);
                break;
            }
            rmb();
            memcpy_from_ring(xenstore_buf->rsp,
                    &msg,
                    MASK_XENSTORE_IDX(xenstore_buf->rsp_cons),
                    sizeof(msg));
            DEBUG("Msg len %d, %d avail, id %d.\n",
                    msg.len + sizeof(msg),
                    xenstore_buf->rsp_prod - xenstore_buf->rsp_cons,
                    msg.req_id);
            if (xenstore_buf->rsp_prod - xenstore_buf->rsp_cons <
                    sizeof(msg) + msg.len) {
                minios_notify_remote_via_evtchn(start_info.store_evtchn);
                break;
            }

            DEBUG("Message is good.\n");

            if(msg.type == XS_WATCH_EVENT)
            {
		struct xenbus_event *event
		    = bmk_xmalloc_bmk(sizeof(*event) + msg.len);
                struct xenbus_event_queue *events = NULL;
		char *data = (char*)event + sizeof(*event);
                struct xenbus_watch *watch;

                memcpy_from_ring(xenstore_buf->rsp,
		    data,
                    MASK_XENSTORE_IDX(xenstore_buf->rsp_cons + sizeof(msg)),
                    msg.len);

		event->path = data;
		event->token = event->path + bmk_strlen(event->path) + 1;

                mb();
                xenstore_buf->rsp_cons += msg.len + sizeof(msg);

                spin_lock(&xenbus_req_lock);

                MINIOS_LIST_FOREACH(watch, &watches, entry)
                    if (!bmk_strcmp(watch->token, event->token)) {
                        event->watch = watch;
                        events = watch->events;
                        break;
                    }

                if (events) {
                    queue_event(events, event);
                } else {
                    minios_printk("unexpected watch token %s\n", event->token);
                    bmk_memfree(event, BMK_MEMWHO_WIREDBMK);
                }

                spin_unlock(&xenbus_req_lock);
            }

            else
            {
                req_info[msg.req_id].for_queue->reply =
                    bmk_xmalloc_bmk(sizeof(msg) + msg.len);
                memcpy_from_ring(xenstore_buf->rsp,
                    req_info[msg.req_id].for_queue->reply,
                    MASK_XENSTORE_IDX(xenstore_buf->rsp_cons),
                    msg.len + sizeof(msg));
                mb();
                xenstore_buf->rsp_cons += msg.len + sizeof(msg);
                spin_lock(&xenbus_req_lock);
                queue_event(req_info[msg.req_id].reply_queue,
                            req_info[msg.req_id].for_queue);
                spin_unlock(&xenbus_req_lock);
            }

            wmb();
            minios_notify_remote_via_evtchn(start_info.store_evtchn);
        }
    }