Now creates text/data areas for all preloaded images.
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@7507 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
d15df01c72
commit
1f4fa35b00
@ -28,6 +28,7 @@
|
|||||||
#include <team.h>
|
#include <team.h>
|
||||||
|
|
||||||
#include <boot/stage2.h>
|
#include <boot/stage2.h>
|
||||||
|
#include <boot/elf.h>
|
||||||
|
|
||||||
#include <arch/cpu.h>
|
#include <arch/cpu.h>
|
||||||
#include <arch/vm.h>
|
#include <arch/vm.h>
|
||||||
@ -1602,15 +1603,46 @@ vm_thread_dump_max_commit(void *unused)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
create_preloaded_image_areas(struct preloaded_image *image)
|
||||||
|
{
|
||||||
|
char name[B_OS_NAME_LENGTH];
|
||||||
|
void *address;
|
||||||
|
int32 length;
|
||||||
|
|
||||||
|
// use file name to create a good area name
|
||||||
|
char *fileName = strrchr(image->name, '/');
|
||||||
|
if (fileName == NULL)
|
||||||
|
fileName = image->name;
|
||||||
|
else
|
||||||
|
fileName++;
|
||||||
|
|
||||||
|
length = strlen(fileName);
|
||||||
|
// make sure there is enough space for the suffix
|
||||||
|
if (length > 25)
|
||||||
|
length = 25;
|
||||||
|
|
||||||
|
memcpy(name, fileName, length);
|
||||||
|
strcpy(name + length, "_text");
|
||||||
|
address = (void *)ROUNDOWN(image->text_region.start, PAGE_SIZE);
|
||||||
|
image->text = vm_create_anonymous_region(vm_get_kernel_aspace_id(), name, &address, REGION_ADDR_EXACT_ADDRESS,
|
||||||
|
PAGE_ALIGN(image->text_region.size), REGION_WIRING_WIRED_ALREADY, LOCK_RW|LOCK_KERNEL);
|
||||||
|
|
||||||
|
strcpy(name + length, "_data");
|
||||||
|
address = (void *)ROUNDOWN(image->data_region.start, PAGE_SIZE);
|
||||||
|
image->data = vm_create_anonymous_region(vm_get_kernel_aspace_id(), name, &address, REGION_ADDR_EXACT_ADDRESS,
|
||||||
|
PAGE_ALIGN(image->data_region.size), REGION_WIRING_WIRED_ALREADY, LOCK_RW|LOCK_KERNEL);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
vm_init(kernel_args *ka)
|
vm_init(kernel_args *ka)
|
||||||
{
|
{
|
||||||
int err = 0;
|
int err = 0;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
// int last_used_virt_range = -1;
|
struct preloaded_image *image;
|
||||||
// int last_used_phys_range = -1;
|
addr_t heap_base;
|
||||||
addr heap_base;
|
void *address;
|
||||||
void *null_addr;
|
|
||||||
|
|
||||||
TRACE(("vm_init: entry\n"));
|
TRACE(("vm_init: entry\n"));
|
||||||
err = vm_translation_map_module_init(ka);
|
err = vm_translation_map_module_init(ka);
|
||||||
@ -1669,25 +1701,33 @@ vm_init(kernel_args *ka)
|
|||||||
vm_page_init2(ka);
|
vm_page_init2(ka);
|
||||||
|
|
||||||
// allocate regions to represent stuff that already exists
|
// allocate regions to represent stuff that already exists
|
||||||
null_addr = (void *)ROUNDOWN(heap_base, PAGE_SIZE);
|
|
||||||
vm_create_anonymous_region(vm_get_kernel_aspace_id(), "kernel_heap", &null_addr, REGION_ADDR_EXACT_ADDRESS,
|
address = (void *)ROUNDOWN(heap_base, PAGE_SIZE);
|
||||||
|
vm_create_anonymous_region(vm_get_kernel_aspace_id(), "kernel_heap", &address, REGION_ADDR_EXACT_ADDRESS,
|
||||||
HEAP_SIZE, REGION_WIRING_WIRED_ALREADY, LOCK_RW|LOCK_KERNEL);
|
HEAP_SIZE, REGION_WIRING_WIRED_ALREADY, LOCK_RW|LOCK_KERNEL);
|
||||||
|
|
||||||
null_addr = (void *)ROUNDOWN(ka->kernel_seg0_addr.start, PAGE_SIZE);
|
address = (void *)ROUNDOWN(ka->kernel_seg0_addr.start, PAGE_SIZE);
|
||||||
vm_create_anonymous_region(vm_get_kernel_aspace_id(), "kernel_ro", &null_addr, REGION_ADDR_EXACT_ADDRESS,
|
vm_create_anonymous_region(vm_get_kernel_aspace_id(), "kernel_ro", &address, REGION_ADDR_EXACT_ADDRESS,
|
||||||
PAGE_ALIGN(ka->kernel_seg0_addr.size), REGION_WIRING_WIRED_ALREADY, LOCK_RW|LOCK_KERNEL);
|
PAGE_ALIGN(ka->kernel_seg0_addr.size), REGION_WIRING_WIRED_ALREADY, LOCK_RW|LOCK_KERNEL);
|
||||||
|
|
||||||
if (ka->kernel_seg1_addr.size > 0) {
|
if (ka->kernel_seg1_addr.size > 0) {
|
||||||
null_addr = (void *)ROUNDOWN(ka->kernel_seg1_addr.start, PAGE_SIZE);
|
address = (void *)ROUNDOWN(ka->kernel_seg1_addr.start, PAGE_SIZE);
|
||||||
vm_create_anonymous_region(vm_get_kernel_aspace_id(), "kernel_rw", &null_addr, REGION_ADDR_EXACT_ADDRESS,
|
vm_create_anonymous_region(vm_get_kernel_aspace_id(), "kernel_rw", &address, REGION_ADDR_EXACT_ADDRESS,
|
||||||
PAGE_ALIGN(ka->kernel_seg1_addr.size), REGION_WIRING_WIRED_ALREADY, LOCK_RW|LOCK_KERNEL);
|
PAGE_ALIGN(ka->kernel_seg1_addr.size), REGION_WIRING_WIRED_ALREADY, LOCK_RW|LOCK_KERNEL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// allocate areas for preloaded images
|
||||||
|
for (image = ka->preloaded_images; image != NULL; image = image->next) {
|
||||||
|
create_preloaded_image_areas(image);
|
||||||
|
}
|
||||||
|
|
||||||
|
// allocate kernel stacks
|
||||||
for (i = 0; i < ka->num_cpus; i++) {
|
for (i = 0; i < ka->num_cpus; i++) {
|
||||||
char temp[64];
|
char temp[64];
|
||||||
|
|
||||||
sprintf(temp, "idle_thread%d_kstack", i);
|
sprintf(temp, "idle_thread%d_kstack", i);
|
||||||
null_addr = (void *)ka->cpu_kstack[i].start;
|
address = (void *)ka->cpu_kstack[i].start;
|
||||||
vm_create_anonymous_region(vm_get_kernel_aspace_id(), temp, &null_addr, REGION_ADDR_EXACT_ADDRESS,
|
vm_create_anonymous_region(vm_get_kernel_aspace_id(), temp, &address, REGION_ADDR_EXACT_ADDRESS,
|
||||||
ka->cpu_kstack[i].size, REGION_WIRING_WIRED_ALREADY, LOCK_RW|LOCK_KERNEL);
|
ka->cpu_kstack[i].size, REGION_WIRING_WIRED_ALREADY, LOCK_RW|LOCK_KERNEL);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user