1*bbb1b6f9SApple OSS Distributions /*
2*bbb1b6f9SApple OSS Distributions * Copyright (c) 2010 Apple Inc. All rights reserved.
3*bbb1b6f9SApple OSS Distributions *
4*bbb1b6f9SApple OSS Distributions * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5*bbb1b6f9SApple OSS Distributions *
6*bbb1b6f9SApple OSS Distributions * This file contains Original Code and/or Modifications of Original Code
7*bbb1b6f9SApple OSS Distributions * as defined in and that are subject to the Apple Public Source License
8*bbb1b6f9SApple OSS Distributions * Version 2.0 (the 'License'). You may not use this file except in
9*bbb1b6f9SApple OSS Distributions * compliance with the License. The rights granted to you under the License
10*bbb1b6f9SApple OSS Distributions * may not be used to create, or enable the creation or redistribution of,
11*bbb1b6f9SApple OSS Distributions * unlawful or unlicensed copies of an Apple operating system, or to
12*bbb1b6f9SApple OSS Distributions * circumvent, violate, or enable the circumvention or violation of, any
13*bbb1b6f9SApple OSS Distributions * terms of an Apple operating system software license agreement.
14*bbb1b6f9SApple OSS Distributions *
15*bbb1b6f9SApple OSS Distributions * Please obtain a copy of the License at
16*bbb1b6f9SApple OSS Distributions * http://www.opensource.apple.com/apsl/ and read it before using this file.
17*bbb1b6f9SApple OSS Distributions *
18*bbb1b6f9SApple OSS Distributions * The Original Code and all software distributed under the License are
19*bbb1b6f9SApple OSS Distributions * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20*bbb1b6f9SApple OSS Distributions * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21*bbb1b6f9SApple OSS Distributions * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22*bbb1b6f9SApple OSS Distributions * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23*bbb1b6f9SApple OSS Distributions * Please see the License for the specific language governing rights and
24*bbb1b6f9SApple OSS Distributions * limitations under the License.
25*bbb1b6f9SApple OSS Distributions *
26*bbb1b6f9SApple OSS Distributions * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27*bbb1b6f9SApple OSS Distributions */
28*bbb1b6f9SApple OSS Distributions
29*bbb1b6f9SApple OSS Distributions #include <sys/cdefs.h>
30*bbb1b6f9SApple OSS Distributions #include <stdbool.h>
31*bbb1b6f9SApple OSS Distributions
32*bbb1b6f9SApple OSS Distributions #include <IOKit/assert.h>
33*bbb1b6f9SApple OSS Distributions #include <IOKit/system.h>
34*bbb1b6f9SApple OSS Distributions #include <IOKit/IOLib.h>
35*bbb1b6f9SApple OSS Distributions #include <IOKit/IOMemoryDescriptor.h>
36*bbb1b6f9SApple OSS Distributions #include <IOKit/IOKitDebug.h>
37*bbb1b6f9SApple OSS Distributions
38*bbb1b6f9SApple OSS Distributions __BEGIN_DECLS
39*bbb1b6f9SApple OSS Distributions
40*bbb1b6f9SApple OSS Distributions #include <pexpert/pexpert.h>
41*bbb1b6f9SApple OSS Distributions
42*bbb1b6f9SApple OSS Distributions static volatile UInt32 alreadyFetched = 0;
43*bbb1b6f9SApple OSS Distributions static IOMemoryDescriptor * newData;
44*bbb1b6f9SApple OSS Distributions
45*bbb1b6f9SApple OSS Distributions IOMemoryDescriptor *
46*bbb1b6f9SApple OSS Distributions IOGetBootKeyStoreData(void);
47*bbb1b6f9SApple OSS Distributions void
48*bbb1b6f9SApple OSS Distributions IOSetKeyStoreData(IOMemoryDescriptor * data);
49*bbb1b6f9SApple OSS Distributions
50*bbb1b6f9SApple OSS Distributions // APFS
51*bbb1b6f9SApple OSS Distributions static volatile UInt32 apfsKeyFetched = 0;
52*bbb1b6f9SApple OSS Distributions static IOMemoryDescriptor* apfsKeyData = NULL;
53*bbb1b6f9SApple OSS Distributions
54*bbb1b6f9SApple OSS Distributions IOMemoryDescriptor* IOGetAPFSKeyStoreData();
55*bbb1b6f9SApple OSS Distributions void IOSetAPFSKeyStoreData(IOMemoryDescriptor* data);
56*bbb1b6f9SApple OSS Distributions
57*bbb1b6f9SApple OSS Distributions static volatile UInt32 ARVRootHashFetched = 0;
58*bbb1b6f9SApple OSS Distributions static volatile UInt32 bsARVRootHashFetched = 0;
59*bbb1b6f9SApple OSS Distributions
60*bbb1b6f9SApple OSS Distributions IOMemoryDescriptor* IOGetARVRootHashData(void);
61*bbb1b6f9SApple OSS Distributions IOMemoryDescriptor* IOGetBaseSystemARVRootHashData(void);
62*bbb1b6f9SApple OSS Distributions
63*bbb1b6f9SApple OSS Distributions bool IOBaseSystemARVRootHashAvailable(void);
64*bbb1b6f9SApple OSS Distributions
65*bbb1b6f9SApple OSS Distributions static volatile UInt32 ARVManifestFetched = 0;
66*bbb1b6f9SApple OSS Distributions static volatile UInt32 bsARVManifestFetched = 0;
67*bbb1b6f9SApple OSS Distributions
68*bbb1b6f9SApple OSS Distributions IOMemoryDescriptor* IOGetARVManifestData(void);
69*bbb1b6f9SApple OSS Distributions IOMemoryDescriptor* IOGetBaseSystemARVManifestData(void);
70*bbb1b6f9SApple OSS Distributions
71*bbb1b6f9SApple OSS Distributions __END_DECLS
72*bbb1b6f9SApple OSS Distributions
73*bbb1b6f9SApple OSS Distributions #if 1
74*bbb1b6f9SApple OSS Distributions #define DEBG(fmt, args...) { kprintf(fmt, ## args); }
75*bbb1b6f9SApple OSS Distributions #else
76*bbb1b6f9SApple OSS Distributions #define DEBG(fmt, args...) {}
77*bbb1b6f9SApple OSS Distributions #endif
78*bbb1b6f9SApple OSS Distributions
79*bbb1b6f9SApple OSS Distributions void
IOSetKeyStoreData(IOMemoryDescriptor * data)80*bbb1b6f9SApple OSS Distributions IOSetKeyStoreData(IOMemoryDescriptor * data)
81*bbb1b6f9SApple OSS Distributions {
82*bbb1b6f9SApple OSS Distributions newData = data;
83*bbb1b6f9SApple OSS Distributions alreadyFetched = 0;
84*bbb1b6f9SApple OSS Distributions }
85*bbb1b6f9SApple OSS Distributions
86*bbb1b6f9SApple OSS Distributions IOMemoryDescriptor *
IOGetBootKeyStoreData(void)87*bbb1b6f9SApple OSS Distributions IOGetBootKeyStoreData(void)
88*bbb1b6f9SApple OSS Distributions {
89*bbb1b6f9SApple OSS Distributions IOMemoryDescriptor *memoryDescriptor;
90*bbb1b6f9SApple OSS Distributions boot_args *args = (boot_args *)PE_state.bootArgs;
91*bbb1b6f9SApple OSS Distributions IOOptionBits options;
92*bbb1b6f9SApple OSS Distributions IOAddressRange ranges;
93*bbb1b6f9SApple OSS Distributions
94*bbb1b6f9SApple OSS Distributions if (!OSCompareAndSwap(0, 1, &alreadyFetched)) {
95*bbb1b6f9SApple OSS Distributions return NULL;
96*bbb1b6f9SApple OSS Distributions }
97*bbb1b6f9SApple OSS Distributions
98*bbb1b6f9SApple OSS Distributions if (newData) {
99*bbb1b6f9SApple OSS Distributions IOMemoryDescriptor * data = newData;
100*bbb1b6f9SApple OSS Distributions newData = NULL;
101*bbb1b6f9SApple OSS Distributions return data;
102*bbb1b6f9SApple OSS Distributions }
103*bbb1b6f9SApple OSS Distributions
104*bbb1b6f9SApple OSS Distributions DEBG("%s: data at address %u size %u\n", __func__,
105*bbb1b6f9SApple OSS Distributions args->keyStoreDataStart,
106*bbb1b6f9SApple OSS Distributions args->keyStoreDataSize);
107*bbb1b6f9SApple OSS Distributions
108*bbb1b6f9SApple OSS Distributions if (args->keyStoreDataStart == 0) {
109*bbb1b6f9SApple OSS Distributions return NULL;
110*bbb1b6f9SApple OSS Distributions }
111*bbb1b6f9SApple OSS Distributions
112*bbb1b6f9SApple OSS Distributions ranges.address = args->keyStoreDataStart;
113*bbb1b6f9SApple OSS Distributions ranges.length = args->keyStoreDataSize;
114*bbb1b6f9SApple OSS Distributions
115*bbb1b6f9SApple OSS Distributions options = kIODirectionInOut | kIOMemoryTypePhysical64 | kIOMemoryMapperNone;
116*bbb1b6f9SApple OSS Distributions
117*bbb1b6f9SApple OSS Distributions memoryDescriptor = IOMemoryDescriptor::withOptions(&ranges,
118*bbb1b6f9SApple OSS Distributions 1,
119*bbb1b6f9SApple OSS Distributions 0,
120*bbb1b6f9SApple OSS Distributions NULL,
121*bbb1b6f9SApple OSS Distributions options);
122*bbb1b6f9SApple OSS Distributions
123*bbb1b6f9SApple OSS Distributions DEBG("%s: memory descriptor %p\n", __func__, memoryDescriptor);
124*bbb1b6f9SApple OSS Distributions
125*bbb1b6f9SApple OSS Distributions return memoryDescriptor;
126*bbb1b6f9SApple OSS Distributions }
127*bbb1b6f9SApple OSS Distributions
128*bbb1b6f9SApple OSS Distributions // APFS volume key fetcher
129*bbb1b6f9SApple OSS Distributions
130*bbb1b6f9SApple OSS Distributions // Store in-memory key (could be used by IOHibernateDone)
131*bbb1b6f9SApple OSS Distributions void
IOSetAPFSKeyStoreData(IOMemoryDescriptor * data)132*bbb1b6f9SApple OSS Distributions IOSetAPFSKeyStoreData(IOMemoryDescriptor* data)
133*bbb1b6f9SApple OSS Distributions {
134*bbb1b6f9SApple OSS Distributions // Do not allow re-fetching of the boot_args key by passing NULL here.
135*bbb1b6f9SApple OSS Distributions if (data != NULL) {
136*bbb1b6f9SApple OSS Distributions apfsKeyData = data;
137*bbb1b6f9SApple OSS Distributions apfsKeyFetched = 0;
138*bbb1b6f9SApple OSS Distributions }
139*bbb1b6f9SApple OSS Distributions }
140*bbb1b6f9SApple OSS Distributions
141*bbb1b6f9SApple OSS Distributions // Retrieve any key we may have (stored in boot_args or by Hibernate)
142*bbb1b6f9SApple OSS Distributions IOMemoryDescriptor*
IOGetAPFSKeyStoreData()143*bbb1b6f9SApple OSS Distributions IOGetAPFSKeyStoreData()
144*bbb1b6f9SApple OSS Distributions {
145*bbb1b6f9SApple OSS Distributions // Check if someone got the key before us
146*bbb1b6f9SApple OSS Distributions if (!OSCompareAndSwap(0, 1, &apfsKeyFetched)) {
147*bbb1b6f9SApple OSS Distributions return NULL;
148*bbb1b6f9SApple OSS Distributions }
149*bbb1b6f9SApple OSS Distributions
150*bbb1b6f9SApple OSS Distributions // Do we have in-memory key?
151*bbb1b6f9SApple OSS Distributions if (apfsKeyData) {
152*bbb1b6f9SApple OSS Distributions IOMemoryDescriptor* data = apfsKeyData;
153*bbb1b6f9SApple OSS Distributions apfsKeyData = NULL;
154*bbb1b6f9SApple OSS Distributions return data;
155*bbb1b6f9SApple OSS Distributions }
156*bbb1b6f9SApple OSS Distributions
157*bbb1b6f9SApple OSS Distributions // Looks like there was no in-memory key and it's the first call - try boot_args
158*bbb1b6f9SApple OSS Distributions boot_args* args = (boot_args*)PE_state.bootArgs;
159*bbb1b6f9SApple OSS Distributions
160*bbb1b6f9SApple OSS Distributions DEBG("%s: data at address %u size %u\n", __func__, args->apfsDataStart, args->apfsDataSize);
161*bbb1b6f9SApple OSS Distributions if (args->apfsDataStart == 0) {
162*bbb1b6f9SApple OSS Distributions return NULL;
163*bbb1b6f9SApple OSS Distributions }
164*bbb1b6f9SApple OSS Distributions
165*bbb1b6f9SApple OSS Distributions // We have the key in the boot_args, create IOMemoryDescriptor for the blob
166*bbb1b6f9SApple OSS Distributions IOAddressRange ranges;
167*bbb1b6f9SApple OSS Distributions ranges.address = args->apfsDataStart;
168*bbb1b6f9SApple OSS Distributions ranges.length = args->apfsDataSize;
169*bbb1b6f9SApple OSS Distributions
170*bbb1b6f9SApple OSS Distributions const IOOptionBits options = kIODirectionInOut | kIOMemoryTypePhysical64 | kIOMemoryMapperNone;
171*bbb1b6f9SApple OSS Distributions
172*bbb1b6f9SApple OSS Distributions IOMemoryDescriptor* memoryDescriptor = IOMemoryDescriptor::withOptions(&ranges, 1, 0, NULL, options);
173*bbb1b6f9SApple OSS Distributions DEBG("%s: memory descriptor %p\n", __func__, memoryDescriptor);
174*bbb1b6f9SApple OSS Distributions return memoryDescriptor;
175*bbb1b6f9SApple OSS Distributions }
176*bbb1b6f9SApple OSS Distributions
177*bbb1b6f9SApple OSS Distributions // ARV Root Hash fetcher
178*bbb1b6f9SApple OSS Distributions
179*bbb1b6f9SApple OSS Distributions // Retrieve any root hash we may have (stored in boot_args)
180*bbb1b6f9SApple OSS Distributions IOMemoryDescriptor*
IOGetARVRootHashData(void)181*bbb1b6f9SApple OSS Distributions IOGetARVRootHashData(void)
182*bbb1b6f9SApple OSS Distributions {
183*bbb1b6f9SApple OSS Distributions // Check if someone got the root hash before us
184*bbb1b6f9SApple OSS Distributions if (!OSCompareAndSwap(0, 1, &ARVRootHashFetched)) {
185*bbb1b6f9SApple OSS Distributions return NULL;
186*bbb1b6f9SApple OSS Distributions }
187*bbb1b6f9SApple OSS Distributions
188*bbb1b6f9SApple OSS Distributions boot_args* args = (boot_args*)PE_state.bootArgs;
189*bbb1b6f9SApple OSS Distributions
190*bbb1b6f9SApple OSS Distributions DEBG("%s: data at address %llu size %llu\n", __func__, args->arvRootHashStart, args->arvRootHashSize);
191*bbb1b6f9SApple OSS Distributions if (args->arvRootHashStart == 0) {
192*bbb1b6f9SApple OSS Distributions return NULL;
193*bbb1b6f9SApple OSS Distributions }
194*bbb1b6f9SApple OSS Distributions
195*bbb1b6f9SApple OSS Distributions // We have the root hash in the boot_args, create IOMemoryDescriptor for the blob
196*bbb1b6f9SApple OSS Distributions IOAddressRange ranges;
197*bbb1b6f9SApple OSS Distributions ranges.address = args->arvRootHashStart;
198*bbb1b6f9SApple OSS Distributions ranges.length = args->arvRootHashSize;
199*bbb1b6f9SApple OSS Distributions
200*bbb1b6f9SApple OSS Distributions const IOOptionBits options = kIODirectionInOut | kIOMemoryTypePhysical64 | kIOMemoryMapperNone;
201*bbb1b6f9SApple OSS Distributions
202*bbb1b6f9SApple OSS Distributions IOMemoryDescriptor* memoryDescriptor = IOMemoryDescriptor::withOptions(&ranges, 1, 0, NULL, options);
203*bbb1b6f9SApple OSS Distributions DEBG("%s: memory descriptor %p\n", __func__, memoryDescriptor);
204*bbb1b6f9SApple OSS Distributions return memoryDescriptor;
205*bbb1b6f9SApple OSS Distributions }
206*bbb1b6f9SApple OSS Distributions
207*bbb1b6f9SApple OSS Distributions // Base System Analogue
208*bbb1b6f9SApple OSS Distributions
209*bbb1b6f9SApple OSS Distributions IOMemoryDescriptor*
IOGetBaseSystemARVRootHashData(void)210*bbb1b6f9SApple OSS Distributions IOGetBaseSystemARVRootHashData(void)
211*bbb1b6f9SApple OSS Distributions {
212*bbb1b6f9SApple OSS Distributions // Check if someone got the base system root hash before us
213*bbb1b6f9SApple OSS Distributions if (!OSCompareAndSwap(0, 1, &bsARVRootHashFetched)) {
214*bbb1b6f9SApple OSS Distributions return NULL;
215*bbb1b6f9SApple OSS Distributions }
216*bbb1b6f9SApple OSS Distributions
217*bbb1b6f9SApple OSS Distributions boot_args* args = (boot_args*)PE_state.bootArgs;
218*bbb1b6f9SApple OSS Distributions
219*bbb1b6f9SApple OSS Distributions DEBG("%s: data at address %llu size %llu\n", __func__, args->bsARVRootHashStart, args->bsARVRootHashSize);
220*bbb1b6f9SApple OSS Distributions if (args->bsARVRootHashStart == 0) {
221*bbb1b6f9SApple OSS Distributions return NULL;
222*bbb1b6f9SApple OSS Distributions }
223*bbb1b6f9SApple OSS Distributions
224*bbb1b6f9SApple OSS Distributions // We have the base system root hash in the boot_args, create IOMemoryDescriptor for the blob
225*bbb1b6f9SApple OSS Distributions IOAddressRange ranges;
226*bbb1b6f9SApple OSS Distributions ranges.address = args->bsARVRootHashStart;
227*bbb1b6f9SApple OSS Distributions ranges.length = args->bsARVRootHashSize;
228*bbb1b6f9SApple OSS Distributions
229*bbb1b6f9SApple OSS Distributions const IOOptionBits options = kIODirectionInOut | kIOMemoryTypePhysical64 | kIOMemoryMapperNone;
230*bbb1b6f9SApple OSS Distributions
231*bbb1b6f9SApple OSS Distributions IOMemoryDescriptor* memoryDescriptor = IOMemoryDescriptor::withOptions(&ranges, 1, 0, NULL, options);
232*bbb1b6f9SApple OSS Distributions DEBG("%s: memory descriptor %p\n", __func__, memoryDescriptor);
233*bbb1b6f9SApple OSS Distributions return memoryDescriptor;
234*bbb1b6f9SApple OSS Distributions }
235*bbb1b6f9SApple OSS Distributions
236*bbb1b6f9SApple OSS Distributions bool
IOBaseSystemARVRootHashAvailable(void)237*bbb1b6f9SApple OSS Distributions IOBaseSystemARVRootHashAvailable(void)
238*bbb1b6f9SApple OSS Distributions {
239*bbb1b6f9SApple OSS Distributions boot_args* args = (boot_args*)PE_state.bootArgs;
240*bbb1b6f9SApple OSS Distributions
241*bbb1b6f9SApple OSS Distributions if (args->bsARVRootHashStart == 0 || args->bsARVRootHashSize == 0) {
242*bbb1b6f9SApple OSS Distributions return false;
243*bbb1b6f9SApple OSS Distributions }
244*bbb1b6f9SApple OSS Distributions
245*bbb1b6f9SApple OSS Distributions if (args->bsARVManifestStart == 0 || args->bsARVManifestSize == 0) {
246*bbb1b6f9SApple OSS Distributions return false;
247*bbb1b6f9SApple OSS Distributions }
248*bbb1b6f9SApple OSS Distributions
249*bbb1b6f9SApple OSS Distributions return true;
250*bbb1b6f9SApple OSS Distributions }
251*bbb1b6f9SApple OSS Distributions
252*bbb1b6f9SApple OSS Distributions // ARV Manifest fetcher
253*bbb1b6f9SApple OSS Distributions
254*bbb1b6f9SApple OSS Distributions // Retrieve any manifest we may have (stored in boot_args)
255*bbb1b6f9SApple OSS Distributions IOMemoryDescriptor*
IOGetARVManifestData(void)256*bbb1b6f9SApple OSS Distributions IOGetARVManifestData(void)
257*bbb1b6f9SApple OSS Distributions {
258*bbb1b6f9SApple OSS Distributions // Check if someone got the manifest before us
259*bbb1b6f9SApple OSS Distributions if (!OSCompareAndSwap(0, 1, &ARVManifestFetched)) {
260*bbb1b6f9SApple OSS Distributions return NULL;
261*bbb1b6f9SApple OSS Distributions }
262*bbb1b6f9SApple OSS Distributions
263*bbb1b6f9SApple OSS Distributions boot_args* args = (boot_args*)PE_state.bootArgs;
264*bbb1b6f9SApple OSS Distributions
265*bbb1b6f9SApple OSS Distributions DEBG("%s: data at address %llu size %llu\n", __func__, args->arvManifestStart, args->arvManifestSize);
266*bbb1b6f9SApple OSS Distributions if (args->arvManifestStart == 0) {
267*bbb1b6f9SApple OSS Distributions return NULL;
268*bbb1b6f9SApple OSS Distributions }
269*bbb1b6f9SApple OSS Distributions
270*bbb1b6f9SApple OSS Distributions // We have the manifest in the boot_args, create IOMemoryDescriptor for the blob
271*bbb1b6f9SApple OSS Distributions IOAddressRange ranges;
272*bbb1b6f9SApple OSS Distributions ranges.address = args->arvManifestStart;
273*bbb1b6f9SApple OSS Distributions ranges.length = args->arvManifestSize;
274*bbb1b6f9SApple OSS Distributions
275*bbb1b6f9SApple OSS Distributions const IOOptionBits options = kIODirectionInOut | kIOMemoryTypePhysical64 | kIOMemoryMapperNone;
276*bbb1b6f9SApple OSS Distributions
277*bbb1b6f9SApple OSS Distributions IOMemoryDescriptor* memoryDescriptor = IOMemoryDescriptor::withOptions(&ranges, 1, 0, NULL, options);
278*bbb1b6f9SApple OSS Distributions DEBG("%s: memory descriptor %p\n", __func__, memoryDescriptor);
279*bbb1b6f9SApple OSS Distributions return memoryDescriptor;
280*bbb1b6f9SApple OSS Distributions }
281*bbb1b6f9SApple OSS Distributions
282*bbb1b6f9SApple OSS Distributions // Base System Analogue
283*bbb1b6f9SApple OSS Distributions
284*bbb1b6f9SApple OSS Distributions IOMemoryDescriptor*
IOGetBaseSystemARVManifestData(void)285*bbb1b6f9SApple OSS Distributions IOGetBaseSystemARVManifestData(void)
286*bbb1b6f9SApple OSS Distributions {
287*bbb1b6f9SApple OSS Distributions // Check if someone got the base system manifest before us
288*bbb1b6f9SApple OSS Distributions if (!OSCompareAndSwap(0, 1, &bsARVManifestFetched)) {
289*bbb1b6f9SApple OSS Distributions return NULL;
290*bbb1b6f9SApple OSS Distributions }
291*bbb1b6f9SApple OSS Distributions
292*bbb1b6f9SApple OSS Distributions boot_args* args = (boot_args*)PE_state.bootArgs;
293*bbb1b6f9SApple OSS Distributions
294*bbb1b6f9SApple OSS Distributions DEBG("%s: data at address %llu size %llu\n", __func__, args->bsARVManifestStart, args->bsARVManifestSize);
295*bbb1b6f9SApple OSS Distributions if (args->bsARVManifestStart == 0) {
296*bbb1b6f9SApple OSS Distributions return NULL;
297*bbb1b6f9SApple OSS Distributions }
298*bbb1b6f9SApple OSS Distributions
299*bbb1b6f9SApple OSS Distributions // We have the manifest in the boot_args, create IOMemoryDescriptor for the blob
300*bbb1b6f9SApple OSS Distributions IOAddressRange ranges;
301*bbb1b6f9SApple OSS Distributions ranges.address = args->bsARVManifestStart;
302*bbb1b6f9SApple OSS Distributions ranges.length = args->bsARVManifestSize;
303*bbb1b6f9SApple OSS Distributions
304*bbb1b6f9SApple OSS Distributions const IOOptionBits options = kIODirectionInOut | kIOMemoryTypePhysical64 | kIOMemoryMapperNone;
305*bbb1b6f9SApple OSS Distributions
306*bbb1b6f9SApple OSS Distributions IOMemoryDescriptor* memoryDescriptor = IOMemoryDescriptor::withOptions(&ranges, 1, 0, NULL, options);
307*bbb1b6f9SApple OSS Distributions DEBG("%s: memory descriptor %p\n", __func__, memoryDescriptor);
308*bbb1b6f9SApple OSS Distributions return memoryDescriptor;
309*bbb1b6f9SApple OSS Distributions }
310