コード例 #1
0
ファイル: aspace_create.c プロジェクト: HobbesOSR/kitten
int
sys_aspace_create(
	id_t                   id_request,
	const char __user *    name,
	id_t __user *          id
)
{
	int status;
	char _name[16];
	id_t _id;

	if (current->uid != 0)
		return -EPERM;

	if ((id_request != ANY_ID) &&
	    ((id_request < UASPACE_MIN_ID) || (id_request > UASPACE_MAX_ID)))
		return -EINVAL;

	if (strncpy_from_user(_name, name, sizeof(_name)) < 0)
		return -EFAULT;
	_name[sizeof(_name) - 1] = '\0';

	if ((status = aspace_create(id_request, _name, &_id)) != 0)
		return status;

	if (id && copy_to_user(id, &_id, sizeof(_id)))
		return -EFAULT;

	return 0;
}
コード例 #2
0
ファイル: hello_world.c プロジェクト: jamesyc/kitten
static int
aspace_api_test(void)
{
	int status;
	id_t my_id, new_id;

	printf("\n");
	printf("TEST BEGIN: Address Space Management\n");

	status = aspace_get_myid(&my_id);
	if (status) {
		printf("ERROR: aspace_get_myid() status=%d\n", status);
		return -1;
	}
	printf("  My address space ID is %u\n", my_id);

	printf("  Creating a new aspace: ");
	status = aspace_create(ANY_ID, "TEST-ASPACE", &new_id);
	if (status) {
		printf("\nERROR: aspace_create() status=%d\n", status);
		return -1;
	}
	printf("id=%u\n", new_id);

	printf("  Using SMARTMAP to map myself into aspace %u\n", new_id);
	status = aspace_smartmap(my_id, new_id, SMARTMAP_ALIGN, SMARTMAP_ALIGN);
	if (status) {
		printf("ERROR: aspace_smartmap() status=%d\n", status);
		return -1;
	}

	aspace_dump2console(new_id);

	status = aspace_unsmartmap(my_id, new_id);
	if (status) {
		printf("ERROR: aspace_unsmartmap() status=%d\n", status);
		return -1;
	}

	printf("  Destroying a aspace %u: ", new_id);
	status = aspace_destroy(new_id);
	if (status) {
		printf("ERROR: aspace_destroy() status=%d\n", status);
		return -1;
	}
	printf("OK\n");

	printf("TEST END:   Address Space Management\n");
	return 0;
}
コード例 #3
0
ファイル: realmode.c プロジェクト: wm4/kernel
//init this module
void realmode_init()
{
    
    //reserve address range for our realmode code and bios data areas
    phys_addr_t res;
    res = mm_physical_alloc_ext(RM_REGION_SIZE, 0, 0, 0,
        RM_REGION_START, RM_REGION_START + RM_REGION_SIZE);
    if (res == INVALID_PHYSICAL_ADDRESS)
        fatal("d'oh 1");
    //BDA
    res = mm_physical_alloc_ext(4096, 0, 0, 0, 4096*2, 4096*30);
    if (res == INVALID_PHYSICAL_ADDRESS)
        fatal("d'oh 2");
    //EBDA
    res = mm_physical_alloc_ext(4096, 0, 0, 0, 636*1024, 640*1024);
    if (res == INVALID_PHYSICAL_ADDRESS)
        fatal("d'oh 3");
    
    spinlock_init(&g_lock_stupido, "Spinlock Stupido (TM)");
    g_realmode_aspace = aspace_create();
    if (!g_realmode_aspace)
        fatal("out of memory");
}