From 26de720c84b1371252eff50f164e6d954e6c44bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Sat, 4 Sep 2004 17:41:42 +0000 Subject: [PATCH] The VM store interface has changed to better match the one of the device interface. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@8848 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kernel/core/cache/vnode_store.cpp | 16 ++++++++-------- src/kernel/core/vm/vm.c | 15 +++++++-------- src/kernel/core/vm/vm_store_anonymous_noswap.c | 12 ++++++------ src/kernel/core/vm/vm_store_device.c | 12 ++++++------ src/kernel/core/vm/vm_store_null.c | 12 ++++++------ 5 files changed, 33 insertions(+), 34 deletions(-) diff --git a/src/kernel/core/cache/vnode_store.cpp b/src/kernel/core/cache/vnode_store.cpp index f1075721af..24f8c8bab7 100644 --- a/src/kernel/core/cache/vnode_store.cpp +++ b/src/kernel/core/cache/vnode_store.cpp @@ -35,30 +35,30 @@ store_commit(struct vm_store *_store, off_t size) } -static int +static bool store_has_page(struct vm_store *_store, off_t offset) { // We always pretend to have the page - even if it's beyond the size of // the file. The read function will only cut down the size of the read, // it won't fail because of that. - return 1; + return true; } -static ssize_t -store_read(struct vm_store *_store, off_t offset, iovecs *vecs) +static status_t +store_read(struct vm_store *_store, off_t offset, const iovec *vecs, size_t count, size_t *_numBytes) { vnode_store *store = (vnode_store *)_store; - return vfs_read_page(store->vnode, vecs, offset); + return vfs_read_pages(store->vnode, offset, vecs, count, _numBytes); // ToDo: the file system must currently clear out the remainder of the last page... } -static ssize_t -store_write(struct vm_store *_store, off_t offset, iovecs *vecs) +static status_t +store_write(struct vm_store *_store, off_t offset, const iovec *vecs, size_t count, size_t *_numBytes) { vnode_store *store = (vnode_store *)_store; - return vfs_write_page(store->vnode, vecs, offset); + return vfs_write_pages(store->vnode, offset, vecs, count, _numBytes); } diff --git a/src/kernel/core/vm/vm.c b/src/kernel/core/vm/vm.c index 990f5607ba..f537725201 100755 --- a/src/kernel/core/vm/vm.c +++ b/src/kernel/core/vm/vm.c @@ -2326,21 +2326,20 @@ vm_soft_fault(addr_t originalAddress, bool isWrite, bool isUser) // see if the vm_store has it if (cache_ref->cache->store->ops->has_page != NULL && cache_ref->cache->store->ops->has_page(cache_ref->cache->store, cache_offset)) { - IOVECS(vecs, 1); + size_t bytesRead; + iovec vec; + + vec.iov_len = bytesRead = B_PAGE_SIZE; TRACEPFAULT; mutex_unlock(&cache_ref->lock); - vecs->num = 1; - vecs->total_len = PAGE_SIZE; - vecs->vec[0].iov_len = PAGE_SIZE; - page = vm_page_allocate_page(PAGE_STATE_FREE); - (*aspace->translation_map.ops->get_physical_page)(page->ppn * PAGE_SIZE, (addr_t *)&vecs->vec[0].iov_base, PHYSICAL_PAGE_CAN_WAIT); + aspace->translation_map.ops->get_physical_page(page->ppn * PAGE_SIZE, (addr_t *)&vec.iov_base, PHYSICAL_PAGE_CAN_WAIT); // ToDo: handle errors here - err = cache_ref->cache->store->ops->read(cache_ref->cache->store, cache_offset, vecs); - (*aspace->translation_map.ops->put_physical_page)((addr_t)vecs->vec[0].iov_base); + err = cache_ref->cache->store->ops->read(cache_ref->cache->store, cache_offset, &vec, 1, &bytesRead); + aspace->translation_map.ops->put_physical_page((addr_t)vec.iov_base); mutex_lock(&cache_ref->lock); diff --git a/src/kernel/core/vm/vm_store_anonymous_noswap.c b/src/kernel/core/vm/vm_store_anonymous_noswap.c index c313bef293..413feda6b3 100755 --- a/src/kernel/core/vm/vm_store_anonymous_noswap.c +++ b/src/kernel/core/vm/vm_store_anonymous_noswap.c @@ -38,23 +38,23 @@ anonymous_commit(struct vm_store *store, off_t size) } -static int +static bool anonymous_has_page(struct vm_store *store, off_t offset) { - return 0; + return false; } -static ssize_t -anonymous_read(struct vm_store *store, off_t offset, iovecs *vecs) +static status_t +anonymous_read(struct vm_store *store, off_t offset, const iovec *vecs, size_t count, size_t *_numBytes) { panic("anonymous_store: read called. Invalid!\n"); return B_ERROR; } -static ssize_t -anonymous_write(struct vm_store *store, off_t offset, iovecs *vecs) +static status_t +anonymous_write(struct vm_store *store, off_t offset, const iovec *vecs, size_t count, size_t *_numBytes) { // no place to write, this will cause the page daemon to skip this store return 0; diff --git a/src/kernel/core/vm/vm_store_device.c b/src/kernel/core/vm/vm_store_device.c index 601a6b2edd..01bb96d408 100755 --- a/src/kernel/core/vm/vm_store_device.c +++ b/src/kernel/core/vm/vm_store_device.c @@ -31,24 +31,24 @@ device_commit(struct vm_store *store, off_t size) } -static int +static bool device_has_page(struct vm_store *store, off_t offset) { // this should never be called - return 0; + return false; } -static ssize_t -device_read(struct vm_store *store, off_t offset, iovecs *vecs) +static status_t +device_read(struct vm_store *store, off_t offset, const iovec *vecs, size_t count, size_t *_numBytes) { panic("device_store: read called. Invalid!\n"); return B_ERROR; } -static ssize_t -device_write(struct vm_store *store, off_t offset, iovecs *vecs) +static status_t +device_write(struct vm_store *store, off_t offset, const iovec *vecs, size_t count, size_t *_numBytes) { // no place to write, this will cause the page daemon to skip this store return 0; diff --git a/src/kernel/core/vm/vm_store_null.c b/src/kernel/core/vm/vm_store_null.c index 2e09a33e03..b69facb097 100755 --- a/src/kernel/core/vm/vm_store_null.c +++ b/src/kernel/core/vm/vm_store_null.c @@ -25,22 +25,22 @@ null_commit(struct vm_store *store, off_t size) } -static int +static bool null_has_page(struct vm_store *store, off_t offset) { - return 1; // we always have the page, man + return true; // we always have the page, man } -static ssize_t -null_read(struct vm_store *store, off_t offset, iovecs *vecs) +static status_t +null_read(struct vm_store *store, off_t offset, const iovec *vecs, size_t count, size_t *_numBytes) { return -1; } -static ssize_t -null_write(struct vm_store *store, off_t offset, iovecs *vecs) +static status_t +null_write(struct vm_store *store, off_t offset, const iovec *vecs, size_t count, size_t *_numBytes) { return -1; }