LinuxBoot.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. /** @file
  2. Copyright (c) 2021, American Megatrends International LLC. All rights reserved.<BR>
  3. SPDX-License-Identifier: BSD-2-Clause-Patent
  4. **/
  5. #ifndef __LINUX_BOOT_PRIVATE__H__
  6. #define __LINUX_BOOT_PRIVATE__H__
  7. #ifdef __cplusplus
  8. extern "C" {
  9. #endif // #ifdef __cplusplus
  10. //---------------------------------------------------------------------------
  11. //#include <Token.h>
  12. #define BOOTSIG 0x1FE
  13. #define SETUP_HDR 0x53726448 /* 0x53726448 == "HdrS" */
  14. #define E820_RAM 1
  15. #define E820_RESERVED 2
  16. #define E820_ACPI 3
  17. #define E820_NVS 4
  18. #define E820_UNUSABLE 5
  19. #pragma pack(1)
  20. struct SetupHeader {
  21. UINT8 SetupSecs; // Sectors for setup code
  22. UINT16 Rootflags;
  23. UINT32 SysSize;
  24. UINT16 RamSize;
  25. UINT16 VideoMode;
  26. UINT16 RootDev;
  27. UINT16 Signature; // Boot signature
  28. UINT16 Jump;
  29. UINT32 Header;
  30. UINT16 Version;
  31. UINT16 SuSwitch;
  32. UINT16 SetupSeg;
  33. UINT16 StartSys;
  34. UINT16 KernelVer;
  35. UINT8 LoaderId;
  36. UINT8 LoadFlags;
  37. UINT16 MoveSize;
  38. UINT32 Code32Start; // Start of code loaded high
  39. UINT32 RamDiskStart; // Start of initial ramdisk
  40. UINT32 RamDiskLen; // Length of initial ramdisk
  41. UINT32 BootSectkludge;
  42. UINT16 HeapEnd;
  43. UINT8 ExtLoaderVer; // Extended boot loader version
  44. UINT8 ExtLoaderType; // Extended boot loader ID
  45. UINT32 CmdLinePtr; // 32-bit pointer to the kernel command line
  46. UINT32 RamDiskMax; // Highest legal initrd address
  47. UINT32 KernelAlignment; // Physical addr alignment required for kernel
  48. UINT8 RelocatableKernel; // Whether kernel is relocatable or not
  49. UINT8 MinAlignment;
  50. UINT16 XloadFlags;
  51. UINT32 CmdlineSize;
  52. UINT32 HardwareSubarch;
  53. UINT64 HardwareSubarchData;
  54. UINT32 PayloadOffset;
  55. UINT32 PayloadLength;
  56. UINT64 SetupData;
  57. UINT64 PrefAddress;
  58. UINT32 InitSize;
  59. UINT32 HandoverOffset;
  60. };
  61. struct EfiInfo {
  62. UINT32 EfiLoaderSignature;
  63. UINT32 EfiSystab;
  64. UINT32 EfiMemdescSize;
  65. UINT32 EfiMemdescVersion;
  66. UINT32 EfiMemMap;
  67. UINT32 EfiMemMapSize;
  68. UINT32 EfiSystabHi;
  69. UINT32 EfiMemMapHi;
  70. };
  71. struct E820Entry {
  72. UINT64 Addr; // start of memory segment
  73. UINT64 Size; // size of memory segment
  74. UINT32 Type; // type of memory segment
  75. };
  76. struct ScreenInfo {
  77. UINT8 OrigX; // 0x00
  78. UINT8 OrigY; // 0x01
  79. UINT16 ExtMemK; // 0x02
  80. UINT16 OrigVideoPage; // 0x04
  81. UINT8 OrigVideoMode; // 0x06
  82. UINT8 OrigVideoCols; // 0x07
  83. UINT8 Flags; // 0x08
  84. UINT8 Unused2; // 0x09
  85. UINT16 OrigVideoEgaBx;// 0x0a
  86. UINT16 Unused3; // 0x0c
  87. UINT8 OrigVideoLines; // 0x0e
  88. UINT8 OrigVideoIsVGA; // 0x0f
  89. UINT16 OrigVideoPoints;// 0x10
  90. // VESA graphic mode -- linear frame buffer
  91. UINT16 LfbWidth; // 0x12
  92. UINT16 LfbHeight; // 0x14
  93. UINT16 LfbDepth; // 0x16
  94. UINT32 LfbBase; // 0x18
  95. UINT32 LfbSize; // 0x1c
  96. UINT16 ClMagic, ClOffset; // 0x20
  97. UINT16 LfbLineLength; // 0x24
  98. UINT8 RedSize; // 0x26
  99. UINT8 RedPos; // 0x27
  100. UINT8 GreenSize; // 0x28
  101. UINT8 GreenPos; // 0x29
  102. UINT8 BlueSize; // 0x2a
  103. UINT8 BluePos; // 0x2b
  104. UINT8 RsvdSize; // 0x2c
  105. UINT8 RsvdPos; // 0x2d
  106. UINT16 VesaPmSeg; // 0x2e
  107. UINT16 VesaPmOff; // 0x30
  108. UINT16 Pages; // 0x32
  109. UINT16 VesaAttributes; // 0x34
  110. UINT32 Capabilities; // 0x36
  111. UINT8 Reserved[6]; // 0x3a
  112. };
  113. struct BootParams {
  114. struct ScreenInfo ScreenInfo;
  115. UINT8 ApmBiosInfo[0x14];
  116. UINT8 Pad2[4];
  117. UINT64 TbootAddr;
  118. UINT8 IstInfo[0x10];
  119. UINT8 Pad3[16];
  120. UINT8 Hd0Info[16];
  121. UINT8 Hd1Info[16];
  122. UINT8 SysDescTable[0x10];
  123. UINT8 OlpcOfwHeader[0x10];
  124. UINT8 Pad4[128];
  125. UINT8 EdidInfo[0x80];
  126. struct EfiInfo EfiInfo;
  127. UINT32 AltMemK;
  128. UINT32 Scratch;
  129. UINT8 E820Entries;
  130. UINT8 EddBufEntries;
  131. UINT8 EddMbrSigBufEntries;
  132. UINT8 Pad6[6];
  133. struct SetupHeader Hdr;
  134. UINT8 Pad7[0x290-0x1f1-sizeof(struct SetupHeader)];
  135. UINT32 EddMbrSigBuffer[16];
  136. struct E820Entry E820Map[128];
  137. UINT8 Pad8[48];
  138. UINT8 EddBuf[0x1ec];
  139. UINT8 Pad9[276];
  140. };
  141. #pragma pack ()
  142. //---------------------------------------------------------------------------
  143. #ifndef MIN
  144. #define MIN(x,y) ((x) < (y) ? (x) : (y))
  145. #endif // #ifndef MIN
  146. #define KERNEL_SETUP_SIZE 16384
  147. //---------------------------------------------------------------------------
  148. ///
  149. /// Function prototypes from Bds module
  150. ///
  151. VOID ConnectEverything();
  152. VOID RecoverTheMemoryAbove4Gb();
  153. VOID SignalAllDriversConnectedEvent();
  154. VOID SignalProtocolEvent(IN EFI_GUID *ProtocolGuid);
  155. #if LINUXBOOT_SIGNAL_EXITPMAUTH == 1
  156. VOID SignalExitPmAuthProtocolEvent(VOID);
  157. #endif // #if LINUXBOOT_SIGNAL_EXITPMAUTH == 1
  158. typedef VOID (BDS_CONTROL_FLOW_FUNCTION)();
  159. //---------------------------------------------------------------------------
  160. /****** DO NOT WRITE BELOW THIS LINE *******/
  161. #ifdef __cplusplus
  162. }
  163. #endif // #ifdef __cplusplus
  164. #endif // #ifndef __LINUX_BOOT_PRIVATE__H__