예제 #1
0
/**
	@brief The driver need a physical space to run, we allocate and map it to its space
*/
static void allocate_physical_bulk(unsigned long *start, unsigned long *size, unsigned long map_base)
{
	struct ke_mem_cluster_info info;
	
	/* Allocate physical for driver system */
	if (NULL == km_cluster_alloc(&info, -1, false))
		goto err;
	else
	{
		*start = info.page_start;
		*size = info.page_count * PAGE_SIZE;
	}
	
	/* Map to the virtual address space of driver system to access */
	if (NULL == km_map_physical(info.page_start, *size,
					(map_base + info.page_start) |  KM_MAP_PHYSICAL_FLAG_WITH_VIRTUAL | KM_MAP_PHYSICAL_FLAG_NORMAL_CACHE))
	{
		goto err1;
	}
	return;
	
err1:
	km_cluster_dealloc_base(info.page_start, true);
	
err:
	*start = 0;
	*size = 0;
}
예제 #2
0
파일: cpu.c 프로젝트: panhaitao/GridOS
static void init_a_cpu(struct kc_cpu * cpu)
{
	int i;
	struct ke_mem_cluster_info info = {0};

	for (i = 0; i < KT_PRIORITY_COUNT; i++)
		INIT_LIST_HEAD(&cpu->run_queue[i]);
	INIT_LIST_HEAD(&cpu->dieing_queue);

	/* Idle routine */
	cpu->idle_ops = dumy_idle_ops;

	/* 安装一个假的THREAD到CPU上,应为在启动阶段我们用CURRENT's preemnt来分配页(防止被抢占的)*/
	cpu->cur = &dummy_kmt;

	/* Give the cpu a memory cluster */
	km_cluster_alloc(&info, 0, false);
	cpu->mm_current_cluster = info.km_cluster;

	/* Its own pointer for accelerated access */
	cpu->self = cpu;

	/* Now set an ARCH way to get the cpu environment (km_cpu) */
	km_setup_percpu(cpu->id, (unsigned long)cpu);
}