1 | /* |
2 | * Copyright (c) 1998-2016 Apple Inc. All rights reserved. |
3 | * |
4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ |
5 | * |
6 | * This file contains Original Code and/or Modifications of Original Code |
7 | * as defined in and that are subject to the Apple Public Source License |
8 | * Version 2.0 (the 'License'). You may not use this file except in |
9 | * compliance with the License. The rights granted to you under the License |
10 | * may not be used to create, or enable the creation or redistribution of, |
11 | * unlawful or unlicensed copies of an Apple operating system, or to |
12 | * circumvent, violate, or enable the circumvention or violation of, any |
13 | * terms of an Apple operating system software license agreement. |
14 | * |
15 | * Please obtain a copy of the License at |
16 | * http://www.opensource.apple.com/apsl/ and read it before using this file. |
17 | * |
18 | * The Original Code and all software distributed under the License are |
19 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER |
20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, |
22 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. |
23 | * Please see the License for the specific language governing rights and |
24 | * limitations under the License. |
25 | * |
26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ |
27 | */ |
28 | /* |
29 | * Copyright (c) 1998 Apple Computer, Inc. All rights reserved. |
30 | * |
31 | * HISTORY |
32 | * |
33 | */ |
34 | |
35 | #ifndef _IOKIT_IODEVICEMEMORY_H |
36 | #define _IOKIT_IODEVICEMEMORY_H |
37 | |
38 | #include <IOKit/IOMemoryDescriptor.h> |
39 | |
40 | /*! @class IODeviceMemory |
41 | @abstract An IOMemoryDescriptor used for device physical memory ranges. |
42 | @discussion The IODeviceMemory class is a simple subclass of IOMemoryDescriptor that uses its methods to describe a single range of physical memory on a device. IODeviceMemory objects are usually looked up with IOService or IOPCIDevice accessors, and are created by memory-mapped bus families. IODeviceMemory implements only some factory methods in addition to the methods of IOMemoryDescriptor. |
43 | */ |
44 | |
45 | class IODeviceMemory : public IOMemoryDescriptor |
46 | { |
47 | OSDeclareDefaultStructors(IODeviceMemory) |
48 | |
49 | public: |
50 | |
51 | /*! @struct InitElement |
52 | @field start First physical address in the range. |
53 | @field length Length of the range. |
54 | @field tag 32-bit value not interpreted by IODeviceMemory or IOMemoryDescriptor, for use by the bus family. */ |
55 | |
56 | struct InitElement { |
57 | IOPhysicalAddress start; |
58 | IOPhysicalLength length; |
59 | IOOptionBits tag; |
60 | }; |
61 | |
62 | /*! @function arrayFromList |
63 | @abstract Constructs an OSArray of IODeviceMemory instances, each describing one physical range, and a tag value. |
64 | @discussion This method creates IODeviceMemory instances for each physical range passed in an IODeviceMemory::InitElement array. Each element consists of a physical address, length and tag value for the IODeviceMemory. The instances are returned as a created OSArray. |
65 | @param list An array of IODeviceMemory::InitElement structures. |
66 | @param count The number of elements in the list. |
67 | @result Returns a created OSArray of IODeviceMemory objects, to be released by the caller, or zero on failure. */ |
68 | |
69 | static OSArray * arrayFromList( |
70 | InitElement list[], |
71 | IOItemCount count ); |
72 | |
73 | /*! @function withRange |
74 | @abstract Constructs an IODeviceMemory instance, describing one physical range. |
75 | @discussion This method creates an IODeviceMemory instance for one physical range passed as a physical address and length. It just calls IOMemoryDescriptor::withPhysicalAddress. |
76 | @param start The physical address of the first byte in the memory. |
77 | @param length The length of memory. |
78 | @result Returns the created IODeviceMemory on success, to be released by the caller, or zero on failure. */ |
79 | |
80 | static IODeviceMemory * withRange( |
81 | IOPhysicalAddress start, |
82 | IOPhysicalLength length ); |
83 | |
84 | /*! @function withSubRange |
85 | @abstract Constructs an IODeviceMemory instance, describing a subset of an existing IODeviceMemory range. |
86 | @discussion This method creates an IODeviceMemory instance for a subset of an existing IODeviceMemory range, passed as a physical address offset and length. It just calls IOMemoryDescriptor::withSubRange. |
87 | @param of The parent IODeviceMemory of which a subrange is to be used for the new descriptor, which will be retained by the subrange IODeviceMemory. |
88 | @param offset A byte offset into the parent's memory. |
89 | @param length The length of the subrange. |
90 | @result Returns the created IODeviceMemory on success, to be released by the caller, or zero on failure. */ |
91 | |
92 | static IODeviceMemory * withSubRange( |
93 | IODeviceMemory * of, |
94 | IOPhysicalAddress offset, |
95 | IOPhysicalLength length ); |
96 | }; |
97 | |
98 | #endif /* ! _IOKIT_IODEVICEMEMORY_H */ |
99 | |