12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- #include <efi.h>
- #include <efilib.h>
- extern UINTN _init_array, _init_array_end;
- extern UINTN __CTOR_LIST__, __CTOR_END__;
- extern UINTN _fini_array, _fini_array_end;
- extern UINTN __DTOR_LIST__, __DTOR_END__;
- typedef void (*funcp)(void);
- static void ctors(void)
- {
- for (funcp *location = (void *)&_init_array; location < (funcp *)&_init_array_end; location++) {
- funcp func = *location;
- if (location != NULL)
- func();
- }
- for (funcp *location = (void *)&__CTOR_LIST__; location < (funcp *)&__CTOR_END__; location++) {
- funcp func = *location;
- if (location != NULL)
- func();
- }
- }
- static void dtors(void)
- {
- for (funcp *location = (void *)&__DTOR_LIST__; location < (funcp *)&__DTOR_END__; location++) {
- funcp func = *location;
- if (location != NULL)
- func();
- }
- for (funcp *location = (void *)&_fini_array; location < (funcp *)&_fini_array_end; location++) {
- funcp func = *location;
- if (location != NULL)
- func();
- }
- }
- extern EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *systab);
- EFI_STATUS _entry(EFI_HANDLE image, EFI_SYSTEM_TABLE *systab)
- {
- EFI_STATUS status;
- InitializeLib(image, systab);
- ctors();
- status = efi_main(image, systab);
- dtors();
- return status;
- }
|