Replaced some more vm_create_anonymous_region() with create_area() and
create_area_etc(). git-svn-id: file:///srv/svn/repos/haiku/trunk/current@4323 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
425b6cdf15
commit
cbc1309c68
@ -18,8 +18,10 @@
|
||||
#define POOL_ALLOC_SZ 4 * 1024
|
||||
#define ROUND_TO_PAGE_SIZE(x) (((x) + (POOL_ALLOC_SZ) - 1) & ~((POOL_ALLOC_SZ) - 1))
|
||||
|
||||
|
||||
#ifdef WALK_POOL_LIST
|
||||
void walk_pool_list(struct pool_ctl *p)
|
||||
void
|
||||
walk_pool_list(struct pool_ctl *p)
|
||||
{
|
||||
struct pool_mem *pb = p->list;
|
||||
|
||||
@ -32,7 +34,8 @@ void walk_pool_list(struct pool_ctl *p)
|
||||
}
|
||||
#endif
|
||||
|
||||
void pool_debug_walk(struct pool_ctl *p)
|
||||
void
|
||||
pool_debug_walk(struct pool_ctl *p)
|
||||
{
|
||||
struct free_blk *ptr;
|
||||
int i = 1;
|
||||
@ -58,13 +61,17 @@ void pool_debug_walk(struct pool_ctl *p)
|
||||
#endif
|
||||
}
|
||||
|
||||
void pool_debug(struct pool_ctl *p, char *name)
|
||||
|
||||
void
|
||||
pool_debug(struct pool_ctl *p, char *name)
|
||||
{
|
||||
p->debug = 1;
|
||||
strlcpy(p->name, name, POOL_DEBUG_NAME_SZ);
|
||||
}
|
||||
|
||||
static struct pool_mem *get_mem_block(struct pool_ctl *pool)
|
||||
|
||||
static struct pool_mem *
|
||||
get_mem_block(struct pool_ctl *pool)
|
||||
{
|
||||
struct pool_mem *block;
|
||||
|
||||
@ -74,12 +81,10 @@ static struct pool_mem *get_mem_block(struct pool_ctl *pool)
|
||||
|
||||
memset(block, 0, sizeof(*block));
|
||||
|
||||
block->aid = vm_create_anonymous_region(vm_get_kernel_aspace_id(),
|
||||
"some pool block",
|
||||
(void**)&block->base_addr,
|
||||
REGION_ADDR_ANY_ADDRESS, pool->block_size,
|
||||
REGION_WIRING_WIRED_CONTIG,
|
||||
LOCK_KERNEL|LOCK_RW);
|
||||
// ToDo: B_CONTIGUOUS for what???
|
||||
block->aid = create_area("some pool block", (void **)&block->base_addr,
|
||||
B_ANY_KERNEL_ADDRESS, pool->block_size, B_CONTIGUOUS,
|
||||
B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA);
|
||||
if (block->aid < 0) {
|
||||
free(block);
|
||||
return NULL;
|
||||
@ -113,15 +118,16 @@ static struct pool_mem *get_mem_block(struct pool_ctl *pool)
|
||||
return block;
|
||||
}
|
||||
UNINIT_BENAPHORE(block->lock);
|
||||
|
||||
vm_delete_region(vm_get_kernel_aspace_id(), block->aid);
|
||||
|
||||
delete_area(block->aid);
|
||||
free(block);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
int32 pool_init(struct pool_ctl **_newPool, size_t size)
|
||||
int32
|
||||
pool_init(struct pool_ctl **_newPool, size_t size)
|
||||
{
|
||||
struct pool_ctl *pool = NULL;
|
||||
|
||||
@ -175,7 +181,8 @@ int32 pool_init(struct pool_ctl **_newPool, size_t size)
|
||||
}
|
||||
|
||||
|
||||
void *pool_get(struct pool_ctl *p)
|
||||
void *
|
||||
pool_get(struct pool_ctl *p)
|
||||
{
|
||||
/* ok, so now we look for a suitable block... */
|
||||
struct pool_mem *mp = p->list;
|
||||
@ -260,7 +267,8 @@ void *pool_get(struct pool_ctl *p)
|
||||
}
|
||||
|
||||
|
||||
void pool_put(struct pool_ctl *p, void *ptr)
|
||||
void
|
||||
pool_put(struct pool_ctl *p, void *ptr)
|
||||
{
|
||||
#if POOL_USES_BENAPHORES
|
||||
ACQUIRE_BENAPHORE(p->lock);
|
||||
@ -292,7 +300,8 @@ void pool_put(struct pool_ctl *p, void *ptr)
|
||||
}
|
||||
|
||||
|
||||
void pool_destroy(struct pool_ctl *p)
|
||||
void
|
||||
pool_destroy(struct pool_ctl *p)
|
||||
{
|
||||
struct pool_mem *mp,*temp;
|
||||
|
||||
@ -304,7 +313,7 @@ void pool_destroy(struct pool_ctl *p)
|
||||
|
||||
mp = p->list;
|
||||
while (mp != NULL) {
|
||||
vm_delete_region(vm_get_kernel_aspace_id(), mp->aid);
|
||||
delete_area(mp->aid);
|
||||
temp = mp;
|
||||
mp = mp->next;
|
||||
UNINIT_BENAPHORE(mp->lock);
|
||||
|
@ -427,8 +427,8 @@ team_create_team2(void *args)
|
||||
// the exact location at the end of the user stack region
|
||||
|
||||
sprintf(ustack_name, "%s_primary_stack", team->name);
|
||||
t->user_stack_region_id = vm_create_anonymous_region(team->_aspace_id, ustack_name, (void **)&t->user_stack_base,
|
||||
REGION_ADDR_EXACT_ADDRESS, totalSize, REGION_WIRING_LAZY, LOCK_RW);
|
||||
t->user_stack_region_id = create_area_etc(team, ustack_name, (void **)&t->user_stack_base,
|
||||
B_EXACT_ADDRESS, totalSize, B_NO_LOCK, B_READ_AREA | B_WRITE_AREA);
|
||||
if (t->user_stack_region_id < 0) {
|
||||
panic("team_create_team2: could not create default user stack region\n");
|
||||
return t->user_stack_region_id;
|
||||
|
@ -366,9 +366,9 @@ create_thread(const char *name, team_id teamID, thread_func entry, void *args1,
|
||||
|
||||
while (t->user_stack_base < mainThreadStackBase) {
|
||||
sprintf(stack_name, "%s_stack%ld", team->name, t->id);
|
||||
t->user_stack_region_id = vm_create_anonymous_region(team->_aspace_id, stack_name,
|
||||
(void **)&t->user_stack_base,
|
||||
REGION_ADDR_EXACT_ADDRESS, STACK_SIZE + TLS_SIZE, REGION_WIRING_LAZY, LOCK_RW);
|
||||
t->user_stack_region_id = create_area_etc(team, stack_name,
|
||||
(void **)&t->user_stack_base, B_EXACT_ADDRESS,
|
||||
STACK_SIZE + TLS_SIZE, B_NO_LOCK, B_READ_AREA | B_WRITE_AREA);
|
||||
if (t->user_stack_region_id >= 0)
|
||||
break;
|
||||
|
||||
@ -730,7 +730,7 @@ thread_exit(void)
|
||||
if (team->_aspace_id >= 0 && t->user_stack_region_id >= 0) {
|
||||
region_id rid = t->user_stack_region_id;
|
||||
t->user_stack_region_id = -1;
|
||||
vm_delete_region(team->_aspace_id, rid);
|
||||
delete_area_etc(team, rid);
|
||||
}
|
||||
|
||||
if (team != team_get_kernel_team()) {
|
||||
|
Loading…
Reference in New Issue
Block a user