Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

298 lines
4.3 KiB

  1. /*++
  2. Module Name:
  3. nvrio.h
  4. Abstract:
  5. Access function to r/w environment variables from NVRAM
  6. Author:
  7. Mudit Vats (v-muditv) 12-13-99
  8. Revision History:
  9. --*/
  10. #define MAXBOOTVARS 30
  11. #define MAXBOOTVARSIZE 1024
  12. #ifndef ANYSIZE_ARRAY
  13. #define ANYSIZE_ARRAY 1 // winnt
  14. #endif
  15. #define DEBUG_PACK 0
  16. #if DEBUG_PACK
  17. VOID
  18. DisplayELOFromLoadOption(
  19. IN UINT32 OptionNum
  20. );
  21. VOID
  22. DisplayELO(
  23. char* elo,
  24. UINT64 eloSize
  25. );
  26. #endif
  27. enum OptionalDataFields {
  28. OSLOADFILENAME,
  29. OSLOADOPTIONS,
  30. OSLOADPATH
  31. };
  32. enum EfiLoadOptionFields {
  33. ATTRIBUTE = 10,
  34. FILEPATHLISTLENGTH,
  35. DESCRIPTION,
  36. EFIFILEPATHLIST,
  37. OSFILEPATHLIST,
  38. OPTIONALDATA
  39. };
  40. //
  41. // from EFI spec, ch. 17
  42. //
  43. typedef struct _EFI_LOAD_OPTION {
  44. UINT32 Attributes;
  45. UINT16 FilePathListLength;
  46. CHAR16 Description[1];
  47. //EFI_DEVICE_PATH FilePath[];
  48. //UINT8 OptionalData[];
  49. } EFI_LOAD_OPTION, *PEFI_LOAD_OPTION;
  50. typedef struct _WINDOWS_OS_OPTIONS {
  51. UINT8 Signature[8];
  52. UINT32 Version;
  53. UINT32 Length;
  54. UINT32 OsLoadPathOffset;
  55. CHAR16 OsLoadOptions[ANYSIZE_ARRAY];
  56. //FILE_PATH OsLoadPath;
  57. } WINDOWS_OS_OPTIONS, *PWINDOWS_OS_OPTIONS;
  58. typedef struct _FILE_PATH {
  59. UINT32 Version;
  60. UINT32 Length;
  61. UINT32 Type;
  62. CHAR8 FilePath[ANYSIZE_ARRAY];
  63. } FILE_PATH, *PFILE_PATH;
  64. #define FILE_PATH_TYPE_ARC 1
  65. #define FILE_PATH_TYPE_ARC_SIGNATURE 2
  66. #define FILE_PATH_TYPE_NT 3
  67. #define FILE_PATH_TYPE_EFI 4
  68. //
  69. // from public/sdk/inc/ntexapi.h
  70. //
  71. /*
  72. typedef struct _WINDOWS_OS_OPTIONS {
  73. UCHAR Signature[8];
  74. ULONG Version;
  75. ULONG Length;
  76. ULONG OsLoadPathOffset;
  77. WCHAR OsLoadOptions[ANYSIZE_ARRAY];
  78. //FILE_PATH OsLoadPath;
  79. } WINDOWS_OS_OPTIONS, *PWINDOWS_OS_OPTIONS;
  80. */
  81. #define WINDOWS_OS_OPTIONS_SIGNATURE "WINDOWS"
  82. #define WINDOWS_OS_OPTIONS_VERSION 1
  83. /*
  84. ** BUGBUG: temp prototypes - move to efilib.h later
  85. */
  86. VOID
  87. RUNTIMEFUNCTION
  88. StrCpyA (
  89. IN CHAR8 *Dest,
  90. IN CHAR8 *Src
  91. );
  92. VOID
  93. RUNTIMEFUNCTION
  94. StrCatA (
  95. IN CHAR8 *Dest,
  96. IN CHAR8 *Src
  97. );
  98. UINTN
  99. RUNTIMEFUNCTION
  100. StrLenA (
  101. IN CHAR8 *s1
  102. );
  103. UINTN
  104. RUNTIMEFUNCTION
  105. StrSizeA (
  106. IN CHAR8 *s1
  107. );
  108. CHAR8 *
  109. RUNTIMEFUNCTION
  110. StrDuplicateA (
  111. IN CHAR8 *Src
  112. );
  113. // temp protos end
  114. VOID
  115. GetBootManagerVars(
  116. );
  117. BOOLEAN
  118. EraseOsBootOption(
  119. UINTN BootVarNum
  120. );
  121. BOOLEAN
  122. EraseAllOsBootOptions(
  123. );
  124. BOOLEAN
  125. PushToTop(
  126. IN UINT32 BootVarNum
  127. );
  128. UINT64
  129. GetBootOrderCount(
  130. );
  131. UINT64
  132. GetOsBootOptionsCount(
  133. );
  134. VOID
  135. InsertString(
  136. IN OUT char* Dest,
  137. IN UINT32 Start,
  138. IN UINT32 End,
  139. IN char* InsertString
  140. );
  141. VOID
  142. SubString(
  143. IN OUT char* Dest,
  144. IN UINT32 Start,
  145. IN UINT32 End,
  146. IN char* Src
  147. );
  148. VOID
  149. SetEnvVar(
  150. IN CHAR16* szVarName,
  151. IN CHAR16* szVarValue,
  152. IN UINT32 deleteFlag
  153. );
  154. BOOLEAN
  155. GetLoadIdentifier(
  156. IN UINT32 BootVarNum,
  157. OUT CHAR16* LoadIdentifier
  158. );
  159. VOID
  160. GetOptionalDataValue(
  161. IN UINT32 BootVarNum,
  162. IN UINT32 Selection,
  163. OUT char* OptionalDataValue
  164. );
  165. BOOLEAN
  166. GetOsLoadOptionVars(
  167. IN UINT32 BootVarNum,
  168. OUT CHAR16* LoadIdentifier,
  169. OUT char* OsLoadOptions,
  170. OUT char* EfiFilePath,
  171. OUT char* OsFilePath
  172. );
  173. VOID
  174. PackLoadOption(
  175. IN UINT32 BootVarNum,
  176. IN CHAR16* LoadIdentifier,
  177. IN CHAR16* OsLoadOptions,
  178. IN char* EfiFilePath,
  179. IN char* OsLoadPath
  180. );
  181. VOID
  182. SetFieldFromLoadOption(
  183. IN UINT32 BootVarNum,
  184. IN UINT32 FieldType,
  185. IN VOID* Data
  186. );
  187. VOID
  188. GetFieldFromLoadOption(
  189. IN UINT32 OptionNum,
  190. IN UINT32 FieldType,
  191. OUT VOID* Data,
  192. OUT UINT64* DataSize
  193. );
  194. VOID
  195. FreeBootManagerVars(
  196. );
  197. BOOLEAN
  198. CopyVar(
  199. IN UINT32 VarNum
  200. );
  201. VOID
  202. SetBootManagerVars(
  203. );
  204. VOID
  205. GetFilePathShort(
  206. EFI_DEVICE_PATH *FilePath,
  207. CHAR16 *FilePathShort
  208. );
  209. VOID
  210. SetFilePathFromShort(
  211. EFI_DEVICE_PATH *FilePath,
  212. CHAR16* FilePathShort
  213. );
  214. UINTN
  215. GetDevPathSize(
  216. IN EFI_DEVICE_PATH *DevPath
  217. );
  218. CHAR16
  219. FindFreeBootOption(
  220. );
  221. UINT32
  222. GetPartitions(
  223. );
  224. EFI_HANDLE
  225. GetDeviceHandleForPartition(
  226. );
  227. VOID
  228. DisplayOsOptions(
  229. char* osOptions
  230. );
  231. BOOLEAN
  232. isWindowsOsBootOption(
  233. char* elo,
  234. UINT64 eloSize
  235. );
  236. char*
  237. GetAlignedOsOptions(
  238. char* elo,
  239. UINT64 eloSize
  240. );