Exemple #1
0
static void expand(u32int new_size, heap_t *heap)
{
	ASSERT(new_size > heap->end_address - heap->start_address);

	if (new_size & 0xfffff000)
	{
		new_size &= 0xfffff000;
		new_size += 0x1000;
	}

	ASSERT(heap->start_address + new_size <= heap->max_address);

	u32int old_size = heap->end_address - heap->start_address;

	u32int i = old_size;
	while (i < new_size)
	{
		if (!get_page_addr(heap->start_address + i))
			put_page((u32int)get_free_page(), heap->start_address + i);

		i += 0x1000;
	}

	heap->end_address = heap->start_address + new_size;
}
Exemple #2
0
u32int kmalloc_int(u32int sz, int align, u32int *phys)
{
	if (kheap)
	{
		void *addr = alloc(sz, (u8int)align, kheap);
		if (phys)
		{
			u32int *page = get_page_addr((u32int)addr);
			*phys = (u32int)page;
		}
		return (u32int)addr;
	}
	else
	{
		if (align == 1 && (placement_address & ~0xFFFFF000))
		{
			placement_address &= 0xFFFFF000;
			placement_address += 0x1000;
		}

		if (phys)
			*phys = placement_address;
		
		u32int tmp = placement_address;
		placement_address += sz;

		return tmp;
	}
}
int appfs_mem_getpageinfo(const devfs_handle_t * handle, void * ctl){
	DECLARE_APPFS_CONFIG();
	u32 size = 0;
	mem_pageinfo_t * pageinfo = ctl;

	if( pageinfo->o_flags & MEM_FLAG_IS_QUERY ){
		u32 type;
		pageinfo->num = get_page(config, pageinfo->addr, 0, &type);
		pageinfo->size = get_page_size(config, pageinfo->num, MEM_FLAG_IS_RAM);
		pageinfo->o_flags = type;
		if( type == 0 ){ return SYSFS_SET_RETURN(EINVAL); }
		return 0;
	}

	size = get_page_size(config, pageinfo->num, pageinfo->o_flags);
	if (size == 0 ){ return SYSFS_SET_RETURN(EINVAL); }
	pageinfo->addr = get_page_addr(config, pageinfo->num, pageinfo->o_flags);
	pageinfo->size = size;

	return 0;
}
Exemple #4
0
int
bc_remove_block(page_idx_t start_page, int order, int zap_page) {
    if (zap_page) {
        char* p = get_page_addr(start_page);
        size_t len = ((size_t)(1 << order)) << alloc_info->page_size_log2;
        madvise(p, len, MADV_DONTDUMP|MADV_DONTNEED);
    }

    if (!blk_cache_init || !enable_blk_cache)
        return 0;

    intptr_t idx;
    if (!rbt_delete(blk_cache->blks, start_page, &idx))
        return 0;

    ASSERT(blk_cache->lru_v[idx].order == order);
    blk_cache->total_page_num -= (1 << order);
    ASSERT(blk_cache->total_page_num >= 0);

    lru_remove(idx);

    return 1;
}