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:
+25
-16
@@ -18,8 +18,10 @@
|
|||||||
#define POOL_ALLOC_SZ 4 * 1024
|
#define POOL_ALLOC_SZ 4 * 1024
|
||||||
#define ROUND_TO_PAGE_SIZE(x) (((x) + (POOL_ALLOC_SZ) - 1) & ~((POOL_ALLOC_SZ) - 1))
|
#define ROUND_TO_PAGE_SIZE(x) (((x) + (POOL_ALLOC_SZ) - 1) & ~((POOL_ALLOC_SZ) - 1))
|
||||||
|
|
||||||
|
|
||||||
#ifdef WALK_POOL_LIST
|
#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;
|
struct pool_mem *pb = p->list;
|
||||||
|
|
||||||
@@ -32,7 +34,8 @@ void walk_pool_list(struct pool_ctl *p)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void pool_debug_walk(struct pool_ctl *p)
|
void
|
||||||
|
pool_debug_walk(struct pool_ctl *p)
|
||||||
{
|
{
|
||||||
struct free_blk *ptr;
|
struct free_blk *ptr;
|
||||||
int i = 1;
|
int i = 1;
|
||||||
@@ -58,13 +61,17 @@ void pool_debug_walk(struct pool_ctl *p)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void pool_debug(struct pool_ctl *p, char *name)
|
|
||||||
|
void
|
||||||
|
pool_debug(struct pool_ctl *p, char *name)
|
||||||
{
|
{
|
||||||
p->debug = 1;
|
p->debug = 1;
|
||||||
strlcpy(p->name, name, POOL_DEBUG_NAME_SZ);
|
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;
|
struct pool_mem *block;
|
||||||
|
|
||||||
@@ -74,12 +81,10 @@ static struct pool_mem *get_mem_block(struct pool_ctl *pool)
|
|||||||
|
|
||||||
memset(block, 0, sizeof(*block));
|
memset(block, 0, sizeof(*block));
|
||||||
|
|
||||||
block->aid = vm_create_anonymous_region(vm_get_kernel_aspace_id(),
|
// ToDo: B_CONTIGUOUS for what???
|
||||||
"some pool block",
|
block->aid = create_area("some pool block", (void **)&block->base_addr,
|
||||||
(void**)&block->base_addr,
|
B_ANY_KERNEL_ADDRESS, pool->block_size, B_CONTIGUOUS,
|
||||||
REGION_ADDR_ANY_ADDRESS, pool->block_size,
|
B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA);
|
||||||
REGION_WIRING_WIRED_CONTIG,
|
|
||||||
LOCK_KERNEL|LOCK_RW);
|
|
||||||
if (block->aid < 0) {
|
if (block->aid < 0) {
|
||||||
free(block);
|
free(block);
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -114,14 +119,15 @@ static struct pool_mem *get_mem_block(struct pool_ctl *pool)
|
|||||||
}
|
}
|
||||||
UNINIT_BENAPHORE(block->lock);
|
UNINIT_BENAPHORE(block->lock);
|
||||||
|
|
||||||
vm_delete_region(vm_get_kernel_aspace_id(), block->aid);
|
delete_area(block->aid);
|
||||||
free(block);
|
free(block);
|
||||||
|
|
||||||
return NULL;
|
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;
|
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... */
|
/* ok, so now we look for a suitable block... */
|
||||||
struct pool_mem *mp = p->list;
|
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
|
#if POOL_USES_BENAPHORES
|
||||||
ACQUIRE_BENAPHORE(p->lock);
|
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;
|
struct pool_mem *mp,*temp;
|
||||||
|
|
||||||
@@ -304,7 +313,7 @@ void pool_destroy(struct pool_ctl *p)
|
|||||||
|
|
||||||
mp = p->list;
|
mp = p->list;
|
||||||
while (mp != NULL) {
|
while (mp != NULL) {
|
||||||
vm_delete_region(vm_get_kernel_aspace_id(), mp->aid);
|
delete_area(mp->aid);
|
||||||
temp = mp;
|
temp = mp;
|
||||||
mp = mp->next;
|
mp = mp->next;
|
||||||
UNINIT_BENAPHORE(mp->lock);
|
UNINIT_BENAPHORE(mp->lock);
|
||||||
|
|||||||
@@ -427,8 +427,8 @@ team_create_team2(void *args)
|
|||||||
// the exact location at the end of the user stack region
|
// the exact location at the end of the user stack region
|
||||||
|
|
||||||
sprintf(ustack_name, "%s_primary_stack", team->name);
|
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,
|
t->user_stack_region_id = create_area_etc(team, ustack_name, (void **)&t->user_stack_base,
|
||||||
REGION_ADDR_EXACT_ADDRESS, totalSize, REGION_WIRING_LAZY, LOCK_RW);
|
B_EXACT_ADDRESS, totalSize, B_NO_LOCK, B_READ_AREA | B_WRITE_AREA);
|
||||||
if (t->user_stack_region_id < 0) {
|
if (t->user_stack_region_id < 0) {
|
||||||
panic("team_create_team2: could not create default user stack region\n");
|
panic("team_create_team2: could not create default user stack region\n");
|
||||||
return t->user_stack_region_id;
|
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) {
|
while (t->user_stack_base < mainThreadStackBase) {
|
||||||
sprintf(stack_name, "%s_stack%ld", team->name, t->id);
|
sprintf(stack_name, "%s_stack%ld", team->name, t->id);
|
||||||
t->user_stack_region_id = vm_create_anonymous_region(team->_aspace_id, stack_name,
|
t->user_stack_region_id = create_area_etc(team, stack_name,
|
||||||
(void **)&t->user_stack_base,
|
(void **)&t->user_stack_base, B_EXACT_ADDRESS,
|
||||||
REGION_ADDR_EXACT_ADDRESS, STACK_SIZE + TLS_SIZE, REGION_WIRING_LAZY, LOCK_RW);
|
STACK_SIZE + TLS_SIZE, B_NO_LOCK, B_READ_AREA | B_WRITE_AREA);
|
||||||
if (t->user_stack_region_id >= 0)
|
if (t->user_stack_region_id >= 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -730,7 +730,7 @@ thread_exit(void)
|
|||||||
if (team->_aspace_id >= 0 && t->user_stack_region_id >= 0) {
|
if (team->_aspace_id >= 0 && t->user_stack_region_id >= 0) {
|
||||||
region_id rid = t->user_stack_region_id;
|
region_id rid = t->user_stack_region_id;
|
||||||
t->user_stack_region_id = -1;
|
t->user_stack_region_id = -1;
|
||||||
vm_delete_region(team->_aspace_id, rid);
|
delete_area_etc(team, rid);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (team != team_get_kernel_team()) {
|
if (team != team_get_kernel_team()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user