* Replaced map_mainmemory() functions with calls to vm_get_physical_page().
* Minor cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16950 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
/*
|
||||
** Copyright 2002/03, Thomas Kurschel. All rights reserved.
|
||||
** Distributed under the terms of the OpenBeOS License.
|
||||
*/
|
||||
* Copyright 2004-2006, Axel Dörfler, [email protected]. All rights reserved.
|
||||
* Copyright 2002/03, Thomas Kurschel. All rights reserved.
|
||||
*
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
/*
|
||||
Functions that are missing in kernel.
|
||||
@@ -26,20 +28,4 @@ status_t get_iovec_memory_map(
|
||||
size_t *mapped_len // actual number of bytes described by map
|
||||
);
|
||||
|
||||
// map main memory into virtual address space
|
||||
status_t map_mainmemory(
|
||||
addr_t physical_addr, // physical address to map
|
||||
void **virtual_addr // receives corresponding virtual address
|
||||
);
|
||||
|
||||
// unmap main memory from virtual address space
|
||||
status_t unmap_mainmemory(
|
||||
void *virtual_addr // virtual address to release
|
||||
);
|
||||
|
||||
|
||||
// this should be moved to SupportDefs.h
|
||||
int32 atomic_exchange(vint32 *value, int32 newValue);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
** Copyright 2002/03, Thomas Kurschel. All rights reserved.
|
||||
** Distributed under the terms of the OpenBeOS License.
|
||||
*/
|
||||
* Copyright 2004-2006, Axel Dörfler, [email protected]. All rights reserved.
|
||||
* Copyright 2002/03, Thomas Kurschel. All rights reserved.
|
||||
*
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
/*
|
||||
Part of Open SCSI bus manager
|
||||
|
||||
DMA buffer handling.
|
||||
|
||||
If the peripheral driver hasn't made sure that the data of a request
|
||||
@@ -26,6 +26,9 @@
|
||||
|
||||
#include "scsi_internal.h"
|
||||
#include "KernelExport_ext.h"
|
||||
|
||||
#include <vm.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
|
||||
@@ -111,20 +114,21 @@ scsi_copy_dma_buffer(scsi_ccb *request, uint32 size, bool to_buffer)
|
||||
// was allocated in kernel and is thus visible even if the thread
|
||||
// was changed
|
||||
for (; size > 0 && num_vecs > 0; ++sg_list, --num_vecs) {
|
||||
addr_t virtualAddress;
|
||||
size_t bytes;
|
||||
void *virt_addr;
|
||||
|
||||
bytes = min( size, sg_list->size );
|
||||
|
||||
if (map_mainmemory((addr_t)sg_list->address, &virt_addr) != B_OK)
|
||||
if (vm_get_physical_page((addr_t)sg_list->address, &virtualAddress,
|
||||
PHYSICAL_PAGE_CAN_WAIT) != B_OK)
|
||||
return false;
|
||||
|
||||
if (to_buffer)
|
||||
memcpy(buffer_data, virt_addr, bytes);
|
||||
memcpy(buffer_data, (void *)virtualAddress, bytes);
|
||||
else
|
||||
memcpy(virt_addr, buffer_data, bytes);
|
||||
memcpy((void *)virtualAddress, buffer_data, bytes);
|
||||
|
||||
unmap_mainmemory(virt_addr);
|
||||
vm_put_physical_page(virtualAddress);
|
||||
|
||||
buffer_data += bytes;
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
* Copyright 2004-2006, Axel Dörfler, [email protected]. All rights reserved.
|
||||
* Copyright 2002/03, Thomas Kurschel. All rights reserved.
|
||||
*
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
/*
|
||||
Part of Open SCSI bus manager
|
||||
|
||||
Emulation of SCSI commands that a device cannot handle.
|
||||
|
||||
Some SCSI devices don't support all SCSI commands, especially
|
||||
@@ -15,7 +15,9 @@
|
||||
|
||||
|
||||
#include "scsi_internal.h"
|
||||
#include "KernelExport_ext.h"
|
||||
|
||||
#include <vm.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
|
||||
@@ -469,21 +471,22 @@ copy_sg_data(scsi_ccb *request, uint offset, uint allocation_length,
|
||||
// copy one S/G entry at a time
|
||||
for (; size > 0 && req_size > 0 && sg_cnt > 0; ++sg_list, --sg_cnt) {
|
||||
size_t bytes;
|
||||
addr_t virt_addr;
|
||||
addr_t virtualAddress;
|
||||
|
||||
bytes = min(size, req_size);
|
||||
bytes = min(bytes, sg_list->size);
|
||||
|
||||
if (map_mainmemory((addr_t)sg_list->address, (void *)&virt_addr) != B_OK)
|
||||
if (vm_get_physical_page((addr_t)sg_list->address, (void *)&virtualAddress,
|
||||
PHYSICAL_PAGE_CAN_WAIT) != B_OK)
|
||||
return false;
|
||||
|
||||
SHOW_FLOW(0, "buffer = %p, virt_addr = %#lx, bytes = %lu, to_buffer = %d",
|
||||
buffer, virt_addr + offset, bytes, to_buffer);
|
||||
buffer, virtualAddress + offset, bytes, to_buffer);
|
||||
|
||||
if (to_buffer)
|
||||
memcpy(buffer, (void *)(virt_addr + offset), bytes);
|
||||
memcpy(buffer, (void *)(virtualAddress + offset), bytes);
|
||||
else
|
||||
memcpy((void *)(virt_addr + offset), buffer, bytes);
|
||||
memcpy((void *)(virtualAddress + offset), buffer, bytes);
|
||||
|
||||
#if 0
|
||||
{
|
||||
@@ -493,7 +496,7 @@ copy_sg_data(scsi_ccb *request, uint offset, uint allocation_length,
|
||||
char byte;
|
||||
|
||||
if (to_buffer)
|
||||
byte = ((char *)virt_addr)[offset + i];
|
||||
byte = ((char *)virtualAddress)[offset + i];
|
||||
else
|
||||
byte = ((char *)buffer)[i];
|
||||
|
||||
@@ -501,8 +504,8 @@ copy_sg_data(scsi_ccb *request, uint offset, uint allocation_length,
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
unmap_mainmemory((void *)virt_addr);
|
||||
|
||||
vm_put_physical_page(virtualAddress);
|
||||
|
||||
buffer = (char *)buffer + bytes;
|
||||
size -= bytes;
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
/*
|
||||
** Copyright 2002/03, Thomas Kurschel. All rights reserved.
|
||||
** Distributed under the terms of the OpenBeOS License.
|
||||
*/
|
||||
* Copyright 2004-2006, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
|
||||
* Copyright 2002/03, Thomas Kurschel. All rights reserved.
|
||||
*
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
/*
|
||||
VM helper functions.
|
||||
@@ -14,7 +16,6 @@
|
||||
#include "KernelExport_ext.h"
|
||||
#include "wrapper.h"
|
||||
|
||||
#include <vm.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
@@ -118,22 +119,3 @@ get_iovec_memory_map(iovec *vec, size_t vec_count, size_t vec_offset, size_t len
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
/** map main memory into virtual address space */
|
||||
|
||||
status_t
|
||||
map_mainmemory(addr_t physicalAddress, void **_virtualAddress)
|
||||
{
|
||||
return vm_get_physical_page(physicalAddress, (addr_t *)_virtualAddress, PHYSICAL_PAGE_CAN_WAIT);
|
||||
// ToDo: check if CAN_WAIT is correct
|
||||
}
|
||||
|
||||
|
||||
/** unmap main memory from virtual address space */
|
||||
|
||||
status_t
|
||||
unmap_mainmemory(void *virtualAddress)
|
||||
{
|
||||
return vm_put_physical_page((addr_t)virtualAddress);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user