2 ** Copyright 2001-2002, Travis Geiselbrecht. All rights reserved.
3 ** Distributed under the terms of the NewOS License.
5 #include <kernel/kernel.h>
7 #include <kernel/vm_priv.h>
8 #include <kernel/heap.h>
9 #include <kernel/debug.h>
10 #include <kernel/lock.h>
11 #include <kernel/vm_store_null.h>
12 #include <kernel/vfs.h>
13 #include <newos/errors.h>
15 static void null_destroy(struct vm_store
*store
)
18 VERIFY_VM_STORE(store
);
23 static off_t
null_commit(struct vm_store
*store
, off_t size
)
25 VERIFY_VM_STORE(store
);
26 store
->committed_size
= size
;
30 static int null_has_page(struct vm_store
*store
, off_t offset
)
32 VERIFY_VM_STORE(store
);
33 return 1; // we always have the page, man
36 static ssize_t
null_read(struct vm_store
*store
, off_t offset
, iovecs
*vecs
)
38 VERIFY_VM_STORE(store
);
42 static ssize_t
null_write(struct vm_store
*store
, off_t offset
, iovecs
*vecs
)
44 VERIFY_VM_STORE(store
);
48 static int null_fault(struct vm_store
*store
, struct vm_address_space
*aspace
, off_t offset
)
50 VERIFY_VM_STORE(store
);
51 /* we can't fault on this region, that's pretty much the point of the null store object */
52 return ERR_VM_PF_FATAL
;
55 static vm_store_ops null_ops
= {
66 vm_store
*vm_store_create_null(void)
70 store
= kmalloc(sizeof(vm_store
));
75 store
->magic
= VM_STORE_MAGIC
;
76 store
->ops
= &null_ops
;
79 store
->committed_size
= 0;