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