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.

400 lines
9.2 KiB

  1. /*++
  2. Copyright (c) 1992 Microsoft Corporation
  3. Module Name:
  4. bldrx86.h
  5. Abstract:
  6. Contains definitions and prototypes specific to the x86 NTLDR.
  7. Author:
  8. John Vert (jvert) 20-Dec-1993
  9. Revision History:
  10. --*/
  11. #ifndef _BLDRX86_
  12. #define _BLDRX86_
  13. #include "bldr.h"
  14. //
  15. // Define specific ranges where parts of the system should be loaded
  16. //
  17. //
  18. // X86 is limited to the first 512MB of physical address space
  19. // We also try to pack kernel and HAL into a single 4MB page
  20. //
  21. #define BL_KERNEL_RANGE_LOW (ULONG)((BlVirtualBias) ? _12MB : _4MB )
  22. #define BL_KERNEL_RANGE_HIGH (ULONG)((BlVirtualBias) ? _16MB : _8MB )
  23. //
  24. // Specific range for the disk cache since this is allocated before the
  25. // kernel and HAL are loaded and we want to keep its 2MB out of the 4MB
  26. // page we are trying to cram the kernel and HAL into.
  27. //
  28. #define BL_DISK_CACHE_RANGE_LOW (_8MB)
  29. #define BL_DISK_CACHE_RANGE_HIGH (_16MB)
  30. #define BL_DRIVER_RANGE_LOW (ULONG)0
  31. #define BL_DRIVER_RANGE_HIGH (ULONG)(_512MB)
  32. #define BL_DECOMPRESS_RANGE_LOW (ULONG)(0)
  33. #define BL_DECOMPRESS_RANGE_HIGH (ULONG)(_512MB)
  34. #define BL_XIPROM_RANGE_LOW (ULONG)BlUsableBase
  35. #define BL_XIPROM_RANGE_HIGH (ULONG)(_512MB)
  36. #define OLD_ALTERNATE (0xe1000000 - 64 * 1024 * 1024)
  37. VOID
  38. AEInitializeStall(
  39. VOID
  40. );
  41. ARC_STATUS
  42. AEInitializeIo(
  43. IN ULONG DriveId
  44. );
  45. VOID
  46. AEGetArcDiskInformation(
  47. VOID
  48. );
  49. PVOID
  50. FwAllocateHeap(
  51. IN ULONG Size
  52. );
  53. VOID
  54. MdShutoffFloppy(
  55. VOID
  56. );
  57. PCHAR
  58. BlSelectKernel(
  59. IN ULONG DriveId,
  60. IN PCHAR BootFile,
  61. OUT PCHAR *LoadOptions,
  62. IN BOOLEAN UseTimeOut
  63. );
  64. BOOLEAN
  65. BlDetectHardware(
  66. IN ULONG DriveId,
  67. IN PCHAR LoadOptions
  68. );
  69. VOID
  70. BlStartup(
  71. IN PCHAR PartitionName
  72. );
  73. //
  74. // Arc routines for supporting common VGA I/O routines
  75. //
  76. #define ARC_DISPLAY_CLEAR_ESCAPE "\033[2J"
  77. #define ARC_DISPLAY_CLEAR() { \
  78. ULONG LocalCount; \
  79. ArcWrite(BlConsoleOutDeviceId, ARC_DISPLAY_CLEAR_ESCAPE, \
  80. sizeof(ARC_DISPLAY_CLEAR_ESCAPE) - 1, &LocalCount); \
  81. }
  82. #define ARC_DISPLAY_CLEAR_TO_EOD() { \
  83. ULONG LocalCount; \
  84. ArcWrite(BlConsoleOutDeviceId, "\033[0J", sizeof("\033[0J") - 1, &LocalCount); \
  85. }
  86. #define ARC_DISPLAY_CLEAR_TO_EOL() { \
  87. ULONG LocalCount; \
  88. ArcWrite(BlConsoleOutDeviceId, "\033[0K", sizeof("\033[0K") - 1, &LocalCount); \
  89. }
  90. #define ARC_DISPLAY_ATTRIBUTES_OFF() { \
  91. ULONG LocalCount; \
  92. ArcWrite(BlConsoleOutDeviceId, "\033[0m", sizeof("\033[0m") - 1, &LocalCount); \
  93. }
  94. #define ARC_DISPLAY_INVERSE_VIDEO() { \
  95. ULONG LocalCount; \
  96. ArcWrite(BlConsoleOutDeviceId, "\033[7m", sizeof("\033[7m") - 1, &LocalCount); \
  97. }
  98. #define ARC_DISPLAY_SET_COLOR(c) { \
  99. ULONG LocalCount; \
  100. CHAR LocalBuffer[40]; \
  101. sprintf(LocalBuffer, "\033[%sm", c); \
  102. ArcWrite(BlConsoleOutDeviceId, LocalBuffer, strlen(LocalBuffer), &LocalCount); \
  103. }
  104. #define ARC_DISPLAY_POSITION_CURSOR(x, y) { \
  105. ULONG LocalCount; \
  106. CHAR LocalBuffer[40]; \
  107. sprintf(LocalBuffer, "\033[%d;%dH", y + 1, x + 1); \
  108. ArcWrite(BlConsoleOutDeviceId, LocalBuffer, strlen(LocalBuffer), &LocalCount); \
  109. }
  110. extern BOOLEAN BlTerminalConnected;
  111. extern ULONG BlTerminalDeviceId;
  112. extern ULONG BlTerminalDelay;
  113. LOGICAL
  114. BlTerminalAttached(
  115. IN ULONG TerminalDeviceId
  116. );
  117. //
  118. // Routine for checking if a character is the lead byt to a double-byte
  119. //
  120. BOOLEAN
  121. GrIsDBCSLeadByte(
  122. IN UCHAR c
  123. );
  124. VOID
  125. UTF8Encode(
  126. USHORT InputValue,
  127. PUCHAR UTF8Encoding
  128. );
  129. VOID
  130. GetDBCSUtf8Translation(
  131. PUCHAR InputChar,
  132. PUCHAR UTF8Encoding
  133. );
  134. VOID
  135. GetSBCSUtf8Translation(
  136. PUCHAR InputChar,
  137. PUCHAR UTF8Encoding
  138. );
  139. ARC_STATUS
  140. MempAllocDescriptor(
  141. IN ULONG StartPage,
  142. IN ULONG EndPage,
  143. IN TYPE_OF_MEMORY MemoryType
  144. );
  145. typedef struct {
  146. ULONG ErrorFlag;
  147. ULONG Key;
  148. ULONG Size;
  149. struct {
  150. ULONG BaseAddrLow;
  151. ULONG BaseAddrHigh;
  152. ULONG SizeLow;
  153. ULONG SizeHigh;
  154. ULONG MemoryType;
  155. } Descriptor;
  156. } E820FRAME, *PE820FRAME;
  157. // E X T E R N A L S E R V I C E S T A B L E
  158. //
  159. // External Services Table - machine dependent services
  160. // like reading a sector from the disk and finding out how
  161. // much memory is installed are provided by a lower level
  162. // module or a ROM BIOS. The EST provides entry points
  163. // for the OS loader.
  164. //
  165. //**
  166. // NOTE WELL
  167. // The offsets of entries in this structure MUST MATCH
  168. // the offsets of BOTH the ExportEntryTable in ....\startup\i386\sudata.asm
  169. // AND ...\startrom\i386\sudata.asm. You must change all 3
  170. // locations together.
  171. //**
  172. typedef struct _EXTERNAL_SERVICES_TABLE {
  173. VOID (__cdecl * RebootProcessor)(VOID);
  174. NTSTATUS (__cdecl * DiskIOSystem)(UCHAR,UCHAR,USHORT,USHORT,UCHAR,UCHAR,PUCHAR);
  175. ULONG (__cdecl * GetKey)(VOID);
  176. ULONG (__cdecl * GetCounter)(VOID);
  177. VOID (__cdecl * Reboot)(ULONG);
  178. VOID (__cdecl * DetectHardware)(ULONG, ULONG, PVOID, PULONG, PCHAR, ULONG);
  179. VOID (__cdecl * HardwareCursor)(ULONG,ULONG);
  180. VOID (__cdecl * GetDateTime)(PULONG,PULONG);
  181. VOID (__cdecl * ComPort)(LONG,ULONG,UCHAR);
  182. ULONG (__cdecl * GetStallCount)(VOID);
  183. VOID (__cdecl * InitializeDisplayForNt)(VOID);
  184. VOID (__cdecl * GetMemoryDescriptor)(P820FRAME);
  185. NTSTATUS (__cdecl * GetEddsSector)(UCHAR,ULONG,ULONG,USHORT,PUCHAR,UCHAR);
  186. NTSTATUS (__cdecl * GetElToritoStatus)(PUCHAR,UCHAR);
  187. BOOLEAN (__cdecl * GetExtendedInt13Params)(PUCHAR,UCHAR);
  188. USHORT (__cdecl * NetPcRomServices)(ULONG,PVOID);
  189. VOID (__cdecl * ApmAttemptReconnect)(VOID);
  190. ULONG (__cdecl * BiosRedirectService)(ULONG);
  191. } EXTERNAL_SERVICES_TABLE, *PEXTERNAL_SERVICES_TABLE;
  192. extern PEXTERNAL_SERVICES_TABLE ExternalServicesTable;
  193. //**
  194. // SEE NOTE AT TOP OF STRUCTURE
  195. //**
  196. //
  197. // External Services Macros
  198. //
  199. #define REBOOT_PROCESSOR (*ExternalServicesTable->RebootProcessor)
  200. #define GET_SECTOR (*ExternalServicesTable->DiskIOSystem)
  201. #define RESET_DISK (*ExternalServicesTable->DiskIOSystem)
  202. #define BIOS_IO (*ExternalServicesTable->DiskIOSystem)
  203. #define GET_KEY (*ExternalServicesTable->GetKey)
  204. #define GET_COUNTER (*ExternalServicesTable->GetCounter)
  205. #define REBOOT (*ExternalServicesTable->Reboot)
  206. #define DETECT_HARDWARE (*ExternalServicesTable->DetectHardware)
  207. #define HW_CURSOR (*ExternalServicesTable->HardwareCursor)
  208. #define GET_DATETIME (*ExternalServicesTable->GetDateTime)
  209. #define COMPORT (*ExternalServicesTable->ComPort)
  210. #define GET_STALL_COUNT (*ExternalServicesTable->GetStallCount)
  211. #define SETUP_DISPLAY_FOR_NT (*ExternalServicesTable->InitializeDisplayForNt)
  212. #define GET_MEMORY_DESCRIPTOR (*ExternalServicesTable->GetMemoryDescriptor)
  213. #define GET_EDDS_SECTOR (*ExternalServicesTable->GetEddsSector)
  214. #define GET_ELTORITO_STATUS (*ExternalServicesTable->GetElToritoStatus)
  215. #define GET_XINT13_PARAMS (*ExternalServicesTable->GetExtendedInt13Params)
  216. #define NETPC_ROM_SERVICES (*ExternalServicesTable->NetPcRomServices)
  217. #define APM_ATTEMPT_RECONNECT (*ExternalServicesTable->ApmAttemptReconnect)
  218. #define BIOS_REDIRECT_SERVICE (*ExternalServicesTable->BiosRedirectService)
  219. //
  220. // Define special key input values
  221. //
  222. #define DOWN_ARROW 0x5000
  223. #define UP_ARROW 0x4800
  224. #define HOME_KEY 0x4700
  225. #define END_KEY 0x4F00
  226. #define LEFT_KEY 0x4B00
  227. #define RIGHT_KEY 0x4D00
  228. #define INS_KEY 0x5200
  229. #define DEL_KEY 0x5300
  230. #define BKSP_KEY 0x0E08
  231. #define TAB_KEY 0x0009
  232. #define BACKTAB_KEY 0x0F00
  233. #define F1_KEY 0x3B00
  234. #define F2_KEY 0x3C00
  235. #define F3_KEY 0x3D00
  236. #define F4_KEY 0x3E00
  237. #define F5_KEY 0x3F00
  238. #define F6_KEY 0x4000
  239. #define F7_KEY 0x4100
  240. #define F8_KEY 0x4200
  241. #define F10_KEY 0x4400
  242. #define F11_KEY 0xD900
  243. #define F12_KEY 0xDA00
  244. #define ENTER_KEY 0x000D
  245. #define ESCAPE_KEY 0x011B
  246. //
  247. // x86-specific video support
  248. //
  249. VOID
  250. TextGetCursorPosition(
  251. OUT PULONG X,
  252. OUT PULONG Y
  253. );
  254. VOID
  255. TextSetCursorPosition(
  256. IN ULONG X,
  257. IN ULONG Y
  258. );
  259. VOID
  260. TextSetCurrentAttribute(
  261. IN UCHAR Attribute
  262. );
  263. UCHAR
  264. TextGetCurrentAttribute(
  265. VOID
  266. );
  267. VOID
  268. TextClearDisplay(
  269. VOID
  270. );
  271. VOID
  272. TextClearToEndOfDisplay(
  273. VOID
  274. );
  275. VOID
  276. TextClearFromStartOfLine(
  277. VOID
  278. );
  279. VOID
  280. TextClearToEndOfLine(
  281. VOID
  282. );
  283. VOID
  284. TextStringOut(
  285. IN PUCHAR String
  286. );
  287. PUCHAR
  288. TextCharOut(
  289. IN PUCHAR pc
  290. );
  291. VOID
  292. TextFillAttribute(
  293. IN UCHAR Attribute,
  294. IN ULONG Length
  295. );
  296. VOID
  297. TextGrInitialize(
  298. IN ULONG DiskId,
  299. OUT PULONG ImageLength
  300. );
  301. VOID
  302. TextGrTerminate(
  303. VOID
  304. );
  305. #define BlPuts(str) TextStringOut(str)
  306. ULONG
  307. BlGetKey(
  308. VOID
  309. );
  310. VOID
  311. BlInputString(
  312. IN ULONG Prompt,
  313. IN ULONG CursorX,
  314. IN ULONG CursorY,
  315. IN PUCHAR String,
  316. IN ULONG MaxLength
  317. );
  318. //
  319. // Watchdog Timer
  320. //
  321. #define X86_WATCHDOG_TIMEOUT (60*5)
  322. VOID
  323. SetX86WatchDog(
  324. ULONG TimeOut
  325. );
  326. #endif // _BLDRX86_