DECLARE_GLOBAL_DATA_PTR;
/* Task priority level */
-static UINTN efi_tpl = TPL_APPLICATION;
+static efi_uintn_t efi_tpl = TPL_APPLICATION;
/* This list contains all the EFI objects our payload has access to */
LIST_HEAD(efi_obj_list);
event->is_queued = false;
}
-/*
- * Write a debug message for an EPI API service that is not implemented yet.
- *
- * @funcname function that is not yet implemented
- * @return EFI_UNSUPPORTED
- */
-static efi_status_t efi_unsupported(const char *funcname)
-{
- debug("EFI: App called into unimplemented function %s\n", funcname);
- return EFI_EXIT(EFI_UNSUPPORTED);
-}
-
/*
* Raise the task priority level.
*
* @new_tpl new value of the task priority level
* @return old value of the task priority level
*/
-static unsigned long EFIAPI efi_raise_tpl(UINTN new_tpl)
+static unsigned long EFIAPI efi_raise_tpl(efi_uintn_t new_tpl)
{
- UINTN old_tpl = efi_tpl;
+ efi_uintn_t old_tpl = efi_tpl;
EFI_ENTRY("0x%zx", new_tpl);
*
* @old_tpl value of the task priority level to be restored
*/
-static void EFIAPI efi_restore_tpl(UINTN old_tpl)
+static void EFIAPI efi_restore_tpl(efi_uintn_t old_tpl)
{
EFI_ENTRY("0x%zx", old_tpl);
* @return status code
*/
static efi_status_t EFIAPI efi_allocate_pages_ext(int type, int memory_type,
- unsigned long pages,
+ efi_uintn_t pages,
uint64_t *memory)
{
efi_status_t r;
- EFI_ENTRY("%d, %d, 0x%lx, %p", type, memory_type, pages, memory);
+ EFI_ENTRY("%d, %d, 0x%zx, %p", type, memory_type, pages, memory);
r = efi_allocate_pages(type, memory_type, pages, memory);
return EFI_EXIT(r);
}
* @return status code
*/
static efi_status_t EFIAPI efi_free_pages_ext(uint64_t memory,
- unsigned long pages)
+ efi_uintn_t pages)
{
efi_status_t r;
- EFI_ENTRY("%"PRIx64", 0x%lx", memory, pages);
+ EFI_ENTRY("%"PRIx64", 0x%zx", memory, pages);
r = efi_free_pages(memory, pages);
return EFI_EXIT(r);
}
* @return status code
*/
static efi_status_t EFIAPI efi_get_memory_map_ext(
- unsigned long *memory_map_size,
+ efi_uintn_t *memory_map_size,
struct efi_mem_desc *memory_map,
- unsigned long *map_key,
- unsigned long *descriptor_size,
+ efi_uintn_t *map_key,
+ efi_uintn_t *descriptor_size,
uint32_t *descriptor_version)
{
efi_status_t r;
* @return status code
*/
static efi_status_t EFIAPI efi_allocate_pool_ext(int pool_type,
- unsigned long size,
+ efi_uintn_t size,
void **buffer)
{
efi_status_t r;
- EFI_ENTRY("%d, %ld, %p", pool_type, size, buffer);
+ EFI_ENTRY("%d, %zd, %p", pool_type, size, buffer);
r = efi_allocate_pool(pool_type, size, buffer);
return EFI_EXIT(r);
}
* @event created event
* @return status code
*/
-efi_status_t efi_create_event(uint32_t type, UINTN notify_tpl,
+efi_status_t efi_create_event(uint32_t type, efi_uintn_t notify_tpl,
void (EFIAPI *notify_function) (
struct efi_event *event,
void *context),
* @return status code
*/
static efi_status_t EFIAPI efi_create_event_ext(
- uint32_t type, UINTN notify_tpl,
+ uint32_t type, efi_uintn_t notify_tpl,
void (EFIAPI *notify_function) (
struct efi_event *event,
void *context),
* @index index of the event that was signaled
* @return status code
*/
-static efi_status_t EFIAPI efi_wait_for_event(unsigned long num_events,
+static efi_status_t EFIAPI efi_wait_for_event(efi_uintn_t num_events,
struct efi_event **event,
- size_t *index)
+ efi_uintn_t *index)
{
int i, j;
- EFI_ENTRY("%ld, %p, %p", num_events, event, index);
+ EFI_ENTRY("%zd, %p, %p", num_events, event, index);
/* Check parameters */
if (!num_events || !event)
return EFI_EXIT(EFI_INVALID_PARAMETER);
}
+/*
+ * Find the internal EFI object for a handle.
+ *
+ * @handle handle to find
+ * @return EFI object
+ */
+struct efi_object *efi_search_obj(void *handle)
+{
+ struct efi_object *efiobj;
+
+ list_for_each_entry(efiobj, &efi_obj_list, link) {
+ if (efiobj->handle == handle)
+ return efiobj;
+ }
+
+ return NULL;
+}
+
/*
* Install protocol interface.
*
- * This is the function for internal calls. For the API implementation of the
- * InstallProtocolInterface service see function
- * efi_install_protocol_interface_ext.
+ * This function implements the InstallProtocolInterface service.
+ * See the Unified Extensible Firmware Interface (UEFI) specification
+ * for details.
*
* @handle handle on which the protocol shall be installed
* @protocol GUID of the protocol to be installed
* @protocol_interface interface of the protocol implementation
* @return status code
*/
-static efi_status_t EFIAPI efi_install_protocol_interface(void **handle,
- const efi_guid_t *protocol, int protocol_interface_type,
- void *protocol_interface)
+static efi_status_t EFIAPI efi_install_protocol_interface(
+ void **handle, const efi_guid_t *protocol,
+ int protocol_interface_type, void *protocol_interface)
{
struct list_head *lhandle;
int i;
efi_status_t r;
+ EFI_ENTRY("%p, %pUl, %d, %p", handle, protocol, protocol_interface_type,
+ protocol_interface);
+
if (!handle || !protocol ||
protocol_interface_type != EFI_NATIVE_INTERFACE) {
r = EFI_INVALID_PARAMETER;
}
r = EFI_INVALID_PARAMETER;
out:
- return r;
-}
-
-/*
- * Install protocol interface.
- *
- * This function implements the InstallProtocolInterface service.
- * See the Unified Extensible Firmware Interface (UEFI) specification
- * for details.
- *
- * @handle handle on which the protocol shall be installed
- * @protocol GUID of the protocol to be installed
- * @protocol_interface_type type of the interface to be installed,
- * always EFI_NATIVE_INTERFACE
- * @protocol_interface interface of the protocol implementation
- * @return status code
- */
-static efi_status_t EFIAPI efi_install_protocol_interface_ext(void **handle,
- const efi_guid_t *protocol, int protocol_interface_type,
- void *protocol_interface)
-{
- EFI_ENTRY("%p, %pUl, %d, %p", handle, protocol, protocol_interface_type,
- protocol_interface);
-
- return EFI_EXIT(efi_install_protocol_interface(handle, protocol,
- protocol_interface_type,
- protocol_interface));
+ return EFI_EXIT(r);
}
/*
/*
* Uninstall protocol interface.
*
- * This is the function for internal calls. For the API implementation of the
- * UninstallProtocolInterface service see function
- * efi_uninstall_protocol_interface_ext.
+ * This function implements the UninstallProtocolInterface service.
+ * See the Unified Extensible Firmware Interface (UEFI) specification
+ * for details.
*
* @handle handle from which the protocol shall be removed
* @protocol GUID of the protocol to be removed
* @protocol_interface interface to be removed
* @return status code
*/
-static efi_status_t EFIAPI efi_uninstall_protocol_interface(void *handle,
- const efi_guid_t *protocol, void *protocol_interface)
+static efi_status_t EFIAPI efi_uninstall_protocol_interface(
+ void *handle, const efi_guid_t *protocol,
+ void *protocol_interface)
{
struct list_head *lhandle;
int i;
efi_status_t r = EFI_NOT_FOUND;
+ EFI_ENTRY("%p, %pUl, %p", handle, protocol, protocol_interface);
+
if (!handle || !protocol) {
r = EFI_INVALID_PARAMETER;
goto out;
}
out:
- return r;
-}
-
-/*
- * Uninstall protocol interface.
- *
- * This function implements the UninstallProtocolInterface service.
- * See the Unified Extensible Firmware Interface (UEFI) specification
- * for details.
- *
- * @handle handle from which the protocol shall be removed
- * @protocol GUID of the protocol to be removed
- * @protocol_interface interface to be removed
- * @return status code
- */
-static efi_status_t EFIAPI efi_uninstall_protocol_interface_ext(void *handle,
- const efi_guid_t *protocol, void *protocol_interface)
-{
- EFI_ENTRY("%p, %pUl, %p", handle, protocol, protocol_interface);
-
- return EFI_EXIT(efi_uninstall_protocol_interface(handle, protocol,
- protocol_interface));
+ return EFI_EXIT(r);
}
/*
int i;
switch (search_type) {
- case all_handles:
+ case ALL_HANDLES:
return 0;
- case by_register_notify:
+ case BY_REGISTER_NOTIFY:
+ /* RegisterProtocolNotify is not implemented yet */
return -1;
- case by_protocol:
+ case BY_PROTOCOL:
for (i = 0; i < ARRAY_SIZE(efiobj->protocols); i++) {
const efi_guid_t *guid = efiobj->protocols[i].guid;
if (guid && !guidcmp(guid, protocol))
static efi_status_t efi_locate_handle(
enum efi_locate_search_type search_type,
const efi_guid_t *protocol, void *search_key,
- unsigned long *buffer_size, efi_handle_t *buffer)
+ efi_uintn_t *buffer_size, efi_handle_t *buffer)
{
- struct list_head *lhandle;
- unsigned long size = 0;
+ struct efi_object *efiobj;
+ efi_uintn_t size = 0;
+
+ /* Check parameters */
+ switch (search_type) {
+ case ALL_HANDLES:
+ break;
+ case BY_REGISTER_NOTIFY:
+ if (!search_key)
+ return EFI_INVALID_PARAMETER;
+ /* RegisterProtocolNotify is not implemented yet */
+ return EFI_UNSUPPORTED;
+ case BY_PROTOCOL:
+ if (!protocol)
+ return EFI_INVALID_PARAMETER;
+ break;
+ default:
+ return EFI_INVALID_PARAMETER;
+ }
+
+ /*
+ * efi_locate_handle_buffer uses this function for
+ * the calculation of the necessary buffer size.
+ * So do not require a buffer for buffersize == 0.
+ */
+ if (!buffer_size || (*buffer_size && !buffer))
+ return EFI_INVALID_PARAMETER;
/* Count how much space we need */
- list_for_each(lhandle, &efi_obj_list) {
- struct efi_object *efiobj;
- efiobj = list_entry(lhandle, struct efi_object, link);
- if (!efi_search(search_type, protocol, search_key, efiobj)) {
+ list_for_each_entry(efiobj, &efi_obj_list, link) {
+ if (!efi_search(search_type, protocol, search_key, efiobj))
size += sizeof(void*);
- }
}
if (*buffer_size < size) {
return EFI_NOT_FOUND;
/* Then fill the array */
- list_for_each(lhandle, &efi_obj_list) {
- struct efi_object *efiobj;
- efiobj = list_entry(lhandle, struct efi_object, link);
- if (!efi_search(search_type, protocol, search_key, efiobj)) {
- *(buffer++) = efiobj->handle;
- }
+ list_for_each_entry(efiobj, &efi_obj_list, link) {
+ if (!efi_search(search_type, protocol, search_key, efiobj))
+ *buffer++ = efiobj->handle;
}
return EFI_SUCCESS;
static efi_status_t EFIAPI efi_locate_handle_ext(
enum efi_locate_search_type search_type,
const efi_guid_t *protocol, void *search_key,
- unsigned long *buffer_size, efi_handle_t *buffer)
+ efi_uintn_t *buffer_size, efi_handle_t *buffer)
{
EFI_ENTRY("%d, %pUl, %p, %p, %p", search_type, protocol, search_key,
buffer_size, buffer);
return EFI_EXIT(EFI_UNSUPPORTED);
}
+ info->system_table = &systab;
+ info->parent_handle = parent_image;
*image_handle = info;
return EFI_EXIT(EFI_SUCCESS);
panic("EFI application exited");
}
-/*
- * Find the internal EFI object for a handle.
- *
- * @handle handle to find
- * @return EFI object
- */
-static struct efi_object *efi_search_obj(void *handle)
-{
- struct list_head *lhandle;
-
- list_for_each(lhandle, &efi_obj_list) {
- struct efi_object *efiobj;
- efiobj = list_entry(lhandle, struct efi_object, link);
- if (efiobj->handle == handle)
- return efiobj;
- }
-
- return NULL;
-}
-
/*
* Unload an EFI image.
*
bootm_disable_interrupts();
/* Give the payload some time to boot */
+ efi_set_watchdog(0);
WATCHDOG_RESET();
return EFI_EXIT(EFI_SUCCESS);
/*
* Reset the watchdog timer.
*
- * This function implements the WatchdogTimer service.
+ * This function implements the SetWatchdogTimer service.
* See the Unified Extensible Firmware Interface (UEFI) specification
* for details.
*
{
EFI_ENTRY("%ld, 0x%"PRIx64", %ld, %p", timeout, watchdog_code,
data_size, watchdog_data);
- return efi_unsupported(__func__);
+ return EFI_EXIT(efi_set_watchdog(timeout));
}
/*
static efi_status_t EFIAPI efi_open_protocol_information(efi_handle_t handle,
const efi_guid_t *protocol,
struct efi_open_protocol_info_entry **entry_buffer,
- unsigned long *entry_count)
+ efi_uintn_t *entry_count)
{
EFI_ENTRY("%p, %pUl, %p, %p", handle, protocol, entry_buffer,
entry_count);
*/
static efi_status_t EFIAPI efi_protocols_per_handle(void *handle,
efi_guid_t ***protocol_buffer,
- unsigned long *protocol_buffer_count)
+ efi_uintn_t *protocol_buffer_count)
{
unsigned long buffer_size;
struct efi_object *efiobj;
static efi_status_t EFIAPI efi_locate_handle_buffer(
enum efi_locate_search_type search_type,
const efi_guid_t *protocol, void *search_key,
- unsigned long *no_handles, efi_handle_t **buffer)
+ efi_uintn_t *no_handles, efi_handle_t **buffer)
{
efi_status_t r;
- unsigned long buffer_size = 0;
+ efi_uintn_t buffer_size = 0;
EFI_ENTRY("%d, %pUl, %p, %p, %p", search_type, protocol, search_key,
no_handles, buffer);
if (!protocol)
break;
protocol_interface = va_arg(argptr, void*);
- r = efi_install_protocol_interface(handle, protocol,
- EFI_NATIVE_INTERFACE,
- protocol_interface);
+ r = EFI_CALL(efi_install_protocol_interface(
+ handle, protocol,
+ EFI_NATIVE_INTERFACE,
+ protocol_interface));
if (r != EFI_SUCCESS)
break;
i++;
if (r == EFI_SUCCESS)
return EFI_EXIT(r);
- /* If an error occured undo all changes. */
+ /* If an error occurred undo all changes. */
va_start(argptr, handle);
for (; i; --i) {
protocol = va_arg(argptr, efi_guid_t*);
protocol_interface = va_arg(argptr, void*);
- efi_uninstall_protocol_interface(handle, protocol,
- protocol_interface);
+ EFI_CALL(efi_uninstall_protocol_interface(handle, protocol,
+ protocol_interface));
}
va_end(argptr);
.signal_event = efi_signal_event_ext,
.close_event = efi_close_event,
.check_event = efi_check_event,
- .install_protocol_interface = efi_install_protocol_interface_ext,
+ .install_protocol_interface = efi_install_protocol_interface,
.reinstall_protocol_interface = efi_reinstall_protocol_interface,
- .uninstall_protocol_interface = efi_uninstall_protocol_interface_ext,
+ .uninstall_protocol_interface = efi_uninstall_protocol_interface,
.handle_protocol = efi_handle_protocol,
.reserved = NULL,
.register_protocol_notify = efi_register_protocol_notify,