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#include "AppleRAID.h"
24
25#undef super
26#define super IOMemoryDescriptor
27OSDefineMetaClassAndAbstractStructors(AppleRAIDMemoryDescriptor, IOMemoryDescriptor);
28
29bool AppleRAIDMemoryDescriptor::initWithStorageRequest(AppleRAIDStorageRequest *storageRequest, UInt32 memberIndex)
30{
31    if (!super::init()) return false;
32
33    mdMemoryDescriptorLock = IOLockAlloc();
34    if (mdMemoryDescriptorLock == 0) return false;
35
36    mdStorageRequest = storageRequest;
37
38    mdMemberIndex = memberIndex;
39    return true;
40}
41
42void AppleRAIDMemoryDescriptor::free(void)
43{
44    IOLockFree(mdMemoryDescriptorLock);
45
46    super::free();
47}
48
49IOReturn AppleRAIDMemoryDescriptor::prepare(IODirection forDirection)
50{
51    IOReturn result;
52
53    IOLockLock(mdMemoryDescriptorLock);
54    result = mdMemoryDescriptor->prepare(forDirection);
55    IOLockUnlock(mdMemoryDescriptorLock);
56
57    return result;
58}
59
60IOReturn AppleRAIDMemoryDescriptor::complete(IODirection forDirection)
61{
62    IOReturn result;
63
64    IOLockLock(mdMemoryDescriptorLock);
65    result = mdMemoryDescriptor->complete(forDirection);
66    IOLockUnlock(mdMemoryDescriptorLock);
67
68    return result;
69}
70
71