t3.c 2.5 KB

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