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.

400 lines
5.5 KiB

4 years ago
  1. /*++
  2. Copyright (c) 1991 Microsoft Corporation
  3. Module Name:
  4. xxconout.c
  5. Abstract:
  6. This module implements a stubbed MIPS console out driver that simply
  7. uses debug print to do its output.
  8. Author:
  9. David N. Cutler (davec) 28-Aug-1991
  10. Environment:
  11. Kernel mode.
  12. Revision History:
  13. --*/
  14. //#include "bldr.h"
  15. #include "bootlib.h"
  16. #include "firmware.h"
  17. #include "string.h"
  18. //
  19. // Define prototypes for all routines used by this module.
  20. //
  21. ARC_STATUS
  22. ConsoleOutClose (
  23. IN ULONG FileId
  24. );
  25. ARC_STATUS
  26. ConsoleOutMount (
  27. IN PCHAR MountPath,
  28. IN MOUNT_OPERATION Operation
  29. );
  30. ARC_STATUS
  31. ConsoleOutOpen (
  32. IN PCHAR OpenPath,
  33. IN OPEN_MODE OpenMode,
  34. OUT PULONG FileId
  35. );
  36. ARC_STATUS
  37. ConsoleOutRead (
  38. IN ULONG FileId,
  39. IN PVOID Buffer,
  40. IN ULONG Length,
  41. OUT PULONG Count
  42. );
  43. ARC_STATUS
  44. ConsoleOutGetReadStatus (
  45. IN ULONG FileId
  46. );
  47. ARC_STATUS
  48. ConsoleOutSeek (
  49. IN ULONG FileId,
  50. IN PLARGE_INTEGER Offset,
  51. IN SEEK_MODE SeekMode
  52. );
  53. ARC_STATUS
  54. ConsoleOutWrite (
  55. IN ULONG FileId,
  56. IN PVOID Buffer,
  57. IN ULONG Length,
  58. OUT PULONG Count
  59. );
  60. //
  61. // Define static data.
  62. //
  63. BL_DEVICE_ENTRY_TABLE ConsoleOutEntryTable;
  64. ARC_STATUS
  65. ConsoleOutClose (
  66. IN ULONG FileId
  67. )
  68. /*++
  69. Routine Description:
  70. This function closes the file table entry specified by the file id.
  71. Arguments:
  72. FileId - Supplies the file table index.
  73. Return Value:
  74. ESUCCESS is returned
  75. --*/
  76. {
  77. BlFileTable[FileId].Flags.Open = 0;
  78. return ESUCCESS;
  79. }
  80. ARC_STATUS
  81. ConsoleOutMount (
  82. IN PCHAR MountPath,
  83. IN MOUNT_OPERATION Operation
  84. )
  85. /*++
  86. Routine Description:
  87. Arguments:
  88. Return Value:
  89. --*/
  90. {
  91. return ESUCCESS;
  92. }
  93. ARC_STATUS
  94. ConsoleOutOpen (
  95. IN PCHAR OpenPath,
  96. IN OPEN_MODE OpenMode,
  97. OUT PULONG FileId
  98. )
  99. /*++
  100. Routine Description:
  101. Arguments:
  102. Return Value:
  103. --*/
  104. {
  105. return ESUCCESS;
  106. }
  107. ARC_STATUS
  108. ConsoleOutRead (
  109. IN ULONG FileId,
  110. IN PVOID Buffer,
  111. IN ULONG Length,
  112. OUT PULONG Count
  113. )
  114. /*++
  115. Routine Description:
  116. This function is invalid for the console and returns an error.
  117. Arguments:
  118. FileId - Supplies the file table index.
  119. Buffer - Supplies a pointer to the buffer that receives the data
  120. read.
  121. Length - Supplies the number of bytes to be read.
  122. Count - Supplies a pointer to a variable that receives the number of
  123. bytes actually read.
  124. Return Value:
  125. ENODEV is returned.
  126. --*/
  127. {
  128. return ENODEV;
  129. }
  130. ARC_STATUS
  131. ConsoleOutGetReadStatus (
  132. IN ULONG FileId
  133. )
  134. /*++
  135. Routine Description:
  136. Arguments:
  137. Return Value:
  138. --*/
  139. {
  140. return ESUCCESS;
  141. }
  142. ARC_STATUS
  143. ConsoleOutSeek (
  144. IN ULONG FileId,
  145. IN PLARGE_INTEGER Offset,
  146. IN SEEK_MODE SeekMode
  147. )
  148. /*++
  149. Routine Description:
  150. This function sets the device position to the specified offset for
  151. the specified file id.
  152. Arguments:
  153. FileId - Supplies the file table index.
  154. Offset - Supplies to new device position.
  155. SeekMode - Supplies the mode for the position.
  156. Return Value:
  157. ESUCCESS is returned.
  158. --*/
  159. {
  160. return ESUCCESS;
  161. }
  162. ARC_STATUS
  163. ConsoleOutWrite (
  164. IN ULONG FileId,
  165. IN PVOID Buffer,
  166. IN ULONG Length,
  167. OUT PULONG Count
  168. )
  169. /*++
  170. Routine Description:
  171. This function write information to the console ConsoleOut device.
  172. Arguments:
  173. FileId - Supplies the file table index.
  174. Buffer - Supplies a pointer to the buffer that receives the data
  175. read.
  176. Length - Supplies the number of bytes to be read.
  177. Count - Supplies a pointer to a variable that receives the number of
  178. bytes actually read.
  179. Return Value:
  180. ESUCCESS is returne as the function value.
  181. --*/
  182. {
  183. CHAR LocalBuffer[512];
  184. //
  185. // Copy the string to the local buffer so it can be zero terminated.
  186. //
  187. strncpy(&LocalBuffer[0], (PCHAR)Buffer, Length);
  188. LocalBuffer[Length] = 0;
  189. //
  190. // Output the string using debug print.
  191. //
  192. DbgPrint("%s", &LocalBuffer[0]);
  193. return ESUCCESS;
  194. }
  195. NTSTATUS
  196. ConsoleOutBootInitialize(
  197. )
  198. /*++
  199. Routine Description:
  200. This routine is invoked to initialize the console output dirver.
  201. Arguments:
  202. None.
  203. Return Value:
  204. None.
  205. --*/
  206. {
  207. return STATUS_SUCCESS;
  208. }
  209. NTSTATUS
  210. ConsoleOutBootClose(
  211. )
  212. /*++
  213. Routine Description:
  214. This routine closes the console output driver.
  215. Arguments:
  216. None.
  217. Return Value:
  218. Normal, successful completion status.
  219. --*/
  220. {
  221. return STATUS_SUCCESS;
  222. }
  223. NTSTATUS
  224. ConsoleOutBootOpen (
  225. IN ULONG FileId
  226. )
  227. /*++
  228. Routine Description:
  229. This routine opens the console driver and initializes the device entry
  230. table in the specified file table entry.
  231. Arguments:
  232. FileId - Supplies the file id for the file table entry.
  233. Return Value:
  234. STATUS_SUCCESS.
  235. --*/
  236. {
  237. //
  238. // Initialize the ConsoleOut disk device entry table.
  239. //
  240. ConsoleOutEntryTable.Close = ConsoleOutClose;
  241. ConsoleOutEntryTable.Mount = ConsoleOutMount;
  242. ConsoleOutEntryTable.Open = ConsoleOutOpen;
  243. ConsoleOutEntryTable.Read = ConsoleOutRead;
  244. ConsoleOutEntryTable.GetReadStatus = ConsoleOutGetReadStatus;
  245. ConsoleOutEntryTable.Seek = ConsoleOutSeek;
  246. ConsoleOutEntryTable.Write = ConsoleOutWrite;
  247. //
  248. // Initialize the file table entry for the specified file id.
  249. //
  250. BlFileTable[FileId].Flags.Open = 1;
  251. BlFileTable[FileId].Flags.Write = 1;
  252. BlFileTable[FileId].DeviceId = 0;
  253. BlFileTable[FileId].Position.LowPart = 0;
  254. BlFileTable[FileId].Position.HighPart = 0;
  255. BlFileTable[FileId].DeviceEntryTable = &ConsoleOutEntryTable;
  256. return STATUS_SUCCESS;
  257. }