+kern_return_t
+ubc_page_op(
+ struct vnode *vp,
+ off_t f_offset,
+ int ops,
+ ppnum_t *phys_entryp,
+ int *flagsp)
+{
+ memory_object_control_t control;
+
+ control = ubc_getobject(vp, UBC_FLAGS_NONE);
+ if (control == MEMORY_OBJECT_CONTROL_NULL)
+ return KERN_INVALID_ARGUMENT;
+
+ return (memory_object_page_op(control,
+ (memory_object_offset_t)f_offset,
+ ops,
+ phys_entryp,
+ flagsp));
+}
+
+__private_extern__ kern_return_t
+ubc_page_op_with_control(
+ memory_object_control_t control,
+ off_t f_offset,
+ int ops,
+ ppnum_t *phys_entryp,
+ int *flagsp)
+{
+ return (memory_object_page_op(control,
+ (memory_object_offset_t)f_offset,
+ ops,
+ phys_entryp,
+ flagsp));
+}
+
+kern_return_t
+ubc_range_op(
+ struct vnode *vp,
+ off_t f_offset_beg,
+ off_t f_offset_end,
+ int ops,
+ int *range)
+{
+ memory_object_control_t control;
+
+ control = ubc_getobject(vp, UBC_FLAGS_NONE);
+ if (control == MEMORY_OBJECT_CONTROL_NULL)
+ return KERN_INVALID_ARGUMENT;
+
+ return (memory_object_range_op(control,
+ (memory_object_offset_t)f_offset_beg,
+ (memory_object_offset_t)f_offset_end,
+ ops,
+ range));
+}
+
+kern_return_t
+ubc_create_upl(
+ struct vnode *vp,
+ off_t f_offset,
+ long bufsize,
+ upl_t *uplp,
+ upl_page_info_t **plp,
+ int uplflags)
+{
+ memory_object_control_t control;
+ int count;
+ int ubcflags;
+ off_t file_offset;
+ kern_return_t kr;
+
+ if (bufsize & 0xfff)
+ return KERN_INVALID_ARGUMENT;
+
+ if (uplflags & UPL_FOR_PAGEOUT) {
+ uplflags &= ~UPL_FOR_PAGEOUT;
+ ubcflags = UBC_FOR_PAGEOUT;
+ } else
+ ubcflags = UBC_FLAGS_NONE;
+
+ control = ubc_getobject(vp, ubcflags);
+ if (control == MEMORY_OBJECT_CONTROL_NULL)
+ return KERN_INVALID_ARGUMENT;
+
+ if (uplflags & UPL_WILL_BE_DUMPED) {
+ uplflags &= ~UPL_WILL_BE_DUMPED;
+ uplflags |= (UPL_NO_SYNC|UPL_SET_INTERNAL);
+ } else
+ uplflags |= (UPL_NO_SYNC|UPL_CLEAN_IN_PLACE|UPL_SET_INTERNAL);
+ count = 0;
+ kr = memory_object_upl_request(control, f_offset, bufsize,
+ uplp, NULL, &count, uplflags);
+ if (plp != NULL)
+ *plp = UPL_GET_INTERNAL_PAGE_LIST(*uplp);
+ return kr;
+}
+
+
+kern_return_t
+ubc_upl_map(
+ upl_t upl,
+ vm_offset_t *dst_addr)
+{
+ return (vm_upl_map(kernel_map, upl, dst_addr));
+}
+
+
+kern_return_t
+ubc_upl_unmap(
+ upl_t upl)
+{
+ return(vm_upl_unmap(kernel_map, upl));
+}
+
+kern_return_t
+ubc_upl_commit(
+ upl_t upl)
+{
+ upl_page_info_t *pl;
+ kern_return_t kr;
+
+ pl = UPL_GET_INTERNAL_PAGE_LIST(upl);
+ kr = upl_commit(upl, pl, MAX_UPL_TRANSFER);
+ upl_deallocate(upl);
+ return kr;
+}
+
+
+kern_return_t
+ubc_upl_commit_range(
+ upl_t upl,
+ vm_offset_t offset,
+ vm_size_t size,
+ int flags)
+{
+ upl_page_info_t *pl;
+ boolean_t empty;
+ kern_return_t kr;
+
+ if (flags & UPL_COMMIT_FREE_ON_EMPTY)
+ flags |= UPL_COMMIT_NOTIFY_EMPTY;
+
+ pl = UPL_GET_INTERNAL_PAGE_LIST(upl);
+
+ kr = upl_commit_range(upl, offset, size, flags,
+ pl, MAX_UPL_TRANSFER, &empty);
+
+ if((flags & UPL_COMMIT_FREE_ON_EMPTY) && empty)
+ upl_deallocate(upl);
+
+ return kr;
+}
+
+kern_return_t
+ubc_upl_abort_range(
+ upl_t upl,
+ vm_offset_t offset,
+ vm_size_t size,
+ int abort_flags)
+{
+ kern_return_t kr;
+ boolean_t empty = FALSE;
+
+ if (abort_flags & UPL_ABORT_FREE_ON_EMPTY)
+ abort_flags |= UPL_ABORT_NOTIFY_EMPTY;
+
+ kr = upl_abort_range(upl, offset, size, abort_flags, &empty);
+
+ if((abort_flags & UPL_ABORT_FREE_ON_EMPTY) && empty)
+ upl_deallocate(upl);
+
+ return kr;
+}
+
+kern_return_t
+ubc_upl_abort(
+ upl_t upl,
+ int abort_type)
+{
+ kern_return_t kr;
+
+ kr = upl_abort(upl, abort_type);
+ upl_deallocate(upl);
+ return kr;
+}
+
+upl_page_info_t *
+ubc_upl_pageinfo(
+ upl_t upl)
+{
+ return (UPL_GET_INTERNAL_PAGE_LIST(upl));
+}