xref: /xnu-10063.141.1/iokit/Kernel/IOMemoryCursor.cpp (revision d8b80295118ef25ac3a784134bcf95cd8e88109f)
1*d8b80295SApple OSS Distributions /*
2*d8b80295SApple OSS Distributions  * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
3*d8b80295SApple OSS Distributions  *
4*d8b80295SApple OSS Distributions  * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5*d8b80295SApple OSS Distributions  *
6*d8b80295SApple OSS Distributions  * This file contains Original Code and/or Modifications of Original Code
7*d8b80295SApple OSS Distributions  * as defined in and that are subject to the Apple Public Source License
8*d8b80295SApple OSS Distributions  * Version 2.0 (the 'License'). You may not use this file except in
9*d8b80295SApple OSS Distributions  * compliance with the License. The rights granted to you under the License
10*d8b80295SApple OSS Distributions  * may not be used to create, or enable the creation or redistribution of,
11*d8b80295SApple OSS Distributions  * unlawful or unlicensed copies of an Apple operating system, or to
12*d8b80295SApple OSS Distributions  * circumvent, violate, or enable the circumvention or violation of, any
13*d8b80295SApple OSS Distributions  * terms of an Apple operating system software license agreement.
14*d8b80295SApple OSS Distributions  *
15*d8b80295SApple OSS Distributions  * Please obtain a copy of the License at
16*d8b80295SApple OSS Distributions  * http://www.opensource.apple.com/apsl/ and read it before using this file.
17*d8b80295SApple OSS Distributions  *
18*d8b80295SApple OSS Distributions  * The Original Code and all software distributed under the License are
19*d8b80295SApple OSS Distributions  * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20*d8b80295SApple OSS Distributions  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21*d8b80295SApple OSS Distributions  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22*d8b80295SApple OSS Distributions  * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23*d8b80295SApple OSS Distributions  * Please see the License for the specific language governing rights and
24*d8b80295SApple OSS Distributions  * limitations under the License.
25*d8b80295SApple OSS Distributions  *
26*d8b80295SApple OSS Distributions  * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27*d8b80295SApple OSS Distributions  */
28*d8b80295SApple OSS Distributions /* IOMemoryCursor.cpp created by wgulland on 1999-3-02 */
29*d8b80295SApple OSS Distributions 
30*d8b80295SApple OSS Distributions #define IOKIT_ENABLE_SHARED_PTR
31*d8b80295SApple OSS Distributions 
32*d8b80295SApple OSS Distributions #include <IOKit/assert.h>
33*d8b80295SApple OSS Distributions #include <IOKit/IOLib.h>
34*d8b80295SApple OSS Distributions #include <IOKit/IOMemoryCursor.h>
35*d8b80295SApple OSS Distributions #include <IOKit/IOMemoryDescriptor.h>
36*d8b80295SApple OSS Distributions #include <libkern/OSByteOrder.h>
37*d8b80295SApple OSS Distributions 
38*d8b80295SApple OSS Distributions /**************************** class IOMemoryCursor ***************************/
39*d8b80295SApple OSS Distributions 
40*d8b80295SApple OSS Distributions #undef super
41*d8b80295SApple OSS Distributions #define super OSObject
OSDefineMetaClassAndStructors(IOMemoryCursor,OSObject)42*d8b80295SApple OSS Distributions OSDefineMetaClassAndStructors(IOMemoryCursor, OSObject)
43*d8b80295SApple OSS Distributions 
44*d8b80295SApple OSS Distributions OSSharedPtr<IOMemoryCursor>
45*d8b80295SApple OSS Distributions IOMemoryCursor::withSpecification(SegmentFunction  inSegFunc,
46*d8b80295SApple OSS Distributions     IOPhysicalLength inMaxSegmentSize,
47*d8b80295SApple OSS Distributions     IOPhysicalLength inMaxTransferSize,
48*d8b80295SApple OSS Distributions     IOPhysicalLength inAlignment)
49*d8b80295SApple OSS Distributions {
50*d8b80295SApple OSS Distributions 	OSSharedPtr<IOMemoryCursor> me = OSMakeShared<IOMemoryCursor>();
51*d8b80295SApple OSS Distributions 
52*d8b80295SApple OSS Distributions 	if (me && !me->initWithSpecification(inSegFunc,
53*d8b80295SApple OSS Distributions 	    inMaxSegmentSize,
54*d8b80295SApple OSS Distributions 	    inMaxTransferSize,
55*d8b80295SApple OSS Distributions 	    inAlignment)) {
56*d8b80295SApple OSS Distributions 		return nullptr;
57*d8b80295SApple OSS Distributions 	}
58*d8b80295SApple OSS Distributions 
59*d8b80295SApple OSS Distributions 	return me;
60*d8b80295SApple OSS Distributions }
61*d8b80295SApple OSS Distributions 
62*d8b80295SApple OSS Distributions /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
63*d8b80295SApple OSS Distributions 
64*d8b80295SApple OSS Distributions bool
initWithSpecification(SegmentFunction inSegFunc,IOPhysicalLength inMaxSegmentSize,IOPhysicalLength inMaxTransferSize,IOPhysicalLength inAlignment)65*d8b80295SApple OSS Distributions IOMemoryCursor::initWithSpecification(SegmentFunction  inSegFunc,
66*d8b80295SApple OSS Distributions     IOPhysicalLength inMaxSegmentSize,
67*d8b80295SApple OSS Distributions     IOPhysicalLength inMaxTransferSize,
68*d8b80295SApple OSS Distributions     IOPhysicalLength inAlignment)
69*d8b80295SApple OSS Distributions {
70*d8b80295SApple OSS Distributions // @@@ gvdl: Remove me
71*d8b80295SApple OSS Distributions #if 1
72*d8b80295SApple OSS Distributions 	static UInt sMaxDBDMASegment;
73*d8b80295SApple OSS Distributions 	if (!sMaxDBDMASegment) {
74*d8b80295SApple OSS Distributions 		sMaxDBDMASegment = (UInt) - 1;
75*d8b80295SApple OSS Distributions 		if (PE_parse_boot_argn("mseg", &sMaxDBDMASegment, sizeof(sMaxDBDMASegment))) {
76*d8b80295SApple OSS Distributions 			IOLog("Setting MaxDBDMASegment to %d\n", sMaxDBDMASegment);
77*d8b80295SApple OSS Distributions 		}
78*d8b80295SApple OSS Distributions 	}
79*d8b80295SApple OSS Distributions 
80*d8b80295SApple OSS Distributions 	if (inMaxSegmentSize > sMaxDBDMASegment) {
81*d8b80295SApple OSS Distributions 		inMaxSegmentSize = sMaxDBDMASegment;
82*d8b80295SApple OSS Distributions 	}
83*d8b80295SApple OSS Distributions #endif
84*d8b80295SApple OSS Distributions 
85*d8b80295SApple OSS Distributions 	if (!super::init()) {
86*d8b80295SApple OSS Distributions 		return false;
87*d8b80295SApple OSS Distributions 	}
88*d8b80295SApple OSS Distributions 
89*d8b80295SApple OSS Distributions 	if (!inSegFunc) {
90*d8b80295SApple OSS Distributions 		return false;
91*d8b80295SApple OSS Distributions 	}
92*d8b80295SApple OSS Distributions 	if (inMaxTransferSize > UINT_MAX) {
93*d8b80295SApple OSS Distributions 		return false;
94*d8b80295SApple OSS Distributions 	}
95*d8b80295SApple OSS Distributions 
96*d8b80295SApple OSS Distributions 	outSeg              = inSegFunc;
97*d8b80295SApple OSS Distributions 	maxSegmentSize      = inMaxSegmentSize;
98*d8b80295SApple OSS Distributions 	if (inMaxTransferSize) {
99*d8b80295SApple OSS Distributions 		maxTransferSize = inMaxTransferSize;
100*d8b80295SApple OSS Distributions 	} else {
101*d8b80295SApple OSS Distributions 		maxTransferSize = (IOPhysicalLength) - 1;
102*d8b80295SApple OSS Distributions 	}
103*d8b80295SApple OSS Distributions 	alignMask           = inAlignment - 1;
104*d8b80295SApple OSS Distributions 	assert(alignMask == 0);         // No alignment code yet!
105*d8b80295SApple OSS Distributions 
106*d8b80295SApple OSS Distributions 	return true;
107*d8b80295SApple OSS Distributions }
108*d8b80295SApple OSS Distributions 
109*d8b80295SApple OSS Distributions /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
110*d8b80295SApple OSS Distributions 
111*d8b80295SApple OSS Distributions UInt32
genPhysicalSegments(IOMemoryDescriptor * inDescriptor,IOByteCount fromPosition,void * inSegments,UInt32 inMaxSegments,UInt32 inMaxTransferSize,IOByteCount * outTransferSize)112*d8b80295SApple OSS Distributions IOMemoryCursor::genPhysicalSegments(IOMemoryDescriptor *inDescriptor,
113*d8b80295SApple OSS Distributions     IOByteCount         fromPosition,
114*d8b80295SApple OSS Distributions     void *              inSegments,
115*d8b80295SApple OSS Distributions     UInt32              inMaxSegments,
116*d8b80295SApple OSS Distributions     UInt32              inMaxTransferSize,
117*d8b80295SApple OSS Distributions     IOByteCount         *outTransferSize)
118*d8b80295SApple OSS Distributions {
119*d8b80295SApple OSS Distributions 	if (!inDescriptor) {
120*d8b80295SApple OSS Distributions 		return 0;
121*d8b80295SApple OSS Distributions 	}
122*d8b80295SApple OSS Distributions 
123*d8b80295SApple OSS Distributions 	if (!inMaxSegments) {
124*d8b80295SApple OSS Distributions 		return 0;
125*d8b80295SApple OSS Distributions 	}
126*d8b80295SApple OSS Distributions 
127*d8b80295SApple OSS Distributions 	if (!inMaxTransferSize) {
128*d8b80295SApple OSS Distributions 		inMaxTransferSize = (typeof(inMaxTransferSize))maxTransferSize;
129*d8b80295SApple OSS Distributions 	}
130*d8b80295SApple OSS Distributions 
131*d8b80295SApple OSS Distributions 	/*
132*d8b80295SApple OSS Distributions 	 * Iterate over the packet, translating segments where allowed
133*d8b80295SApple OSS Distributions 	 *
134*d8b80295SApple OSS Distributions 	 * If we finished cleanly return number of segments found
135*d8b80295SApple OSS Distributions 	 * and update the position in the descriptor.
136*d8b80295SApple OSS Distributions 	 */
137*d8b80295SApple OSS Distributions 	PhysicalSegment curSeg = { 0, 0 };
138*d8b80295SApple OSS Distributions 	UInt curSegIndex = 0;
139*d8b80295SApple OSS Distributions 	UInt curTransferSize = 0;
140*d8b80295SApple OSS Distributions 	IOByteCount inDescriptorLength = inDescriptor->getLength();
141*d8b80295SApple OSS Distributions 	PhysicalSegment seg = { 0, 0 };
142*d8b80295SApple OSS Distributions 
143*d8b80295SApple OSS Distributions 	while ((seg.location) || (fromPosition < inDescriptorLength)) {
144*d8b80295SApple OSS Distributions 		if (!seg.location) {
145*d8b80295SApple OSS Distributions 			seg.location = inDescriptor->getPhysicalSegment(
146*d8b80295SApple OSS Distributions 				fromPosition, (IOByteCount*)&seg.length);
147*d8b80295SApple OSS Distributions 			assert(seg.location);
148*d8b80295SApple OSS Distributions 			assert(seg.length);
149*d8b80295SApple OSS Distributions 			fromPosition += seg.length;
150*d8b80295SApple OSS Distributions 		}
151*d8b80295SApple OSS Distributions 
152*d8b80295SApple OSS Distributions 		if (!curSeg.location) {
153*d8b80295SApple OSS Distributions 			curTransferSize += seg.length;
154*d8b80295SApple OSS Distributions 			curSeg = seg;
155*d8b80295SApple OSS Distributions 			seg.location = 0;
156*d8b80295SApple OSS Distributions 		} else if ((curSeg.location + curSeg.length == seg.location)) {
157*d8b80295SApple OSS Distributions 			curTransferSize += seg.length;
158*d8b80295SApple OSS Distributions 			curSeg.length += seg.length;
159*d8b80295SApple OSS Distributions 			seg.location = 0;
160*d8b80295SApple OSS Distributions 		}
161*d8b80295SApple OSS Distributions 
162*d8b80295SApple OSS Distributions 		if (!seg.location) {
163*d8b80295SApple OSS Distributions 			if ((curSeg.length > maxSegmentSize)) {
164*d8b80295SApple OSS Distributions 				seg.location = curSeg.location + maxSegmentSize;
165*d8b80295SApple OSS Distributions 				seg.length = curSeg.length - maxSegmentSize;
166*d8b80295SApple OSS Distributions 				curTransferSize -= seg.length;
167*d8b80295SApple OSS Distributions 				curSeg.length -= seg.length;
168*d8b80295SApple OSS Distributions 			}
169*d8b80295SApple OSS Distributions 
170*d8b80295SApple OSS Distributions 			if ((curTransferSize >= inMaxTransferSize)) {
171*d8b80295SApple OSS Distributions 				curSeg.length -= curTransferSize - inMaxTransferSize;
172*d8b80295SApple OSS Distributions 				curTransferSize = inMaxTransferSize;
173*d8b80295SApple OSS Distributions 				break;
174*d8b80295SApple OSS Distributions 			}
175*d8b80295SApple OSS Distributions 		}
176*d8b80295SApple OSS Distributions 
177*d8b80295SApple OSS Distributions 		if (seg.location) {
178*d8b80295SApple OSS Distributions 			if ((curSegIndex + 1 == inMaxSegments)) {
179*d8b80295SApple OSS Distributions 				break;
180*d8b80295SApple OSS Distributions 			}
181*d8b80295SApple OSS Distributions 			(*outSeg)(curSeg, inSegments, curSegIndex++);
182*d8b80295SApple OSS Distributions 			curSeg.location = 0;
183*d8b80295SApple OSS Distributions 		}
184*d8b80295SApple OSS Distributions 	}
185*d8b80295SApple OSS Distributions 
186*d8b80295SApple OSS Distributions 	if (curSeg.location) {
187*d8b80295SApple OSS Distributions 		(*outSeg)(curSeg, inSegments, curSegIndex++);
188*d8b80295SApple OSS Distributions 	}
189*d8b80295SApple OSS Distributions 
190*d8b80295SApple OSS Distributions 	if (outTransferSize) {
191*d8b80295SApple OSS Distributions 		*outTransferSize = curTransferSize;
192*d8b80295SApple OSS Distributions 	}
193*d8b80295SApple OSS Distributions 
194*d8b80295SApple OSS Distributions 	return curSegIndex;
195*d8b80295SApple OSS Distributions }
196*d8b80295SApple OSS Distributions 
197*d8b80295SApple OSS Distributions /************************ class IONaturalMemoryCursor ************************/
198*d8b80295SApple OSS Distributions 
199*d8b80295SApple OSS Distributions #undef super
200*d8b80295SApple OSS Distributions #define super IOMemoryCursor
OSDefineMetaClassAndStructors(IONaturalMemoryCursor,IOMemoryCursor)201*d8b80295SApple OSS Distributions OSDefineMetaClassAndStructors(IONaturalMemoryCursor, IOMemoryCursor)
202*d8b80295SApple OSS Distributions 
203*d8b80295SApple OSS Distributions void
204*d8b80295SApple OSS Distributions IONaturalMemoryCursor::outputSegment(PhysicalSegment segment,
205*d8b80295SApple OSS Distributions     void *          outSegments,
206*d8b80295SApple OSS Distributions     UInt32          outSegmentIndex)
207*d8b80295SApple OSS Distributions {
208*d8b80295SApple OSS Distributions 	((PhysicalSegment *) outSegments)[outSegmentIndex] = segment;
209*d8b80295SApple OSS Distributions }
210*d8b80295SApple OSS Distributions 
211*d8b80295SApple OSS Distributions OSSharedPtr<IONaturalMemoryCursor>
withSpecification(IOPhysicalLength inMaxSegmentSize,IOPhysicalLength inMaxTransferSize,IOPhysicalLength inAlignment)212*d8b80295SApple OSS Distributions IONaturalMemoryCursor::withSpecification(IOPhysicalLength inMaxSegmentSize,
213*d8b80295SApple OSS Distributions     IOPhysicalLength inMaxTransferSize,
214*d8b80295SApple OSS Distributions     IOPhysicalLength inAlignment)
215*d8b80295SApple OSS Distributions {
216*d8b80295SApple OSS Distributions 	OSSharedPtr<IONaturalMemoryCursor> me = OSMakeShared<IONaturalMemoryCursor>();
217*d8b80295SApple OSS Distributions 
218*d8b80295SApple OSS Distributions 	if (me && !me->initWithSpecification(inMaxSegmentSize,
219*d8b80295SApple OSS Distributions 	    inMaxTransferSize,
220*d8b80295SApple OSS Distributions 	    inAlignment)) {
221*d8b80295SApple OSS Distributions 		return nullptr;
222*d8b80295SApple OSS Distributions 	}
223*d8b80295SApple OSS Distributions 
224*d8b80295SApple OSS Distributions 	return me;
225*d8b80295SApple OSS Distributions }
226*d8b80295SApple OSS Distributions 
227*d8b80295SApple OSS Distributions bool
initWithSpecification(IOPhysicalLength inMaxSegmentSize,IOPhysicalLength inMaxTransferSize,IOPhysicalLength inAlignment)228*d8b80295SApple OSS Distributions IONaturalMemoryCursor::initWithSpecification(IOPhysicalLength inMaxSegmentSize,
229*d8b80295SApple OSS Distributions     IOPhysicalLength inMaxTransferSize,
230*d8b80295SApple OSS Distributions     IOPhysicalLength inAlignment)
231*d8b80295SApple OSS Distributions {
232*d8b80295SApple OSS Distributions 	return super::initWithSpecification(&IONaturalMemoryCursor::outputSegment,
233*d8b80295SApple OSS Distributions 	           inMaxSegmentSize,
234*d8b80295SApple OSS Distributions 	           inMaxTransferSize,
235*d8b80295SApple OSS Distributions 	           inAlignment);
236*d8b80295SApple OSS Distributions }
237*d8b80295SApple OSS Distributions 
238*d8b80295SApple OSS Distributions /************************** class IOBigMemoryCursor **************************/
239*d8b80295SApple OSS Distributions 
240*d8b80295SApple OSS Distributions #undef super
241*d8b80295SApple OSS Distributions #define super IOMemoryCursor
OSDefineMetaClassAndStructors(IOBigMemoryCursor,IOMemoryCursor)242*d8b80295SApple OSS Distributions OSDefineMetaClassAndStructors(IOBigMemoryCursor, IOMemoryCursor)
243*d8b80295SApple OSS Distributions 
244*d8b80295SApple OSS Distributions void
245*d8b80295SApple OSS Distributions IOBigMemoryCursor::outputSegment(PhysicalSegment inSegment,
246*d8b80295SApple OSS Distributions     void *          inSegments,
247*d8b80295SApple OSS Distributions     UInt32          inSegmentIndex)
248*d8b80295SApple OSS Distributions {
249*d8b80295SApple OSS Distributions 	IOPhysicalAddress * segment;
250*d8b80295SApple OSS Distributions 
251*d8b80295SApple OSS Distributions 	segment = &((PhysicalSegment *) inSegments)[inSegmentIndex].location;
252*d8b80295SApple OSS Distributions #if IOPhysSize == 64
253*d8b80295SApple OSS Distributions 	OSWriteBigInt64(segment, 0, inSegment.location);
254*d8b80295SApple OSS Distributions 	OSWriteBigInt64(segment, sizeof(IOPhysicalAddress), inSegment.length);
255*d8b80295SApple OSS Distributions #else
256*d8b80295SApple OSS Distributions 	OSWriteBigInt(segment, 0, inSegment.location);
257*d8b80295SApple OSS Distributions 	OSWriteBigInt(segment, sizeof(IOPhysicalAddress), inSegment.length);
258*d8b80295SApple OSS Distributions #endif
259*d8b80295SApple OSS Distributions }
260*d8b80295SApple OSS Distributions 
261*d8b80295SApple OSS Distributions OSSharedPtr<IOBigMemoryCursor>
withSpecification(IOPhysicalLength inMaxSegmentSize,IOPhysicalLength inMaxTransferSize,IOPhysicalLength inAlignment)262*d8b80295SApple OSS Distributions IOBigMemoryCursor::withSpecification(IOPhysicalLength inMaxSegmentSize,
263*d8b80295SApple OSS Distributions     IOPhysicalLength inMaxTransferSize,
264*d8b80295SApple OSS Distributions     IOPhysicalLength inAlignment)
265*d8b80295SApple OSS Distributions {
266*d8b80295SApple OSS Distributions 	OSSharedPtr<IOBigMemoryCursor> me = OSMakeShared<IOBigMemoryCursor>();
267*d8b80295SApple OSS Distributions 
268*d8b80295SApple OSS Distributions 	if (me && !me->initWithSpecification(inMaxSegmentSize,
269*d8b80295SApple OSS Distributions 	    inMaxTransferSize,
270*d8b80295SApple OSS Distributions 	    inAlignment)) {
271*d8b80295SApple OSS Distributions 		return nullptr;
272*d8b80295SApple OSS Distributions 	}
273*d8b80295SApple OSS Distributions 
274*d8b80295SApple OSS Distributions 	return me;
275*d8b80295SApple OSS Distributions }
276*d8b80295SApple OSS Distributions 
277*d8b80295SApple OSS Distributions bool
initWithSpecification(IOPhysicalLength inMaxSegmentSize,IOPhysicalLength inMaxTransferSize,IOPhysicalLength inAlignment)278*d8b80295SApple OSS Distributions IOBigMemoryCursor::initWithSpecification(IOPhysicalLength inMaxSegmentSize,
279*d8b80295SApple OSS Distributions     IOPhysicalLength inMaxTransferSize,
280*d8b80295SApple OSS Distributions     IOPhysicalLength inAlignment)
281*d8b80295SApple OSS Distributions {
282*d8b80295SApple OSS Distributions 	return super::initWithSpecification(&IOBigMemoryCursor::outputSegment,
283*d8b80295SApple OSS Distributions 	           inMaxSegmentSize,
284*d8b80295SApple OSS Distributions 	           inMaxTransferSize,
285*d8b80295SApple OSS Distributions 	           inAlignment);
286*d8b80295SApple OSS Distributions }
287*d8b80295SApple OSS Distributions 
288*d8b80295SApple OSS Distributions /************************* class IOLittleMemoryCursor ************************/
289*d8b80295SApple OSS Distributions 
290*d8b80295SApple OSS Distributions #undef super
291*d8b80295SApple OSS Distributions #define super IOMemoryCursor
OSDefineMetaClassAndStructors(IOLittleMemoryCursor,IOMemoryCursor)292*d8b80295SApple OSS Distributions OSDefineMetaClassAndStructors(IOLittleMemoryCursor, IOMemoryCursor)
293*d8b80295SApple OSS Distributions 
294*d8b80295SApple OSS Distributions void
295*d8b80295SApple OSS Distributions IOLittleMemoryCursor::outputSegment(PhysicalSegment inSegment,
296*d8b80295SApple OSS Distributions     void *          inSegments,
297*d8b80295SApple OSS Distributions     UInt32          inSegmentIndex)
298*d8b80295SApple OSS Distributions {
299*d8b80295SApple OSS Distributions 	IOPhysicalAddress * segment;
300*d8b80295SApple OSS Distributions 
301*d8b80295SApple OSS Distributions 	segment = &((PhysicalSegment *) inSegments)[inSegmentIndex].location;
302*d8b80295SApple OSS Distributions #if IOPhysSize == 64
303*d8b80295SApple OSS Distributions 	OSWriteLittleInt64(segment, 0, inSegment.location);
304*d8b80295SApple OSS Distributions 	OSWriteLittleInt64(segment, sizeof(IOPhysicalAddress), inSegment.length);
305*d8b80295SApple OSS Distributions #else
306*d8b80295SApple OSS Distributions 	OSWriteLittleInt(segment, 0, inSegment.location);
307*d8b80295SApple OSS Distributions 	OSWriteLittleInt(segment, sizeof(IOPhysicalAddress), inSegment.length);
308*d8b80295SApple OSS Distributions #endif
309*d8b80295SApple OSS Distributions }
310*d8b80295SApple OSS Distributions 
311*d8b80295SApple OSS Distributions OSSharedPtr<IOLittleMemoryCursor>
withSpecification(IOPhysicalLength inMaxSegmentSize,IOPhysicalLength inMaxTransferSize,IOPhysicalLength inAlignment)312*d8b80295SApple OSS Distributions IOLittleMemoryCursor::withSpecification(IOPhysicalLength inMaxSegmentSize,
313*d8b80295SApple OSS Distributions     IOPhysicalLength inMaxTransferSize,
314*d8b80295SApple OSS Distributions     IOPhysicalLength inAlignment)
315*d8b80295SApple OSS Distributions {
316*d8b80295SApple OSS Distributions 	OSSharedPtr<IOLittleMemoryCursor> me = OSMakeShared<IOLittleMemoryCursor>();
317*d8b80295SApple OSS Distributions 
318*d8b80295SApple OSS Distributions 	if (me && !me->initWithSpecification(inMaxSegmentSize,
319*d8b80295SApple OSS Distributions 	    inMaxTransferSize,
320*d8b80295SApple OSS Distributions 	    inAlignment)) {
321*d8b80295SApple OSS Distributions 		return nullptr;
322*d8b80295SApple OSS Distributions 	}
323*d8b80295SApple OSS Distributions 
324*d8b80295SApple OSS Distributions 	return me;
325*d8b80295SApple OSS Distributions }
326*d8b80295SApple OSS Distributions 
327*d8b80295SApple OSS Distributions /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
328*d8b80295SApple OSS Distributions 
329*d8b80295SApple OSS Distributions bool
initWithSpecification(IOPhysicalLength inMaxSegmentSize,IOPhysicalLength inMaxTransferSize,IOPhysicalLength inAlignment)330*d8b80295SApple OSS Distributions IOLittleMemoryCursor::initWithSpecification(IOPhysicalLength inMaxSegmentSize,
331*d8b80295SApple OSS Distributions     IOPhysicalLength inMaxTransferSize,
332*d8b80295SApple OSS Distributions     IOPhysicalLength inAlignment)
333*d8b80295SApple OSS Distributions {
334*d8b80295SApple OSS Distributions 	return super::initWithSpecification(&IOLittleMemoryCursor::outputSegment,
335*d8b80295SApple OSS Distributions 	           inMaxSegmentSize,
336*d8b80295SApple OSS Distributions 	           inMaxTransferSize,
337*d8b80295SApple OSS Distributions 	           inAlignment);
338*d8b80295SApple OSS Distributions }
339