Example #1
0
int map_fpage(as_t* src, as_t* dst, fpage_t* fpage, map_action_t action) {
	fpage_t* fpmap = (fpage_t*) ktable_alloc(&fpage_table);

	/*FIXME: check for fpmap == NULL*/
	fpmap->as_next = NULL;

	/*Copy fpage description*/
	fpmap->raw[0] = fpage->raw[0];
	fpmap->raw[1] = fpage->raw[1];

	/*Set flags correctly*/
	if(action == MAP)
		fpage->fpage.flags |= FPAGE_MAPPED;
	fpmap->fpage.flags = FPAGE_CLONE;

	/*Insert into mapee list*/
	fpmap->map_next = fpage->map_next;
	fpage->map_next = fpmap;

	/*Insert into AS*/
	insert_fpage_to_as(dst, fpmap);

	dbg_printf(DL_MEMORY, "MEM: %s fpage %p from %p to %p\n", (action == MAP)? "mapped" : "granted", fpage, src, dst);

	return 0;
}
Example #2
0
ktimer_event_t *ktimer_event_create(uint32_t ticks,
	                                ktimer_event_handler_t handler,
	                                void *data)
{
	ktimer_event_t *kte = NULL;

	if (!handler)
		goto ret;

	kte = (ktimer_event_t *) ktable_alloc(&ktimer_event_table);

	/* No available slots */
	if (kte == NULL)
		goto ret;

	kte->next = NULL;
	kte->handler = handler;
	kte->data = data;

	if (ktimer_event_schedule(ticks, kte) == -1) {
		ktable_free(&ktimer_event_table, kte);
		kte = NULL;
	}

ret:
	return kte;
}
Example #3
0
/**
 * Create and initialize new fpage
 * @param base base address of fpage
 * @param shift (1 << shift) - fpage size
 * @param mpid - id of mpool
 * */
fpage_t* create_fpage(memptr_t base, size_t shift, int mpid) {
	fpage_t* fpage = (fpage_t*) ktable_alloc(&fpage_table);

	assert(fpage != NULL);

	fpage->as_next = NULL;
	fpage->map_next = fpage; 	/*That is first fpage in mapping*/
	fpage->fpage.mpid = mpid;
	fpage->fpage.flags = 0;
	fpage->fpage.rwx = MP_USER_PERM(mempool_getbyid(mpid)->flags);

	fpage->fpage.base = base;
	fpage->fpage.shift = shift;

	if(mempool_getbyid(mpid)->flags & MP_MAP_ALWAYS)
		fpage->fpage.flags |= FPAGE_ALWAYS;

	return fpage;
}