When the need for physical to virtual mapping arises because of emulating IO

reads or writes for old style drivers, map the physical memory at once. Since
USB is pretty much the only one affected and there small reads/writes are
exponentially slower, the performance gain of the burst transfer far outweighs
the additional overhead of the mapping. Still this could be further optimized
and will eventually be superseeded by also providing a physical memory API in
USB. For now it should bring back USB reads to an acceptable level. Writes are
still page wise though because of how writing back memory works in general.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33503 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Michael Lotz
2009-10-10 19:55:13 +00:00
parent 0855dececa
commit f3bd145c09
+18
View File
@@ -89,6 +89,24 @@ public:
addr_t buffer = (addr_t)_buffer;
size_t length = *_length;
if (length > B_PAGE_SIZE) {
// try to not split up the request if possible
// TODO: map with less overhead! pre-reserved address space
// could be used as a scratch space for example, directly mapping
// pages into that instead of creating new areas for each request
void* virtualAddress;
area_id mapArea = map_physical_memory("physical io request map",
(void*)buffer, length, B_ANY_ADDRESS, B_KERNEL_READ_AREA
| B_KERNEL_WRITE_AREA, &virtualAddress);
if (mapArea >= 0) {
status_t result = InternalIO(offset, virtualAddress, _length);
delete_area(mapArea);
return result;
}
// otherwise we fall back to page wise mapping
}
while (length > 0) {
addr_t pageOffset = buffer % B_PAGE_SIZE;
addr_t virtualAddress;