void efi_runtime_relocate(ulong offset, struct efi_mem_desc *map);
/* Call this to set the current device name */
void efi_set_bootdev(const char *dev, const char *devnr, const char *path);
+/* Add a new object to the object list. */
+void efi_add_handle(struct efi_object *obj);
/* Create handle */
efi_status_t efi_create_handle(void **handle);
/* Call this to validate a handle and find the EFI object for it */
return EFI_EXIT(r);
}
+/*
+ * Add a new object to the object list.
+ *
+ * The protocols list is initialized.
+ * The object handle is set.
+ *
+ * @obj object to be added
+ */
+void efi_add_handle(struct efi_object *obj)
+{
+ if (!obj)
+ return;
+ INIT_LIST_HEAD(&obj->protocols);
+ obj->handle = obj;
+ list_add_tail(&obj->link, &efi_obj_list);
+}
+
/*
* Create handle.
*
(void **)&obj);
if (r != EFI_SUCCESS)
return r;
- memset(obj, 0, sizeof(struct efi_object));
- obj->handle = obj;
- INIT_LIST_HEAD(&obj->protocols);
- list_add_tail(&obj->link, &efi_obj_list);
- *handle = obj;
+ efi_add_handle(obj);
+ *handle = obj->handle;
return r;
}
{
efi_status_t ret;
+ /* Add internal object to object list */
+ efi_add_handle(obj);
+ /* efi_exit() assumes that the handle points to the info */
obj->handle = info;
info->file_path = file_path;
if (device_path)
info->device_handle = efi_dp_find_obj(device_path, NULL);
- INIT_LIST_HEAD(&obj->protocols);
- list_add_tail(&obj->link, &efi_obj_list);
/*
* When asking for the device path interface, return
* bootefi_device_path
efi_status_t exit_status, unsigned long exit_data_size,
int16_t *exit_data)
{
+ /*
+ * We require that the handle points to the original loaded
+ * image protocol interface.
+ *
+ * For getting the longjmp address this is safer than locating
+ * the protocol because the protocol may have been reinstalled
+ * pointing to another memory location.
+ *
+ * TODO: We should call the unload procedure of the loaded
+ * image protocol.
+ */
struct efi_loaded_image *loaded_image_info = (void*)image_handle;
EFI_ENTRY("%p, %ld, %ld, %p", image_handle, exit_status,
goto out_of_memory;
/* Hook up to the device list */
- INIT_LIST_HEAD(&diskobj->parent.protocols);
- list_add_tail(&diskobj->parent.link, &efi_obj_list);
+ efi_add_handle(&diskobj->parent);
/* Fill in object data */
diskobj->dp = efi_dp_from_part(desc, part);
diskobj->part = part;
- diskobj->parent.handle = diskobj;
ret = efi_add_protocol(diskobj->parent.handle, &efi_block_io_guid,
&diskobj->ops);
if (ret != EFI_SUCCESS)
}
/* Hook up to the device list */
- INIT_LIST_HEAD(&gopobj->parent.protocols);
- list_add_tail(&gopobj->parent.link, &efi_obj_list);
+ efi_add_handle(&gopobj->parent);
/* Fill in object data */
- gopobj->parent.handle = &gopobj->ops;
ret = efi_add_protocol(gopobj->parent.handle, &efi_gop_guid,
&gopobj->ops);
if (ret != EFI_SUCCESS) {
goto out_of_memory;
/* Hook net up to the device list */
- INIT_LIST_HEAD(&netobj->parent.protocols);
- list_add_tail(&netobj->parent.link, &efi_obj_list);
+ efi_add_handle(&netobj->parent);
/* Fill in object data */
- netobj->parent.handle = &netobj->net;
r = efi_add_protocol(netobj->parent.handle, &efi_net_guid,
&netobj->net);
if (r != EFI_SUCCESS)