]>
Commit | Line | Data |
---|---|---|
1c79356b A |
1 | /* |
2 | * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved. | |
3 | * | |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
37839358 A |
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. | |
1c79356b | 11 | * |
37839358 A |
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 | |
1c79356b A |
14 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
15 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
37839358 A |
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. | |
1c79356b A |
19 | * |
20 | * @APPLE_LICENSE_HEADER_END@ | |
21 | */ | |
1c79356b A |
22 | |
23 | #include <IOKit/IODeviceMemory.h> | |
24 | ||
25 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ | |
26 | ||
27 | IODeviceMemory * IODeviceMemory::withRange( | |
28 | IOPhysicalAddress start, | |
29 | IOPhysicalLength length ) | |
30 | { | |
31 | return( (IODeviceMemory *) IOMemoryDescriptor::withPhysicalAddress( | |
32 | start, length, kIODirectionNone )); | |
33 | } | |
34 | ||
35 | ||
36 | IODeviceMemory * IODeviceMemory::withSubRange( | |
37 | IODeviceMemory * of, | |
38 | IOPhysicalAddress offset, | |
39 | IOPhysicalLength length ) | |
40 | { | |
41 | return( (IODeviceMemory *) IOMemoryDescriptor::withSubRange( | |
42 | of, offset, length, kIODirectionNone )); | |
43 | } | |
44 | ||
45 | ||
46 | OSArray * IODeviceMemory::arrayFromList( | |
47 | InitElement list[], | |
48 | IOItemCount count ) | |
49 | { | |
50 | OSArray * array; | |
51 | IODeviceMemory * range; | |
52 | IOItemCount i; | |
53 | ||
54 | array = OSArray::withCapacity( count ); | |
55 | if( 0 == array ) | |
56 | return( 0); | |
57 | ||
58 | for( i = 0; i < count; i++) { | |
59 | range = IODeviceMemory::withRange( list[i].start, list[i].length ); | |
60 | if( range) { | |
61 | range->setTag( list[i].tag ); | |
62 | array->setObject( range); | |
63 | range->release(); | |
64 | } else { | |
65 | array->release(); | |
66 | array = 0; | |
67 | break; | |
68 | } | |
69 | } | |
70 | ||
71 | return( array ); | |
72 | } | |
73 |