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.

258 lines
5.5 KiB

  1. /*++
  2. Copyright (c) 1991 Microsoft Corporation
  3. Module Name:
  4. blmisc.c
  5. Abstract:
  6. This module contains miscellaneous routines for use by
  7. the boot loader and setupldr.
  8. Author:
  9. David N. Cutler (davec) 10-May-1991
  10. Revision History:
  11. --*/
  12. #include "bootlib.h"
  13. //
  14. // Value indicating whether a dbcs locale is active.
  15. // If this value is non-0 we use alternate display routines, etc,
  16. // and fetch messages in this language.
  17. //
  18. ULONG DbcsLangId;
  19. PCHAR
  20. BlGetArgumentValue (
  21. IN ULONG Argc,
  22. IN CHAR * FIRMWARE_PTR * FIRMWARE_PTR Argv,
  23. IN PCHAR ArgumentName
  24. )
  25. /*++
  26. Routine Description:
  27. This routine scans the specified argument list for the named argument
  28. and returns the address of the argument value. Argument strings are
  29. specified as:
  30. ArgumentName=ArgumentValue
  31. Argument names are specified as:
  32. ArgumentName=
  33. The argument name match is case insensitive.
  34. Arguments:
  35. Argc - Supplies the number of argument strings that are to be scanned.
  36. Argv - Supplies a pointer to a vector of pointers to null terminated
  37. argument strings.
  38. ArgumentName - Supplies a pointer to a null terminated argument name.
  39. Return Value:
  40. If the specified argument name is located, then a pointer to the argument
  41. value is returned as the function value. Otherwise, a value of NULL is
  42. returned.
  43. --*/
  44. {
  45. PCHAR Name;
  46. PCHAR String;
  47. //
  48. // Scan the argument strings until either a match is found or all of
  49. // the strings have been scanned.
  50. //
  51. while (Argc > 0) {
  52. String = Argv[Argc - 1];
  53. if (String != NULL) {
  54. Name = ArgumentName;
  55. while ((*Name != 0) && (*String != 0)) {
  56. if (toupper(*Name) != toupper(*String)) {
  57. break;
  58. }
  59. Name += 1;
  60. String += 1;
  61. }
  62. if ((*Name == 0) && (*String == '=')) {
  63. return String + 1;
  64. }
  65. Argc -= 1;
  66. }
  67. }
  68. return NULL;
  69. }
  70. PCHAR
  71. BlSetArgumentValue (
  72. IN ULONG Argc,
  73. IN CHAR * FIRMWARE_PTR * FIRMWARE_PTR Argv,
  74. IN PCHAR ArgumentName,
  75. IN PCHAR NewValue
  76. )
  77. /*++
  78. Routine Description:
  79. This routine scans the specified argument list for the named argument
  80. and returns the address of the argument value. The value associated
  81. with the arg is changed to the value passed in. Argument strings are
  82. specified as:
  83. ArgumentName=ArgumentValue
  84. Argument names are specified as:
  85. ArgumentName=
  86. The argument name match is case insensitive.
  87. Arguments:
  88. Argc - Supplies the number of argument strings that are to be scanned.
  89. Argv - Supplies a pointer to a vector of pointers to null terminated
  90. argument strings.
  91. ArgumentName - Supplies a pointer to a null terminated argument name.
  92. Return Value:
  93. If the specified argument name is located, then a pointer to the argument
  94. value is returned as the function value. Otherwise, a value of NULL is
  95. returned.
  96. --*/
  97. {
  98. PCHAR Name;
  99. PCHAR String;
  100. //
  101. // Scan the argument strings until either a match is found or all of
  102. // the strings have been scanned.
  103. //
  104. while (Argc > 0) {
  105. String = Argv[Argc - 1];
  106. if (String != NULL) {
  107. Name = ArgumentName;
  108. while ((*Name != 0) && (*String != 0)) {
  109. if (toupper(*Name) != toupper(*String)) {
  110. break;
  111. }
  112. Name += 1;
  113. String += 1;
  114. }
  115. if ((*Name == 0) && (*String == '=')) {
  116. Name = (PCHAR)BlAllocateHeap(strlen(ArgumentName)+2+strlen(NewValue));
  117. if (Name) {
  118. strcpy( Name, ArgumentName );
  119. strcat( Name, "=" );
  120. strcat( Name, NewValue );
  121. return Name+strlen(ArgumentName)+1;
  122. }
  123. return String + 1;
  124. }
  125. Argc -= 1;
  126. }
  127. }
  128. return NULL;
  129. }
  130. //
  131. // Line draw chars -- different scheme in Far East vs. SBCS
  132. //
  133. _TUCHAR
  134. GetGraphicsChar(
  135. IN GraphicsChar WhichOne
  136. )
  137. {
  138. #ifdef EFI
  139. return(TextGetGraphicsCharacter(WhichOne));
  140. #else
  141. #if defined(_X86_) && !defined(ARCI386)
  142. return(TextGetGraphicsCharacter(WhichOne));
  143. #else
  144. //
  145. // ARC machines don't support dbcs for now
  146. //
  147. static _TUCHAR ArcGraphicsChars[GraphicsCharMax] = { (UCHAR)'\311', // right-down
  148. (UCHAR)'\273', // left-down
  149. (UCHAR)'\310', // right-up
  150. (UCHAR)'\274', // left-up
  151. (UCHAR)'\272', // vertical
  152. (UCHAR)'\315' // horizontal
  153. };
  154. return(((unsigned)WhichOne < (unsigned)GraphicsCharMax)
  155. ? ArcGraphicsChars[WhichOne]
  156. : TEXT(' '));
  157. #endif
  158. #endif
  159. }
  160. LOGICAL
  161. BdPollBreakIn(
  162. VOID
  163. );
  164. #if defined(_X86_)
  165. #include <bldrx86.h>
  166. #endif
  167. VOID
  168. BlWaitForReboot (
  169. VOID
  170. )
  171. {
  172. #if defined(_X86)
  173. BlPrint( TEXT("Press any key to reboot\n") );
  174. #endif
  175. while (TRUE) {
  176. #if defined(_X86_)
  177. if ( BdPollBreakIn() ) {
  178. DbgBreakPoint();
  179. }
  180. if ( ArcGetReadStatus(BlConsoleInDeviceId) ) {
  181. BlPrint( TEXT("Rebooting...\n") );
  182. REBOOT_PROCESSOR();
  183. }
  184. #endif
  185. ;
  186. }
  187. }