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
This commit is contained in:
Axel Dörfler 2004-09-04 17:41:42 +00:00
parent c66a5d50b7
commit 26de720c84
5 changed files with 33 additions and 34 deletions

View File

@ -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);
}

View File

@ -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);

View File

@ -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;

View File

@ -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;

View File

@ -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;
}