Lines 207-212
static efi_status_t exit_boot_func(struct efi_boot_memmap *map,
Link Here
|
207 |
void *priv) |
207 |
void *priv) |
208 |
{ |
208 |
{ |
209 |
struct exit_boot_struct *p = priv; |
209 |
struct exit_boot_struct *p = priv; |
|
|
210 |
efi_debug("Entered exit_boot_func() - updating map with virtual addresses\n"); |
210 |
/* |
211 |
/* |
211 |
* Update the memory map with virtual addresses. The function will also |
212 |
* Update the memory map with virtual addresses. The function will also |
212 |
* populate @runtime_map with copies of just the EFI_MEMORY_RUNTIME |
213 |
* populate @runtime_map with copies of just the EFI_MEMORY_RUNTIME |
Lines 214-220
static efi_status_t exit_boot_func(struct efi_boot_memmap *map,
Link Here
|
214 |
*/ |
215 |
*/ |
215 |
efi_get_virtmap(*map->map, *map->map_size, *map->desc_size, |
216 |
efi_get_virtmap(*map->map, *map->map_size, *map->desc_size, |
216 |
p->runtime_map, p->runtime_entry_count); |
217 |
p->runtime_map, p->runtime_entry_count); |
217 |
|
218 |
efi_boot_memmap_report(map); |
|
|
219 |
efi_debug("Returning after calling update_fdt_memmap()\n"); |
218 |
return update_fdt_memmap(p->new_fdt_addr, map); |
220 |
return update_fdt_memmap(p->new_fdt_addr, map); |
219 |
} |
221 |
} |
220 |
|
222 |
|
Lines 243-248
efi_status_t allocate_new_fdt_and_exit_boot(void *handle,
Link Here
|
243 |
unsigned long fdt_addr, |
245 |
unsigned long fdt_addr, |
244 |
unsigned long fdt_size) |
246 |
unsigned long fdt_size) |
245 |
{ |
247 |
{ |
|
|
248 |
unsigned long stall_delay = 10000000; |
246 |
unsigned long map_size, desc_size, buff_size; |
249 |
unsigned long map_size, desc_size, buff_size; |
247 |
u32 desc_ver; |
250 |
u32 desc_ver; |
248 |
unsigned long mmap_key; |
251 |
unsigned long mmap_key; |
Lines 259-264
efi_status_t allocate_new_fdt_and_exit_boot(void *handle,
Link Here
|
259 |
map.key_ptr = &mmap_key; |
262 |
map.key_ptr = &mmap_key; |
260 |
map.buff_size = &buff_size; |
263 |
map.buff_size = &buff_size; |
261 |
|
264 |
|
|
|
265 |
efi_debug("Entering allocate_new_fdt_and_exit_boot()\n"); |
262 |
/* |
266 |
/* |
263 |
* Get a copy of the current memory map that we will use to prepare |
267 |
* Get a copy of the current memory map that we will use to prepare |
264 |
* the input for SetVirtualAddressMap(). We don't have to worry about |
268 |
* the input for SetVirtualAddressMap(). We don't have to worry about |
Lines 279-285
efi_status_t allocate_new_fdt_and_exit_boot(void *handle,
Link Here
|
279 |
efi_err("Unable to allocate memory for new device tree.\n"); |
283 |
efi_err("Unable to allocate memory for new device tree.\n"); |
280 |
goto fail; |
284 |
goto fail; |
281 |
} |
285 |
} |
282 |
|
|
|
283 |
/* |
286 |
/* |
284 |
* Now that we have done our final memory allocation (and free) |
287 |
* Now that we have done our final memory allocation (and free) |
285 |
* we can get the memory map key needed for exit_boot_services(). |
288 |
* we can get the memory map key needed for exit_boot_services(). |
Lines 287-319
efi_status_t allocate_new_fdt_and_exit_boot(void *handle,
Link Here
|
287 |
status = efi_get_memory_map(&map); |
290 |
status = efi_get_memory_map(&map); |
288 |
if (status != EFI_SUCCESS) |
291 |
if (status != EFI_SUCCESS) |
289 |
goto fail_free_new_fdt; |
292 |
goto fail_free_new_fdt; |
290 |
|
|
|
291 |
status = update_fdt((void *)fdt_addr, fdt_size, |
293 |
status = update_fdt((void *)fdt_addr, fdt_size, |
292 |
(void *)*new_fdt_addr, MAX_FDT_SIZE, cmdline_ptr, |
294 |
(void *)*new_fdt_addr, MAX_FDT_SIZE, cmdline_ptr, |
293 |
initrd_addr, initrd_size); |
295 |
initrd_addr, initrd_size); |
294 |
|
|
|
295 |
if (status != EFI_SUCCESS) { |
296 |
if (status != EFI_SUCCESS) { |
296 |
efi_err("Unable to construct new device tree.\n"); |
297 |
efi_err("Unable to construct new device tree.\n"); |
297 |
goto fail_free_new_fdt; |
298 |
goto fail_free_new_fdt; |
298 |
} |
299 |
} |
299 |
|
300 |
|
|
|
301 |
efi_debug("Busy Wait so you can read the debug messages!"); |
302 |
efi_bs_call(stall, stall_delay); |
303 |
|
300 |
runtime_entry_count = 0; |
304 |
runtime_entry_count = 0; |
301 |
priv.runtime_map = runtime_map; |
305 |
priv.runtime_map = runtime_map; |
302 |
priv.runtime_entry_count = &runtime_entry_count; |
306 |
priv.runtime_entry_count = &runtime_entry_count; |
303 |
priv.new_fdt_addr = (void *)*new_fdt_addr; |
307 |
priv.new_fdt_addr = (void *)*new_fdt_addr; |
304 |
|
308 |
|
|
|
309 |
efi_debug("Calling efi_exit_boot_services() with map:\n"); |
310 |
efi_boot_memmap_report(&map); |
305 |
status = efi_exit_boot_services(handle, &map, &priv, exit_boot_func); |
311 |
status = efi_exit_boot_services(handle, &map, &priv, exit_boot_func); |
306 |
|
312 |
efi_debug("Returned from efi_exit_boot_services()\n"); |
307 |
if (status == EFI_SUCCESS) { |
313 |
if (status == EFI_SUCCESS) { |
308 |
efi_set_virtual_address_map_t *svam; |
314 |
efi_set_virtual_address_map_t *svam; |
309 |
|
315 |
efi_debug("Preparing to do virtual address map\n"); |
310 |
if (efi_novamap) |
316 |
if (efi_novamap) { |
|
|
317 |
efi_debug("Got 'novamap' so nothing to do\n"); |
311 |
return EFI_SUCCESS; |
318 |
return EFI_SUCCESS; |
|
|
319 |
} |
312 |
|
320 |
|
313 |
/* Install the new virtual address map */ |
321 |
/* Install the new virtual address map */ |
314 |
svam = efi_system_table->runtime->set_virtual_address_map; |
322 |
svam = efi_system_table->runtime->set_virtual_address_map; |
|
|
323 |
efi_debug("Calling svam()\n"); |
315 |
status = svam(runtime_entry_count * desc_size, desc_size, |
324 |
status = svam(runtime_entry_count * desc_size, desc_size, |
316 |
desc_ver, runtime_map); |
325 |
desc_ver, runtime_map); |
|
|
326 |
efi_debug("Returned from svam()\n"); |
317 |
|
327 |
|
318 |
/* |
328 |
/* |
319 |
* We are beyond the point of no return here, so if the call to |
329 |
* We are beyond the point of no return here, so if the call to |
Lines 322-327
efi_status_t allocate_new_fdt_and_exit_boot(void *handle,
Link Here
|
322 |
*/ |
332 |
*/ |
323 |
if (status != EFI_SUCCESS) { |
333 |
if (status != EFI_SUCCESS) { |
324 |
int l; |
334 |
int l; |
|
|
335 |
efi_debug("svam() failed with %ld\n", status); |
325 |
|
336 |
|
326 |
/* |
337 |
/* |
327 |
* Set the virtual address field of all |
338 |
* Set the virtual address field of all |
Lines 336-352
efi_status_t allocate_new_fdt_and_exit_boot(void *handle,
Link Here
|
336 |
p->virt_addr = 0; |
347 |
p->virt_addr = 0; |
337 |
} |
348 |
} |
338 |
} |
349 |
} |
|
|
350 |
efi_debug("allocate_new_fdt_and_exit_boot() returning EFI_SUCCESS\n"); |
339 |
return EFI_SUCCESS; |
351 |
return EFI_SUCCESS; |
340 |
} |
352 |
} |
341 |
|
353 |
|
342 |
efi_err("Exit boot services failed.\n"); |
354 |
efi_err("Exit boot services failed.\n"); |
343 |
|
355 |
|
344 |
fail_free_new_fdt: |
356 |
fail_free_new_fdt: |
|
|
357 |
efi_debug("fail_free_new_fdt: status=%ld\n", status); |
345 |
efi_free(MAX_FDT_SIZE, *new_fdt_addr); |
358 |
efi_free(MAX_FDT_SIZE, *new_fdt_addr); |
346 |
|
359 |
|
347 |
fail: |
360 |
fail: |
|
|
361 |
efi_debug("fail: status=%ld\n", status); |
348 |
efi_system_table->boottime->free_pool(runtime_map); |
362 |
efi_system_table->boottime->free_pool(runtime_map); |
349 |
|
363 |
efi_debug("Busy Wait so you can read the debug messages!"); |
|
|
364 |
efi_bs_call(stall, stall_delay); |
350 |
return EFI_LOAD_ERROR; |
365 |
return EFI_LOAD_ERROR; |
351 |
} |
366 |
} |
352 |
|
367 |
|