int sched_comp_config_initstr(spdid_t spdid, struct cos_array *data) { int max_len, str_len = 0; struct component_init_str *cis; char *s; if (first) { first = 0; parse_initialization_strings(); } if (!cos_argreg_arr_intern(data)) { BUG(); return -1; } max_len = data->sz; cis = init_str_for_spdid(spdid); if (NULL == cis) return -1; /* no dice */ params_initstr(cis->init_str, &s, &str_len); if (str_len+1 > max_len) { BUG(); return -1; } memcpy(data->mem, s, str_len); data->mem[str_len] = '\0'; data->sz = str_len; return 0; }
int sched_comp_config_default(spdid_t spdid, spdid_t target, struct cos_array *data) { int max_len, str_len; struct component_init_str *cis; char *s; if (first) { first = 0; parse_initialization_strings(); } if (!cos_argreg_arr_intern(data)) { BUG(); return -1; } max_len = data->sz; cis = spd_for_sched(spdid, target); if (0 == cis->spdid) return -1; /* no dice */ assert(cis->schedid == spdid); params_sched(cis->init_str, &s, &str_len); //str_len = strlen(cis->init_str); if (str_len+1 > max_len) { BUG(); return -1; } if (str_len == 0) return 1; memcpy(data->mem, s, str_len); data->mem[str_len] = '\0'; //strcpy(data->mem, cis->init_str); data->sz = str_len; return 0; }
int netif_event_xmit(spdid_t spdid, struct cos_array *d) { int ret; if (!cos_argreg_arr_intern(d)) return -EINVAL; if (d->sz > MTU || d->sz <= 0) return -EINVAL; NET_LOCK_TAKE(); ret = __netif_xmit(d->mem, (unsigned int)d->sz); NET_LOCK_RELEASE(); return ret; }
int netif_event_wait(spdid_t spdid, struct cos_array *d) { int ret_sz = 0; if (!cos_argreg_arr_intern(d)) return -EINVAL; if (d->sz < MTU) return -EINVAL; interrupt_wait(); NET_LOCK_TAKE(); if (interrupt_process(d->mem, d->sz, &ret_sz)) BUG(); NET_LOCK_RELEASE(); d->sz = ret_sz; return 0; }
/* As above, but return more than one event notifications */ int evt_grp_mult_wait(spdid_t spdid, struct cos_array *data) { struct evt_grp *g; struct evt *e = NULL; int evt_gathered = 0, evt_max; if (!cos_argreg_arr_intern(data)) return -EINVAL; evt_max = data->sz / sizeof(long); while (1) { lock_take(&evt_lock); g = evt_grp_find(cos_get_thd_id()); ACT_RECORD(ACT_WAIT_GRP, spdid, e ? e->extern_id : 0, cos_get_thd_id(), 0); if (NULL == g) goto err; /* gather multiple events */ do { if (__evt_grp_read_noblock(g, &e)) goto err; if (NULL != e) { ((long*)data->mem)[evt_gathered] = e->extern_id; evt_gathered++; } } while (e && evt_gathered < evt_max); /* return them if they were gathered */ if (evt_gathered > 0) { lock_release(&evt_lock); return evt_gathered; } /* * otherwise sleep till there is an event (first we * need to call evt_grp_read to set the blocked * status) */ if (__evt_grp_read(g, &e)) goto err; assert(NULL == e); lock_release(&evt_lock); ACT_RECORD(ACT_SLEEP, spdid, 0, cos_get_thd_id(), 0); if (0 > sched_block(cos_spd_id(), 0)) BUG(); } err: lock_release(&evt_lock); return -1; }
spdid_t __sched_comp_config(spdid_t spdid, int i, struct cos_array *data, int dyn_loaded) { int max_len, str_len; struct component_init_str *cis; char *s; if (first) { first = 0; parse_initialization_strings(); } if (!cos_argreg_arr_intern(data)) { BUG(); return 0; } max_len = data->sz; cis = nth_for_sched(spdid, i, dyn_loaded); if (0 == cis->spdid) return 0; /* no dice */ assert(cis->schedid == spdid); params_sched(cis->init_str, &s, &str_len); //str_len = strlen(cis->init_str); if (str_len+1 > max_len) { BUG(); return -1; } memcpy(data->mem, s, str_len); data->mem[str_len] = '\0'; //strcpy(data->mem, cis->init_str); data->sz = str_len; return cis->spdid; }