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
|
* 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
|
efi_handle_t image, efi_system_table_t *systab
|
||||||
#ifndef __clang__
|
#ifndef __clang__
|
||||||
, uintptr_t ldbase, Elf64_Dyn *dyn
|
, uintptr_t ldbase, Elf64_Dyn *dyn
|
||||||
|
@ -156,10 +156,10 @@ int uefi_init (
|
||||||
efi_shell_interface_protocol_t *shi = NULL;
|
efi_shell_interface_protocol_t *shi = NULL;
|
||||||
efi_guid_t lipGuid = EFI_LOADED_IMAGE_PROTOCOL_GUID;
|
efi_guid_t lipGuid = EFI_LOADED_IMAGE_PROTOCOL_GUID;
|
||||||
efi_status_t status;
|
efi_status_t status;
|
||||||
int argc = 0, i;
|
int argc = 0, i, ret;
|
||||||
wchar_t **argv = NULL;
|
wchar_t **argv = NULL;
|
||||||
#if USE_UTF8
|
#if USE_UTF8
|
||||||
int ret, j;
|
int j;
|
||||||
char *s;
|
char *s;
|
||||||
#endif
|
#endif
|
||||||
#ifndef __clang__
|
#ifndef __clang__
|
||||||
|
@ -186,6 +186,10 @@ int uefi_init (
|
||||||
#else
|
#else
|
||||||
(void)i;
|
(void)i;
|
||||||
#endif
|
#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 */
|
/* save EFI pointers and loaded image into globals */
|
||||||
IM = image;
|
IM = image;
|
||||||
ST = systab;
|
ST = systab;
|
||||||
|
@ -227,6 +231,7 @@ int uefi_init (
|
||||||
if(__argvutf8) BS->FreePool(__argvutf8);
|
if(__argvutf8) BS->FreePool(__argvutf8);
|
||||||
return ret;
|
return ret;
|
||||||
#else
|
#else
|
||||||
return main(argc, argv);
|
ret = main(argc, argv);
|
||||||
#endif
|
#endif
|
||||||
|
return ret ? EFIERR(ret) : EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -137,7 +137,7 @@ void bootstrap()
|
||||||
/**
|
/**
|
||||||
* Initialize POSIX-UEFI and call the application's main() function
|
* Initialize POSIX-UEFI and call the application's main() function
|
||||||
*/
|
*/
|
||||||
int uefi_init (
|
efi_status_t uefi_init (
|
||||||
#ifndef __clang__
|
#ifndef __clang__
|
||||||
uintptr_t ldbase, Elf64_Dyn *dyn, efi_system_table_t *systab, efi_handle_t image
|
uintptr_t ldbase, Elf64_Dyn *dyn, efi_system_table_t *systab, efi_handle_t image
|
||||||
#else
|
#else
|
||||||
|
@ -150,10 +150,10 @@ int uefi_init (
|
||||||
efi_shell_interface_protocol_t *shi = NULL;
|
efi_shell_interface_protocol_t *shi = NULL;
|
||||||
efi_guid_t lipGuid = EFI_LOADED_IMAGE_PROTOCOL_GUID;
|
efi_guid_t lipGuid = EFI_LOADED_IMAGE_PROTOCOL_GUID;
|
||||||
efi_status_t status;
|
efi_status_t status;
|
||||||
int argc = 0, i;
|
int argc = 0, i, ret;
|
||||||
wchar_t **argv = NULL;
|
wchar_t **argv = NULL;
|
||||||
#if USE_UTF8
|
#if USE_UTF8
|
||||||
int ret, j;
|
int j;
|
||||||
char *s;
|
char *s;
|
||||||
#endif
|
#endif
|
||||||
#ifndef __clang__
|
#ifndef __clang__
|
||||||
|
@ -189,6 +189,10 @@ int uefi_init (
|
||||||
" orw $3 << 9, %ax\n"
|
" orw $3 << 9, %ax\n"
|
||||||
" mov %rax, %cr4\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 */
|
/* save EFI pointers and loaded image into globals */
|
||||||
IM = image;
|
IM = image;
|
||||||
ST = systab;
|
ST = systab;
|
||||||
|
@ -228,8 +232,8 @@ int uefi_init (
|
||||||
}
|
}
|
||||||
ret = main(argc, (char**)__argvutf8);
|
ret = main(argc, (char**)__argvutf8);
|
||||||
if(__argvutf8) BS->FreePool(__argvutf8);
|
if(__argvutf8) BS->FreePool(__argvutf8);
|
||||||
return ret;
|
|
||||||
#else
|
#else
|
||||||
return main(argc, argv);
|
ret = main(argc, argv);
|
||||||
#endif
|
#endif
|
||||||
|
return ret ? EFIERR(ret) : EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue