* Replaced the vm_get_physical_page() "flags"

PHYSICAL_PAGE_{NO,CAN}_WAIT into an actual flag
  PHYSICAL_PAGE_DONT_WAIT.
* Pass the flags through to the chunk mapper callback.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27979 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold
2008-10-11 20:55:32 +00:00
parent 9fc81c5394
commit 1b6eff280f
14 changed files with 102 additions and 99 deletions
+1 -2
View File
@@ -49,8 +49,7 @@
// flags for vm_get_physical_page()
enum {
PHYSICAL_PAGE_NO_WAIT = 0,
PHYSICAL_PAGE_CAN_WAIT,
PHYSICAL_PAGE_DONT_WAIT = 0x01
};
// mapping argument for several internal VM functions
@@ -92,8 +92,8 @@ copy_sg_data(scsi_ccb *request, uint offset, uint allocationLength,
bytes = min(size, requestSize);
bytes = min(bytes, sgList->size);
if (vm_get_physical_page((addr_t)sgList->address, &virtualAddress,
PHYSICAL_PAGE_CAN_WAIT) != B_OK)
if (vm_get_physical_page((addr_t)sgList->address, &virtualAddress, 0)
!= B_OK)
return false;
SHOW_FLOW(4, "buffer=%p, virt_addr=%p, bytes=%d, to_buffer=%d",
+1 -2
View File
@@ -150,8 +150,7 @@ transfer_PIO_physcont(ide_device_info *device, addr_t physicalAddress,
SHOW_FLOW(4, "Transmitting to/from physical address %lx, %d bytes left",
physicalAddress, length);
if (vm_get_physical_page(physicalAddress, &virtualAddress,
PHYSICAL_PAGE_CAN_WAIT) != B_OK) {
if (vm_get_physical_page(physicalAddress, &virtualAddress, 0) != B_OK) {
// ouch: this should never ever happen
set_sense(device, SCSIS_KEY_HARDWARE_ERROR, SCSIS_ASC_INTERNAL_FAILURE);
return B_ERROR;
@@ -119,8 +119,8 @@ scsi_copy_dma_buffer(scsi_ccb *request, uint32 size, bool to_buffer)
bytes = min( size, sg_list->size );
if (vm_get_physical_page((addr_t)sg_list->address, &virtualAddress,
PHYSICAL_PAGE_CAN_WAIT) != B_OK)
if (vm_get_physical_page((addr_t)sg_list->address, &virtualAddress, 0)
!= B_OK)
return false;
if (to_buffer)
@@ -464,8 +464,8 @@ copy_sg_data(scsi_ccb *request, uint offset, uint allocation_length,
bytes = min(size, req_size);
bytes = min(bytes, sg_list->size);
if (vm_get_physical_page((addr_t)sg_list->address, (void *)&virtualAddress,
PHYSICAL_PAGE_CAN_WAIT) != B_OK)
if (vm_get_physical_page((addr_t)sg_list->address,
(void*)&virtualAddress, 0) != B_OK)
return false;
SHOW_FLOW(0, "buffer = %p, virt_addr = %#lx, bytes = %lu, to_buffer = %d",
+2 -2
View File
@@ -93,8 +93,8 @@ sg_memcpy(const physical_entry *sgTable, int sgCount, const void *data,
size_t size = min_c(dataSize, sgTable[i].size);
addr_t address;
if (vm_get_physical_page((addr_t)sgTable[i].address, &address,
PHYSICAL_PAGE_CAN_WAIT) < B_OK)
if (vm_get_physical_page((addr_t)sgTable[i].address, &address, 0)
< B_OK)
return B_ERROR;
TRACE("sg_memcpy phyAddr %p, addr %p, size %lu\n", sgTable[i].address, (void *)address, size);
@@ -90,7 +90,8 @@ restart:
break;
}
sMapIOSpaceChunk(paddr_desc[index].va, index * sIOSpaceChunkSize);
sMapIOSpaceChunk(paddr_desc[index].va, index * sIOSpaceChunkSize,
flags);
mutex_unlock(&sMutex);
return B_OK;
@@ -99,7 +100,7 @@ restart:
// replace an earlier mapping
if (queue_peek(&mapped_paddr_lru) == NULL) {
// no free slots available
if (flags == PHYSICAL_PAGE_NO_WAIT) {
if ((flags & PHYSICAL_PAGE_DONT_WAIT) != 0) {
// put back to the caller and let them handle this
mutex_unlock(&sMutex);
return B_NO_MEMORY;
@@ -123,7 +124,7 @@ restart:
virtual_pmappings[(*va - sIOSpaceBase) / sIOSpaceChunkSize]
= paddr_desc + index;
sMapIOSpaceChunk(paddr_desc[index].va, index * sIOSpaceChunkSize);
sMapIOSpaceChunk(paddr_desc[index].va, index * sIOSpaceChunkSize, flags);
mutex_unlock(&sMutex);
return B_OK;
@@ -12,7 +12,8 @@
extern "C" {
#endif
typedef status_t (*generic_map_iospace_chunk_func)(addr_t, addr_t);
typedef status_t (*generic_map_iospace_chunk_func)(addr_t virtualAddress,
addr_t physicalAddress, uint32 flags);
status_t generic_get_physical_page(addr_t pa, addr_t *va, uint32 flags);
status_t generic_put_physical_page(addr_t va);
@@ -571,7 +571,7 @@ map_tmap(vm_translation_map *map, addr_t va, addr_t pa, uint32 attributes)
// now, fill in the pentry
do {
err = get_physical_page_tmap(PRE_TO_PA(pr[rindex]),
&pd_pg, PHYSICAL_PAGE_NO_WAIT);
&pd_pg, PHYSICAL_PAGE_DONT_WAIT);
} while (err < 0);
pd = (page_directory_entry *)pd_pg;
// we want the table at rindex, not at rindex%(tbl/page)
@@ -615,7 +615,7 @@ map_tmap(vm_translation_map *map, addr_t va, addr_t pa, uint32 attributes)
// now, fill in the pentry
do {
err = get_physical_page_tmap(PDE_TO_PA(pd[dindex]),
&pt_pg, PHYSICAL_PAGE_NO_WAIT);
&pt_pg, PHYSICAL_PAGE_DONT_WAIT);
} while (err < 0);
pt = (page_table_entry *)pt_pg;
// we want the table at rindex, not at rindex%(tbl/page)
@@ -668,7 +668,7 @@ restart:
do {
status = get_physical_page_tmap(PRE_TO_PA(pr[index]),
&pd_pg, PHYSICAL_PAGE_NO_WAIT);
&pd_pg, PHYSICAL_PAGE_DONT_WAIT);
} while (status < B_OK);
pd = (page_directory_entry *)pd_pg;
// we want the table at rindex, not at rindex%(tbl/page)
@@ -684,7 +684,7 @@ restart:
do {
status = get_physical_page_tmap(PDE_TO_PA(pd[index]),
&pt_pg, PHYSICAL_PAGE_NO_WAIT);
&pt_pg, PHYSICAL_PAGE_DONT_WAIT);
} while (status < B_OK);
pt = (page_table_entry *)pt_pg;
// we want the table at rindex, not at rindex%(tbl/page)
@@ -795,7 +795,7 @@ query_tmap(vm_translation_map *map, addr_t va, addr_t *_physical, uint32 *_flags
do {
status = get_physical_page_tmap(PRE_TO_PA(pr[index]),
&pd_pg, PHYSICAL_PAGE_NO_WAIT);
&pd_pg, PHYSICAL_PAGE_DONT_WAIT);
} while (status < B_OK);
pd = (page_directory_entry *)pd_pg;
// we want the table at rindex, not at rindex%(tbl/page)
@@ -811,7 +811,7 @@ query_tmap(vm_translation_map *map, addr_t va, addr_t *_physical, uint32 *_flags
do {
status = get_physical_page_tmap(PDE_TO_PA(pd[index]),
&pt_pg, PHYSICAL_PAGE_NO_WAIT);
&pt_pg, PHYSICAL_PAGE_DONT_WAIT);
} while (status < B_OK);
pt = (page_table_entry *)pt_pg;
// we want the table at rindex, not at rindex%(tbl/page)
@@ -825,7 +825,7 @@ query_tmap(vm_translation_map *map, addr_t va, addr_t *_physical, uint32 *_flags
pi_pg = pt_pg;
do {
status = get_physical_page_tmap(PIE_TO_PA(pi[index]),
&pt_pg, PHYSICAL_PAGE_NO_WAIT);
&pt_pg, PHYSICAL_PAGE_DONT_WAIT);
} while (status < B_OK);
pt = (page_table_entry *)pt_pg;
// add offset from start of page
@@ -890,7 +890,7 @@ restart:
do {
status = get_physical_page_tmap(PRE_TO_PA(pr[index]),
&pd_pg, PHYSICAL_PAGE_NO_WAIT);
&pd_pg, PHYSICAL_PAGE_DONT_WAIT);
} while (status < B_OK);
pd = (page_directory_entry *)pd_pg;
// we want the table at rindex, not at rindex%(tbl/page)
@@ -906,7 +906,7 @@ restart:
do {
status = get_physical_page_tmap(PDE_TO_PA(pd[index]),
&pt_pg, PHYSICAL_PAGE_NO_WAIT);
&pt_pg, PHYSICAL_PAGE_DONT_WAIT);
} while (status < B_OK);
pt = (page_table_entry *)pt_pg;
// we want the table at rindex, not at rindex%(tbl/page)
@@ -962,7 +962,7 @@ clear_flags_tmap(vm_translation_map *map, addr_t va, uint32 flags)
do {
status = get_physical_page_tmap(PRE_TO_PA(pr[index]),
&pd_pg, PHYSICAL_PAGE_NO_WAIT);
&pd_pg, PHYSICAL_PAGE_DONT_WAIT);
} while (status < B_OK);
pd = (page_directory_entry *)pd_pg;
// we want the table at rindex, not at rindex%(tbl/page)
@@ -978,7 +978,7 @@ clear_flags_tmap(vm_translation_map *map, addr_t va, uint32 flags)
do {
status = get_physical_page_tmap(PDE_TO_PA(pd[index]),
&pt_pg, PHYSICAL_PAGE_NO_WAIT);
&pt_pg, PHYSICAL_PAGE_DONT_WAIT);
} while (status < B_OK);
pt = (page_table_entry *)pt_pg;
// we want the table at rindex, not at rindex%(tbl/page)
@@ -992,7 +992,7 @@ clear_flags_tmap(vm_translation_map *map, addr_t va, uint32 flags)
pi_pg = pt_pg;
do {
status = get_physical_page_tmap(PIE_TO_PA(pi[index]),
&pt_pg, PHYSICAL_PAGE_NO_WAIT);
&pt_pg, PHYSICAL_PAGE_DONT_WAIT);
} while (status < B_OK);
pt = (page_table_entry *)pt_pg;
// add offset from start of page
@@ -1059,7 +1059,7 @@ flush_tmap(vm_translation_map *map)
static status_t
map_iospace_chunk(addr_t va, addr_t pa)
map_iospace_chunk(addr_t va, addr_t pa, uint32 flags)
{
int i;
page_table_entry *pt;
@@ -1354,13 +1354,13 @@ m68k_vm_translation_map_init_post_area(kernel_args *args)
physicalPageDir = PRE_TO_PA(sKernelVirtualPageRoot[index]);
get_physical_page_tmap(physicalPageDir,
(addr_t *)&pageDirEntry, PHYSICAL_PAGE_NO_WAIT);
(addr_t *)&pageDirEntry, PHYSICAL_PAGE_DONT_WAIT);
index = VADDR_TO_PDENT((addr_t)&sQueryDesc);
physicalPageTable = PDE_TO_PA(pageDirEntry[index]);
get_physical_page_tmap(physicalPageTable,
(addr_t *)&pageTableEntry, PHYSICAL_PAGE_NO_WAIT);
(addr_t *)&pageTableEntry, PHYSICAL_PAGE_DONT_WAIT);
index = VADDR_TO_PTENT((addr_t)&sQueryDesc);
@@ -1380,13 +1380,13 @@ m68k_vm_translation_map_init_post_area(kernel_args *args)
physicalPageDir = PRE_TO_PA(sKernelVirtualPageRoot[index]);
get_physical_page_tmap(physicalPageDir,
(addr_t *)&pageDirEntry, PHYSICAL_PAGE_NO_WAIT);
(addr_t *)&pageDirEntry, PHYSICAL_PAGE_DONT_WAIT);
index = VADDR_TO_PDENT(queryPage);
physicalPageTable = PDE_TO_PA(pageDirEntry[index]);
get_physical_page_tmap(physicalPageTable,
(addr_t *)&pageTableEntry, PHYSICAL_PAGE_NO_WAIT);
(addr_t *)&pageTableEntry, PHYSICAL_PAGE_DONT_WAIT);
index = VADDR_TO_PTENT(queryPage);
@@ -374,7 +374,7 @@ query_tmap(vm_translation_map *map, addr_t va, addr_t *_outPhysical, uint32 *_ou
static status_t
map_iospace_chunk(addr_t va, addr_t pa)
map_iospace_chunk(addr_t va, addr_t pa, uint32 flags)
{
pa &= ~(B_PAGE_SIZE - 1); // make sure it's page aligned
va &= ~(B_PAGE_SIZE - 1); // make sure it's page aligned
@@ -379,7 +379,7 @@ map_tmap(vm_translation_map *map, addr_t va, addr_t pa, uint32 attributes)
// now, fill in the pentry
do {
err = get_physical_page_tmap(ADDR_REVERSE_SHIFT(pd[index].addr),
(addr_t *)&pt, PHYSICAL_PAGE_NO_WAIT);
(addr_t *)&pt, PHYSICAL_PAGE_DONT_WAIT);
} while (err < 0);
index = VADDR_TO_PTENT(va);
@@ -425,7 +425,7 @@ restart:
do {
status = get_physical_page_tmap(ADDR_REVERSE_SHIFT(pd[index].addr),
(addr_t *)&pt, PHYSICAL_PAGE_NO_WAIT);
(addr_t *)&pt, PHYSICAL_PAGE_DONT_WAIT);
} while (status < B_OK);
for (index = VADDR_TO_PTENT(start); (index < 1024) && (start < end);
@@ -517,7 +517,7 @@ query_tmap(vm_translation_map *map, addr_t va, addr_t *_physical, uint32 *_flags
do {
status = get_physical_page_tmap(ADDR_REVERSE_SHIFT(pd[index].addr),
(addr_t *)&pt, PHYSICAL_PAGE_NO_WAIT);
(addr_t *)&pt, PHYSICAL_PAGE_DONT_WAIT);
} while (status < B_OK);
index = VADDR_TO_PTENT(va);
@@ -573,7 +573,7 @@ restart:
do {
status = get_physical_page_tmap(ADDR_REVERSE_SHIFT(pd[index].addr),
(addr_t *)&pt, PHYSICAL_PAGE_NO_WAIT);
(addr_t *)&pt, PHYSICAL_PAGE_DONT_WAIT);
} while (status < B_OK);
for (index = VADDR_TO_PTENT(start); index < 1024 && start < end; index++, start += B_PAGE_SIZE) {
@@ -619,7 +619,7 @@ clear_flags_tmap(vm_translation_map *map, addr_t va, uint32 flags)
do {
status = get_physical_page_tmap(ADDR_REVERSE_SHIFT(pd[index].addr),
(addr_t *)&pt, PHYSICAL_PAGE_NO_WAIT);
(addr_t *)&pt, PHYSICAL_PAGE_DONT_WAIT);
} while (status < B_OK);
index = VADDR_TO_PTENT(va);
@@ -706,7 +706,7 @@ flush_tmap(vm_translation_map *map)
static status_t
map_iospace_chunk(addr_t va, addr_t pa)
map_iospace_chunk(addr_t va, addr_t pa, uint32 flags)
{
int i;
page_table_entry *pt;
@@ -979,7 +979,7 @@ arch_vm_translation_map_init_post_area(kernel_args *args)
physicalPageTable = ADDR_REVERSE_SHIFT(sKernelVirtualPageDirectory[index].addr);
get_physical_page_tmap(physicalPageTable,
(addr_t *)&pageTableEntry, PHYSICAL_PAGE_NO_WAIT);
(addr_t *)&pageTableEntry, PHYSICAL_PAGE_DONT_WAIT);
index = VADDR_TO_PTENT((addr_t)sQueryPageTable);
put_page_table_entry_in_pgtable(&pageTableEntry[index], physicalPageTable,
+3 -3
View File
@@ -235,7 +235,7 @@ read_into_cache(file_cache_ref *ref, void *cookie, off_t offset,
addr_t virtualAddress;
if (vm_get_physical_page(
pages[i]->physical_page_number * B_PAGE_SIZE,
&virtualAddress, PHYSICAL_PAGE_CAN_WAIT) < B_OK) {
&virtualAddress, 0) < B_OK) {
panic("could not get physical page");
}
@@ -334,7 +334,7 @@ write_to_cache(file_cache_ref *ref, void *cookie, off_t offset,
addr_t virtualAddress;
vm_get_physical_page(page->physical_page_number * B_PAGE_SIZE,
&virtualAddress, PHYSICAL_PAGE_CAN_WAIT);
&virtualAddress, 0);
add_to_iovec(vecs, vecCount, MAX_IO_VECS, virtualAddress, B_PAGE_SIZE);
// ToDo: check if the array is large enough!
@@ -649,7 +649,7 @@ cache_io(void *_cacheRef, void *cookie, off_t offset, addr_t buffer,
addr_t virtualAddress;
vm_get_physical_page(page->physical_page_number * B_PAGE_SIZE,
&virtualAddress, PHYSICAL_PAGE_CAN_WAIT);
&virtualAddress, 0);
// copy the contents of the page already in memory
if (doWrite) {
+8 -5
View File
@@ -3107,7 +3107,8 @@ display_mem(int argc, char **argv)
gKernelStartup = true;
// vm_get_physical_page() needs to lock...
if (vm_get_physical_page(address, &copyAddress, PHYSICAL_PAGE_NO_WAIT) != B_OK) {
if (vm_get_physical_page(address, &copyAddress, PHYSICAL_PAGE_DONT_WAIT)
!= B_OK) {
kprintf("getting the hardware page failed.");
gKernelStartup = false;
return 0;
@@ -4624,11 +4625,13 @@ if (cacheOffset == 0x12000)
// try to get a mapping for the src and dest page so we can copy it
for (;;) {
map->ops->get_physical_page(sourcePage->physical_page_number * B_PAGE_SIZE,
(addr_t *)&source, PHYSICAL_PAGE_CAN_WAIT);
map->ops->get_physical_page(
sourcePage->physical_page_number * B_PAGE_SIZE,
(addr_t *)&source, 0);
if (map->ops->get_physical_page(page->physical_page_number * B_PAGE_SIZE,
(addr_t *)&dest, PHYSICAL_PAGE_NO_WAIT) == B_OK)
if (map->ops->get_physical_page(
page->physical_page_number * B_PAGE_SIZE,
(addr_t *)&dest, PHYSICAL_PAGE_DONT_WAIT) == B_OK)
break;
// it couldn't map the second one, so sleep and retry
+1 -1
View File
@@ -817,7 +817,7 @@ clear_page(struct vm_page *page)
{
addr_t virtualAddress;
vm_get_physical_page(page->physical_page_number << PAGE_SHIFT,
&virtualAddress, PHYSICAL_PAGE_CAN_WAIT);
&virtualAddress, 0);
memset((void *)virtualAddress, 0, B_PAGE_SIZE);