X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/e5568f75972dfc723778653c11cb6b4dc825716a..593a1d5fd87cdf5b46dd5fcb84467b432cea0f91:/iokit/IOKit/IORangeAllocator.h diff --git a/iokit/IOKit/IORangeAllocator.h b/iokit/IOKit/IORangeAllocator.h index 761084e84..b6f7ee17b 100644 --- a/iokit/IOKit/IORangeAllocator.h +++ b/iokit/IOKit/IORangeAllocator.h @@ -1,23 +1,29 @@ /* * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved. * - * @APPLE_LICENSE_HEADER_START@ + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ * - * The contents of this file constitute Original Code as defined in and - * are subject to the Apple Public Source License Version 1.1 (the - * "License"). You may not use this file except in compliance with the - * License. Please obtain a copy of the License at - * http://www.apple.com/publicsource and read it before using this file. + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. The rights granted to you under the License + * may not be used to create, or enable the creation or redistribution of, + * unlawful or unlicensed copies of an Apple operating system, or to + * circumvent, violate, or enable the circumvention or violation of, any + * terms of an Apple operating system software license agreement. * - * This Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * - * @APPLE_LICENSE_HEADER_END@ + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ */ /* * Copyright (c) 1999 Apple Computer, Inc. @@ -36,9 +42,10 @@ typedef UInt32 IORangeScalar; -/*! @class IORangeAllocator : public OSObject +/*! @class IORangeAllocator @abstract A utility class to manage allocations from a range. - @discussion The IORangeAllocator class provides functions for allocating ranges, at a fixed or any offset, and freeing them back to a free list. It is useful for describing ranges of memory or address space without requiring storage in the memory - information describing the free elements is kept elsewhere. Ranges are described by a start offset and a size. IORangeAllocator is optionally protected against multithreaded access. */ + @discussion The IORangeAllocator class provides functions for allocating ranges, at a fixed or any offset, and freeing them back to a free list. It is useful for describing ranges of memory or address space without requiring storage in the memory - information describing the free elements is kept elsewhere. Ranges are described by a start offset and a size. IORangeAllocator is optionally protected against multithreaded access. +*/ class IORangeAllocator : public OSObject { @@ -66,11 +73,11 @@ public: /*! @function init @abstract Standard initializer for IORangeAllocator. @discussion This method initializes an IORangeAllocator and optionally sets the free list to contain one fragment, from zero to an endOfRange parameter. The capacity in terms of free fragments and locking options are set for the instance. - @param endOfRange If the free list is to contain an initial fragment, set endOfRange to the last offset in the range, ie. size - 1, to create a free fragment for the range zero to endOfRange inclusive. If zero is passed the free list will be initialized empty, and can be populated with calls to the deallocate method. + @param endOfRange If the free list is to contain an initial fragment, set endOfRange to the last offset in the range, ie. size - 1, to create a free fragment for the range zero to endOfRange inclusive. If zero is passed, the free list will be initialized empty, and can be populated with calls to the deallocate method. @param defaultAlignment If this parameter is non-zero it specifies a required alignment for all allocations, for example pass 256 to align allocations on 256 byte boundaries. Zero or one specify unaligned allocations. - @param capacity Sets the initial size of the free list in number of non-contiguous fragments. This value is also used for the capacityIncrement. + @param capacity Sets the initial size of the free list in number of noncontiguous fragments. This value is also used for the capacityIncrement. @param options Pass kLocking if the instance can be used by multiple threads. - @result Returns true if the instance is successfully initialize, false on failure. */ + @result Returns true if the instance is successfully initialized, false on failure. */ virtual bool init( IORangeScalar endOfRange, IORangeScalar defaultAlignment, @@ -96,58 +103,65 @@ public: /*! @function getFragmentCount @abstract Accessor to return the number of free fragments in the range. @discussion This method returns a count of free fragments. Each fragment describes a non-contiguous free range - deallocations will merge contiguous fragments together. - @result The count of free fragments. */ + @result Returns the count of free fragments. +*/ virtual UInt32 getFragmentCount( void ); /*! @function getFragmentCapacity @abstract Accessor to return the number of free fragments in the range. @discussion This method returns the current capacity of the free fragment list. - @result The current capacity of free fragment list. */ + @result Returns the current capacity of free fragment list. +*/ virtual UInt32 getFragmentCapacity( void ); /*! @function setFragmentCapacityIncrement @abstract Sets the count of fragments the free list will increase by when full. - @discussion This method sets the number of extra fragments the free list will expand to when full. It defaults to the initial capacity. - @param count The number of fragments to increment the capacity by when the free list is full. */ + @discussion This method sets the number of extra fragments the free list will expand to when full. It defaults to the initial capacity. + @param count The number of fragments to increment the capacity by when the free list is full. +*/ virtual void setFragmentCapacityIncrement( UInt32 count ); /*! @function getFreeCount @abstract Totals the sizes of the free fragments. @discussion This method returns the total of the sizes of the fragments on the free list. - @result The total of the free fragments sizes. */ + @result Returns the total of the free fragments sizes. +*/ virtual IORangeScalar getFreeCount( void ); /*! @function allocate - @abstract Allocate from the free list, at any offset. + @abstract Allocates from the free list, at any offset. @discussion This method allocates a range from the free list. The alignment will default to the alignment set when the allocator was created or may be set here. @param size The size of the range requested. @param result The beginning of the range allocated is returned here on success. @param alignment If zero is passed, default to the allocators alignment, otherwise pass an alignment required for the allocation, for example 4096 to page align. - @result True if the allocation was successful, else false. */ + @result Returns true if the allocation was successful, else false. +*/ virtual bool allocate( IORangeScalar size, IORangeScalar * result, IORangeScalar alignment = 0 ); /*! @function allocateRange - @abstract Allocate from the free list, at a set offset. + @abstract Allocates from the free list, at a set offset. @discussion This method allocates a range from the free list, given a set offset passed in. @param start The beginning of the range requested. @param size The size of the range requested. - @result True if the allocation was successful, else false. */ + @result Returns true if the allocation was successful, else false. +*/ virtual bool allocateRange( IORangeScalar start, IORangeScalar size ); /*! @function deallocate - @abstract Deallocate a range to the free list. + @abstract Deallocates a range to the free list. @discussion This method deallocates a range to the free list, given a the start offset and length passed in. @param start The beginning of the range requested. - @param size The size of the range requested. */ + @param size Returns the size of the range requested. +*/ virtual void deallocate( IORangeScalar start, IORangeScalar size );