int main (int argc, char **argv) { int res; TestClass *obj1; TestClass *obj2; obj1 = malloc ( sizeof (TestClass) ); obj2 = malloc ( sizeof (TestClass) ); class_init(obj1, Impl1); class_init(obj2, Impl2); SMCALL(obj1, &res, test_method, 1); SVMCALL(obj1, test_void_method, res); SMCALL(obj2, &res, test_method, 1); SVMCALL(obj2, test_void_method, 4); free (obj1); free (obj2); return 0; }
/* allocate and initialize new builtin class */ class_t *new_builtin_class(class_t *super) { class_t *cl = mm_alloc(mt_class); add_notifier(cl, dbg_notify, NULL); class_init(cl); if (super) { cl->super = super; cl->atsuper = super->backptr; } assert(class_class); cl->backptr = new_at(class_class, cl); return cl; }
void pre_init_oostruct(void) { if (mt_class == mt_undefined) mt_class = MM_REGTYPE("class", sizeof(class_t), clear_class, mark_class, 0); if (!class_class) { class_class = mm_alloc(mt_class); class_init(class_class); class_class->dispose = (dispose_func_t *)class_dispose; class_class->name = class_name; class_class->dontdelete = true; } }
void stmt.dcl() /* typecheck statement "this" in scope "curr_block->tbl" */ { Pstmt ss; Pname n; Pname nn; Pstmt ostmt = Cstmt; for (ss=this; ss; ss=ss->s_list) { Pstmt old_loop, old_switch; Cstmt = ss; Ptable tbl = curr_block->memtbl; /*error('d',"ss %d%k tbl %d e %d%k s %d%k sl %d%k", ss, ss->base, tbl, ss->e, (ss->e)?ss->e->base:0, ss->s, (ss->s)?ss->s->base:0, ss->s_list, (ss->s_list)?ss->s_list->base:0);*/ switch (ss->base) { case BREAK: if (curr_loop==0 && curr_switch==0) error("%k not in loop or switch",BREAK); ss->reached(); break; case CONTINUE: if (curr_loop == 0) error("%k not in loop",CONTINUE); ss->reached(); break; case DEFAULT: if (curr_switch == 0) { error("default not in switch"); break; } if (curr_switch->has_default) error("two defaults in switch"); curr_switch->has_default = ss; ss->s->s_list = ss->s_list; ss->s_list = 0; ss->s->dcl(); break; case SM: switch (ss->e->base) { case DUMMY: ss->e = 0; break; // check for unused results // don't check operators that are likely // to be overloaded to represent "actions": // ! ~ < <= > >= << >> case EQ: case NE: case PLUS: case MINUS: case REF: case DOT: case MUL: case DIV: case ADDROF: case AND: case OR: case ER: case DEREF: case ANDAND: case OROR: case NAME: if (ss->e->tp) break; // avoid looking at generated code ss->e = ss->e->typ(tbl); if (ss->e->tp->base != VOID) error('w',"result of%kE not used",ss->e->base); break; default: ss->e = ss->e->typ(tbl); } // ss->e = (ss->e != dummy) ? ss->e->typ(tbl) : 0; break; case RETURN: { Pname fn = cc->nof; Ptype rt = Pfct(fn->tp)->returns; Pexpr v = ss->e; if (v != dummy) { if (rt->base == VOID) { error('w',"unX return value"); /*refuse to return the value:*/ ss->e = dummy; } else { v = v->typ(tbl); lx: //error('d',"return %t",rt); switch (rt->base) { case TYPE: rt = Pbase(rt)->b_name->tp; goto lx; case RPTR: ss->e = ref_init(Pptr(rt),v,tbl); if (v->lval(0)==0 && v->tp->tconst()==0) error('w',"reference to non-lvalue returned"); else if (v->base==NAME && Pname(v)->n_scope==FCT) error('w',"reference to local variable returned"); break; case COBJ: { Pname rv = tbl->look("_result",0); ss->e = class_init(rv,rt,v,tbl); //error('d',"ss->e %t %d",ss->e->tp,ss->e->base); break; } case ANY: break; case INT: case CHAR: case LONG: case SHORT: if (Pbase(rt)->b_unsigned && v->base==UMINUS && v->e2->base==ICON) error('w',"negative retured fromF returning unsigned"); default: { Pname cn; int i; if ((cn=v->tp->is_cl_obj()) && (i=can_coerce(rt,v->tp)) && Ncoerce) { if (1 < i) error("%d possible conversions for return value",i); Pclass cl = (Pclass)cn->tp; Pref r = new ref(DOT,v,Ncoerce); Pexpr c = new expr(G_CALL,r,0); c->fct_name = Ncoerce; c->tp = rt; ss->e = c; break; } } ss->e = v; if (rt->check(v->tp,ASSIGN)) error("bad return valueT for%n:%t (%tX)",fn,v->tp,rt); } } } else { if (rt->base != VOID) error('w',"return valueX"); } ss->reached(); break; } case DO: /* in DO the stmt is before the test */ inline_restr |= 8; old_loop = curr_loop; curr_loop = ss; if (ss->s->base == DCL) error('s',"D as onlyS in do-loop"); ss->s->dcl(); /* tbl = curr_block->memtbl;*/ ss->e = ss->e->typ(tbl); ss->e = check_cond(ss->e,DO,tbl); curr_loop = old_loop; break; case WHILE: inline_restr |= 8; old_loop = curr_loop; curr_loop = ss; ss->e = ss->e->typ(tbl); /*ss->e->tp->num_ptr(ss->base);*/ ss->e = check_cond(ss->e,WHILE,tbl); if (ss->s->base == DCL) error('s',"D as onlyS in while-loop"); ss->s->dcl(); curr_loop = old_loop; break; case SWITCH: { int ne = 0; inline_restr |= 4; old_switch = curr_switch; curr_switch = ss; ss->e = ss->e->typ(tbl); /* ss->e->tp->num_ptr(SWITCH);*/ ss->e = check_cond(ss->e,SWITCH,tbl); { Ptype tt = ss->e->tp; sii: switch (tt->base) { case TYPE: tt = ((Pbase)tt)->b_name->tp; goto sii; case EOBJ: ne = Penum(Pbase(tt)->b_name->tp)->no_of_enumerators; case ZTYPE: case ANY: case CHAR: case SHORT: case INT: case LONG: case FIELD: break; default: error('s',"%t switchE",ss->e->tp); } } ss->s->dcl(); if (ne) { /* see if the number of cases is "close to" but not equal to the number of enumerators */ int i = 0; Pstmt cs; for (cs=ss->case_list; cs; cs=cs->case_list) i++; if (i && i!=ne) { if (ne < i) { ee: error('w',"switch (%t) with %d cases (%d enumerators)",ss->e->tp,i,ne); } else { switch (ne-i) { case 1: if (3<ne) goto ee; case 2: if (7<ne) goto ee; case 3: if (23<ne) goto ee; case 4: if (60<ne) goto ee; case 5: if (99<ne) goto ee; } } } } curr_switch = old_switch; break; } case CASE: if (curr_switch == 0) { error("case not in switch"); break; } ss->e = ss->e->typ(tbl); ss->e->tp->num_ptr(CASE); { Ptype tt = ss->e->tp; iii: switch (tt->base) { case TYPE: tt = Pbase(tt)->b_name->tp; goto iii; case ZTYPE: case ANY: case CHAR: case SHORT: case INT: case LONG: break; default: error('s',"%t caseE",ss->e->tp); } } if (1) { Neval = 0; int i = ss->e->eval(); if (Neval == 0) { Pstmt cs; for (cs=curr_switch->case_list; cs; cs=cs->case_list) { if (cs->case_value == i) error("case %d used twice in switch",i); } ss->case_value = i; ss->case_list = curr_switch->case_list; curr_switch->case_list = ss; } else error("bad case label: %s",Neval); } if (ss->s->s_list) error('i',"case%k",ss->s->s_list->base); ss->s->s_list = ss->s_list; ss->s_list = 0; ss->s->dcl(); break; case GOTO: inline_restr |= 2; ss->reached(); case LABEL: /* Insert label in function mem table; labels have function scope. */ n = ss->d; nn = cc->ftbl->insert(n,LABEL); /* Set a ptr to the mem table corresponding to the scope in which the label actually occurred. This allows the processing of goto's in the presence of ctors and dtors */ if(ss->base == LABEL) { nn->n_realscope = curr_block->memtbl; inline_restr |= 1; } if (Nold) { if (ss->base == LABEL) { if (nn->n_initializer) error("twoDs of label%n",n); nn->n_initializer = (Pexpr)1; } if (n != nn) ss->d = nn; } else { if (ss->base == LABEL) nn->n_initializer = (Pexpr)1; nn->where = ss->where; } if (ss->base == GOTO) nn->use(); else { if (ss->s->s_list) error('i',"label%k",ss->s->s_list->base); ss->s->s_list = ss->s_list; ss->s_list = 0; nn->assign(); } if (ss->s) ss->s->dcl(); break; case IF: { Pexpr ee = ss->e->typ(tbl); if (ee->base == ASSIGN) { Neval = 0; (void)ee->e2->eval(); if (Neval == 0) error('w',"constant assignment in condition"); } ss->e = ee = check_cond(ee,IF,tbl); //error('d',"if (%t)",ee->tp); switch (ee->tp->base) { case INT: case ZTYPE: { int i; Neval = 0; i = ee->eval(); //error('d',"if (int:%k) => (i %s)",ss->e->base,i,Neval?Neval:"0"); if (Neval == 0) { Pstmt sl = ss->s_list; if (i) { DEL(ss->else_stmt); ss->s->dcl(); *ss = *ss->s; } else { DEL(ss->s); if (ss->else_stmt) { ss->else_stmt->dcl(); *ss = *ss->else_stmt; } else { ss->base = SM; ss->e = dummy; ss->s = 0; } } ss->s_list = sl; continue; } } } ss->s->dcl(); if (ss->else_stmt) ss->else_stmt->dcl(); break; } case FOR: inline_restr |= 8; old_loop = curr_loop; curr_loop = ss; if (ss->for_init) { Pstmt fi = ss->for_init; switch (fi->base) { case SM: if (fi->e == dummy) { ss->for_init = 0; break; } default: fi->dcl(); break; case DCL: fi->dcl(); //error('d',"dcl=>%k %d",fi->base,fi->base); switch (fi->base) { case BLOCK: { /* { ... for( { a } b ; c) d ; e } => { ... { a for ( ; b ; c) d ; e }} */ Pstmt tmp = new stmt (SM,curloc,0); *tmp = *ss; /* tmp = for */ tmp->for_init = 0; *ss = *fi; /* ss = { } */ if (ss->s) ss->s->s_list = tmp; else ss->s = tmp; curr_block = (Pblock)ss; tbl = curr_block->memtbl; ss = tmp; /* rest of for and s_list */ break; } } } } if (ss->e == dummy) ss->e = 0; else { ss->e = ss->e->typ(tbl); ss->e = check_cond(ss->e,FOR,tbl); } if (ss->s->base == DCL) error('s',"D as onlyS in for-loop"); ss->s->dcl(); ss->e2 = (ss->e2 == dummy) ? 0 : ss->e2->typ(tbl); curr_loop = old_loop; break; case DCL: /* declaration after statement */ { /* collect all the contiguous DCL nodes from the head of the s_list. find the next statement */ int non_trivial = 0; int count = 0; Pname tail = ss->d; for (Pname nn=tail; nn; nn=nn->n_list) { // find tail; // detect non-trivial declarations count++; //error('d',"dcl:%n list %d stc %d in %d",nn,nn->n_list,nn->n_sto,nn->n_initializer); if (nn->n_list) tail = nn->n_list; Pname n = tbl->look(nn->string,0); if (n && n->n_table==tbl) non_trivial = 2; if (non_trivial == 2) continue; if (nn->n_sto==STATIC || nn->tp->is_ref()) { non_trivial = 2; continue; } Pexpr in = nn->n_initializer; if (in) switch (in->base) { case ILIST: case STRING: non_trivial = 2; continue; default: non_trivial = 1; } Pname cln = nn->tp->is_cl_obj(); if (cln == 0) cln = cl_obj_vec; if (cln == 0) continue; if (Pclass(cln->tp)->has_dtor()) non_trivial = 2; if (Pclass(cln->tp)->has_ctor()) non_trivial = 2; } //error('d',"non_trivial %d",non_trivial); while( ss->s_list && ss->s_list->base==DCL ) { Pstmt sx = ss->s_list; tail = tail->n_list = sx->d; // add to tail for (nn=sx->d; nn; nn=nn->n_list) { // find tail; // detect non-trivial declarations count++; if (nn->n_list) tail = nn->n_list; Pname n = tbl->look(nn->string,0); if (n && n->n_table==tbl) non_trivial = 2; if (non_trivial == 2) continue; if (nn->n_sto==STATIC || nn->tp->is_ref()) { non_trivial = 2; continue; } Pexpr in = nn->n_initializer; if (in) switch (in->base) { case ILIST: case STRING: non_trivial = 2; continue; } non_trivial = 1; Pname cln = nn->tp->is_cl_obj(); if (cln == 0) cln = cl_obj_vec; if (cln == 0) continue; if (Pclass(cln->tp)->has_ctor()) non_trivial = 2; if (Pclass(cln->tp)->has_dtor()) non_trivial = 2; } ss->s_list = sx->s_list; /* delete sx; */ } Pstmt next_st = ss->s_list; //error('d',"non_trivial %d curr_block->own_tbl %d inline_restr %d",non_trivial,curr_block->own_tbl,inline_restr); if (non_trivial==2 /* must */ || (non_trivial==1 /* might */ && ( curr_block->own_tbl==0 /* just as well */ || inline_restr&3 /* label seen */) ) ) { /* Create a new block, put all the declarations at the head, and the remainder of the slist as the statement list of the block. */ ss->base = BLOCK; /* check that there are no redefinitions since the last "real" (user-written, non-generated) block */ for( nn=ss->d; nn; nn=nn->n_list ) { Pname n; if( curr_block->own_tbl && (n=curr_block->memtbl->look(nn->string,0)) && n->n_table->real_block==curr_block->memtbl->real_block) error("twoDs of%n",n); } /* attach the remainder of the s_list as the statement part of the block. */ ss->s = next_st; ss->s_list = 0; /* create the table in advance, in order to set the real_block ptr to that of the enclosing table */ ss->memtbl = new table(count+4,tbl,0); ss->memtbl->real_block = curr_block->memtbl->real_block; Pblock(ss)->dcl(ss->memtbl); } else { /* to reduce the number of symbol tables, do not make a new block, instead insert names in enclosing block, and make the initializers into expression statements. */ Pstmt sss = ss; for( nn=ss->d; nn; nn=nn->n_list ) { Pname n = nn->dcl(tbl,FCT); //error('d',"%n->dcl(%d) -> %d init %d sss=%d ss=%d",nn,tbl,n,n->n_initializer,sss,ss); if (n == 0) continue; Pexpr in = n->n_initializer; n->n_initializer = 0; if (ss) { sss->base = SM; ss = 0; } else sss = sss->s_list = new estmt(SM,sss->where,0,0); if (in) { switch (in->base) { case G_CALL: /* constructor? */ { Pname fn = in->fct_name; if (fn && fn->n_oper==CTOR) break; } default: in = new expr(ASSIGN,n,in); } sss->e = in->typ(tbl); } else sss->e = dummy; } ss = sss; ss->s_list = next_st; } break; } case BLOCK: Pblock(ss)->dcl(tbl); break; case ASM: /* save string */ break; default: error('i',"badS(%d %d)",ss,ss->base); } } Cstmt = ostmt; }
void __z_object_class_init(struct zco_context_t *ctx, ZObjectClass *_class) { #ifdef CLASS_INIT_EXISTS class_init(ctx, _class); #endif }
int main(int argc, char *argv[]) { /* Check to see if the user is running us as root, which is a nono */ if (!geteuid()) { fprintf(stderr, "ERROR: This server won't run as root/superuser\n"); return -1; } /* Setup corefile size immediately after boot -kre */ setup_corefile(); /* Save server boot time right away, so getrusage works correctly */ set_time(); /* It's not random, but it ought to be a little harder to guess */ init_genrand(SystemTime.tv_sec ^ (SystemTime.tv_usec | (getpid() << 20))); dlinkAdd(&me, &me.node, &global_client_list); ConfigGeneral.dpath = DPATH; ConfigGeneral.spath = SPATH; ConfigGeneral.mpath = MPATH; ConfigGeneral.configfile = CPATH; /* Server configuration file */ ConfigGeneral.klinefile = KPATH; /* Server kline file */ ConfigGeneral.glinefile = GPATH; /* Server gline file */ ConfigGeneral.xlinefile = XPATH; /* Server xline file */ ConfigGeneral.dlinefile = DLPATH; /* dline file */ ConfigGeneral.resvfile = RESVPATH; /* resv file */ myargv = argv; umask(077); /* umask 077: u=rwx,g=,o= */ parseargs(&argc, &argv, myopts); if (printVersion) { printf("ircd: version %s(%s)\n", ircd_version, serno); exit(EXIT_SUCCESS); } if (chdir(ConfigGeneral.dpath)) { perror("chdir"); exit(EXIT_FAILURE); } ssl_init(); if (!server_state.foreground) { make_daemon(); close_standard_fds(); /* this needs to be before init_netio()! */ } else print_startup(getpid()); setup_signals(); /* We need this to initialise the fd array before anything else */ fdlist_init(); log_set_file(LOG_TYPE_IRCD, 0, logFileName); init_netio(); /* This needs to be setup early ! -- adrian */ /* Check if there is pidfile and daemon already running */ check_pidfile(pidFileName); mp_pool_init(); init_dlink_nodes(); init_isupport(); dbuf_init(); hash_init(); ipcache_init(); client_init(); class_init(); whowas_init(); watch_init(); auth_init(); /* Initialise the auth code */ init_resolver(); /* Needs to be setup before the io loop */ modules_init(); read_conf_files(1); /* cold start init conf files */ init_uid(); initialize_server_capabs(); /* Set up default_server_capabs */ initialize_global_set_options(); /* Has to be called after read_conf_files() */ channel_init(); read_links_file(); motd_init(); user_usermodes_init(); #ifdef HAVE_LIBGEOIP geoip_ctx = GeoIP_new(GEOIP_MEMORY_CACHE); #endif if (EmptyString(ConfigServerInfo.sid)) { ilog(LOG_TYPE_IRCD, "ERROR: No server id specified in serverinfo block."); exit(EXIT_FAILURE); } strlcpy(me.id, ConfigServerInfo.sid, sizeof(me.id)); if (EmptyString(ConfigServerInfo.name)) { ilog(LOG_TYPE_IRCD, "ERROR: No server name specified in serverinfo block."); exit(EXIT_FAILURE); } strlcpy(me.name, ConfigServerInfo.name, sizeof(me.name)); /* serverinfo{} description must exist. If not, error out.*/ if (EmptyString(ConfigServerInfo.description)) { ilog(LOG_TYPE_IRCD, "ERROR: No server description specified in serverinfo block."); exit(EXIT_FAILURE); } strlcpy(me.info, ConfigServerInfo.description, sizeof(me.info)); me.from = &me; me.servptr = &me; me.connection->lasttime = CurrentTime; me.connection->since = CurrentTime; me.connection->firsttime = CurrentTime; SetMe(&me); make_server(&me); hash_add_id(&me); hash_add_client(&me); dlinkAdd(&me, make_dlink_node(), &global_server_list); load_kline_database(); load_dline_database(); load_gline_database(); load_xline_database(); load_resv_database(); load_all_modules(1); load_conf_modules(); load_core_modules(1); write_pidfile(pidFileName); ilog(LOG_TYPE_IRCD, "Server Ready"); event_addish(&event_cleanup_glines, NULL); event_addish(&event_cleanup_tklines, NULL); /* We want try_connections to be called as soon as possible now! -- adrian */ /* No, 'cause after a restart it would cause all sorts of nick collides */ event_addish(&event_try_connections, NULL); /* Setup the timeout check. I'll shift it later :) -- adrian */ event_add(&event_comm_checktimeouts, NULL); event_addish(&event_save_all_databases, NULL); if (ConfigServerHide.links_delay > 0) { event_write_links_file.when = ConfigServerHide.links_delay; event_addish(&event_write_links_file, NULL); } else ConfigServerHide.links_disabled = 1; if (splitmode) event_addish(&splitmode_event, NULL); io_loop(); return 0; }
/* usbcore: usbc_stack_checkin(USB_CLASS_NUM, NULL); usbclass: ex. usbc_stack_checkin(USB_CLASS_ACM1, XXX); */ void usbc_stack_checkin(usb_class_type_e class_type, usbc_node_reg_entry_t *reg_table) { usbc_class_init_func_t class_init; kal_uint32 idx_cfg, idx_class; kal_uint32 cfg_num; usb_cfg_param_t *cfg_param; usbc_device_descriptor_t *dev_desc; usbc_device_qualifier_descriptor_t *dev_qual_desc; usbc_configuration_descriptor_t *config_desc_p; usbc_core_t *usbc_inst; _CHECKIN_NODE(class_type, reg_table); if (_ALL_NODES_CHECKIN()) { usbc_trace_info(USBCORE_ALL_NODE_CHECKIN); usbc_inst = usbc_core_get_instance(); /* 1. hif init */ usbc_normal_hif_init(); // Check for META mode #if defined(__MTK_TARGET__) && defined(__MULTI_BOOT__) && !defined(__ESL_COSIM_HIF__) if( INT_BootMode() == MTK_FACTORY_MODE ) { usbc_inst->is_mode_meta = KAL_TRUE; usbc_inst->is_mode_meta_reused = usbc_normal_hif_is_meta_reused(); } else #endif { usbc_inst->is_mode_meta = usbc_inst->is_mode_meta_reused = KAL_FALSE; } /* 2. Reset usbcore resources/structures */ usbc_resource_reset(); usbc_core_clear_register(); usbc_core_clear_status(); /* 3. If Morphing is enabled, use WIN8 mode configuration If it is resulted from mode switch, use usbc_inst->mode */ usbc_inst->dev_param = (usb_dev_param_t*)usb_get_custom_func()->get_device_param_func(); if( !usbc_inst->is_mode_meta ) { #if defined (BTT_STANDALONE_MODE) usbc_inst->mode = USB_MODE_BTT_STANDALONE; #elif defined(__ESL_COSIM_HIF__) usbc_inst->mode = USB_MODE_ESL; #else if (!usbc_inst->is_mode_switch) { usbc_inst->morphing_enable = (custom_em_get_usb_cdrom_config() & 0x02)? KAL_TRUE:KAL_FALSE; // check for morphing enable if ( usbc_inst->morphing_enable ) { usbc_inst->mode = usbc_inst->dev_param->usb_mode[USB_OS_WIN8]; } else { if( (custom_em_get_usb_cdrom_config() & 0x01) == 0 ) { usbc_inst->mode = USB_MODE_MSD_ONLY; } else { usbc_inst->mode = USB_MODE_MT6290_DATACARD; } } } #endif } else { // set USB enumeration to USB_MODE_META if it is in meta mode usbc_inst->mode = USB_MODE_META; } cfg_num = usbc_inst->dev_param->mode_param[usbc_inst->mode].cfg_num; /* 4. Set device_descriptor */ dev_desc = (usbc_device_descriptor_t *)usbc_inst->descriptors.device; kal_mem_cpy(dev_desc, &usbc_default_device_descriptor, USBC_DEVICE_DESC_SIZE); dev_desc->bDeviceClass = usbc_inst->dev_param->mode_param[usbc_inst->mode].device_class; dev_desc->bDeviceSubClass = usbc_inst->dev_param->mode_param[usbc_inst->mode].device_sub_class; dev_desc->bDeviceProtocol = usbc_inst->dev_param->mode_param[usbc_inst->mode].device_protocol; dev_desc->idVendor = usbc_inst->dev_param->vendor_id; dev_desc->idProduct = usbc_inst->dev_param->mode_param[usbc_inst->mode].product_id; dev_desc->bcdDevice = usbc_inst->dev_param->bcd_device; dev_desc->bNumConfigurations = usbc_inst->dev_param->mode_param[usbc_inst->mode].cfg_num; dev_qual_desc = &usbc_inst->device_qualifier_descriptor; dev_qual_desc->bLength = 0x0A; dev_qual_desc->bDescriptorType = USBC_DT_DEVICE_QUALIFIER; dev_qual_desc->bcdUSB = dev_desc->bcdUSB; dev_qual_desc->bDeviceClass = dev_desc->bDeviceClass; dev_qual_desc->bDeviceSubClass = dev_desc->bDeviceSubClass; dev_qual_desc->bDeviceProtocol = dev_desc->bDeviceProtocol; dev_qual_desc->bMaxPacketSize0 = dev_desc->bMaxPacketSize0; dev_qual_desc->bNumConfigurations = dev_desc->bNumConfigurations; /* 5. Store device string - language/manufacturere/product/serialnum */ usbc_get_string_number((void*)usb_language_string); dev_desc->iManufacturer = usbc_get_string_number((void*)usbc_inst->dev_param->manufacture_string); dev_desc->iProduct = usbc_get_string_number((void*)usbc_inst->dev_param->product_string); // Update serial number by reading the IMEI from NVRAM #ifdef __PRODUCTION_RELEASE__ dev_desc->iSerialNumber = usbc_core_set_serial_number()? usbc_get_string_number((void*)usbc_inst->dev_param->serial_number):0x00; #else /* under construction !*/ #endif /* 6. Call init function of each usb class for all configurations */ for (idx_cfg = 0; idx_cfg < cfg_num; idx_cfg++) { cfg_param = &usbc_inst->dev_param->mode_param[usbc_inst->mode].cfg_param[idx_cfg]; for (idx_class = 0; idx_class < cfg_param->class_num; idx_class++) { class_init = _get_class_init_func(cfg_param->class_type[idx_class]); if (class_init) { usbc_trace_info(USBCORE_ALL_NODE_CHECKIN_INIT_CLASS_START, cfg_param->class_type[idx_class]); class_init( idx_class, usbc_inst->mode, idx_cfg, cfg_param->class_ctxt[idx_class], cfg_param->bulk_double_fifo_bitmap[idx_class]); usbc_trace_info(USBCORE_ALL_NODE_CHECKIN_INIT_CLASS_END, cfg_param->class_type[idx_class]); } else { EXT_ASSERT(KAL_FALSE, 1, 0, 0); } } } if( !usbc_inst->is_mode_meta_reused ) { /* 7. Construct configuration descriptor */ _usbc_construct_config_descriptor(usbc_inst); /* 8. Update descriptors for META (non-reuse COM) */ if(usbc_inst->is_mode_meta) { dev_desc->idProduct = 0x7101; } /* 9. Set configuration and connect to hif */ usbc_normal_hif_disconnect(); usbc_core_set_hif_configuration(); usbc_normal_hif_connect(); } else { /* 7. Construct configuration descriptor */ usbc_inst->resource_iad_number[0] = 0; // Discard IAD if it is in META mode _usbc_construct_config_descriptor(usbc_inst); // construct configuration descriptor /* 8. Update descriptors for META */ dev_desc->iSerialNumber = 0x00; // no serial number in BootROM/pre-loader's COM config_desc_p = (usbc_configuration_descriptor_t*)usbc_inst->descriptors.configuration[0]; // only one configuration in META mode config_desc_p->bmAttributes &= 0xdf; // the remote wakeup is not capable in BootROM/Pre-loader COM config_desc_p->bMaxPower = 0xc8; // the max power of BootROM/Preloader COM's confiuration is 400mA usbc_inst->u3ConfMaxPower = (U3_CONF_BMAXPOWER_META / USBC_USB30_POWER_DESC_UINT); // the max power is 400mA in USB 3.0 /* 9. Enqueue and prepare for fake enumeration */ usbc_meta_hif_factory(); // set function pointers of USB driver to META state usbc_core_set_hif_configuration(); usbc_normal_hif_meta_attach(); } } }