LoadLinuxLib.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. /** @file
  2. Load/boot UEFI Linux.
  3. Copyright (c) 2011 - 2013, Intel Corporation. All rights reserved.<BR>
  4. SPDX-License-Identifier: BSD-2-Clause-Patent
  5. **/
  6. #ifndef __LOAD_LINUX_LIB__
  7. #define __LOAD_LINUX_LIB__
  8. /**
  9. Verifies that the kernel setup image is valid and supported.
  10. The kernel setup image should be checked before using other library
  11. routines which take the kernel setup as an input.
  12. @param[in] KernelSetup - The kernel setup image
  13. @param[in] KernelSetupSize - The kernel setup size
  14. @retval EFI_SUCCESS - The Linux kernel setup is valid and supported
  15. @retval EFI_INVALID_PARAMETER - KernelSetup was NULL
  16. @retval EFI_UNSUPPORTED - The Linux kernel is not supported
  17. **/
  18. EFI_STATUS
  19. EFIAPI
  20. LoadLinuxCheckKernelSetup (
  21. IN VOID *KernelSetup,
  22. IN UINTN KernelSetupSize
  23. );
  24. /**
  25. Gets the initial runtime size of the Linux kernel image by examining
  26. the kernel setup image.
  27. @param[in] KernelSetup - The kernel setup image
  28. @param[in] KernelSize - The kernel size on disk.
  29. @retval 0 An error occurred
  30. @retval !0 The initial size required by the kernel to
  31. begin execution.
  32. **/
  33. UINTN
  34. EFIAPI
  35. LoadLinuxGetKernelSize (
  36. IN VOID *KernelSetup,
  37. IN UINTN KernelSize
  38. );
  39. /**
  40. Loads and boots UEFI Linux.
  41. Note: If successful, then this routine will not return
  42. @param[in] Kernel - The main kernel image
  43. @param[in,out] KernelSetup - The kernel setup image
  44. @retval EFI_NOT_FOUND - The Linux kernel was not found
  45. @retval EFI_INVALID_PARAMETER - Kernel or KernelSetup was NULL
  46. @retval EFI_UNSUPPORTED - The Linux kernel version is not supported
  47. **/
  48. EFI_STATUS
  49. EFIAPI
  50. LoadLinux (
  51. IN VOID *Kernel,
  52. IN OUT VOID *KernelSetup
  53. );
  54. /**
  55. Allocates pages for the kernel setup image.
  56. @param[in] Pages - The number of pages
  57. @retval NULL - Unable to allocate pages
  58. @retval !NULL - The address of the pages allocated
  59. **/
  60. VOID*
  61. EFIAPI
  62. LoadLinuxAllocateKernelSetupPages (
  63. IN UINTN Pages
  64. );
  65. /**
  66. Clears the uninitialised space before and after the struct setup_header
  67. in the kernel setup image. The kernel requires that these be zeroed
  68. unless explicitly initialised, so this function should be called after
  69. the setup_header has been copied in from a bzImage, before setting up
  70. anything else.
  71. @param[in] KernelSetup - The kernel setup image
  72. @retval EFI_SUCCESS - The Linux kernel setup was successfully initialized
  73. @retval EFI_INVALID_PARAMETER - KernelSetup was NULL
  74. @retval EFI_UNSUPPORTED - The Linux kernel is not supported
  75. **/
  76. EFI_STATUS
  77. EFIAPI
  78. LoadLinuxInitializeKernelSetup (
  79. IN VOID *KernelSetup
  80. );
  81. /**
  82. Allocates pages for the kernel.
  83. @param[in] KernelSetup - The kernel setup image
  84. @param[in] Pages - The number of pages. (It is recommended to use the
  85. size returned from LoadLinuxGetKernelSize.)
  86. @retval NULL - Unable to allocate pages
  87. @retval !NULL - The address of the pages allocated
  88. **/
  89. VOID*
  90. EFIAPI
  91. LoadLinuxAllocateKernelPages (
  92. IN VOID *KernelSetup,
  93. IN UINTN Pages
  94. );
  95. /**
  96. Allocates pages for the kernel command line.
  97. @param[in] Pages - The number of pages.
  98. @retval NULL - Unable to allocate pages
  99. @retval !NULL - The address of the pages allocated
  100. **/
  101. VOID*
  102. EFIAPI
  103. LoadLinuxAllocateCommandLinePages (
  104. IN UINTN Pages
  105. );
  106. /**
  107. Allocates pages for the initrd image.
  108. @param[in,out] KernelSetup - The kernel setup image
  109. @param[in] Pages - The number of pages.
  110. @retval NULL - Unable to allocate pages
  111. @retval !NULL - The address of the pages allocated
  112. **/
  113. VOID*
  114. EFIAPI
  115. LoadLinuxAllocateInitrdPages (
  116. IN VOID *KernelSetup,
  117. IN UINTN Pages
  118. );
  119. /**
  120. Sets the kernel command line parameter within the setup image.
  121. @param[in,out] KernelSetup - The kernel setup image
  122. @param[in] CommandLine - The kernel command line
  123. @retval EFI_SUCCESS - The Linux kernel setup is valid and supported
  124. @retval EFI_INVALID_PARAMETER - KernelSetup was NULL
  125. @retval EFI_UNSUPPORTED - The Linux kernel is not supported
  126. **/
  127. EFI_STATUS
  128. EFIAPI
  129. LoadLinuxSetCommandLine (
  130. IN OUT VOID *KernelSetup,
  131. IN CHAR8 *CommandLine
  132. );
  133. /**
  134. Sets the kernel initial ram disk pointer within the setup image.
  135. @param[in,out] KernelSetup - The kernel setup image
  136. @param[in] Initrd - Pointer to the initial ram disk
  137. @param[in] InitrdSize - The initial ram disk image size
  138. @retval EFI_SUCCESS - The Linux kernel setup is valid and supported
  139. @retval EFI_INVALID_PARAMETER - KernelSetup was NULL
  140. @retval EFI_UNSUPPORTED - The Linux kernel is not supported
  141. **/
  142. EFI_STATUS
  143. EFIAPI
  144. LoadLinuxSetInitrd (
  145. IN OUT VOID *KernelSetup,
  146. IN VOID *Initrd,
  147. IN UINTN InitrdSize
  148. );
  149. #endif