|
|
1.1 ! root 1: /* ! 2: * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved. ! 3: * ! 4: * @APPLE_LICENSE_HEADER_START@ ! 5: * ! 6: * The contents of this file constitute Original Code as defined in and ! 7: * are subject to the Apple Public Source License Version 1.1 (the ! 8: * "License"). You may not use this file except in compliance with the ! 9: * License. Please obtain a copy of the License at ! 10: * http://www.apple.com/publicsource and read it before using this file. ! 11: * ! 12: * This Original Code and all software distributed under the License are ! 13: * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER ! 14: * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, ! 15: * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, ! 16: * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the ! 17: * License for the specific language governing rights and limitations ! 18: * under the License. ! 19: * ! 20: * @APPLE_LICENSE_HEADER_END@ ! 21: */ ! 22: #ifndef _IOBUFFERMEMORYDESCRIPTOR_H ! 23: #define _IOBUFFERMEMORYDESCRIPTOR_H ! 24: ! 25: #include <IOKit/IOMemoryDescriptor.h> ! 26: ! 27: class IOBufferMemoryDescriptor : public IOGeneralMemoryDescriptor ! 28: { ! 29: OSDeclareDefaultStructors(IOBufferMemoryDescriptor); ! 30: ! 31: protected: ! 32: void * _buffer; ! 33: vm_size_t _capacity; ! 34: bool _contiguous; ! 35: IOPhysicalAddress * _physAddrs; ! 36: unsigned _physSegCount; ! 37: ! 38: virtual void free(); ! 39: ! 40: IOGeneralMemoryDescriptor::initWithAddress; /* not supported in subclass */ ! 41: IOGeneralMemoryDescriptor::withAddress; /* not supported in subclass */ ! 42: IOGeneralMemoryDescriptor::initWithRanges; /* not supported in subclass */ ! 43: IOGeneralMemoryDescriptor::withRanges; /* not supported in subclass */ ! 44: ! 45: public: ! 46: ! 47: /* ! 48: * initWithCapacity: ! 49: * ! 50: * Initialize a new IOBufferMemoryDescriptor with a buffer large enough to ! 51: * hold capacity bytes. The descriptor's length is initially set to zero. ! 52: */ ! 53: virtual bool initWithCapacity(vm_size_t capacity, ! 54: IODirection withDirection, ! 55: bool withContiguousMemory = false); ! 56: ! 57: /* ! 58: * withCapacity: ! 59: * ! 60: * Returns a new IOBufferMemoryDescriptor with a buffer large enough to ! 61: * hold capacity bytes. The descriptor's length is initially set to zero. ! 62: */ ! 63: static IOBufferMemoryDescriptor * withCapacity( ! 64: vm_size_t capacity, ! 65: IODirection withDirection, ! 66: bool withContiguousMemory = false); ! 67: /* ! 68: * initWithBytes: ! 69: * ! 70: * Initialize a new IOBufferMemoryDescriptor preloaded with bytes (copied). ! 71: * The descriptor's length and capacity are set to the input buffer's size. ! 72: */ ! 73: virtual bool initWithBytes(const void * bytes, ! 74: vm_size_t withLength, ! 75: IODirection withDirection, ! 76: bool withContiguousMemory = false); ! 77: ! 78: /* ! 79: * withBytes: ! 80: * ! 81: * Returns a new IOBufferMemoryDescriptor preloaded with bytes (copied). ! 82: * The descriptor's length and capacity are set to the input buffer's size. ! 83: */ ! 84: static IOBufferMemoryDescriptor * withBytes( ! 85: const void * bytes, ! 86: vm_size_t withLength, ! 87: IODirection withDirection, ! 88: bool withContiguousMemory = false); ! 89: ! 90: /* ! 91: * setLength: ! 92: * ! 93: * Change the buffer length of the memory descriptor. When a new buffer is ! 94: * created with initWithBytes, the descriptor's length is set to capacity, ! 95: * or its length is initially zero. This method allows one to resize the ! 96: * buffer length up to capacity or less. This eliminates the need to ! 97: * destroy and create new buffers when different sizes are needed. The ! 98: * descriptor position is implicitly reset to zero as a result of this call. ! 99: */ ! 100: virtual void setLength(vm_size_t length); ! 101: ! 102: /* ! 103: * setDirection: ! 104: * ! 105: * Change the direction of the transfer. This method allows one to redirect ! 106: * the descriptor's transfer direction. This eliminates the need to destroy ! 107: * and create new buffers when different transfer directions are needed. ! 108: */ ! 109: virtual void setDirection(IODirection direction); ! 110: ! 111: /* ! 112: * getCapacity: ! 113: * ! 114: * Get the buffer capacity ! 115: */ ! 116: virtual vm_size_t getCapacity() const; ! 117: ! 118: /* ! 119: * getBytesNoCopy: ! 120: * ! 121: * Return the virtual address of the beginning of the buffer ! 122: */ ! 123: virtual void *getBytesNoCopy(); ! 124: ! 125: /* ! 126: * getBytesNoCopy: ! 127: * ! 128: * Return the virtual address of an offset from the beginning of the buffer ! 129: */ ! 130: virtual void *getBytesNoCopy(vm_size_t start, vm_size_t withLength); ! 131: ! 132: /* ! 133: * appendBytes: ! 134: * ! 135: * Add some data to the end of the buffer. This method automatically ! 136: * maintains the memory descriptor buffer length. Note that appendBytes ! 137: * will not copy past the end of the memory descriptor's current capacity. ! 138: */ ! 139: virtual bool appendBytes(const void *bytes, vm_size_t withLength); ! 140: ! 141: /* ! 142: * getPhysicalSegment: ! 143: * ! 144: * Get the physical address of the buffer, relative to the current position. ! 145: * If the current position is at the end of the buffer, a zero is returned. ! 146: */ ! 147: virtual IOPhysicalAddress getPhysicalSegment(IOByteCount offset, ! 148: IOPhysicalLength * length); ! 149: }; ! 150: ! 151: #endif /* !_IOBUFFERMEMORYDESCRIPTOR_H */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.