1/*
2 * Copyright (c) 2001-2007 Apple 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
23#ifndef _APPLERAIDMEMORYDESCRIPTOR_H
24#define _APPLERAIDMEMORYDESCRIPTOR_H
25
26class AppleLVMVolume;
27
28class AppleRAIDMemoryDescriptor : public IOMemoryDescriptor
29{
30    OSDeclareAbstractStructors(AppleRAIDMemoryDescriptor);
31
32    friend class AppleRAIDEventSource;		// XXX remove this
33    friend class AppleRAIDStorageRequest;	// XXX remove this
34    friend class AppleLVMStorageRequest;	// XXX remove this
35    friend class AppleLVMGroup;			// XXX remove this
36
37protected:
38    IOMemoryDescriptor		*mdMemoryDescriptor;
39    IOLock			*mdMemoryDescriptorLock;
40
41    AppleRAIDStorageRequest	*mdStorageRequest;
42    UInt32			mdMemberIndex;
43    UInt64			mdMemberByteStart;
44
45    virtual bool initWithAddress(void *address, IOByteCount withLength, IODirection withDirection) { return false; }
46    virtual bool initWithAddress(vm_address_t address, IOByteCount withLength, IODirection withDirection, task_t withTask)
47				{ return false; }
48    virtual bool initWithPhysicalAddress(IOPhysicalAddress address, IOByteCount withLength, IODirection withDirection)
49                                         { return false; }
50    virtual bool initWithRanges(IOVirtualRange *ranges, UInt32 withCount, IODirection withDirection, task_t withTask,
51                                bool asReference = false) { return false; }
52    virtual bool initWithPhysicalRanges(IOPhysicalRange *ranges, UInt32 withCount, IODirection withDirection,
53                                        bool asReference = false) { return false; }
54
55 public:
56    virtual bool initWithStorageRequest(AppleRAIDStorageRequest *storageRequest, UInt32 memberIndex);
57    virtual void free(void);
58
59    virtual bool configureForMemoryDescriptor(IOMemoryDescriptor *memoryDescriptor, UInt64 byteStart, UInt32 activeIndex) { return false; }
60    virtual bool configureForMemoryDescriptor(IOMemoryDescriptor * memoryDescriptor, UInt64 requestStart, UInt64 requestSize, AppleLVMVolume * lv) { return false; }
61
62    virtual addr64_t getPhysicalSegment(IOByteCount offset, IOByteCount * length, IOOptionBits options = 0) = 0;
63    virtual IOReturn prepare(IODirection forDirection = kIODirectionNone);
64    virtual IOReturn complete(IODirection forDirection = kIODirectionNone);
65};
66
67#endif  /* ! _APPLERAIDMEMORYDESCRIPTOR_H */
68