1
0

loader.h 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370
  1. /*++
  2. Copyright (c) 2012 Minoca Corp.
  3. This file is licensed under the terms of the GNU General Public License
  4. version 3. Alternative licensing terms are available. Contact
  5. info@minocacorp.com for details. See the LICENSE file at the root of this
  6. project for complete licensing information.
  7. Module Name:
  8. loader.h
  9. Abstract:
  10. This header contains private definitions for the boot loader.
  11. Author:
  12. Evan Green 30-Jul-2012
  13. --*/
  14. //
  15. // ------------------------------------------------------------------- Includes
  16. //
  17. //
  18. // ---------------------------------------------------------------- Definitions
  19. //
  20. //
  21. // Define default paths for the unusual case where there is no boot entry.
  22. //
  23. #define DEFAULT_SYSTEM_ROOT_PATH "minoca"
  24. #define DEFAULT_DRIVERS_DIRECTORY_PATH "drivers"
  25. #define DEFAULT_KERNEL_BINARY_PATH "system/kernel"
  26. //
  27. // Define hard-coded paths underneath the system root or configuration
  28. // directory.
  29. //
  30. #define CONFIGURATION_DIRECTORY_PATH "config"
  31. #define BOOT_DRIVER_FILE "bootdrv.set"
  32. #define DEVICE_TO_DRIVER_FILE "dev2drv.set"
  33. #define DEVICE_MAP_FILE "devmap.set"
  34. #define FIRMWARE_TABLES_FILE "fwtables.dat"
  35. //
  36. // ------------------------------------------------------ Data Type Definitions
  37. //
  38. //
  39. // -------------------------------------------------------------------- Globals
  40. //
  41. extern MEMORY_DESCRIPTOR_LIST BoMemoryMap;
  42. extern LIST_ENTRY BoLoadedImageList;
  43. //
  44. // -------------------------------------------------------- Function Prototypes
  45. //
  46. INT
  47. BoMain (
  48. PBOOT_INITIALIZATION_BLOCK Parameters
  49. );
  50. /*++
  51. Routine Description:
  52. This routine is the entry point for the boot loader program.
  53. Arguments:
  54. Parameters - Supplies a pointer to the application initialization
  55. parameters.
  56. Return Value:
  57. On success, this function does not return.
  58. On failure, this function returns the step number on which it failed. This
  59. provides an indication as to where in the boot process it failed.
  60. --*/
  61. KSTATUS
  62. BoLoadAndMapFile (
  63. PBOOT_VOLUME Volume,
  64. PFILE_ID Directory,
  65. PSTR FileName,
  66. PVOID *FilePhysical,
  67. PVOID *FileVirtual,
  68. PUINTN FileSize,
  69. MEMORY_TYPE VirtualType
  70. );
  71. /*++
  72. Routine Description:
  73. This routine loads a file into memory and maps it into the kernel's
  74. virtual address space.
  75. Arguments:
  76. Volume - Supplies a pointer to the mounted volume to read the file from.
  77. Directory - Supplies an optional pointer to the ID of the directory to
  78. start path traversal from. If NULL, the root of the volume will be used.
  79. FileName - Supplies the name of the file to load.
  80. FilePhysical - Supplies a pointer where the file buffer's physical address
  81. will be returned. This routine will allocate the buffer to hold the
  82. file. If this parameter and the virtual parameter are NULL, the status
  83. code will reflect whether or not the file could be opened, but the file
  84. contents will not be loaded.
  85. FileVirtual - Supplies a pointer where the file buffer's virtual address
  86. will be returned. If this parameter and the physical parameter are
  87. NULL, the status code will reflect whether or not the file could be
  88. opened, but the file contents will not be loaded.
  89. FileSize - Supplies a pointer where the size of the file in bytes will be
  90. returned.
  91. VirtualType - Supplies the memory type to use for the virtual allocation.
  92. The physical allocation type will be loader permanent.
  93. Return Value:
  94. Status code.
  95. --*/
  96. PVOID
  97. BoGetAcpiTable (
  98. ULONG Signature,
  99. PVOID PreviousTable
  100. );
  101. /*++
  102. Routine Description:
  103. This routine attempts to find an ACPI description table with the given
  104. signature. This routine does not validate the checksum of the table.
  105. Arguments:
  106. Signature - Supplies the signature of the desired table.
  107. PreviousTable - Supplies an optional pointer to the table to start the
  108. search from.
  109. Return Value:
  110. Returns a pointer to the beginning of the header to the table if the table
  111. was found, or NULL if the table could not be located.
  112. --*/
  113. KSTATUS
  114. BoAddFirmwareTable (
  115. PKERNEL_INITIALIZATION_BLOCK KernelParameters,
  116. PVOID Table
  117. );
  118. /*++
  119. Routine Description:
  120. This routine adds a firmware configuration table to the loader's list of
  121. tables.
  122. Arguments:
  123. KernelParameters - Supplies a pointer to the kernel initialization
  124. parameters.
  125. Table - Supplies a pointer to the table to add.
  126. Return Value:
  127. STATUS_SUCCESS on success.
  128. STATUS_INSUFFICIENT_RESOURCES on allocation failure.
  129. STATUS_TOO_EARLY if firmware tables are not yet available.
  130. --*/
  131. KSTATUS
  132. BoFwMapKnownRegions (
  133. ULONG Phase,
  134. PKERNEL_INITIALIZATION_BLOCK Parameters
  135. );
  136. /*++
  137. Routine Description:
  138. This routine maps known ARM regions of memory.
  139. Arguments:
  140. Phase - Supplies the phase number, as this routine is called twice: once
  141. before any other mappings have been established (0), and once near the
  142. end of the loader (1).
  143. Parameters - Supplies a pointer to the kernel's initialization parameters.
  144. Return Value:
  145. Status code.
  146. --*/
  147. KSTATUS
  148. BoFwPrepareForKernelLaunch (
  149. PKERNEL_INITIALIZATION_BLOCK Parameters
  150. );
  151. /*++
  152. Routine Description:
  153. This routine coordinates with the firmware to end boot services and
  154. prepare for the operating system to take over. Translation is still
  155. disabled (or identity mapped) at this point.
  156. Arguments:
  157. Parameters - Supplies a pointer to the kernel initialization block.
  158. Return Value:
  159. Status code.
  160. --*/
  161. VOID
  162. BoTransferToKernelAsm (
  163. PVOID Parameters,
  164. PVOID EntryPoint,
  165. PVOID StackAddress
  166. );
  167. /*++
  168. Routine Description:
  169. This routine transfers control of execution to the kernel.
  170. Arguments:
  171. Parameters - Supplies the parameter block to pass on to the kernel for its
  172. initialization.
  173. EntryPoint - Supplies the entry point of the kernel. The function will end
  174. with a jump to here.
  175. StackAddress - Supplies the top of the kernel stack. The stack pointer will
  176. get set to this value just before the kernel is launched.
  177. Return Value:
  178. None. This function does not return.
  179. --*/
  180. KSTATUS
  181. BoInitializeImageSupport (
  182. PBOOT_VOLUME BootDevice,
  183. PBOOT_ENTRY BootEntry
  184. );
  185. /*++
  186. Routine Description:
  187. This routine initializes the image library for use in the boot
  188. environment.
  189. Arguments:
  190. BootDevice - Supplies a pointer to the boot volume token, used for loading
  191. images from disk.
  192. BootEntry - Supplies a pointer to the boot entry being launched.
  193. Return Value:
  194. Status code.
  195. --*/
  196. PLIST_ENTRY
  197. BoHlGetPhysicalMemoryUsageListHead (
  198. VOID
  199. );
  200. /*++
  201. Routine Description:
  202. This routine returns the head of the list of regions of physical address
  203. space in use by the hardware layer.
  204. Arguments:
  205. None.
  206. Return Value:
  207. Returns a pointer to a list head pointing to a list of
  208. HL_PHYSICAL_ADDRESS_USAGE structures. Note that the first entry (the value
  209. returned) is not an entry itself but just the list head. The first valid
  210. entry comes from ReturnValue->Next.
  211. --*/
  212. KSTATUS
  213. BoArchMapNeededHardwareRegions (
  214. VOID
  215. );
  216. /*++
  217. Routine Description:
  218. This routine maps architecture-specific pieces of hardware needed for very
  219. early kernel initialization.
  220. Arguments:
  221. None.
  222. Return Value:
  223. Status code.
  224. --*/
  225. VOID
  226. BoArchMeasureCycleCounter (
  227. PKERNEL_INITIALIZATION_BLOCK Parameters
  228. );
  229. /*++
  230. Routine Description:
  231. This routine attempts to measure the processor cycle counter.
  232. Arguments:
  233. Parameters - Supplies a pointer to the kernel initialization block.
  234. Return Value:
  235. None. The cycle counter frequency (or zero on failure) will be placed in
  236. the parameter block.
  237. --*/