[e16e8f2] | 1 | #include <efi.h> |
---|
| 2 | #include <efilib.h> |
---|
| 3 | |
---|
| 4 | EFI_STATUS |
---|
| 5 | efi_main( |
---|
| 6 | EFI_HANDLE image_handle, |
---|
| 7 | EFI_SYSTEM_TABLE *systab |
---|
| 8 | ) |
---|
| 9 | { |
---|
| 10 | EFI_GUID loaded_image_protocol = LOADED_IMAGE_PROTOCOL; |
---|
| 11 | EFI_STATUS efi_status; |
---|
| 12 | EFI_LOADED_IMAGE *li; |
---|
| 13 | UINTN pat = PoolAllocationType; |
---|
| 14 | VOID *void_li_p; |
---|
| 15 | |
---|
| 16 | InitializeLib(image_handle, systab); |
---|
| 17 | PoolAllocationType = 2; /* klooj */ |
---|
| 18 | |
---|
| 19 | Print(L"Hello World! (0xd=0x%x, 13=%d)\n", 13, 13); |
---|
| 20 | |
---|
| 21 | Print(L"before InitializeLib(): PoolAllocationType=%d\n", |
---|
| 22 | pat); |
---|
| 23 | |
---|
| 24 | Print(L" after InitializeLib(): PoolAllocationType=%d\n", |
---|
| 25 | PoolAllocationType); |
---|
| 26 | |
---|
| 27 | /* |
---|
| 28 | * Locate loaded_image_handle instance. |
---|
| 29 | */ |
---|
| 30 | |
---|
| 31 | Print(L"BS->HandleProtocol() "); |
---|
| 32 | |
---|
| 33 | efi_status = uefi_call_wrapper( |
---|
| 34 | BS->HandleProtocol, |
---|
| 35 | 3, |
---|
| 36 | image_handle, |
---|
| 37 | &loaded_image_protocol, |
---|
| 38 | &void_li_p); |
---|
| 39 | li = void_li_p; |
---|
| 40 | |
---|
| 41 | Print(L"%xh (%r)\n", efi_status, efi_status); |
---|
| 42 | |
---|
| 43 | if (efi_status != EFI_SUCCESS) { |
---|
| 44 | return efi_status; |
---|
| 45 | } |
---|
| 46 | |
---|
| 47 | Print(L" li: %xh\n", li); |
---|
| 48 | |
---|
| 49 | if (!li) { |
---|
| 50 | return EFI_UNSUPPORTED; |
---|
| 51 | } |
---|
| 52 | |
---|
| 53 | Print(L" li->Revision: %xh\n", li->Revision); |
---|
| 54 | Print(L" li->ParentHandle: %xh\n", li->ParentHandle); |
---|
| 55 | Print(L" li->SystemTable: %xh\n", li->SystemTable); |
---|
| 56 | Print(L" li->DeviceHandle: %xh\n", li->DeviceHandle); |
---|
| 57 | Print(L" li->FilePath: %xh\n", li->FilePath); |
---|
| 58 | Print(L" li->Reserved: %xh\n", li->Reserved); |
---|
| 59 | Print(L" li->LoadOptionsSize: %xh\n", li->LoadOptionsSize); |
---|
| 60 | Print(L" li->LoadOptions: %xh\n", li->LoadOptions); |
---|
| 61 | Print(L" li->ImageBase: %xh\n", li->ImageBase); |
---|
| 62 | Print(L" li->ImageSize: %xh\n", li->ImageSize); |
---|
| 63 | Print(L" li->ImageCodeType: %xh\n", li->ImageCodeType); |
---|
| 64 | Print(L" li->ImageDataType: %xh\n", li->ImageDataType); |
---|
| 65 | Print(L" li->Unload: %xh\n", li->Unload); |
---|
| 66 | |
---|
| 67 | #if 0 |
---|
| 68 | typedef struct { |
---|
| 69 | UINT32 Revision; |
---|
| 70 | EFI_HANDLE ParentHandle; |
---|
| 71 | struct _EFI_SYSTEM_TABLE *SystemTable; |
---|
| 72 | |
---|
| 73 | // Source location of image |
---|
| 74 | EFI_HANDLE DeviceHandle; |
---|
| 75 | EFI_DEVICE_PATH *FilePath; |
---|
| 76 | VOID *Reserved; |
---|
| 77 | |
---|
| 78 | // Images load options |
---|
| 79 | UINT32 LoadOptionsSize; |
---|
| 80 | VOID *LoadOptions; |
---|
| 81 | |
---|
| 82 | // Location of where image was loaded |
---|
| 83 | VOID *ImageBase; |
---|
| 84 | UINT64 ImageSize; |
---|
| 85 | EFI_MEMORY_TYPE ImageCodeType; |
---|
| 86 | EFI_MEMORY_TYPE ImageDataType; |
---|
| 87 | |
---|
| 88 | // If the driver image supports a dynamic unload request |
---|
| 89 | EFI_IMAGE_UNLOAD Unload; |
---|
| 90 | |
---|
| 91 | } EFI_LOADED_IMAGE; |
---|
| 92 | #endif |
---|
| 93 | |
---|
| 94 | return EFI_SUCCESS; |
---|
| 95 | } |
---|