/* Main execution loop */ int execution_loop(void) { int ret; enum client_interface call; capability_t server = current->utcb->boot_info.boot_caps[LCD_BOOT_FREE_CAP0]; capability_t server_interface; struct message_info *msg = ¤t->utcb->msg_info; ret = lcd_alloc_cap(¤t->cap_cache, &server_interface); if(ret) { printk(KERN_ERR "Failed to allocate free capability\n"); return -ENOSPC; }; msg->cap_regs[0] = server_interface; msg->valid_cap_regs = 1; ret = ipc_recv(server, msg); if (ret) { printk(KERN_ERR "client failed to receive from the server:%d\n", ret); return ret; }; call = msg->regs[0]; switch (call) { case client_interface_register_server: ret = register(lcd_api, reply_cap); break; default: printk(KERN_ERR "lcd_api: invalid call number:%d\n", call); msg->valid_regs = 0; msg->valid_cap_regs = 0; ipc_reply(reply_cap, msg); lcd_cap_drop(¤t->cspace, reply_cap); }; return 0; }; struct sync_ipc *client_server_rvp; int accept_client_introduction(void) { return lcd_accept_introduction(&client_server_rvp, &client); }; EXPORT_SYMBOL(accept_client_introduction); int execution_loop_thread(void *p) { int ret; ret = lcd_init_current(); if (ret) { printk(KERN_ERR "Failed to init current thread with LCD:%d\n", ret); return -EINVAL; } ret = lcd_init_cspace(&module_cspace); if (ret) { printk(KERN_ERR "Failed to init global cspace for this module:%d\n", ret); return ret; }; /* Introduction code */ ret = lcd_prepare_introduction(lcd_api_cap(), lcd_api_reply_cap(), &client_server_rvp, ¤t->utcb->boot_info.boot_caps[LCD_BOOT_FREE_CAP0]); if (ret) { printk(KERN_ERR "client failed to initialize client-server environtment\n"); return -EINVAL; } /* Record the clients session */ lcd_cap_make_cspace(&module_cspace, &module_cap_cache, * return execution_loop(); }