Replaced calls to vm_create_anonymous_region() with the BeOS compatible

create_area() where possible.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@4318 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2003-08-19 14:28:11 +00:00
parent fe8a9052c0
commit 7b25ddd21a
5 changed files with 30 additions and 34 deletions

View File

@ -956,17 +956,15 @@ cbuf_init(void)
// errors are fatal, that's why we don't clean up here
sBufferArea = vm_create_anonymous_region(vm_get_kernel_aspace_id(), "cbuf region",
(void **)&sBuffer, REGION_ADDR_ANY_ADDRESS, CBUF_REGION_SIZE,
REGION_WIRING_LAZY, LOCK_RW|LOCK_KERNEL);
sBufferArea = create_area("cbuf region", (void **)&sBuffer, B_ANY_KERNEL_ADDRESS,
CBUF_REGION_SIZE, B_NO_LOCK, B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA);
if (sBufferArea < 0) {
panic("cbuf_init: error creating cbuf region\n");
return B_NO_MEMORY;
}
sBitmapArea = vm_create_anonymous_region(vm_get_kernel_aspace_id(), "cbuf bitmap region",
(void **)&sBitmap, REGION_ADDR_ANY_ADDRESS,
CBUF_BITMAP_SIZE / 8, REGION_WIRING_WIRED, LOCK_RW|LOCK_KERNEL);
sBitmapArea = create_area("cbuf bitmap region", (void **)&sBitmap, B_ANY_KERNEL_ADDRESS,
CBUF_BITMAP_SIZE / 8, B_FULL_LOCK, B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA);
if (sBitmapArea < 0) {
panic("cbuf_init: error creating cbuf bitmap region\n");
return B_NO_MEMORY;

View File

@ -755,7 +755,7 @@ elf_load_kspace(const char *path, const char *sym_prepend)
bool ro_segment_handled = false;
bool rw_segment_handled = false;
int image_region;
int lock;
int protection;
PRINT(("looking at program header %d\n", i));
@ -773,24 +773,26 @@ elf_load_kspace(const char *path, const char *sym_prepend)
// we're here, so it must be a PT_LOAD segment
if ((pheaders[i].p_flags & (PF_R | PF_W | PF_X)) == (PF_R | PF_W)) {
// this is the writable segment
if(rw_segment_handled) {
if (rw_segment_handled) {
// we've already created this segment
continue;
}
rw_segment_handled = true;
image_region = 1;
lock = LOCK_RW|LOCK_KERNEL;
protection = B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA;
sprintf(region_name, "%s_rw", path);
} else if ((pheaders[i].p_flags & (PF_R | PF_W | PF_X)) == (PF_R | PF_X)) {
// this is the non-writable segment
if(ro_segment_handled) {
if (ro_segment_handled) {
// we've already created this segment
continue;
}
ro_segment_handled = true;
image_region = 0;
// lock = LOCK_RO|LOCK_KERNEL;
lock = LOCK_RW|LOCK_KERNEL;
protection = B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA;
// ToDo: why is this? Right now, the kernel crashes without
// it, so go, investigate!
sprintf(region_name, "%s_ro", path);
} else {
dprintf("weird program header flags 0x%lx\n", pheaders[i].p_flags);
@ -798,9 +800,9 @@ elf_load_kspace(const char *path, const char *sym_prepend)
}
image->regions[image_region].size = ROUNDUP(pheaders[i].p_memsz + (pheaders[i].p_vaddr % PAGE_SIZE), PAGE_SIZE);
image->regions[image_region].id = vm_create_anonymous_region(vm_get_kernel_aspace_id(), region_name,
(void **)&image->regions[image_region].start, REGION_ADDR_ANY_ADDRESS,
image->regions[image_region].size, REGION_WIRING_WIRED, lock);
image->regions[image_region].id = create_area(region_name,
(void **)&image->regions[image_region].start, B_ANY_KERNEL_ADDRESS,
image->regions[image_region].size, B_FULL_LOCK, protection);
if (image->regions[image_region].id < 0) {
dprintf("error allocating region!\n");
err = ERR_INVALID_BINARY;
@ -853,9 +855,9 @@ done:
error4:
if (image->regions[1].id >= 0)
vm_delete_region(vm_get_kernel_aspace_id(), image->regions[1].id);
delete_area(image->regions[1].id);
if (image->regions[0].id >= 0)
vm_delete_region(vm_get_kernel_aspace_id(), image->regions[0].id);
delete_area(image->regions[0].id);
error3:
free(image);
error2:
@ -895,7 +897,7 @@ elf_unload_image_final(struct elf_image_info *image)
int i;
for (i = 0; i < 2; ++i) {
vm_delete_region(vm_get_kernel_aspace_id(), image->regions[i].id);
delete_area(image->regions[i].id);
}
if (image->vnode)

View File

@ -68,18 +68,16 @@ status_t
port_init(kernel_args *ka)
{
int i;
int sz;
sz = sizeof(struct port_entry) * MAX_PORTS;
int size = sizeof(struct port_entry) * MAX_PORTS;
// create and initialize semaphore table
port_region = vm_create_anonymous_region(vm_get_kernel_aspace_id(), "port_table", (void **)&ports,
REGION_ADDR_ANY_ADDRESS, sz, REGION_WIRING_WIRED, LOCK_RW|LOCK_KERNEL);
port_region = create_area("port_table", (void **)&ports, B_ANY_KERNEL_ADDRESS,
size, B_FULL_LOCK, B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA);
if (port_region < 0) {
panic("unable to allocate kernel port table!\n");
}
memset(ports, 0, sz);
memset(ports, 0, size);
for (i = 0; i < MAX_PORTS; i++)
ports[i].id = -1;

View File

@ -185,9 +185,8 @@ sem_init(kernel_args *ka)
TRACE(("sem_init: entry\n"));
// create and initialize semaphore table
gSemRegion = vm_create_anonymous_region(vm_get_kernel_aspace_id(), "sem_table",
(void **)&gSems, REGION_ADDR_ANY_ADDRESS, sizeof(struct sem_entry) * MAX_SEMS,
REGION_WIRING_WIRED, LOCK_RW | LOCK_KERNEL);
gSemRegion = create_area("sem_table", (void **)&gSems, B_ANY_KERNEL_ADDRESS,
sizeof(struct sem_entry) * MAX_SEMS, B_FULL_LOCK, B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA);
if (gSemRegion < 0)
panic("unable to allocate semaphore table!\n");

View File

@ -334,9 +334,9 @@ create_thread(const char *name, team_id teamID, thread_func entry, void *args1,
}
sprintf(stack_name, "%s_kstack", name);
t->kernel_stack_region_id = vm_create_anonymous_region(vm_get_kernel_aspace_id(), stack_name,
(void **)&t->kernel_stack_base, REGION_ADDR_ANY_ADDRESS, KSTACK_SIZE,
REGION_WIRING_WIRED, LOCK_RW|LOCK_KERNEL);
t->kernel_stack_region_id = create_area(stack_name, (void **)&t->kernel_stack_base,
B_ANY_KERNEL_ADDRESS, KSTACK_SIZE, B_FULL_LOCK, B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA);
if (t->kernel_stack_region_id < 0)
panic("_create_thread: error creating kernel stack!\n");
@ -672,7 +672,7 @@ thread_exit2(void *_args)
// delete the old kernel stack region
TRACE(("thread_exit2: deleting old kernel stack id 0x%x for thread 0x%x\n", args.old_kernel_stack, args.t->id));
vm_delete_region(vm_get_kernel_aspace_id(), args.old_kernel_stack);
delete_area(args.old_kernel_stack);
// remove this thread from all of the global lists
TRACE(("thread_exit2: removing thread 0x%x from global lists\n", args.t->id));
@ -1094,9 +1094,8 @@ thread_init(kernel_args *ka)
for (i = 0; i < num_death_stacks; i++) {
sprintf(temp, "death_stack%d", i);
death_stacks[i].rid = vm_create_anonymous_region(vm_get_kernel_aspace_id(), temp,
(void **)&death_stacks[i].address,
REGION_ADDR_ANY_ADDRESS, KSTACK_SIZE, REGION_WIRING_WIRED, LOCK_RW|LOCK_KERNEL);
death_stacks[i].rid = create_area(temp, (void **)&death_stacks[i].address,
B_ANY_KERNEL_ADDRESS, KSTACK_SIZE, B_FULL_LOCK, B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA);
if (death_stacks[i].rid < 0) {
panic("error creating death stacks\n");
return death_stacks[i].rid;