Example #1
0
static inline void 
tor_add_pair(int from, int to, long feid, long teid)
{
#define MAXVAL (1<<16)
	assert(from < MAXVAL);
	assert(to   < MAXVAL);
	assert(feid < MAXVAL);
	assert(teid < MAXVAL);
	if (cvect_add(&tor_from, (void*)((teid << 16) | to), from) < 0) BUG();
	if (cvect_add(&tor_to, (void*)((feid << 16) | from), to) < 0) BUG();
}
Example #2
0
static struct cbuf_alloc_desc *
__cbuf_desc_alloc(int cbid, int size, void *addr, struct cbuf_meta *cm, int tmem)
{
	struct cbuf_alloc_desc *d;
	int idx = ((int)addr >> PAGE_ORDER);

	assert(addr && cm);
	assert(cm->nfo.c.ptr == idx);
	assert(__cbuf_alloc_lookup(idx) == NULL);
	assert((!tmem && !(cm->nfo.c.flags & CBUFM_TMEM)) ||
	       (tmem && cm->nfo.c.flags & CBUFM_TMEM));

	d = cslab_alloc_desc();
	if (!d) return NULL;

	d->cbid   = cbid;
	d->addr   = addr;
	d->length = size;
	d->meta   = cm;
	d->tmem   = tmem;
	INIT_LIST(d, next, prev);
	//ADD_LIST(&cbuf_alloc_freelists, d, next, prev);
	if (tmem) d->flhead = &cbuf_alloc_freelists;
	else      d->flhead = __cbufp_freelist_get(size);
	cvect_add(&alloc_descs, d, idx);

	return d;
}
Example #3
0
/*--------------------------------------*/
static struct rec_data_mm_list *
rdmm_list_init(long id)
{
	struct rec_data_mm_list *rdmm_list;

	/* FIXME: A BUG here that bitmap will be all 0 */
	rdmm_list = cslab_alloc_rdmm_ls();
	assert(rdmm_list);
	rdmm_list->id = id;
	rdmm_list->fcnt = fcounter;
	rdmm_list->recordable = 1;

	rdmm_list->head = rdmm_list->tail = &rdmm_list->first;

	if (cvect_add(&rec_mm_vect, rdmm_list, rdmm_list->id)) {
		printc("Cli: can not add list into cvect\n");
		return NULL;
	}
	/* printc("Init a list using id %d (vect @ %p ", id,&rec_mm_vect); */
	/* printc("list @ %p)\n", rdmm_list); */

#if (!LAZY_RECOVERY)
	INIT_LIST(rdmm_list, next, prev);
	if (!all_rdmm_list) {
		all_rdmm_list = cslab_alloc_rdmm_ls();
		assert(all_rdmm_list);
		INIT_LIST(all_rdmm_list, next, prev);
	} else {
		ADD_LIST(all_rdmm_list, rdmm_list, next, prev);
	}
#endif

	return rdmm_list;
}
static inline struct desc_track *call_desc_alloc(int id) {
	struct desc_track *desc = NULL;
	desc = cslab_alloc_IDL_service_slab();
	assert(desc);
	desc->IDL_id  = id;
	cvect_add(&IDL_service_desc_maps, desc, id);
	return desc;
}
static struct rec_data_tor *
rd_alloc(td_t c_tid)    // should pass c_tid
{
    struct rec_data_tor *rd;
    rd = cslab_alloc_rd();
    assert(rd);
    cvect_add(&rec_vect, rd, c_tid);
    return rd;
}
static inline struct desc_track *call_desc_alloc(long id)
{
	struct desc_track *desc = NULL;
	desc = cslab_alloc_evt_slab();
	assert(desc);
	desc->evtid = id;
	if (cvect_add(&evt_desc_maps, desc, id))
		assert(0);
	return desc;
}
static inline struct desc_track *call_desc_alloc(int id)
{
	struct desc_track *desc = NULL;
	desc = cslab_alloc_sched_slab();
	assert(desc);
	desc->thdid = id;
	if (cvect_add(&sched_desc_maps, desc, id))
		assert(0);
	return desc;
}
Example #8
0
static void
cbuf_comp_info_init(spdid_t spdid, struct cbuf_comp_info *cci)
{
	void *p;

	memset(cci, 0, sizeof(*cci));
	cci->spdid       = spdid;
	cci->target_size = CB_DEF_POOL_SZ;
	INIT_LIST(&cci->bthd_list, next, prev);
	cvect_add(&components, cci, spdid);
}
static struct rec_data_mm *
rdmm_alloc(vaddr_t addr)
{
	struct rec_data_mm *rd;

	printc("cli: rdmm_alloc cslab_alloc_rdmm....1\n");
	rd = cslab_alloc_rdmm();
	printc("cli: rdmm_alloc cslab_alloc_rdmm....2\n");
	assert(rd);

	if (cvect_add(&rec_mm_vect, rd, vaddr2id(addr))) assert(0);

	return rd;
}
Example #10
0
static struct cbufp_comp_info *
cbufp_comp_info_get(spdid_t spdid)
{
	struct cbufp_comp_info *cci;

	cci = cvect_lookup(&components, spdid);
	if (!cci) {
		cci = malloc(sizeof(struct cbufp_comp_info));
		if (!cci) return NULL;
		memset(cci, 0, sizeof(struct cbufp_comp_info));
		cci->spdid = spdid;
		cvect_add(&components, cci, spdid);
	}
	return cci;
}
static struct comp_vas *
cvas_alloc(spdid_t spdid)
{
	struct comp_vas *cv;

	assert(!cvas_lookup(spdid));
	cv = cslab_alloc_cvas();
	if (!cv) goto done;
	cv->pages = cvect_alloc();
	if (!cv->pages) goto free;
	cvect_init(cv->pages);
	cvect_add(&comps, cv, spdid);
	cv->nmaps = 0;
done:
	return cv;
free:
	cslab_free_cvas(cv);
	cv = NULL;
	goto done;
}
Example #12
0
/* Make a child mapping */
static struct mapping *
mapping_crt(struct mapping *p, struct frame *f, spdid_t dest, vaddr_t to, int flags)
{
	struct comp_vas *cv = cvas_lookup(dest);
	struct mapping *m = NULL;
	long idx = to >> PAGE_SHIFT;

	assert(!p || p->f == f);
	assert(dest && to);

	/* no vas structure for this spd yet... */
	if (!cv) {
		cv = cvas_alloc(dest);
		if (!cv) goto done;
		assert(cv == cvas_lookup(dest));
	}
	assert(cv->pages);
	if (cvect_lookup(cv->pages, idx)) goto collision;

	cvas_ref(cv);
	m = cslab_alloc_mapping();
	if (!m) goto collision;

	if (cos_mmap_cntl(COS_MMAP_GRANT, flags, dest, to, frame_index(f))) {
		printc("mem_man: could not grant at %x:%d\n", dest, (int)to);
		goto no_mapping;
	}
	mapping_init(m, dest, to, p, f);
	assert(!p || frame_nrefs(f) > 0);
	frame_ref(f);
	assert(frame_nrefs(f) > 0);
	if (cvect_add(cv->pages, m, idx)) BUG();
done:
	return m;
no_mapping:
	cslab_free_mapping(m);
collision:
	cvas_deref(cv);
	m = NULL;
	goto done;
}
Example #13
0
static inline void
evt_add(int tid, long evtid) { cvect_add(&evts, (void*)tid, evtid); }
Example #14
0
static inline void 
tor_add_pair(int from, int to)
{
	if (cvect_add(&tor_from, (void*)to, from) < 0) BUG();
	if (cvect_add(&tor_to, (void*)from, to) < 0) BUG();
}