Replaced all remaining PAGE_SIZE with B_PAGE_SIZE and "addr" with addr_t.
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@9430 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -77,7 +77,7 @@ arch_cpu_init2(kernel_args *ka)
|
|||||||
|
|
||||||
sprintf(tss_name, "tss%d", i);
|
sprintf(tss_name, "tss%d", i);
|
||||||
rid = vm_create_anonymous_region(vm_get_kernel_aspace_id(), tss_name, (void **)&tss[i],
|
rid = vm_create_anonymous_region(vm_get_kernel_aspace_id(), tss_name, (void **)&tss[i],
|
||||||
B_ANY_KERNEL_ADDRESS, PAGE_SIZE, B_FULL_LOCK,
|
B_ANY_KERNEL_ADDRESS, B_PAGE_SIZE, B_FULL_LOCK,
|
||||||
B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA);
|
B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA);
|
||||||
if (rid < 0) {
|
if (rid < 0) {
|
||||||
panic("arch_cpu_init2: unable to create region for tss\n");
|
panic("arch_cpu_init2: unable to create region for tss\n");
|
||||||
@@ -124,10 +124,10 @@ i386_set_tss_and_kstack(addr_t kstack)
|
|||||||
void
|
void
|
||||||
arch_cpu_invalidate_TLB_range(addr_t start, addr_t end)
|
arch_cpu_invalidate_TLB_range(addr_t start, addr_t end)
|
||||||
{
|
{
|
||||||
int num_pages = end/PAGE_SIZE - start/PAGE_SIZE;
|
int num_pages = end / B_PAGE_SIZE - start / B_PAGE_SIZE;
|
||||||
while (num_pages-- >= 0) {
|
while (num_pages-- >= 0) {
|
||||||
invalidate_TLB(start);
|
invalidate_TLB(start);
|
||||||
start += PAGE_SIZE;
|
start += B_PAGE_SIZE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -214,7 +214,7 @@ arch_thread_context_switch(struct thread *t_from, struct thread *t_to)
|
|||||||
new_pgdir = i386_translation_map_get_pgdir(&t_to->team->aspace->translation_map);
|
new_pgdir = i386_translation_map_get_pgdir(&t_to->team->aspace->translation_map);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (((uint32)new_pgdir % PAGE_SIZE) != 0)
|
if (((uint32)new_pgdir % B_PAGE_SIZE) != 0)
|
||||||
panic("arch_thread_context_switch: bad pgdir 0x%lx\n", new_pgdir);
|
panic("arch_thread_context_switch: bad pgdir 0x%lx\n", new_pgdir);
|
||||||
|
|
||||||
i386_fsave_swap(t_from->arch_info.fpu_state, t_to->arch_info.fpu_state);
|
i386_fsave_swap(t_from->arch_info.fpu_state, t_to->arch_info.fpu_state);
|
||||||
|
|||||||
@@ -73,11 +73,11 @@ static spinlock tmap_list_lock;
|
|||||||
#define ADDR_SHIFT(x) ((x)>>12)
|
#define ADDR_SHIFT(x) ((x)>>12)
|
||||||
#define ADDR_REVERSE_SHIFT(x) ((x)<<12)
|
#define ADDR_REVERSE_SHIFT(x) ((x)<<12)
|
||||||
|
|
||||||
#define VADDR_TO_PDENT(va) (((va) / PAGE_SIZE) / 1024)
|
#define VADDR_TO_PDENT(va) (((va) / B_PAGE_SIZE) / 1024)
|
||||||
#define VADDR_TO_PTENT(va) (((va) / PAGE_SIZE) % 1024)
|
#define VADDR_TO_PTENT(va) (((va) / B_PAGE_SIZE) % 1024)
|
||||||
|
|
||||||
#define FIRST_USER_PGDIR_ENT (VADDR_TO_PDENT(USER_BASE))
|
#define FIRST_USER_PGDIR_ENT (VADDR_TO_PDENT(USER_BASE))
|
||||||
#define NUM_USER_PGDIR_ENTS (VADDR_TO_PDENT(ROUNDUP(USER_SIZE, PAGE_SIZE * 1024)))
|
#define NUM_USER_PGDIR_ENTS (VADDR_TO_PDENT(ROUNDUP(USER_SIZE, B_PAGE_SIZE * 1024)))
|
||||||
#define FIRST_KERNEL_PGDIR_ENT (VADDR_TO_PDENT(KERNEL_BASE))
|
#define FIRST_KERNEL_PGDIR_ENT (VADDR_TO_PDENT(KERNEL_BASE))
|
||||||
#define NUM_KERNEL_PGDIR_ENTS (VADDR_TO_PDENT(KERNEL_SIZE))
|
#define NUM_KERNEL_PGDIR_ENTS (VADDR_TO_PDENT(KERNEL_SIZE))
|
||||||
|
|
||||||
@@ -137,7 +137,7 @@ early_query(addr_t va, addr_t *out_physical)
|
|||||||
return ERR_VM_PAGE_NOT_PRESENT;
|
return ERR_VM_PAGE_NOT_PRESENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
pentry = page_hole + va / PAGE_SIZE;
|
pentry = page_hole + va / B_PAGE_SIZE;
|
||||||
if (pentry->present == 0) {
|
if (pentry->present == 0) {
|
||||||
// page mapping not valid
|
// page mapping not valid
|
||||||
return ERR_VM_PAGE_NOT_PRESENT;
|
return ERR_VM_PAGE_NOT_PRESENT;
|
||||||
@@ -278,11 +278,11 @@ map_tmap(vm_translation_map *map, addr_t va, addr_t pa, uint32 attributes)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
dprintf("pgdir at 0x%x\n", pgdir);
|
dprintf("pgdir at 0x%x\n", pgdir);
|
||||||
dprintf("index is %d\n", va / PAGE_SIZE / 1024);
|
dprintf("index is %d\n", va / B_PAGE_SIZE / 1024);
|
||||||
dprintf("final at 0x%x\n", &pgdir[va / PAGE_SIZE / 1024]);
|
dprintf("final at 0x%x\n", &pgdir[va / B_PAGE_SIZE / 1024]);
|
||||||
dprintf("value is 0x%x\n", *(int *)&pgdir[va / PAGE_SIZE / 1024]);
|
dprintf("value is 0x%x\n", *(int *)&pgdir[va / B_PAGE_SIZE / 1024]);
|
||||||
dprintf("present bit is %d\n", pgdir[va / PAGE_SIZE / 1024].present);
|
dprintf("present bit is %d\n", pgdir[va / B_PAGE_SIZE / 1024].present);
|
||||||
dprintf("addr is %d\n", pgdir[va / PAGE_SIZE / 1024].addr);
|
dprintf("addr is %d\n", pgdir[va / B_PAGE_SIZE / 1024].addr);
|
||||||
*/
|
*/
|
||||||
pd = map->arch_data->pgdir_virt;
|
pd = map->arch_data->pgdir_virt;
|
||||||
|
|
||||||
@@ -298,7 +298,7 @@ map_tmap(vm_translation_map *map, addr_t va, addr_t pa, uint32 attributes)
|
|||||||
// mark the page WIRED
|
// mark the page WIRED
|
||||||
vm_page_set_state(page, PAGE_STATE_WIRED);
|
vm_page_set_state(page, PAGE_STATE_WIRED);
|
||||||
|
|
||||||
pgtable = page->ppn * PAGE_SIZE;
|
pgtable = page->ppn * B_PAGE_SIZE;
|
||||||
|
|
||||||
TRACE(("map_tmap: asked for free page for pgtable. 0x%lx\n", pgtable));
|
TRACE(("map_tmap: asked for free page for pgtable. 0x%lx\n", pgtable));
|
||||||
|
|
||||||
@@ -342,8 +342,8 @@ unmap_tmap(vm_translation_map *map, addr_t start, addr_t end)
|
|||||||
int index;
|
int index;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
start = ROUNDOWN(start, PAGE_SIZE);
|
start = ROUNDOWN(start, B_PAGE_SIZE);
|
||||||
end = ROUNDUP(end, PAGE_SIZE);
|
end = ROUNDUP(end, B_PAGE_SIZE);
|
||||||
|
|
||||||
TRACE(("unmap_tmap: asked to free pages 0x%lx to 0x%lx\n", start, end));
|
TRACE(("unmap_tmap: asked to free pages 0x%lx to 0x%lx\n", start, end));
|
||||||
|
|
||||||
@@ -354,7 +354,7 @@ restart:
|
|||||||
index = VADDR_TO_PDENT(start);
|
index = VADDR_TO_PDENT(start);
|
||||||
if (pd[index].present == 0) {
|
if (pd[index].present == 0) {
|
||||||
// no pagetable here, move the start up to access the next page table
|
// no pagetable here, move the start up to access the next page table
|
||||||
start = ROUNDUP(start + 1, PAGE_SIZE);
|
start = ROUNDUP(start + 1, B_PAGE_SIZE);
|
||||||
goto restart;
|
goto restart;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -362,7 +362,7 @@ restart:
|
|||||||
err = get_physical_page_tmap(ADDR_REVERSE_SHIFT(pd[index].addr), (addr_t *)&pt, PHYSICAL_PAGE_NO_WAIT);
|
err = get_physical_page_tmap(ADDR_REVERSE_SHIFT(pd[index].addr), (addr_t *)&pt, PHYSICAL_PAGE_NO_WAIT);
|
||||||
} while (err < 0);
|
} while (err < 0);
|
||||||
|
|
||||||
for (index = VADDR_TO_PTENT(start); (index < 1024) && (start < end); index++, start += PAGE_SIZE) {
|
for (index = VADDR_TO_PTENT(start); (index < 1024) && (start < end); index++, start += B_PAGE_SIZE) {
|
||||||
if (pt[index].present == 0) {
|
if (pt[index].present == 0) {
|
||||||
// page mapping not valid
|
// page mapping not valid
|
||||||
continue;
|
continue;
|
||||||
@@ -520,13 +520,13 @@ map_iospace_chunk(addr_t va, addr_t pa)
|
|||||||
addr_t ppn;
|
addr_t ppn;
|
||||||
int state;
|
int state;
|
||||||
|
|
||||||
pa &= ~(PAGE_SIZE - 1); // make sure it's page aligned
|
pa &= ~(B_PAGE_SIZE - 1); // make sure it's page aligned
|
||||||
va &= ~(PAGE_SIZE - 1); // make sure it's page aligned
|
va &= ~(B_PAGE_SIZE - 1); // make sure it's page aligned
|
||||||
if (va < IOSPACE_BASE || va >= (IOSPACE_BASE + IOSPACE_SIZE))
|
if (va < IOSPACE_BASE || va >= (IOSPACE_BASE + IOSPACE_SIZE))
|
||||||
panic("map_iospace_chunk: passed invalid va 0x%lx\n", va);
|
panic("map_iospace_chunk: passed invalid va 0x%lx\n", va);
|
||||||
|
|
||||||
ppn = ADDR_SHIFT(pa);
|
ppn = ADDR_SHIFT(pa);
|
||||||
pt = &iospace_pgtables[(va - IOSPACE_BASE)/PAGE_SIZE];
|
pt = &iospace_pgtables[(va - IOSPACE_BASE) / B_PAGE_SIZE];
|
||||||
for (i = 0; i < 1024; i++) {
|
for (i = 0; i < 1024; i++) {
|
||||||
init_ptentry(&pt[i]);
|
init_ptentry(&pt[i]);
|
||||||
pt[i].addr = ppn + i;
|
pt[i].addr = ppn + i;
|
||||||
@@ -536,8 +536,8 @@ map_iospace_chunk(addr_t va, addr_t pa)
|
|||||||
}
|
}
|
||||||
|
|
||||||
state = disable_interrupts();
|
state = disable_interrupts();
|
||||||
arch_cpu_invalidate_TLB_range(va, va + (IOSPACE_CHUNK_SIZE - PAGE_SIZE));
|
arch_cpu_invalidate_TLB_range(va, va + (IOSPACE_CHUNK_SIZE - B_PAGE_SIZE));
|
||||||
smp_send_broadcast_ici(SMP_MSG_INVL_PAGE_RANGE, va, va + (IOSPACE_CHUNK_SIZE - PAGE_SIZE), 0,
|
smp_send_broadcast_ici(SMP_MSG_INVL_PAGE_RANGE, va, va + (IOSPACE_CHUNK_SIZE - B_PAGE_SIZE), 0,
|
||||||
NULL, SMP_MSG_FLAG_SYNC);
|
NULL, SMP_MSG_FLAG_SYNC);
|
||||||
restore_interrupts(state);
|
restore_interrupts(state);
|
||||||
|
|
||||||
@@ -754,7 +754,7 @@ arch_vm_translation_map_init(kernel_args *args)
|
|||||||
// page hole set up in stage2
|
// page hole set up in stage2
|
||||||
page_hole = (ptentry *)args->arch_args.page_hole;
|
page_hole = (ptentry *)args->arch_args.page_hole;
|
||||||
// calculate where the pgdir would be
|
// calculate where the pgdir would be
|
||||||
page_hole_pgdir = (pdentry *)(((unsigned int)args->arch_args.page_hole) + (PAGE_SIZE * 1024 - PAGE_SIZE));
|
page_hole_pgdir = (pdentry *)(((unsigned int)args->arch_args.page_hole) + (B_PAGE_SIZE * 1024 - B_PAGE_SIZE));
|
||||||
// clear out the bottom 2 GB, unmap everything
|
// clear out the bottom 2 GB, unmap everything
|
||||||
memset(page_hole_pgdir + FIRST_USER_PGDIR_ENT, 0, sizeof(pdentry) * NUM_USER_PGDIR_ENTS);
|
memset(page_hole_pgdir + FIRST_USER_PGDIR_ENT, 0, sizeof(pdentry) * NUM_USER_PGDIR_ENTS);
|
||||||
|
|
||||||
@@ -771,7 +771,7 @@ arch_vm_translation_map_init(kernel_args *args)
|
|||||||
virtual_pmappings = (paddr_chunk_desc **)vm_alloc_from_kernel_args(args,
|
virtual_pmappings = (paddr_chunk_desc **)vm_alloc_from_kernel_args(args,
|
||||||
sizeof(paddr_chunk_desc *) * num_virtual_chunks, B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA);
|
sizeof(paddr_chunk_desc *) * num_virtual_chunks, B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA);
|
||||||
iospace_pgtables = (ptentry *)vm_alloc_from_kernel_args(args,
|
iospace_pgtables = (ptentry *)vm_alloc_from_kernel_args(args,
|
||||||
PAGE_SIZE * (IOSPACE_SIZE / (PAGE_SIZE * 1024)), B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA);
|
B_PAGE_SIZE * (IOSPACE_SIZE / (B_PAGE_SIZE * 1024)), B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA);
|
||||||
|
|
||||||
TRACE(("paddr_desc %p, virtual_pmappings %p, iospace_pgtables %p\n",
|
TRACE(("paddr_desc %p, virtual_pmappings %p, iospace_pgtables %p\n",
|
||||||
paddr_desc, virtual_pmappings, iospace_pgtables));
|
paddr_desc, virtual_pmappings, iospace_pgtables));
|
||||||
@@ -781,7 +781,7 @@ arch_vm_translation_map_init(kernel_args *args)
|
|||||||
memset(virtual_pmappings, 0, sizeof(paddr_chunk_desc *) * num_virtual_chunks);
|
memset(virtual_pmappings, 0, sizeof(paddr_chunk_desc *) * num_virtual_chunks);
|
||||||
first_free_vmapping = 0;
|
first_free_vmapping = 0;
|
||||||
queue_init(&mapped_paddr_lru);
|
queue_init(&mapped_paddr_lru);
|
||||||
memset(iospace_pgtables, 0, PAGE_SIZE * (IOSPACE_SIZE / (PAGE_SIZE * 1024)));
|
memset(iospace_pgtables, 0, B_PAGE_SIZE * (IOSPACE_SIZE / (B_PAGE_SIZE * 1024)));
|
||||||
iospace_mutex.sem = -1;
|
iospace_mutex.sem = -1;
|
||||||
iospace_mutex.holder = -1;
|
iospace_mutex.holder = -1;
|
||||||
iospace_full_sem = -1;
|
iospace_full_sem = -1;
|
||||||
@@ -797,9 +797,9 @@ arch_vm_translation_map_init(kernel_args *args)
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
virt_pgtable = (addr_t)iospace_pgtables;
|
virt_pgtable = (addr_t)iospace_pgtables;
|
||||||
for (i = 0; i < (IOSPACE_SIZE / (PAGE_SIZE * 1024)); i++, virt_pgtable += PAGE_SIZE) {
|
for (i = 0; i < (IOSPACE_SIZE / (B_PAGE_SIZE * 1024)); i++, virt_pgtable += B_PAGE_SIZE) {
|
||||||
early_query(virt_pgtable, &phys_pgtable);
|
early_query(virt_pgtable, &phys_pgtable);
|
||||||
e = &page_hole_pgdir[(IOSPACE_BASE / (PAGE_SIZE * 1024)) + i];
|
e = &page_hole_pgdir[(IOSPACE_BASE / (B_PAGE_SIZE * 1024)) + i];
|
||||||
put_pgtable_in_pgdir(e, phys_pgtable, B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA);
|
put_pgtable_in_pgdir(e, phys_pgtable, B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -838,12 +838,12 @@ arch_vm_translation_map_init_post_area(kernel_args *args)
|
|||||||
|
|
||||||
temp = (void *)paddr_desc;
|
temp = (void *)paddr_desc;
|
||||||
vm_create_anonymous_region(vm_get_kernel_aspace_id(), "physical_page_mapping_descriptors", &temp,
|
vm_create_anonymous_region(vm_get_kernel_aspace_id(), "physical_page_mapping_descriptors", &temp,
|
||||||
B_EXACT_ADDRESS, ROUNDUP(sizeof(paddr_chunk_desc) * 1024, PAGE_SIZE),
|
B_EXACT_ADDRESS, ROUNDUP(sizeof(paddr_chunk_desc) * 1024, B_PAGE_SIZE),
|
||||||
B_ALREADY_WIRED, B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA);
|
B_ALREADY_WIRED, B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA);
|
||||||
|
|
||||||
temp = (void *)virtual_pmappings;
|
temp = (void *)virtual_pmappings;
|
||||||
vm_create_anonymous_region(vm_get_kernel_aspace_id(), "iospace_virtual_chunk_descriptors", &temp,
|
vm_create_anonymous_region(vm_get_kernel_aspace_id(), "iospace_virtual_chunk_descriptors", &temp,
|
||||||
B_EXACT_ADDRESS, ROUNDUP(sizeof(paddr_chunk_desc *) * num_virtual_chunks, PAGE_SIZE),
|
B_EXACT_ADDRESS, ROUNDUP(sizeof(paddr_chunk_desc *) * num_virtual_chunks, B_PAGE_SIZE),
|
||||||
B_ALREADY_WIRED, B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA);
|
B_ALREADY_WIRED, B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA);
|
||||||
|
|
||||||
temp = (void *)iospace_pgtables;
|
temp = (void *)iospace_pgtables;
|
||||||
@@ -884,7 +884,7 @@ arch_vm_translation_map_early_map(kernel_args *args, addr_t va, addr_t pa,
|
|||||||
// we need to allocate a pgtable
|
// we need to allocate a pgtable
|
||||||
pgtable = get_free_page(args);
|
pgtable = get_free_page(args);
|
||||||
// pgtable is in pages, convert to physical address
|
// pgtable is in pages, convert to physical address
|
||||||
pgtable *= PAGE_SIZE;
|
pgtable *= B_PAGE_SIZE;
|
||||||
|
|
||||||
TRACE(("early_map: asked for free page for pgtable. 0x%lx\n", pgtable));
|
TRACE(("early_map: asked for free page for pgtable. 0x%lx\n", pgtable));
|
||||||
|
|
||||||
@@ -893,10 +893,10 @@ arch_vm_translation_map_early_map(kernel_args *args, addr_t va, addr_t pa,
|
|||||||
put_pgtable_in_pgdir(e, pgtable, attributes);
|
put_pgtable_in_pgdir(e, pgtable, attributes);
|
||||||
|
|
||||||
// zero it out in it's new mapping
|
// zero it out in it's new mapping
|
||||||
memset((unsigned int *)((unsigned int)page_hole + (va / PAGE_SIZE / 1024) * PAGE_SIZE), 0, PAGE_SIZE);
|
memset((unsigned int *)((unsigned int)page_hole + (va / B_PAGE_SIZE / 1024) * B_PAGE_SIZE), 0, B_PAGE_SIZE);
|
||||||
}
|
}
|
||||||
// now, fill in the pentry
|
// now, fill in the pentry
|
||||||
put_ptentry_in_pgtable(page_hole + va / PAGE_SIZE, pa, attributes);
|
put_ptentry_in_pgtable(page_hole + va / B_PAGE_SIZE, pa, attributes);
|
||||||
|
|
||||||
arch_cpu_invalidate_TLB_range(va, va);
|
arch_cpu_invalidate_TLB_range(va, va);
|
||||||
|
|
||||||
|
|||||||
Vendored
+2
-2
@@ -199,7 +199,7 @@ read_from_cache(file_cache_ref *ref, off_t offset, size_t size, addr_t buffer, s
|
|||||||
vm_cache_insert_page(ref->cache, page, offset + pos);
|
vm_cache_insert_page(ref->cache, page, offset + pos);
|
||||||
|
|
||||||
addr_t virtualAddress;
|
addr_t virtualAddress;
|
||||||
vm_get_physical_page(page->ppn * PAGE_SIZE, &virtualAddress, PHYSICAL_PAGE_CAN_WAIT);
|
vm_get_physical_page(page->ppn * B_PAGE_SIZE, &virtualAddress, PHYSICAL_PAGE_CAN_WAIT);
|
||||||
|
|
||||||
add_to_iovec(vecs, vecCount, MAX_IO_VECS, virtualAddress, B_PAGE_SIZE);
|
add_to_iovec(vecs, vecCount, MAX_IO_VECS, virtualAddress, B_PAGE_SIZE);
|
||||||
// ToDo: check if the array is large enough!
|
// ToDo: check if the array is large enough!
|
||||||
@@ -268,7 +268,7 @@ write_to_cache(file_cache_ref *ref, off_t offset, size_t size, addr_t buffer, si
|
|||||||
vm_cache_insert_page(ref->cache, page, offset + pos);
|
vm_cache_insert_page(ref->cache, page, offset + pos);
|
||||||
|
|
||||||
addr_t virtualAddress;
|
addr_t virtualAddress;
|
||||||
vm_get_physical_page(page->ppn * PAGE_SIZE, &virtualAddress, PHYSICAL_PAGE_CAN_WAIT);
|
vm_get_physical_page(page->ppn * B_PAGE_SIZE, &virtualAddress, PHYSICAL_PAGE_CAN_WAIT);
|
||||||
|
|
||||||
add_to_iovec(vecs, vecCount, MAX_IO_VECS, virtualAddress, B_PAGE_SIZE);
|
add_to_iovec(vecs, vecCount, MAX_IO_VECS, virtualAddress, B_PAGE_SIZE);
|
||||||
// ToDo: check if the array is large enough!
|
// ToDo: check if the array is large enough!
|
||||||
|
|||||||
+11
-2
@@ -1,3 +1,12 @@
|
|||||||
|
/*
|
||||||
|
** Copyright 2002-2004, The Haiku Team. All rights reserved.
|
||||||
|
** Distributed under the terms of the Haiku License.
|
||||||
|
**
|
||||||
|
** Copyright 2001-2002, Travis Geiselbrecht. All rights reserved.
|
||||||
|
** Distributed under the terms of the NewOS License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
/* This file contains the cbuf functions. Cbuf is a memory allocator,
|
/* This file contains the cbuf functions. Cbuf is a memory allocator,
|
||||||
* currently not used for anything in kernel land other than ports.
|
* currently not used for anything in kernel land other than ports.
|
||||||
*/
|
*/
|
||||||
@@ -28,7 +37,7 @@ struct cbuf {
|
|||||||
2*sizeof(int) - sizeof(void *) - sizeof(int)];
|
2*sizeof(int) - sizeof(void *) - sizeof(int)];
|
||||||
};
|
};
|
||||||
|
|
||||||
#define ALLOCATE_CHUNK (PAGE_SIZE * 16)
|
#define ALLOCATE_CHUNK (B_PAGE_SIZE * 16)
|
||||||
#define CBUF_REGION_SIZE (4*1024*1024)
|
#define CBUF_REGION_SIZE (4*1024*1024)
|
||||||
#define CBUF_BITMAP_SIZE (CBUF_REGION_SIZE / CBUF_LENGTH)
|
#define CBUF_BITMAP_SIZE (CBUF_REGION_SIZE / CBUF_LENGTH)
|
||||||
|
|
||||||
@@ -774,7 +783,7 @@ cbuf_ones_cksum16(cbuf *buffer, size_t offset, size_t length)
|
|||||||
|
|
||||||
// start checksumming
|
// start checksumming
|
||||||
while (buffer && length > 0) {
|
while (buffer && length > 0) {
|
||||||
void *ptr = (void *)((addr)buffer->data + offset);
|
void *ptr = (void *)((addr_t)buffer->data + offset);
|
||||||
size_t plen = min(length, buffer->length - offset);
|
size_t plen = min(length, buffer->length - offset);
|
||||||
|
|
||||||
sum = ones_sum16(sum, ptr, plen);
|
sum = ones_sum16(sum, ptr, plen);
|
||||||
|
|||||||
+14
-15
@@ -1,5 +1,3 @@
|
|||||||
/* Contains the ELF loader */
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Copyright 2002-2004, The Haiku Team. All rights reserved.
|
** Copyright 2002-2004, The Haiku Team. All rights reserved.
|
||||||
** Distributed under the terms of the Haiku License.
|
** Distributed under the terms of the Haiku License.
|
||||||
@@ -8,6 +6,7 @@
|
|||||||
** Distributed under the terms of the NewOS License.
|
** Distributed under the terms of the NewOS License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* Contains the ELF loader */
|
||||||
|
|
||||||
#include <OS.h>
|
#include <OS.h>
|
||||||
#include <elf.h>
|
#include <elf.h>
|
||||||
@@ -1077,16 +1076,16 @@ elf_load_user_image(const char *path, struct team *p, int flags, addr_t *entry)
|
|||||||
if (pheaders[i].p_type != PT_LOAD)
|
if (pheaders[i].p_type != PT_LOAD)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
regionAddress = (char *)ROUNDOWN(pheaders[i].p_vaddr, PAGE_SIZE);
|
regionAddress = (char *)ROUNDOWN(pheaders[i].p_vaddr, B_PAGE_SIZE);
|
||||||
if (pheaders[i].p_flags & PF_WRITE) {
|
if (pheaders[i].p_flags & PF_WRITE) {
|
||||||
/*
|
/*
|
||||||
* rw/data segment
|
* rw/data segment
|
||||||
*/
|
*/
|
||||||
uint32 memUpperBound = (pheaders[i].p_vaddr % PAGE_SIZE) + pheaders[i].p_memsz;
|
uint32 memUpperBound = (pheaders[i].p_vaddr % B_PAGE_SIZE) + pheaders[i].p_memsz;
|
||||||
uint32 fileUpperBound = (pheaders[i].p_vaddr % PAGE_SIZE) + pheaders[i].p_filesz;
|
uint32 fileUpperBound = (pheaders[i].p_vaddr % B_PAGE_SIZE) + pheaders[i].p_filesz;
|
||||||
|
|
||||||
memUpperBound = ROUNDUP(memUpperBound, PAGE_SIZE);
|
memUpperBound = ROUNDUP(memUpperBound, B_PAGE_SIZE);
|
||||||
fileUpperBound = ROUNDUP(fileUpperBound, PAGE_SIZE);
|
fileUpperBound = ROUNDUP(fileUpperBound, B_PAGE_SIZE);
|
||||||
|
|
||||||
sprintf(regionName, "%s_seg%drw", baseName, i);
|
sprintf(regionName, "%s_seg%drw", baseName, i);
|
||||||
|
|
||||||
@@ -1095,7 +1094,7 @@ elf_load_user_image(const char *path, struct team *p, int flags, addr_t *entry)
|
|||||||
B_EXACT_ADDRESS,
|
B_EXACT_ADDRESS,
|
||||||
fileUpperBound,
|
fileUpperBound,
|
||||||
B_READ_AREA | B_WRITE_AREA, REGION_PRIVATE_MAP,
|
B_READ_AREA | B_WRITE_AREA, REGION_PRIVATE_MAP,
|
||||||
path, ROUNDOWN(pheaders[i].p_offset, PAGE_SIZE));
|
path, ROUNDOWN(pheaders[i].p_offset, B_PAGE_SIZE));
|
||||||
if (id < 0) {
|
if (id < 0) {
|
||||||
dprintf("error allocating region: %s!\n", strerror(id));
|
dprintf("error allocating region: %s!\n", strerror(id));
|
||||||
err = B_NOT_AN_EXECUTABLE;
|
err = B_NOT_AN_EXECUTABLE;
|
||||||
@@ -1106,10 +1105,10 @@ elf_load_user_image(const char *path, struct team *p, int flags, addr_t *entry)
|
|||||||
// at least parts of it are the bss and have to be zeroed)
|
// at least parts of it are the bss and have to be zeroed)
|
||||||
{
|
{
|
||||||
uint32 start = (uint32)regionAddress
|
uint32 start = (uint32)regionAddress
|
||||||
+ (pheaders[i].p_vaddr % PAGE_SIZE)
|
+ (pheaders[i].p_vaddr % B_PAGE_SIZE)
|
||||||
+ pheaders[i].p_filesz;
|
+ pheaders[i].p_filesz;
|
||||||
uint32 amount = fileUpperBound
|
uint32 amount = fileUpperBound
|
||||||
- (pheaders[i].p_vaddr % PAGE_SIZE)
|
- (pheaders[i].p_vaddr % B_PAGE_SIZE)
|
||||||
- (pheaders[i].p_filesz);
|
- (pheaders[i].p_filesz);
|
||||||
memset((void *)start, 0, amount);
|
memset((void *)start, 0, amount);
|
||||||
}
|
}
|
||||||
@@ -1140,9 +1139,9 @@ elf_load_user_image(const char *path, struct team *p, int flags, addr_t *entry)
|
|||||||
id = vm_map_file(p->aspace->id, regionName,
|
id = vm_map_file(p->aspace->id, regionName,
|
||||||
(void **)®ionAddress,
|
(void **)®ionAddress,
|
||||||
B_EXACT_ADDRESS,
|
B_EXACT_ADDRESS,
|
||||||
ROUNDUP(pheaders[i].p_memsz + (pheaders[i].p_vaddr % PAGE_SIZE), PAGE_SIZE),
|
ROUNDUP(pheaders[i].p_memsz + (pheaders[i].p_vaddr % B_PAGE_SIZE), B_PAGE_SIZE),
|
||||||
B_READ_AREA | B_EXECUTE_AREA, REGION_PRIVATE_MAP,
|
B_READ_AREA | B_EXECUTE_AREA, REGION_PRIVATE_MAP,
|
||||||
path, ROUNDOWN(pheaders[i].p_offset, PAGE_SIZE));
|
path, ROUNDOWN(pheaders[i].p_offset, B_PAGE_SIZE));
|
||||||
if (id < 0) {
|
if (id < 0) {
|
||||||
dprintf("error mapping text!\n");
|
dprintf("error mapping text!\n");
|
||||||
err = B_NOT_AN_EXECUTABLE;
|
err = B_NOT_AN_EXECUTABLE;
|
||||||
@@ -1318,7 +1317,7 @@ load_kernel_add_on(const char *path)
|
|||||||
// ToDo: this won't work if the on-disk order of the sections doesn't
|
// ToDo: this won't work if the on-disk order of the sections doesn't
|
||||||
// fit the in-memory order...
|
// fit the in-memory order...
|
||||||
region->start = start;
|
region->start = start;
|
||||||
region->size = ROUNDUP(pheaders[i].p_memsz + (pheaders[i].p_vaddr % PAGE_SIZE), PAGE_SIZE);
|
region->size = ROUNDUP(pheaders[i].p_memsz + (pheaders[i].p_vaddr % B_PAGE_SIZE), B_PAGE_SIZE);
|
||||||
region->id = create_area(regionName, (void **)®ion->start, B_EXACT_ADDRESS,
|
region->id = create_area(regionName, (void **)®ion->start, B_EXACT_ADDRESS,
|
||||||
region->size, B_FULL_LOCK, B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA);
|
region->size, B_FULL_LOCK, B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA);
|
||||||
if (region->id < 0) {
|
if (region->id < 0) {
|
||||||
@@ -1326,13 +1325,13 @@ load_kernel_add_on(const char *path)
|
|||||||
err = B_NOT_AN_EXECUTABLE;
|
err = B_NOT_AN_EXECUTABLE;
|
||||||
goto error4;
|
goto error4;
|
||||||
}
|
}
|
||||||
region->delta = region->start - ROUNDOWN(pheaders[i].p_vaddr, PAGE_SIZE);
|
region->delta = region->start - ROUNDOWN(pheaders[i].p_vaddr, B_PAGE_SIZE);
|
||||||
start += region->size;
|
start += region->size;
|
||||||
|
|
||||||
TRACE(("elf_load_kspace: created a region at %p\n", (void *)region->start));
|
TRACE(("elf_load_kspace: created a region at %p\n", (void *)region->start));
|
||||||
|
|
||||||
len = _kern_read(fd, pheaders[i].p_offset,
|
len = _kern_read(fd, pheaders[i].p_offset,
|
||||||
(void *)(region->start + (pheaders[i].p_vaddr % PAGE_SIZE)),
|
(void *)(region->start + (pheaders[i].p_vaddr % B_PAGE_SIZE)),
|
||||||
pheaders[i].p_filesz);
|
pheaders[i].p_filesz);
|
||||||
if (len < 0) {
|
if (len < 0) {
|
||||||
err = len;
|
err = len;
|
||||||
|
|||||||
@@ -397,7 +397,7 @@ bootfs_mount(mount_id id, const char *device, void *args, fs_volume *_fs, vnode_
|
|||||||
if (err < 0)
|
if (err < 0)
|
||||||
goto err1;
|
goto err1;
|
||||||
|
|
||||||
fs->vnode_list_hash = hash_init(BOOTFS_HASH_SIZE, (addr)&v->all_next - (addr)v,
|
fs->vnode_list_hash = hash_init(BOOTFS_HASH_SIZE, (addr_t)&v->all_next - (addr_t)v,
|
||||||
&bootfs_vnode_compare_func, &bootfs_vnode_hash_func);
|
&bootfs_vnode_compare_func, &bootfs_vnode_hash_func);
|
||||||
if (fs->vnode_list_hash == NULL) {
|
if (fs->vnode_list_hash == NULL) {
|
||||||
err = ENOMEM;
|
err = ENOMEM;
|
||||||
|
|||||||
@@ -653,7 +653,7 @@ devfs_mount(mount_id id, const char *devfs, void *args, fs_volume *_fs, vnode_id
|
|||||||
if (err < B_OK)
|
if (err < B_OK)
|
||||||
goto err1;
|
goto err1;
|
||||||
|
|
||||||
fs->vnode_list_hash = hash_init(BOOTFS_HASH_SIZE, (addr)&v->all_next - (addr)v,
|
fs->vnode_list_hash = hash_init(BOOTFS_HASH_SIZE, (addr_t)&v->all_next - (addr_t)v,
|
||||||
&devfs_vnode_compare_func, &devfs_vnode_hash_func);
|
&devfs_vnode_compare_func, &devfs_vnode_hash_func);
|
||||||
if (fs->vnode_list_hash == NULL) {
|
if (fs->vnode_list_hash == NULL) {
|
||||||
err = B_NO_MEMORY;
|
err = B_NO_MEMORY;
|
||||||
|
|||||||
@@ -314,7 +314,7 @@ rootfs_mount(mount_id id, const char *device, void *args, fs_volume *_fs, vnode_
|
|||||||
if (err < B_OK)
|
if (err < B_OK)
|
||||||
goto err1;
|
goto err1;
|
||||||
|
|
||||||
fs->vnode_list_hash = hash_init(ROOTFS_HASH_SIZE, (addr)&vnode->all_next - (addr)vnode,
|
fs->vnode_list_hash = hash_init(ROOTFS_HASH_SIZE, (addr_t)&vnode->all_next - (addr_t)vnode,
|
||||||
&rootfs_vnode_compare_func, &rootfs_vnode_hash_func);
|
&rootfs_vnode_compare_func, &rootfs_vnode_hash_func);
|
||||||
if (fs->vnode_list_hash == NULL) {
|
if (fs->vnode_list_hash == NULL) {
|
||||||
err = B_NO_MEMORY;
|
err = B_NO_MEMORY;
|
||||||
|
|||||||
@@ -1,7 +1,3 @@
|
|||||||
/* Virtual File System and
|
|
||||||
** File System Interface Layer
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Copyright 2002-2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
|
** Copyright 2002-2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
|
||||||
** Distributed under the terms of the Haiku License.
|
** Distributed under the terms of the Haiku License.
|
||||||
@@ -10,6 +6,8 @@
|
|||||||
** Distributed under the terms of the NewOS License.
|
** Distributed under the terms of the NewOS License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* Virtual File System and File System Interface Layer */
|
||||||
|
|
||||||
#include <OS.h>
|
#include <OS.h>
|
||||||
#include <StorageDefs.h>
|
#include <StorageDefs.h>
|
||||||
#include <fs_info.h>
|
#include <fs_info.h>
|
||||||
@@ -2098,18 +2096,18 @@ vfs_mount_boot_file_system()
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
vfs_init(kernel_args *ka)
|
vfs_init(kernel_args *args)
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
struct vnode *v;
|
struct vnode *v;
|
||||||
sVnodeTable = hash_init(VNODE_HASH_TABLE_SIZE, (addr)&v->next - (addr)v,
|
sVnodeTable = hash_init(VNODE_HASH_TABLE_SIZE, (addr_t)&v->next - (addr_t)v,
|
||||||
&vnode_compare, &vnode_hash);
|
&vnode_compare, &vnode_hash);
|
||||||
if (sVnodeTable == NULL)
|
if (sVnodeTable == NULL)
|
||||||
panic("vfs_init: error creating vnode hash table\n");
|
panic("vfs_init: error creating vnode hash table\n");
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
struct fs_mount *mount;
|
struct fs_mount *mount;
|
||||||
sMountsTable = hash_init(MOUNTS_HASH_TABLE_SIZE, (addr)&mount->next - (addr)mount,
|
sMountsTable = hash_init(MOUNTS_HASH_TABLE_SIZE, (addr_t)&mount->next - (addr_t)mount,
|
||||||
&mount_compare, &mount_hash);
|
&mount_compare, &mount_hash);
|
||||||
if (sMountsTable == NULL)
|
if (sMountsTable == NULL)
|
||||||
panic("vfs_init: error creating mounts hash table\n");
|
panic("vfs_init: error creating mounts hash table\n");
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
/* Functionality for symetrical multi-processors */
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Copyright 2001-2002, Travis Geiselbrecht. All rights reserved.
|
** Copyright 2001-2002, Travis Geiselbrecht. All rights reserved.
|
||||||
** Distributed under the terms of the NewOS License.
|
** Distributed under the terms of the NewOS License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* Functionality for symetrical multi-processors */
|
||||||
|
|
||||||
#include <kernel.h>
|
#include <kernel.h>
|
||||||
#include <thread.h>
|
#include <thread.h>
|
||||||
#include <console.h>
|
#include <console.h>
|
||||||
@@ -314,10 +314,10 @@ smp_process_pending_ici(int curr_cpu)
|
|||||||
|
|
||||||
switch (msg->message) {
|
switch (msg->message) {
|
||||||
case SMP_MSG_INVL_PAGE_RANGE:
|
case SMP_MSG_INVL_PAGE_RANGE:
|
||||||
arch_cpu_invalidate_TLB_range((addr)msg->data, (addr)msg->data2);
|
arch_cpu_invalidate_TLB_range((addr_t)msg->data, (addr_t)msg->data2);
|
||||||
break;
|
break;
|
||||||
case SMP_MSG_INVL_PAGE_LIST:
|
case SMP_MSG_INVL_PAGE_LIST:
|
||||||
arch_cpu_invalidate_TLB_list((addr *)msg->data, (int)msg->data2);
|
arch_cpu_invalidate_TLB_list((addr_t *)msg->data, (int)msg->data2);
|
||||||
break;
|
break;
|
||||||
case SMP_MSG_GLOBAL_INVL_PAGE:
|
case SMP_MSG_GLOBAL_INVL_PAGE:
|
||||||
arch_cpu_global_TLB_invalidate();
|
arch_cpu_global_TLB_invalidate();
|
||||||
|
|||||||
@@ -143,7 +143,7 @@ team_init(kernel_args *ka)
|
|||||||
struct process_group *group;
|
struct process_group *group;
|
||||||
|
|
||||||
// create the team hash table
|
// create the team hash table
|
||||||
team_hash = hash_init(15, (addr)&kernel_team->next - (addr)kernel_team,
|
team_hash = hash_init(15, (addr_t)&kernel_team->next - (addr_t)kernel_team,
|
||||||
&team_struct_compare, &team_struct_hash);
|
&team_struct_compare, &team_struct_hash);
|
||||||
|
|
||||||
// create initial session and process groups
|
// create initial session and process groups
|
||||||
@@ -802,7 +802,7 @@ team_create_thread_start(void *args)
|
|||||||
struct team *team;
|
struct team *team;
|
||||||
struct team_arg *teamArgs = args;
|
struct team_arg *teamArgs = args;
|
||||||
const char *path;
|
const char *path;
|
||||||
addr entry;
|
addr_t entry;
|
||||||
char ustack_name[128];
|
char ustack_name[128];
|
||||||
uint32 sizeLeft;
|
uint32 sizeLeft;
|
||||||
char **uargs;
|
char **uargs;
|
||||||
@@ -1688,7 +1688,7 @@ sys_setenv(const char *name, const char *value, int overwrite)
|
|||||||
{
|
{
|
||||||
char var[SYS_THREAD_STRING_LENGTH_MAX];
|
char var[SYS_THREAD_STRING_LENGTH_MAX];
|
||||||
int state;
|
int state;
|
||||||
addr env_space;
|
addr_t env_space;
|
||||||
char **envp;
|
char **envp;
|
||||||
int envc;
|
int envc;
|
||||||
bool var_exists = false;
|
bool var_exists = false;
|
||||||
@@ -1713,7 +1713,7 @@ sys_setenv(const char *name, const char *value, int overwrite)
|
|||||||
name_size = strlen(var);
|
name_size = strlen(var);
|
||||||
strncat(var, value, SYS_THREAD_STRING_LENGTH_MAX-1);
|
strncat(var, value, SYS_THREAD_STRING_LENGTH_MAX-1);
|
||||||
|
|
||||||
env_space = (addr)thread_get_current_thread()->team->user_env_base;
|
env_space = (addr_t)thread_get_current_thread()->team->user_env_base;
|
||||||
envp = (char **)env_space;
|
envp = (char **)env_space;
|
||||||
for (envc = 0; envp[envc]; envc++) {
|
for (envc = 0; envp[envc]; envc++) {
|
||||||
if (!strncmp(envp[envc], var, name_size)) {
|
if (!strncmp(envp[envc], var, name_size)) {
|
||||||
|
|||||||
@@ -1645,7 +1645,9 @@ dump_region(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
region_id
|
// ToDo: fix these and move them to find_area() and area_for()!
|
||||||
|
|
||||||
|
static region_id
|
||||||
find_region_by_address(addr_t address)
|
find_region_by_address(addr_t address)
|
||||||
{
|
{
|
||||||
vm_address_space *aspace;
|
vm_address_space *aspace;
|
||||||
@@ -1667,7 +1669,7 @@ find_region_by_address(addr_t address)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
region_id
|
static region_id
|
||||||
find_region_by_name(const char *name)
|
find_region_by_name(const char *name)
|
||||||
{
|
{
|
||||||
vm_region *region;
|
vm_region *region;
|
||||||
|
|||||||
@@ -15,18 +15,18 @@
|
|||||||
#include <vm_page.h>
|
#include <vm_page.h>
|
||||||
|
|
||||||
bool trimming_cycle;
|
bool trimming_cycle;
|
||||||
static addr free_memory_low_water;
|
static addr_t free_memory_low_water;
|
||||||
static addr free_memory_high_water;
|
static addr_t free_memory_high_water;
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
scan_pages(vm_address_space *aspace, addr free_target)
|
scan_pages(vm_address_space *aspace, addr_t free_target)
|
||||||
{
|
{
|
||||||
vm_region *first_region;
|
vm_region *first_region;
|
||||||
vm_region *region;
|
vm_region *region;
|
||||||
vm_page *page;
|
vm_page *page;
|
||||||
addr va;
|
addr_t va;
|
||||||
addr pa;
|
addr_t pa;
|
||||||
uint32 flags, flags2;
|
uint32 flags, flags2;
|
||||||
// int err;
|
// int err;
|
||||||
int quantum = PAGE_SCAN_QUANTUM;
|
int quantum = PAGE_SCAN_QUANTUM;
|
||||||
@@ -58,7 +58,7 @@ scan_pages(vm_address_space *aspace, addr free_target)
|
|||||||
// scan the pages in this region
|
// scan the pages in this region
|
||||||
mutex_lock(®ion->cache_ref->lock);
|
mutex_lock(®ion->cache_ref->lock);
|
||||||
if (!region->cache_ref->cache->scan_skip) {
|
if (!region->cache_ref->cache->scan_skip) {
|
||||||
for(va = region->base; va < (region->base + region->size); va += PAGE_SIZE) {
|
for(va = region->base; va < (region->base + region->size); va += B_PAGE_SIZE) {
|
||||||
aspace->translation_map.ops->lock(&aspace->translation_map);
|
aspace->translation_map.ops->lock(&aspace->translation_map);
|
||||||
aspace->translation_map.ops->query(&aspace->translation_map, va, &pa, &flags);
|
aspace->translation_map.ops->query(&aspace->translation_map, va, &pa, &flags);
|
||||||
if ((flags & PAGE_PRESENT) == 0) {
|
if ((flags & PAGE_PRESENT) == 0) {
|
||||||
@@ -66,7 +66,7 @@ scan_pages(vm_address_space *aspace, addr free_target)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
page = vm_lookup_page(pa / PAGE_SIZE);
|
page = vm_lookup_page(pa / B_PAGE_SIZE);
|
||||||
if (!page) {
|
if (!page) {
|
||||||
aspace->translation_map.ops->unlock(&aspace->translation_map);
|
aspace->translation_map.ops->unlock(&aspace->translation_map);
|
||||||
continue;
|
continue;
|
||||||
@@ -83,7 +83,7 @@ scan_pages(vm_address_space *aspace, addr free_target)
|
|||||||
// look for a page we can steal
|
// look for a page we can steal
|
||||||
if (!(flags & PAGE_ACCESSED) && page->state == PAGE_STATE_ACTIVE) {
|
if (!(flags & PAGE_ACCESSED) && page->state == PAGE_STATE_ACTIVE) {
|
||||||
// unmap the page
|
// unmap the page
|
||||||
aspace->translation_map.ops->unmap(&aspace->translation_map, va, va + PAGE_SIZE);
|
aspace->translation_map.ops->unmap(&aspace->translation_map, va, va + B_PAGE_SIZE);
|
||||||
|
|
||||||
// flush the tlbs of all cpus
|
// flush the tlbs of all cpus
|
||||||
aspace->translation_map.ops->flush(&aspace->translation_map);
|
aspace->translation_map.ops->flush(&aspace->translation_map);
|
||||||
@@ -137,8 +137,8 @@ page_daemon(void *unused)
|
|||||||
struct hash_iterator i;
|
struct hash_iterator i;
|
||||||
vm_address_space *old_aspace;
|
vm_address_space *old_aspace;
|
||||||
vm_address_space *aspace;
|
vm_address_space *aspace;
|
||||||
addr mapped_size;
|
addr_t mapped_size;
|
||||||
addr free_memory_target;
|
addr_t free_memory_target;
|
||||||
int faults_per_second;
|
int faults_per_second;
|
||||||
bigtime_t now;
|
bigtime_t now;
|
||||||
|
|
||||||
|
|||||||
@@ -23,15 +23,15 @@ vm_test(void)
|
|||||||
dprintf("vm_test 1: creating anonymous region and writing to it\n");
|
dprintf("vm_test 1: creating anonymous region and writing to it\n");
|
||||||
{
|
{
|
||||||
region_id region;
|
region_id region;
|
||||||
addr region_addr;
|
addr_t region_addr;
|
||||||
|
|
||||||
region = vm_create_anonymous_region(vm_get_kernel_aspace_id(), "test_region", (void **)®ion_addr,
|
region = vm_create_anonymous_region(vm_get_kernel_aspace_id(), "test_region", (void **)®ion_addr,
|
||||||
B_ANY_KERNEL_ADDRESS, PAGE_SIZE * 16, B_NO_LOCK, B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA);
|
B_ANY_KERNEL_ADDRESS, B_PAGE_SIZE * 16, B_NO_LOCK, B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA);
|
||||||
if (region < 0)
|
if (region < 0)
|
||||||
panic("vm_test 1: failed to create test region\n");
|
panic("vm_test 1: failed to create test region\n");
|
||||||
dprintf("region = 0x%lx, addr = 0x%lx\n", region, region_addr);
|
dprintf("region = 0x%lx, addr = 0x%lx\n", region, region_addr);
|
||||||
|
|
||||||
memset((void *)region_addr, 0, PAGE_SIZE * 16);
|
memset((void *)region_addr, 0, B_PAGE_SIZE * 16);
|
||||||
|
|
||||||
dprintf("memsetted the region\n");
|
dprintf("memsetted the region\n");
|
||||||
if (vm_delete_region(vm_get_kernel_aspace_id(), region) < 0)
|
if (vm_delete_region(vm_get_kernel_aspace_id(), region) < 0)
|
||||||
@@ -48,7 +48,7 @@ vm_test(void)
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
region = vm_map_physical_memory(vm_get_kernel_aspace_id(), "test_physical_region", (void **)&ptr,
|
region = vm_map_physical_memory(vm_get_kernel_aspace_id(), "test_physical_region", (void **)&ptr,
|
||||||
B_ANY_KERNEL_ADDRESS, PAGE_SIZE * 16, B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA, 0xb8000);
|
B_ANY_KERNEL_ADDRESS, B_PAGE_SIZE * 16, B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA, 0xb8000);
|
||||||
if(region < 0)
|
if(region < 0)
|
||||||
panic("vm_test 2: failed to create test region\n");
|
panic("vm_test 2: failed to create test region\n");
|
||||||
|
|
||||||
@@ -68,18 +68,18 @@ vm_test(void)
|
|||||||
#if 1
|
#if 1
|
||||||
dprintf("vm_test 3: testing some functionality of vm_get_page_mapping(), vm_get/put_physical_page()\n");
|
dprintf("vm_test 3: testing some functionality of vm_get_page_mapping(), vm_get/put_physical_page()\n");
|
||||||
{
|
{
|
||||||
addr va, pa;
|
addr_t va, pa;
|
||||||
addr va2;
|
addr_t va2;
|
||||||
|
|
||||||
vm_get_page_mapping(vm_get_kernel_aspace_id(), 0x80000000, &pa);
|
vm_get_page_mapping(vm_get_kernel_aspace_id(), 0x80000000, &pa);
|
||||||
vm_get_physical_page(pa, &va, PHYSICAL_PAGE_CAN_WAIT);
|
vm_get_physical_page(pa, &va, PHYSICAL_PAGE_CAN_WAIT);
|
||||||
dprintf("pa 0x%lx va 0x%lx\n", pa, va);
|
dprintf("pa 0x%lx va 0x%lx\n", pa, va);
|
||||||
dprintf("%d\n", memcmp((void *)0x80000000, (void *)va, PAGE_SIZE));
|
dprintf("%d\n", memcmp((void *)0x80000000, (void *)va, B_PAGE_SIZE));
|
||||||
|
|
||||||
vm_get_page_mapping(vm_get_kernel_aspace_id(), 0x80001000, &pa);
|
vm_get_page_mapping(vm_get_kernel_aspace_id(), 0x80001000, &pa);
|
||||||
vm_get_physical_page(pa, &va2, PHYSICAL_PAGE_CAN_WAIT);
|
vm_get_physical_page(pa, &va2, PHYSICAL_PAGE_CAN_WAIT);
|
||||||
dprintf("pa 0x%lx va 0x%lx\n", pa, va2);
|
dprintf("pa 0x%lx va 0x%lx\n", pa, va2);
|
||||||
dprintf("%d\n", memcmp((void *)0x80001000, (void *)va2, PAGE_SIZE));
|
dprintf("%d\n", memcmp((void *)0x80001000, (void *)va2, B_PAGE_SIZE));
|
||||||
|
|
||||||
vm_put_physical_page(va);
|
vm_put_physical_page(va);
|
||||||
vm_put_physical_page(va2);
|
vm_put_physical_page(va2);
|
||||||
@@ -87,7 +87,7 @@ vm_test(void)
|
|||||||
vm_get_page_mapping(vm_get_kernel_aspace_id(), 0x80000000, &pa);
|
vm_get_page_mapping(vm_get_kernel_aspace_id(), 0x80000000, &pa);
|
||||||
vm_get_physical_page(pa, &va, PHYSICAL_PAGE_CAN_WAIT);
|
vm_get_physical_page(pa, &va, PHYSICAL_PAGE_CAN_WAIT);
|
||||||
dprintf("pa 0x%lx va 0x%lx\n", pa, va);
|
dprintf("pa 0x%lx va 0x%lx\n", pa, va);
|
||||||
dprintf("%d\n", memcmp((void *)0x80000000, (void *)va, PAGE_SIZE));
|
dprintf("%d\n", memcmp((void *)0x80000000, (void *)va, B_PAGE_SIZE));
|
||||||
|
|
||||||
vm_put_physical_page(va);
|
vm_put_physical_page(va);
|
||||||
}
|
}
|
||||||
@@ -160,12 +160,12 @@ vm_test(void)
|
|||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
region = vm_create_anonymous_region(vm_get_kernel_aspace_id(), "test_region", ®ion_addr,
|
region = vm_create_anonymous_region(vm_get_kernel_aspace_id(), "test_region", ®ion_addr,
|
||||||
B_ANY_KERNEL_ADDRESS, PAGE_SIZE * 16, B_NO_LOCK, B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA);
|
B_ANY_KERNEL_ADDRESS, B_PAGE_SIZE * 16, B_NO_LOCK, B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA);
|
||||||
if (region < 0)
|
if (region < 0)
|
||||||
panic("vm_test 6: error creating test region\n");
|
panic("vm_test 6: error creating test region\n");
|
||||||
dprintf("region = 0x%lx, addr = %p\n", region, region_addr);
|
dprintf("region = 0x%lx, addr = %p\n", region, region_addr);
|
||||||
|
|
||||||
memset(region_addr, 99, PAGE_SIZE * 16);
|
memset(region_addr, 99, B_PAGE_SIZE * 16);
|
||||||
|
|
||||||
dprintf("memsetted the region\n");
|
dprintf("memsetted the region\n");
|
||||||
|
|
||||||
@@ -175,7 +175,7 @@ vm_test(void)
|
|||||||
panic("vm_test 6: error cloning test region\n");
|
panic("vm_test 6: error cloning test region\n");
|
||||||
dprintf("region2 = 0x%lx, ptr = %p\n", region2, ptr);
|
dprintf("region2 = 0x%lx, ptr = %p\n", region2, ptr);
|
||||||
|
|
||||||
rc = memcmp(region_addr, ptr, PAGE_SIZE * 16);
|
rc = memcmp(region_addr, ptr, B_PAGE_SIZE * 16);
|
||||||
if(rc != 0)
|
if(rc != 0)
|
||||||
panic("vm_test 6: regions are not identical\n");
|
panic("vm_test 6: regions are not identical\n");
|
||||||
else
|
else
|
||||||
@@ -199,12 +199,12 @@ vm_test(void)
|
|||||||
fd = _kern_open("/boot/beos/system/kernel_" OBOS_ARCH, 0);
|
fd = _kern_open("/boot/beos/system/kernel_" OBOS_ARCH, 0);
|
||||||
|
|
||||||
rid = vm_map_file(vm_get_kernel_aspace_id(), "mmap_test", &ptr, B_ANY_KERNEL_ADDRESS,
|
rid = vm_map_file(vm_get_kernel_aspace_id(), "mmap_test", &ptr, B_ANY_KERNEL_ADDRESS,
|
||||||
PAGE_SIZE, B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA, REGION_NO_PRIVATE_MAP, "/boot/kernel", 0);
|
B_PAGE_SIZE, B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA, REGION_NO_PRIVATE_MAP, "/boot/kernel", 0);
|
||||||
|
|
||||||
rid2 = vm_map_file(vm_get_kernel_aspace_id(), "mmap_test2", &ptr2, B_ANY_KERNEL_ADDRESS,
|
rid2 = vm_map_file(vm_get_kernel_aspace_id(), "mmap_test2", &ptr2, B_ANY_KERNEL_ADDRESS,
|
||||||
PAGE_SIZE, B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA, REGION_NO_PRIVATE_MAP, "/boot/kernel", 0);
|
B_PAGE_SIZE, B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA, REGION_NO_PRIVATE_MAP, "/boot/kernel", 0);
|
||||||
|
|
||||||
dprintf("diff %d\n", memcmp(ptr, ptr2, PAGE_SIZE));
|
dprintf("diff %d\n", memcmp(ptr, ptr2, B_PAGE_SIZE));
|
||||||
|
|
||||||
dprintf("removing regions\n");
|
dprintf("removing regions\n");
|
||||||
|
|
||||||
@@ -229,14 +229,14 @@ vm_test(void)
|
|||||||
dprintf("vm_test 8: creating test region...\n");
|
dprintf("vm_test 8: creating test region...\n");
|
||||||
|
|
||||||
region = vm_create_anonymous_region(vm_get_kernel_aspace_id(), "test_region", ®ion_addr,
|
region = vm_create_anonymous_region(vm_get_kernel_aspace_id(), "test_region", ®ion_addr,
|
||||||
B_ANY_KERNEL_ADDRESS, PAGE_SIZE * 16, B_NO_LOCK, B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA);
|
B_ANY_KERNEL_ADDRESS, B_PAGE_SIZE * 16, B_NO_LOCK, B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA);
|
||||||
if(region < 0)
|
if(region < 0)
|
||||||
panic("vm_test 8: error creating test region\n");
|
panic("vm_test 8: error creating test region\n");
|
||||||
dprintf("region = 0x%lx, addr = %p\n", region, region_addr);
|
dprintf("region = 0x%lx, addr = %p\n", region, region_addr);
|
||||||
|
|
||||||
dprintf("vm_test 8: memsetting the first 2 pages\n");
|
dprintf("vm_test 8: memsetting the first 2 pages\n");
|
||||||
|
|
||||||
memset(region_addr, 99, PAGE_SIZE * 2);
|
memset(region_addr, 99, B_PAGE_SIZE * 2);
|
||||||
|
|
||||||
dprintf("vm_test 8: cloning test region with PRIVATE_MAP\n");
|
dprintf("vm_test 8: cloning test region with PRIVATE_MAP\n");
|
||||||
|
|
||||||
@@ -248,7 +248,7 @@ vm_test(void)
|
|||||||
|
|
||||||
dprintf("vm_test 8: comparing first 2 pages, shoudld be identical\n");
|
dprintf("vm_test 8: comparing first 2 pages, shoudld be identical\n");
|
||||||
|
|
||||||
rc = memcmp(region_addr, ptr, PAGE_SIZE * 2);
|
rc = memcmp(region_addr, ptr, B_PAGE_SIZE * 2);
|
||||||
if(rc != 0)
|
if(rc != 0)
|
||||||
panic("vm_test 8: regions are not identical\n");
|
panic("vm_test 8: regions are not identical\n");
|
||||||
else
|
else
|
||||||
@@ -258,7 +258,7 @@ vm_test(void)
|
|||||||
|
|
||||||
memset(ptr, 1, 1);
|
memset(ptr, 1, 1);
|
||||||
|
|
||||||
rc = memcmp(region_addr, ptr, PAGE_SIZE);
|
rc = memcmp(region_addr, ptr, B_PAGE_SIZE);
|
||||||
if(rc != 0)
|
if(rc != 0)
|
||||||
dprintf("vm_test 8: regions are not identical, good\n");
|
dprintf("vm_test 8: regions are not identical, good\n");
|
||||||
else
|
else
|
||||||
@@ -266,7 +266,7 @@ vm_test(void)
|
|||||||
|
|
||||||
dprintf("vm_test 8: comparing untouched pages in source and clone, should be identical\n");
|
dprintf("vm_test 8: comparing untouched pages in source and clone, should be identical\n");
|
||||||
|
|
||||||
rc = memcmp((char *)region_addr + 2*PAGE_SIZE, (char *)ptr + 2*PAGE_SIZE, PAGE_SIZE * 1);
|
rc = memcmp((char *)region_addr + 2*B_PAGE_SIZE, (char *)ptr + 2*B_PAGE_SIZE, B_PAGE_SIZE * 1);
|
||||||
if(rc != 0)
|
if(rc != 0)
|
||||||
panic("vm_test 8: regions are not identical\n");
|
panic("vm_test 8: regions are not identical\n");
|
||||||
else
|
else
|
||||||
@@ -274,9 +274,9 @@ vm_test(void)
|
|||||||
|
|
||||||
dprintf("vm_test 8: modifying source page and comparing, should be the same\n");
|
dprintf("vm_test 8: modifying source page and comparing, should be the same\n");
|
||||||
|
|
||||||
memset((char *)region_addr + 3*PAGE_SIZE, 2, 4);
|
memset((char *)region_addr + 3*B_PAGE_SIZE, 2, 4);
|
||||||
|
|
||||||
rc = memcmp((char *)region_addr + 3*PAGE_SIZE, (char *)ptr + 3*PAGE_SIZE, PAGE_SIZE * 1);
|
rc = memcmp((char *)region_addr + 3*B_PAGE_SIZE, (char *)ptr + 3*B_PAGE_SIZE, B_PAGE_SIZE * 1);
|
||||||
if(rc != 0)
|
if(rc != 0)
|
||||||
panic("vm_test 8: regions are not identical\n");
|
panic("vm_test 8: regions are not identical\n");
|
||||||
else
|
else
|
||||||
@@ -285,9 +285,9 @@ vm_test(void)
|
|||||||
|
|
||||||
dprintf("vm_test 8: modifying new page in clone, should not effect source, which is also untouched\n");
|
dprintf("vm_test 8: modifying new page in clone, should not effect source, which is also untouched\n");
|
||||||
|
|
||||||
memset((char *)ptr + 4*PAGE_SIZE, 2, 4);
|
memset((char *)ptr + 4*B_PAGE_SIZE, 2, 4);
|
||||||
|
|
||||||
rc = memcmp((char *)region_addr + 4*PAGE_SIZE, (char *)ptr + 4*PAGE_SIZE, PAGE_SIZE * 1);
|
rc = memcmp((char *)region_addr + 4*B_PAGE_SIZE, (char *)ptr + 4*B_PAGE_SIZE, B_PAGE_SIZE * 1);
|
||||||
if(rc != 0)
|
if(rc != 0)
|
||||||
dprintf("vm_test 8: regions are not identical, good\n");
|
dprintf("vm_test 8: regions are not identical, good\n");
|
||||||
else
|
else
|
||||||
@@ -310,12 +310,12 @@ vm_test(void)
|
|||||||
dprintf("vm_test 9: mapping /boot/kernel twice\n");
|
dprintf("vm_test 9: mapping /boot/kernel twice\n");
|
||||||
|
|
||||||
rid = vm_map_file(vm_get_kernel_aspace_id(), "mmap_test", &ptr, B_ANY_KERNEL_ADDRESS,
|
rid = vm_map_file(vm_get_kernel_aspace_id(), "mmap_test", &ptr, B_ANY_KERNEL_ADDRESS,
|
||||||
PAGE_SIZE*4, B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA, REGION_NO_PRIVATE_MAP, "/boot/kernel", 0);
|
B_PAGE_SIZE*4, B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA, REGION_NO_PRIVATE_MAP, "/boot/kernel", 0);
|
||||||
|
|
||||||
rid2 = vm_map_file(vm_get_kernel_aspace_id(), "mmap_test2", &ptr2, B_ANY_KERNEL_ADDRESS,
|
rid2 = vm_map_file(vm_get_kernel_aspace_id(), "mmap_test2", &ptr2, B_ANY_KERNEL_ADDRESS,
|
||||||
PAGE_SIZE*4, B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA, REGION_PRIVATE_MAP, "/boot/kernel", 0);
|
B_PAGE_SIZE*4, B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA, REGION_PRIVATE_MAP, "/boot/kernel", 0);
|
||||||
|
|
||||||
err = memcmp(ptr, ptr2, PAGE_SIZE);
|
err = memcmp(ptr, ptr2, B_PAGE_SIZE);
|
||||||
if(err)
|
if(err)
|
||||||
panic("vm_test 9: two mappings are different\n");
|
panic("vm_test 9: two mappings are different\n");
|
||||||
|
|
||||||
@@ -323,23 +323,23 @@ vm_test(void)
|
|||||||
|
|
||||||
memset(ptr2, 0xaa, 4);
|
memset(ptr2, 0xaa, 4);
|
||||||
|
|
||||||
err = memcmp(ptr, ptr2, PAGE_SIZE);
|
err = memcmp(ptr, ptr2, B_PAGE_SIZE);
|
||||||
if(!err)
|
if(!err)
|
||||||
panic("vm_test 9: two mappings still identical\n");
|
panic("vm_test 9: two mappings still identical\n");
|
||||||
|
|
||||||
dprintf("vm_test 9: modifying private mapping in section that hasn't been touched, should be different\n");
|
dprintf("vm_test 9: modifying private mapping in section that hasn't been touched, should be different\n");
|
||||||
|
|
||||||
memset((char *)ptr2 + PAGE_SIZE, 0xaa, 4);
|
memset((char *)ptr2 + B_PAGE_SIZE, 0xaa, 4);
|
||||||
|
|
||||||
err = memcmp((char *)ptr + PAGE_SIZE, (char *)ptr2 + PAGE_SIZE, PAGE_SIZE);
|
err = memcmp((char *)ptr + B_PAGE_SIZE, (char *)ptr2 + B_PAGE_SIZE, B_PAGE_SIZE);
|
||||||
if(!err)
|
if(!err)
|
||||||
panic("vm_test 9: two mappings still identical\n");
|
panic("vm_test 9: two mappings still identical\n");
|
||||||
|
|
||||||
dprintf("vm_test 9: modifying non-private mapping in section that hasn't been touched\n");
|
dprintf("vm_test 9: modifying non-private mapping in section that hasn't been touched\n");
|
||||||
|
|
||||||
memset((char *)ptr + PAGE_SIZE*2, 0xaa, 4);
|
memset((char *)ptr + B_PAGE_SIZE*2, 0xaa, 4);
|
||||||
|
|
||||||
err = memcmp((char *)ptr + PAGE_SIZE*2, (char *)ptr2 + PAGE_SIZE*2, PAGE_SIZE);
|
err = memcmp((char *)ptr + B_PAGE_SIZE*2, (char *)ptr2 + B_PAGE_SIZE*2, B_PAGE_SIZE);
|
||||||
if(err)
|
if(err)
|
||||||
panic("vm_test 9: two mappings are different\n");
|
panic("vm_test 9: two mappings are different\n");
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user