lock_memory() now at least makes sure that the memory range is mapped in.
It's a bit hackish due to the iospace area, and it also might not work perfectly in all situations, but it does fulfill the current needs. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10445 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
+27
-4
@@ -2575,11 +2575,34 @@ user_memset(void *s, char c, size_t count)
|
||||
|
||||
|
||||
long
|
||||
lock_memory(void *buffer, ulong numBytes, ulong flags)
|
||||
lock_memory(void *address, ulong numBytes, ulong flags)
|
||||
{
|
||||
// The NewOS VM currently doesn't support locking - dunno if we'll
|
||||
// ever change this, but if, we should definitely implement these
|
||||
// functions :-)
|
||||
addr_t base = (addr_t)address;
|
||||
addr_t end = base + numBytes;
|
||||
bool isUser = IS_USER_ADDRESS(address);
|
||||
|
||||
// ToDo: Our VM currently doesn't support locking, this function
|
||||
// will now at least make sure that the memory is paged in, but
|
||||
// that's about it.
|
||||
// Nevertheless, it must be implemented as soon as we're able to
|
||||
// swap pages out of memory.
|
||||
|
||||
// ToDo: this is a hack, too; the iospace area is a null region and
|
||||
// officially cannot be written to or read; ie. vm_soft_fault() will
|
||||
// fail there. Furthermore, this is x86 specific as well.
|
||||
#define IOSPACE_SIZE (256 * 1024 * 1024)
|
||||
if (base >= KERNEL_BASE + IOSPACE_SIZE && base + numBytes < KERNEL_BASE + 2 * IOSPACE_SIZE)
|
||||
return B_OK;
|
||||
|
||||
for (; base < end; base += B_PAGE_SIZE) {
|
||||
status_t status = vm_soft_fault(base, (flags & B_READ_DEVICE) != 0, isUser);
|
||||
if (status != B_OK) {
|
||||
dprintf("lock_memory(address = %p, numBytes = %lu, flags = %lu) failed: %s\n",
|
||||
address, numBytes, flags, strerror(status));
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user