Leaked source code of windows server 2003
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.

232 lines
5.0 KiB

  1. /*++
  2. Copyright (c) 1992 Microsoft Corporation
  3. Module Name:
  4. initia64.c
  5. Abstract:
  6. Gets boot environment vars from c:\boot.nvr
  7. -- This will go away once we r/w the vars directly to/fro nvram
  8. Author:
  9. Mudit Vats (v-muditv) 11-02-99
  10. Revision History:
  11. --*/
  12. #include "parsebnvr.h"
  13. #include "stdio.h"
  14. #include "string.h"
  15. #define SYSTEMPARTITION 0
  16. #define OSLOADER 1
  17. #define OSLOADPARTITION 2
  18. #define OSLOADFILENAME 3
  19. #define LOADIDENTIFIER 4
  20. #define OSLOADOPTIONS 5
  21. #define COUNTDOWN 6
  22. #define AUTOLOAD 7
  23. #define LASTKNOWNGOOD 8
  24. #define MAXBOOTVARS 9
  25. #define MAXBOOTVARSIZE 1024
  26. CHAR g_szBootVars[MAXBOOTVARS][MAXBOOTVARSIZE];
  27. CHAR szSelectKernelString[MAXBOOTVARSIZE];
  28. VOID
  29. BlGetBootVars(
  30. IN PCHAR szBootNVR,
  31. IN ULONG nLengthBootNVR
  32. )
  33. /*++
  34. Routine Description:
  35. Parses the boot.txt file and determines the fully-qualified name of
  36. the kernel to be booted.
  37. Arguments:
  38. szBootNVR - pointer "boot.nvr" image in memory
  39. nLengthBootNVR - lenghth, in bytes, of szBootNVR
  40. Return Value:
  41. none
  42. --*/
  43. {
  44. ULONG i=0, j;
  45. ULONG nbootvar;
  46. if (*szBootNVR == '\0') {
  47. //
  48. // No boot.nvr file, so we boot the default.
  49. //
  50. strcpy( g_szBootVars[ SYSTEMPARTITION ], "multi(0)disk(0)rdisk(0)partition(1)" );
  51. strcpy( g_szBootVars[ OSLOADER ], "multi(0)disk(0)rdisk(0)partition(1)\\setupldr.efi" );
  52. strcpy( g_szBootVars[ OSLOADPARTITION ], "multi(0)disk(0)rdisk(0)partition(2)" );
  53. strcpy( g_szBootVars[ OSLOADFILENAME ], "\\$WIN_NT$.~LS\\IA64" );
  54. strcpy( g_szBootVars[ LOADIDENTIFIER ], "Windows 2000 Setup" );
  55. strcpy( g_szBootVars[ OSLOADOPTIONS ], "WINNT32" );
  56. strcpy( g_szBootVars[ COUNTDOWN ], "10" );
  57. strcpy( g_szBootVars[ AUTOLOAD ], "YES" );
  58. strcpy( g_szBootVars[ LASTKNOWNGOOD ], "FALSE" );
  59. } else {
  60. //
  61. // Get the boot vars
  62. //
  63. // BOOTVAR ::= =<VARVALUE>
  64. // <VARVALUE> ::= null | {;} | <VALUE>{;} | <VALUE>;<VARVALUE>
  65. //
  66. for( nbootvar = SYSTEMPARTITION; nbootvar<=LASTKNOWNGOOD; nbootvar++ ) {
  67. // read to '='
  68. while( (szBootNVR[i] != '=') && (i<nLengthBootNVR) )
  69. i++;
  70. // read past '='
  71. i++;
  72. j = 0;
  73. // get env var from '=' to CR or ';'
  74. while( (szBootNVR[i] != '\r') && (szBootNVR[i] != ';') && (i<nLengthBootNVR) )
  75. g_szBootVars[nbootvar][j++] = szBootNVR[i++];
  76. g_szBootVars[nbootvar][j++] = '\0';
  77. // if ';' read to CR
  78. if( szBootNVR[i] == ';' ) {
  79. while( (szBootNVR[i] != '\r') && (i<nLengthBootNVR) )
  80. i++;
  81. }
  82. }
  83. }
  84. }
  85. PCHAR
  86. BlSelectKernel(
  87. )
  88. /*++
  89. Routine Description:
  90. Parses the boot.txt file and determines the fully-qualified name of
  91. the kernel to be booted.
  92. Arguments:
  93. Return Value:
  94. Pointer to the name of a kernel to boot.
  95. --*/
  96. {
  97. sprintf( szSelectKernelString, "%s%s", g_szBootVars[OSLOADPARTITION], g_szBootVars[OSLOADFILENAME] );
  98. return szSelectKernelString;
  99. }
  100. /*++
  101. Routine Descriptions:
  102. The following are access functions to GET boot env vars
  103. Arguments:
  104. PCHAR XXX - where the env var is copied to
  105. Return Value:
  106. --*/
  107. VOID
  108. BlGetVarSystemPartition(
  109. OUT PCHAR szSystemPartition
  110. )
  111. {
  112. sprintf( szSystemPartition, "SYSTEMPARTITION=%s", g_szBootVars[SYSTEMPARTITION] );
  113. }
  114. VOID
  115. BlGetVarOsLoader(
  116. OUT PCHAR szOsLoader
  117. )
  118. {
  119. sprintf( szOsLoader, "OSLOADER=%s", g_szBootVars[OSLOADER] );
  120. }
  121. VOID
  122. BlGetVarOsLoadPartition(
  123. OUT PCHAR szOsLoadPartition
  124. )
  125. {
  126. sprintf( szOsLoadPartition, "OSLOADPARTITION=%s", g_szBootVars[OSLOADPARTITION] );
  127. }
  128. VOID
  129. BlGetVarOsLoadFilename(
  130. OUT PCHAR szOsLoadFilename
  131. )
  132. {
  133. sprintf( szOsLoadFilename, "OSLOADFILENAME=%s", g_szBootVars[OSLOADFILENAME] );
  134. }
  135. VOID
  136. BlGetVarOsLoaderShort(
  137. OUT PCHAR szOsLoaderShort
  138. )
  139. {
  140. sprintf( szOsLoaderShort, "%s", g_szBootVars[OSLOADER] );
  141. }
  142. VOID
  143. BlGetVarLoadIdentifier(
  144. OUT PCHAR szLoadIdentifier
  145. )
  146. {
  147. sprintf( szLoadIdentifier, "LOADIDENTIFIER=%s", g_szBootVars[LOADIDENTIFIER] );
  148. }
  149. VOID
  150. BlGetVarOsLoadOptions(
  151. OUT PCHAR szLoadOptions
  152. )
  153. {
  154. sprintf( szLoadOptions, "OSLOADOPTIONS=%s", g_szBootVars[OSLOADOPTIONS] );
  155. }
  156. VOID
  157. BlGetVarCountdown(
  158. OUT PCHAR szCountdown
  159. )
  160. {
  161. sprintf( szCountdown, "COUNTDOWN=%s", g_szBootVars[COUNTDOWN] );
  162. }
  163. VOID
  164. BlGetVarAutoload(
  165. OUT PCHAR szAutoload
  166. )
  167. {
  168. sprintf( szAutoload, "AUTOLOAD=%s", g_szBootVars[AUTOLOAD] );
  169. }
  170. VOID
  171. BlGetVarLastKnownGood(
  172. OUT PCHAR szLastKnownGood
  173. )
  174. {
  175. sprintf( szLastKnownGood, "LASTKNOWNGOOD=%s", g_szBootVars[LASTKNOWNGOOD] );
  176. }