/*
- * Copyright (c) 2000-2005 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2014 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
#define B_FUA 0x00000400 /* Write-through disk cache(if supported) */
#define B_PASSIVE 0x00000800 /* PASSIVE I/Os are ignored by THROTTLE I/O */
#define B_IOSTREAMING 0x00001000 /* sequential access pattern detected */
-#define B_THROTTLED_IO 0x00002000 /* low priority I/O */
+#define B_THROTTLED_IO 0x00002000 /* low priority I/O (deprecated) */
+#define B_ENCRYPTED_IO 0x00004000 /* Encrypted I/O */
+#define B_STATICCONTENT 0x00008000 /* Buffer is likely to remain unaltered */
+
/*
* make sure to check when adding flags that
* that the new flags don't overlap the definitions
*/
void buf_markdelayed(buf_t);
+void buf_markclean(buf_t);
+
/*!
@function buf_markeintr
@abstract Mark a buffer as having been interrupted during I/O.
/*!
@function buf_setflags
@abstract Set flags on a buffer.
- @discussion: buffer_flags |= flags
+ @discussion buffer_flags |= flags
@param bp Buffer whose flags to set.
@param flags Flags to add to buffer's mask. B_LOCKED/B_NOCACHE/B_ASYNC/B_READ/B_WRITE/B_PAGEIO/B_FUA
@return void.
/*!
@function buf_clearflags
@abstract Clear flags on a buffer.
- @discussion: buffer_flags &= ~flags
+ @discussion buffer_flags &= ~flags
@param bp Buffer whose flags to clear.
@param flags Flags to remove from buffer's mask. B_LOCKED/B_NOCACHE/B_ASYNC/B_READ/B_WRITE/B_PAGEIO/B_FUA
@return void.
*/
buf_t buf_clone(buf_t, int, int, void (*)(buf_t, void *), void *);
+
+/*!
+ @function buf_create_shadow
+ @abstract Create a shadow buffer with optional private storage and an optional callback.
+ @param bp Buffer to shadow.
+ @param force_copy If TRUE, do not link the shadaow to 'bp' and if 'external_storage' == NULL,
+ force a copy of the data associated with 'bp'.
+ @param external_storage If non-NULL, associate it with the new buffer as its storage instead of the
+ storage currently associated with 'bp'.
+ @param iodone Callback to be called from buf_biodone() when I/O completes, in the sense of buf_setcallback().
+ @param arg Argument to pass to iodone() callback.
+ @return NULL if the buffer to be shadowed is not B_META or a primary buffer (i.e. not a shadow buffer); otherwise, the new buffer.
+*/
+
+buf_t buf_create_shadow(buf_t bp, boolean_t force_copy, uintptr_t external_storage, void (*iodone)(buf_t, void *), void *arg);
+
+
+/*!
+ @function buf_shadow
+ @abstract returns true if 'bp' is a shadow of another buffer.
+ @param bp Buffer to query.
+ @return 1 if 'bp' is a shadow, 0 otherwise.
+*/
+int buf_shadow(buf_t bp);
+
+
/*!
@function buf_alloc
@abstract Allocate an uninitialized buffer.
*/
#define BUF_WRITE_DATA 0x0001 /* write data blocks first */
#define BUF_SKIP_META 0x0002 /* skip over metadata blocks */
+#define BUF_INVALIDATE_LOCKED 0x0004 /* force B_LOCKED blocks to be invalidated */
/*!
@function buf_invalidateblks
@return Always returns a new buffer.
*/
buf_t buf_geteblk(int);
+
+/*!
+ @function buf_clear_redundancy_flags
+ @abstract Clear flags on a buffer.
+ @discussion buffer_redundancy_flags &= ~flags
+ @param bp Buffer whose flags to clear.
+ @param flags Flags to remove from buffer's mask
+ @return void.
+ */
+void buf_clear_redundancy_flags(buf_t, uint32_t);
+
+/*!
+ @function buf_redundancyflags
+ @abstract Get redundancy flags set on a buffer.
+ @param bp Buffer whose redundancy flags to grab.
+ @return flags.
+ */
+uint32_t buf_redundancy_flags(buf_t);
+
+/*!
+ @function buf_setredundancyflags
+ @abstract Set redundancy flags on a buffer.
+ @discussion buffer_redundancy_flags |= flags
+ @param bp Buffer whose flags to set.
+ @param flags Flags to add to buffer's redundancy flags
+ @return void.
+ */
+void buf_set_redundancy_flags(buf_t, uint32_t);
+
+/*!
+ @function buf_attr
+ @abstract Gets the attributes for this buf.
+ @param bp Buffer whose attributes to get.
+ @return bufattr_t.
+ */
+bufattr_t buf_attr(buf_t);
+
+/*!
+ @function buf_markstatic
+ @abstract Mark a buffer as being likely to contain static data.
+ @param bp Buffer to mark.
+ @return void.
+ */
+ void buf_markstatic(buf_t);
+
+/*!
+ @function buf_static
+ @abstract Check if a buffer contains static data.
+ @param bp Buffer to test.
+ @return Nonzero if buffer has static data, 0 otherwise.
+ */
+int buf_static(buf_t);
+
#ifdef KERNEL_PRIVATE
-void buf_setfilter(buf_t, void (*)(buf_t, void *), void *, void **, void **);
-#endif /* KERNEL_PRIVATE */
+void buf_setfilter(buf_t, void (*)(buf_t, void *), void *, void (**)(buf_t, void *), void **);
+
+/* bufattr allocation/duplication/deallocation functions */
+bufattr_t bufattr_alloc(void);
+bufattr_t bufattr_dup (bufattr_t bap);
+void bufattr_free(bufattr_t bap);
+
+/*!
+ @function bufattr_cpx
+ @abstract Returns a pointer to a cpx_t structure.
+ @param bap Buffer Attribute whose cpx_t structure you wish to get.
+ @return Returns a cpx_t structure, or NULL if not valid
+ */
+struct cpx *bufattr_cpx(bufattr_t);
+
+/*!
+ @function bufattr_setcpx
+ @abstract Set the cp_ctx on a buffer attribute.
+ @param bap Buffer Attribute that you wish to change
+ @return void
+ */
+void bufattr_setcpx(bufattr_t, struct cpx *cpx);
+
+/*!
+ @function bufattr_cpoff
+ @abstract Gets the file offset on the buffer.
+ @param bap Buffer Attribute whose file offset value is used
+ @return void.
+ */
+uint64_t bufattr_cpoff(bufattr_t);
+/*!
+ @function bufattr_setcpoff
+ @abstract Set the file offset for a content protected I/O on
+ a buffer attribute.
+ @param bap Buffer Attribute whose cp file offset has to be set
+ @return void.
+ */
+void bufattr_setcpoff(bufattr_t, uint64_t);
+
+/*!
+ @function bufattr_rawencrypted
+ @abstract Check if a buffer contains raw encrypted data.
+ @param bap Buffer attribute to test.
+ @return Nonzero if buffer has raw encrypted data, 0 otherwise.
+ */
+int bufattr_rawencrypted(bufattr_t bap);
+
+/*!
+ @function bufattr_markgreedymode
+ @abstract Mark a buffer to use the greedy mode for writing.
+ @param bap Buffer attributes to mark.
+ @discussion Greedy Mode: request improved write performance from the underlying device at the expense of storage efficiency
+ @return void.
+ */
+ void bufattr_markgreedymode(bufattr_t bap);
+
+/*!
+ @function bufattr_greedymode
+ @abstract Check if a buffer is written using the Greedy Mode
+ @param bap Buffer attributes to test.
+ @discussion Greedy Mode: request improved write performance from the underlying device at the expense of storage efficiency
+ @return Nonzero if buffer uses greedy mode, 0 otherwise.
+ */
+int bufattr_greedymode(bufattr_t bap);
+
+/*!
+ @function bufattr_markisochronous
+ @abstract Mark a buffer to use the isochronous throughput mode for writing.
+ @param bap Buffer attributes to mark.
+ @discussion isochronous mode: request improved write performance from the underlying device at the expense of storage efficiency
+ @return void.
+ */
+ void bufattr_markisochronous(bufattr_t bap);
+
+ /*!
+ @function bufattr_isochronous
+ @abstract Check if a buffer is written using the isochronous
+ @param bap Buffer attributes to test.
+ @discussion isochronous mode: request improved write performance from the underlying device at the expense of storage efficiency
+ @return Nonzero if buffer uses isochronous mode, 0 otherwise.
+ */
+int bufattr_isochronous(bufattr_t bap);
+
+
+/*!
+ @function bufattr_throttled
+ @abstract Check if a buffer is throttled.
+ @param bap Buffer attribute to test.
+ @return Nonzero if the buffer is throttled, 0 otherwise.
+ */
+int bufattr_throttled(bufattr_t bap);
+
+/*!
+ @function bufattr_passive
+ @abstract Check if a buffer is marked passive.
+ @param bap Buffer attribute to test.
+ @return Nonzero if the buffer is marked passive, 0 otherwise.
+ */
+int bufattr_passive(bufattr_t bap);
+
+/*!
+ @function bufattr_nocache
+ @abstract Check if a buffer has nocache attribute.
+ @param bap Buffer attribute to test.
+ @return Nonzero if the buffer is not cached, 0 otherwise.
+ */
+int bufattr_nocache(bufattr_t bap);
+
+/*!
+ @function bufattr_meta
+ @abstract Check if a buffer has the bufattr meta attribute.
+ @param bap Buffer attribute to test.
+ @return Nonzero if the buffer has meta attribute, 0 otherwise.
+ */
+
+int bufattr_meta(bufattr_t bap);
+
+/*!
+ @function bufattr_markmeta
+ @abstract Set the bufattr meta attribute.
+ @param bap Buffer attribute to manipulate.
+ @return void
+ */
+void bufattr_markmeta(bufattr_t bap);
+
+
+/*!
+ @function bufattr_delayidlesleep
+ @abstract Check if a buffer is marked to delay idle sleep on disk IO.
+ @param bap Buffer attribute to test.
+ @return Nonzero if the buffer is marked to delay idle sleep on disk IO, 0 otherwise.
+ */
+int bufattr_delayidlesleep(bufattr_t bap);
+
+/*!
+ @function buf_kernel_addrperm_addr
+ @abstract Obfuscate the buf pointers.
+ @param addr Buf_t pointer.
+ @return Obfuscated pointer if addr is non zero, 0 otherwise.
+ */
+vm_offset_t buf_kernel_addrperm_addr(void * addr);
+
+/*!
+ @function bufattr_markquickcomplete
+ @abstract Mark a buffer to hint quick completion to the driver.
+ @discussion This flag hints the storage driver that some thread is waiting for this I/O to complete.
+ It should therefore attempt to complete it as soon as possible at the cost of device efficiency.
+ @param bap Buffer attributes to mark.
+ @return void.
+ */
+void bufattr_markquickcomplete(bufattr_t bap);
+
+/*!
+ @function bufattr_quickcomplete
+ @abstract Check if a buffer is marked for quick completion
+ @discussion This flag hints the storage driver that some thread is waiting for this I/O to complete.
+ It should therefore attempt to complete it as soon as possible at the cost of device efficiency.
+ @param bap Buffer attribute to test.
+ @return Nonzero if the buffer is marked for quick completion, 0 otherwise.
+ */
+int bufattr_quickcomplete(bufattr_t bap);
+
+#endif /* KERNEL_PRIVATE */
__END_DECLS