Windows NT 4.0 source code leak
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.

249 lines
5.0 KiB

4 years ago
  1. /*++
  2. Copyright (c) 1991 Microsoft Corporation
  3. Module Name:
  4. jxdisp.c
  5. Abstract:
  6. This module implements the HAL display initialization and output routines
  7. for a MIPS R3000 or R4000 Jazz system.
  8. Author:
  9. Andre Vachon (andreva) 09-May-1992
  10. David N. Cutler (davec) 27-Apr-1991
  11. Environment:
  12. Kernel mode
  13. Revision History:
  14. --*/
  15. #include "halp.h"
  16. #include "eisa.h"
  17. #include "string.h"
  18. #define CSI 0x9b
  19. int sprintf();
  20. extern ULONG IoSpaceAlreadyMapped;
  21. static UCHAR DisplayInitializationString[] = {CSI,'3','7',';','4','4','m',CSI,'2','J',0};
  22. static UCHAR CarriageReturnString[] = {13,0};
  23. static ULONG HalOwnsDisplay = FALSE;
  24. static ULONG DisplayFile;
  25. PHAL_RESET_DISPLAY_PARAMETERS HalpResetDisplayParameters;
  26. VOID
  27. HalAcquireDisplayOwnership (
  28. IN PHAL_RESET_DISPLAY_PARAMETERS ResetDisplayParameters
  29. )
  30. /*++
  31. Routine Description:
  32. This routine switches ownership of the display away from the HAL to
  33. the system display driver. It is called when the system has reached
  34. a point during bootstrap where it is self supporting and can output
  35. its own messages. Once ownership has passed to the system display
  36. driver any attempts to output messages using HalDisplayString must
  37. result in ownership of the display reverting to the HAL and the
  38. display hardware reinitialized for use by the HAL.
  39. Arguments:
  40. ResetDisplayParameters - if non-NULL the address of a function
  41. the hal can call to reset the video card. The function returns
  42. TRUE if the display was reset.
  43. Return Value:
  44. None.
  45. --*/
  46. {
  47. ArcClose(DisplayFile);
  48. HalOwnsDisplay = FALSE;
  49. HalpResetDisplayParameters = ResetDisplayParameters;
  50. return;
  51. }
  52. VOID
  53. HalDisplayString (
  54. PUCHAR String
  55. )
  56. /*++
  57. Routine Description:
  58. This routine displays a character string on the display screen.
  59. Arguments:
  60. String - Supplies a pointer to the characters that are to be displayed.
  61. Return Value:
  62. None.
  63. --*/
  64. {
  65. ULONG Count;
  66. if (IoSpaceAlreadyMapped == FALSE) {
  67. HalpMapIoSpace();
  68. HalpInitializeX86DisplayAdapter();
  69. IoSpaceAlreadyMapped = TRUE;
  70. }
  71. if (HalOwnsDisplay==FALSE) {
  72. if (HalpResetDisplayParameters != NULL) {
  73. (HalpResetDisplayParameters)(80,25);
  74. }
  75. HalpResetX86DisplayAdapter();
  76. ArcOpen(ArcGetEnvironmentVariable("ConsoleOut"),ArcOpenWriteOnly,&DisplayFile);
  77. ArcWrite(DisplayFile,DisplayInitializationString,strlen(DisplayInitializationString),&Count);
  78. HalOwnsDisplay=TRUE;
  79. }
  80. ArcWrite(DisplayFile,String,strlen(String),&Count);
  81. ArcWrite(DisplayFile,CarriageReturnString,strlen(CarriageReturnString),&Count);
  82. return;
  83. }
  84. VOID
  85. HalQueryDisplayParameters (
  86. OUT PULONG WidthInCharacters,
  87. OUT PULONG HeightInLines,
  88. OUT PULONG CursorColumn,
  89. OUT PULONG CursorRow
  90. )
  91. /*++
  92. Routine Description:
  93. This routine return information about the display area and current
  94. cursor position.
  95. Arguments:
  96. WidthInCharacter - Supplies a pointer to a varible that receives
  97. the width of the display area in characters.
  98. HeightInLines - Supplies a pointer to a variable that receives the
  99. height of the display area in lines.
  100. CursorColumn - Supplies a pointer to a variable that receives the
  101. current display column position.
  102. CursorRow - Supplies a pointer to a variable that receives the
  103. current display row position.
  104. Return Value:
  105. None.
  106. --*/
  107. {
  108. ARC_DISPLAY_STATUS *DisplayStatus;
  109. //
  110. // Get the display parameter values and return.
  111. //
  112. //
  113. // If the HAL does not already own the display, then print an empty string.
  114. // This guarantees that the file descriptor DisplayFile is valid.
  115. //
  116. if (!HalOwnsDisplay) {
  117. HalDisplayString("");
  118. }
  119. //
  120. // Make firmware call to get the display's current status
  121. //
  122. DisplayStatus = ArcGetDisplayStatus(DisplayFile);
  123. *WidthInCharacters = DisplayStatus->CursorMaxXPosition;
  124. *HeightInLines = DisplayStatus->CursorMaxYPosition;
  125. *CursorColumn = DisplayStatus->CursorXPosition;
  126. *CursorRow = DisplayStatus->CursorYPosition;
  127. return;
  128. }
  129. VOID
  130. HalSetDisplayParameters (
  131. IN ULONG CursorColumn,
  132. IN ULONG CursorRow
  133. )
  134. /*++
  135. Routine Description:
  136. This routine set the current cursor position on the display area.
  137. Arguments:
  138. CursorColumn - Supplies the new display column position.
  139. CursorRow - Supplies a the new display row position.
  140. Return Value:
  141. None.
  142. --*/
  143. {
  144. CHAR SetCursorPositionString[20];
  145. ULONG Count;
  146. //
  147. // Set the display parameter values and return.
  148. //
  149. //
  150. // If the HAL does not already own the display, then print an empty string.
  151. // This guarantees that the file descriptor DisplayFile is valid.
  152. //
  153. if (!HalOwnsDisplay) {
  154. HalDisplayString("");
  155. }
  156. //
  157. // Build ANSI sequence to set the cursor position.
  158. //
  159. sprintf(SetCursorPositionString,"%c%d;%dH",CSI,CursorRow,CursorColumn);
  160. ArcWrite(DisplayFile,SetCursorPositionString,strlen(SetCursorPositionString),&Count);
  161. return;
  162. }