mirror of
https://gitlab.com/bztsrc/posix-uefi.git
synced 2025-01-01 03:25:52 +01:00
Added more failsafes, fixed issue #19
This commit is contained in:
parent
378f44ea70
commit
7ba599ad0f
2 changed files with 18 additions and 9 deletions
|
@ -144,7 +144,7 @@ void bootstrap()
|
|||
/**
|
||||
* Initialize POSIX-UEFI and call the application's main() function
|
||||
*/
|
||||
int uefi_init (
|
||||
efi_status_t uefi_init (
|
||||
efi_handle_t image, efi_system_table_t *systab
|
||||
#ifndef __clang__
|
||||
, uintptr_t ldbase, Elf64_Dyn *dyn
|
||||
|
@ -156,10 +156,10 @@ int uefi_init (
|
|||
efi_shell_interface_protocol_t *shi = NULL;
|
||||
efi_guid_t lipGuid = EFI_LOADED_IMAGE_PROTOCOL_GUID;
|
||||
efi_status_t status;
|
||||
int argc = 0, i;
|
||||
int argc = 0, i, ret;
|
||||
wchar_t **argv = NULL;
|
||||
#if USE_UTF8
|
||||
int ret, j;
|
||||
int j;
|
||||
char *s;
|
||||
#endif
|
||||
#ifndef __clang__
|
||||
|
@ -186,6 +186,10 @@ int uefi_init (
|
|||
#else
|
||||
(void)i;
|
||||
#endif
|
||||
/* failsafes, should never happen */
|
||||
if(!image || !systab || !systab->BootServices || !systab->BootServices->HandleProtocol ||
|
||||
!systab->BootServices->OpenProtocol || !systab->BootServices->AllocatePool || !systab->BootServices->FreePool)
|
||||
return EFI_UNSUPPORTED;
|
||||
/* save EFI pointers and loaded image into globals */
|
||||
IM = image;
|
||||
ST = systab;
|
||||
|
@ -227,6 +231,7 @@ int uefi_init (
|
|||
if(__argvutf8) BS->FreePool(__argvutf8);
|
||||
return ret;
|
||||
#else
|
||||
return main(argc, argv);
|
||||
ret = main(argc, argv);
|
||||
#endif
|
||||
return ret ? EFIERR(ret) : EFI_SUCCESS;
|
||||
}
|
||||
|
|
|
@ -137,7 +137,7 @@ void bootstrap()
|
|||
/**
|
||||
* Initialize POSIX-UEFI and call the application's main() function
|
||||
*/
|
||||
int uefi_init (
|
||||
efi_status_t uefi_init (
|
||||
#ifndef __clang__
|
||||
uintptr_t ldbase, Elf64_Dyn *dyn, efi_system_table_t *systab, efi_handle_t image
|
||||
#else
|
||||
|
@ -150,10 +150,10 @@ int uefi_init (
|
|||
efi_shell_interface_protocol_t *shi = NULL;
|
||||
efi_guid_t lipGuid = EFI_LOADED_IMAGE_PROTOCOL_GUID;
|
||||
efi_status_t status;
|
||||
int argc = 0, i;
|
||||
int argc = 0, i, ret;
|
||||
wchar_t **argv = NULL;
|
||||
#if USE_UTF8
|
||||
int ret, j;
|
||||
int j;
|
||||
char *s;
|
||||
#endif
|
||||
#ifndef __clang__
|
||||
|
@ -189,6 +189,10 @@ int uefi_init (
|
|||
" orw $3 << 9, %ax\n"
|
||||
" mov %rax, %cr4\n"
|
||||
);
|
||||
/* failsafes, should never happen */
|
||||
if(!image || !systab || !systab->BootServices || !systab->BootServices->HandleProtocol ||
|
||||
!systab->BootServices->OpenProtocol || !systab->BootServices->AllocatePool || !systab->BootServices->FreePool)
|
||||
return EFI_UNSUPPORTED;
|
||||
/* save EFI pointers and loaded image into globals */
|
||||
IM = image;
|
||||
ST = systab;
|
||||
|
@ -228,8 +232,8 @@ int uefi_init (
|
|||
}
|
||||
ret = main(argc, (char**)__argvutf8);
|
||||
if(__argvutf8) BS->FreePool(__argvutf8);
|
||||
return ret;
|
||||
#else
|
||||
return main(argc, argv);
|
||||
ret = main(argc, argv);
|
||||
#endif
|
||||
return ret ? EFIERR(ret) : EFI_SUCCESS;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue