static __inline IBlk * _extract_blk_by_uuid( struct kernel_t * kernel, IMemStream * s ) { f8_uuid id; if(!_extract_uuid(s, &id)){ return 0; } return ke_get_blk(kernel, &id); }
void CRegRequirementList::Commit(__bool bCharge) { reglist::iterator it; varlist::iterator vit; reg_item *item; var_item *vitem; int i; for(i = m_rlist.size(), it = m_rlist.begin(); i; i--, it++){ item = &(*it); /* fixup owner */ if(item->blk_id != BLK_ID_NONE){ IBlk * blk; blk = ke_get_blk(proxy_adapter->kernel, &item->blk_id); assert(blk); item->owner = __vcall__(blk, pin_by_id, (blk, item->pin_id)); assert(item->owner); } set_address_owner( item->owner, &item->addr, item->length, PIN_MAGIC, bCharge ); } for(i = m_vlist.size(), vit = m_vlist.begin(); i; i--, vit++){ vitem = &(vit->second); vitem->var->blk = ke_get_blk( proxy_adapter->kernel, &vitem->var->blk->uuid ); vitem->var->ref_count += vitem->ref_count; } m_rlist.clear(); m_vlist.clear(); }
KPROXY_API f8_bool kproxy_init(int leakDetect) { ITcpAdapter *a; _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); _CrtSetBreakAlloc(leakDetect); /* initialize and start kernel */ ex_init(); /* KERN_F_ENABLE_INPUT */ x_buffer = (char *)__malloc__(LARGE_BUF_SIZE); x_buf_len = LARGE_BUF_SIZE; b_ShellExit = __false; __new__(ITcpAdapter, a); proxy_adapter = __ucast__(ITcpAdapter, IKAdapter, a); sections = ke_get_blk(proxy_adapter->kernel, 0); assert(sections->uuid == BLK_ID_ROOT); create_resource(§ions->uuid); create_f8_uuid(§ions->h.uuid); create_resource(§ions->h.uuid); memset(fileName, 0 , sizeof(fileName)); g_shell = shell_create(commands); reset_reg_map(); init_blklib(); init_clipboard(); g_bDirty = __false; init_network(RTK_INIT_AS_SERVER, 0); vbus = connect_vbus(0xf8, VBUS_CONNECT_AS_SERVER, sr, 0); return __true; }
/* in WIN32, the executive can run in two mode, i.e., the SoftPLC mode or the simulator mode. in SoftPLC mode, the executive will try to probe additional IO drivers and perform IOs during execution, while in simulator mode, no IO is performed. */ KSERVER_API int kserver_main2(int c, char **v) { int flags; char * mode = 0; int port = 0; __bool dbgMode; int leakDetect = 0; BEGIN_ARGS ARG("mode=", mode, "char *", "mode specifiers") ARG("port=", port, "int", "agent port") ARG("leak=", leakDetect, "int", "detect memory leakage") ARG("--debug", dbgMode, "tbool", "debug mode") END_ARGS if(process_args_1(c, v)<0){ print_usage_1(); return F8_SYNTAX; } if(leakDetect){ _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); _CrtSetBreakAlloc(leakDetect); } if(mode){ CArgs a; parse_arg_ex(mode, &a, "+/|-= ,;:"); int i; flags = 0; for(i=0; i<a.argc; i++){ if(!strcmp(a.argv[i], "sched")){ flags |= KERN_F_ENABLE_SCHEDULER; }else if(!strcmp(a.argv[i], "standby")){ flags |= KERN_F_ENABLE_STANDBY; }else if(!strcmp(a.argv[i], "io")){ flags |= KERN_F_ENABLE_IO; }else if(!strcmp(a.argv[i], "sio")){ flags |= KERN_F_SERIALIZED_IO; }else if(!strcmp(a.argv[i], "agent")){ flags |= KERN_F_ENABLE_AGENT; }else if(!strcmp(a.argv[i], "single")){ flags = KERN_F_ENABLE_SCHEDULER | KERN_F_ENABLE_IO | KERN_F_ENABLE_AGENT; break; }else if(!strcmp(a.argv[i], "all")){ flags = KERN_F_ENABLE_SCHEDULER | KERN_F_ENABLE_IO | KERN_F_ENABLE_AGENT | KERN_F_ENABLE_STANDBY; break; }else if(!strcmp(a.argv[i], "headless")){ flags = KERN_F_ENABLE_SCHEDULER | KERN_F_ENABLE_AGENT | KERN_F_ENABLE_STANDBY; break; } } }else{ flags = KERN_F_ENABLE_SCHEDULER | KERN_F_ENABLE_IO | KERN_F_ENABLE_AGENT | KERN_F_ENABLE_STANDBY; } ex_init(); g_kernel = ke_get_default_kernel(); ex_start(flags, port); sections = ke_get_blk(g_kernel, NULL); return F8_SUCCESS; }