Got rid of a global, hope no one minds

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21349 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stefano Ceccherini 2007-06-08 09:44:13 +00:00
parent 96493dcae9
commit d9be8bc0fe
2 changed files with 17 additions and 18 deletions

View File

@ -58,8 +58,6 @@
#define ROUNDOWN(a, b) (((a) / (b)) * (b))
extern vm_address_space *gKernelAddressSpace;
#define REGION_HASH_TABLE_SIZE 1024
static area_id sNextAreaID;
static hash_table *sAreaHash;
@ -1321,7 +1319,7 @@ vm_clone_area(team_id team, const char *name, void **address, uint32 addressSpec
// have been adapted. Maybe it should be part of the kernel settings,
// anyway (so that old drivers can always work).
#if 0
if (sourceArea->aspace == gKernelAddressSpace && addressSpace != gKernelAddressSpace
if (sourceArea->aspace == vm_kernel_address_space() && addressSpace != vm_kernel_address_space()
&& !(sourceArea->protection & B_USER_CLONEABLE_AREA)) {
// kernel areas must not be cloned in userland, unless explicitly
// declared user-cloneable upon construction
@ -2574,7 +2572,7 @@ unmap_and_free_physical_pages(vm_translation_map *map, addr_t start, addr_t end)
void
vm_free_unused_boot_loader_range(addr_t start, addr_t size)
{
vm_translation_map *map = &gKernelAddressSpace->translation_map;
vm_translation_map *map = &vm_kernel_address_space()->translation_map;
addr_t end = start + size;
addr_t lastEnd = start;
vm_area *area;
@ -2587,7 +2585,7 @@ vm_free_unused_boot_loader_range(addr_t start, addr_t size)
map->ops->lock(map);
for (area = gKernelAddressSpace->areas; area; area = area->address_space_next) {
for (area = vm_kernel_address_space()->areas; area; area = area->address_space_next) {
addr_t areaStart = area->base;
addr_t areaEnd = areaStart + area->size;
@ -2981,7 +2979,7 @@ vm_init_post_sem(kernel_args *args)
arch_vm_translation_map_init_post_sem(args);
vm_address_space_init_post_sem();
for (area = gKernelAddressSpace->areas; area; area = area->address_space_next) {
for (area = vm_kernel_address_space()->areas; area; area = area->address_space_next) {
if (area->id == RESERVED_AREA_ID)
continue;
@ -3617,14 +3615,14 @@ found:
status_t
vm_get_physical_page(addr_t paddr, addr_t *_vaddr, uint32 flags)
{
return (*gKernelAddressSpace->translation_map.ops->get_physical_page)(paddr, _vaddr, flags);
return (*vm_kernel_address_space()->translation_map.ops->get_physical_page)(paddr, _vaddr, flags);
}
status_t
vm_put_physical_page(addr_t vaddr)
{
return (*gKernelAddressSpace->translation_map.ops->put_physical_page)(vaddr);
return (*vm_kernel_address_space()->translation_map.ops->put_physical_page)(vaddr);
}

View File

@ -26,7 +26,8 @@
# define TRACE(x) ;
#endif
vm_address_space *gKernelAddressSpace;
static vm_address_space *sKernelAddressSpace;
#define ASPACE_HASH_TABLE_SIZE 1024
static void *sAddressSpaceTable;
@ -140,7 +141,7 @@ delete_address_space(vm_address_space *addressSpace)
{
TRACE(("delete_address_space: called on aspace 0x%lx\n", addressSpace->id));
if (addressSpace == gKernelAddressSpace)
if (addressSpace == sKernelAddressSpace)
panic("tried to delete the kernel aspace!\n");
// put this aspace in the deletion state
@ -178,22 +179,22 @@ vm_address_space *
vm_get_kernel_address_space(void)
{
/* we can treat this one a little differently since it can't be deleted */
atomic_add(&gKernelAddressSpace->ref_count, 1);
return gKernelAddressSpace;
atomic_add(&sKernelAddressSpace->ref_count, 1);
return sKernelAddressSpace;
}
vm_address_space *
vm_kernel_address_space(void)
{
return gKernelAddressSpace;
return sKernelAddressSpace;
}
team_id
vm_kernel_address_space_id(void)
{
return gKernelAddressSpace->id;
return sKernelAddressSpace->id;
}
@ -354,11 +355,11 @@ vm_address_space_init(void)
panic("vm_init: error creating aspace hash table\n");
}
gKernelAddressSpace = NULL;
sKernelAddressSpace = NULL;
// create the initial kernel address space
if (vm_create_address_space(1, KERNEL_BASE, KERNEL_SIZE,
true, &gKernelAddressSpace) != B_OK)
true, &sKernelAddressSpace) != B_OK)
panic("vm_init: error creating kernel address space!\n");
add_debugger_command("aspaces", &dump_aspace_list, "Dump a list of all address spaces");
@ -371,11 +372,11 @@ vm_address_space_init(void)
status_t
vm_address_space_init_post_sem(void)
{
status_t status = arch_vm_translation_map_init_kernel_map_post_sem(&gKernelAddressSpace->translation_map);
status_t status = arch_vm_translation_map_init_kernel_map_post_sem(&sKernelAddressSpace->translation_map);
if (status < B_OK)
return status;
status = gKernelAddressSpace->sem = create_sem(WRITE_COUNT, "kernel_aspacelock");
status = sKernelAddressSpace->sem = create_sem(WRITE_COUNT, "kernel_aspacelock");
if (status < B_OK)
return status;