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.

390 lines
8.8 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 _16MB ((16*1024*1024) >> PAGE_SHIFT)
  22. #define BL_KERNEL_RANGE_LOW (((BlVirtualBias) ? (12*1024*1024) : (4*1024*1024)) >> PAGE_SHIFT)
  23. #define BL_KERNEL_RANGE_HIGH (((BlVirtualBias) ? (16*1024*1024) : (8*1024*1024)) >> PAGE_SHIFT)
  24. //
  25. // Specific range for the disk cache since this is allocated before the
  26. // kernel and HAL are loaded and we want to keep its 2MB out of the 4MB
  27. // page we are trying to cram the kernel and HAL into.
  28. //
  29. #define BL_DISK_CACHE_RANGE_LOW ((8*1024*1024) >> PAGE_SHIFT)
  30. #define BL_DISK_CACHE_RANGE_HIGH ((16*1024*1024) >> PAGE_SHIFT)
  31. #define BL_DRIVER_RANGE_LOW 0
  32. #define BL_DRIVER_RANGE_HIGH (512*1024*1024 >> PAGE_SHIFT)
  33. #define BL_DECOMPRESS_RANGE_LOW (0)
  34. #define BL_DECOMPRESS_RANGE_HIGH (512*1024*1024 >> PAGE_SHIFT)
  35. #define BL_XIPROM_RANGE_LOW BlUsableBase
  36. #define BL_XIPROM_RANGE_HIGH (512*1024*1024 >> PAGE_SHIFT)
  37. #define OLD_ALTERNATE (0xe1000000 - 64 * 1024 * 1024)
  38. VOID
  39. AEInitializeStall(
  40. VOID
  41. );
  42. ARC_STATUS
  43. AEInitializeIo(
  44. IN ULONG DriveId
  45. );
  46. VOID
  47. AEGetArcDiskInformation(
  48. VOID
  49. );
  50. PVOID
  51. FwAllocateHeap(
  52. IN ULONG Size
  53. );
  54. VOID
  55. MdShutoffFloppy(
  56. VOID
  57. );
  58. PCHAR
  59. BlSelectKernel(
  60. IN ULONG DriveId,
  61. IN PCHAR BootFile,
  62. OUT PCHAR *LoadOptions,
  63. IN BOOLEAN UseTimeOut
  64. );
  65. BOOLEAN
  66. BlDetectHardware(
  67. IN ULONG DriveId,
  68. IN PCHAR LoadOptions
  69. );
  70. VOID
  71. BlStartup(
  72. IN PCHAR PartitionName
  73. );
  74. //
  75. // Arc routines for supporting common VGA I/O routines
  76. //
  77. #define ARC_DISPLAY_CLEAR_ESCAPE "\033[2J"
  78. #define ARC_DISPLAY_CLEAR() { \
  79. ULONG LocalCount; \
  80. ArcWrite(BlConsoleOutDeviceId, ARC_DISPLAY_CLEAR_ESCAPE, \
  81. sizeof(ARC_DISPLAY_CLEAR_ESCAPE) - 1, &LocalCount); \
  82. }
  83. #define ARC_DISPLAY_CLEAR_TO_EOD() { \
  84. ULONG LocalCount; \
  85. ArcWrite(BlConsoleOutDeviceId, "\033[0J", sizeof("\033[0J") - 1, &LocalCount); \
  86. }
  87. #define ARC_DISPLAY_CLEAR_TO_EOL() { \
  88. ULONG LocalCount; \
  89. ArcWrite(BlConsoleOutDeviceId, "\033[0K", sizeof("\033[0K") - 1, &LocalCount); \
  90. }
  91. #define ARC_DISPLAY_ATTRIBUTES_OFF() { \
  92. ULONG LocalCount; \
  93. ArcWrite(BlConsoleOutDeviceId, "\033[0m", sizeof("\033[0m") - 1, &LocalCount); \
  94. }
  95. #define ARC_DISPLAY_INVERSE_VIDEO() { \
  96. ULONG LocalCount; \
  97. ArcWrite(BlConsoleOutDeviceId, "\033[7m", sizeof("\033[7m") - 1, &LocalCount); \
  98. }
  99. #define ARC_DISPLAY_SET_COLOR(c) { \
  100. ULONG LocalCount; \
  101. UCHAR LocalBuffer[40]; \
  102. sprintf(LocalBuffer, "\033[%sm", c); \
  103. ArcWrite(BlConsoleOutDeviceId, LocalBuffer, strlen(LocalBuffer), &LocalCount); \
  104. }
  105. #define ARC_DISPLAY_POSITION_CURSOR(x, y) { \
  106. ULONG LocalCount; \
  107. UCHAR LocalBuffer[40]; \
  108. sprintf(LocalBuffer, "\033[%d;%dH", y + 1, x + 1); \
  109. ArcWrite(BlConsoleOutDeviceId, LocalBuffer, strlen(LocalBuffer), &LocalCount); \
  110. }
  111. extern BOOLEAN BlTerminalConnected;
  112. extern ULONG BlTerminalDeviceId;
  113. extern ULONG BlTerminalDelay;
  114. LOGICAL
  115. BlTerminalAttached(
  116. IN ULONG TerminalDeviceId
  117. );
  118. //
  119. // Routine for checking if a character is the lead byt to a double-byte
  120. //
  121. BOOLEAN
  122. GrIsDBCSLeadByte(
  123. IN UCHAR c
  124. );
  125. VOID
  126. UTF8Encode(
  127. USHORT InputValue,
  128. PUCHAR UTF8Encoding
  129. );
  130. VOID
  131. GetDBCSUtf8Translation(
  132. PUCHAR InputChar,
  133. PUCHAR UTF8Encoding
  134. );
  135. VOID
  136. GetSBCSUtf8Translation(
  137. PUCHAR InputChar,
  138. PUCHAR UTF8Encoding
  139. );
  140. ARC_STATUS
  141. MempAllocDescriptor(
  142. IN ULONG StartPage,
  143. IN ULONG EndPage,
  144. IN TYPE_OF_MEMORY MemoryType
  145. );
  146. typedef struct {
  147. ULONG ErrorFlag;
  148. ULONG Key;
  149. ULONG Size;
  150. struct {
  151. ULONG BaseAddrLow;
  152. ULONG BaseAddrHigh;
  153. ULONG SizeLow;
  154. ULONG SizeHigh;
  155. ULONG MemoryType;
  156. } Descriptor;
  157. } E820FRAME, *PE820FRAME;
  158. // E X T E R N A L S E R V I C E S T A B L E
  159. //
  160. // External Services Table - machine dependent services
  161. // like reading a sector from the disk and finding out how
  162. // much memory is installed are provided by a lower level
  163. // module or a ROM BIOS. The EST provides entry points
  164. // for the OS loader.
  165. //
  166. //**
  167. // NOTE WELL
  168. // The offsets of entries in this structure MUST MATCH
  169. // the offsets of BOTH the ExportEntryTable in ....\startup\i386\sudata.asm
  170. // AND ...\startrom\i386\sudata.asm. You must change all 3
  171. // locations together.
  172. //**
  173. typedef struct _EXTERNAL_SERVICES_TABLE {
  174. VOID (__cdecl * RebootProcessor)(VOID);
  175. NTSTATUS (__cdecl * DiskIOSystem)(UCHAR,UCHAR,USHORT,USHORT,UCHAR,UCHAR,PUCHAR);
  176. ULONG (__cdecl * GetKey)(VOID);
  177. ULONG (__cdecl * GetCounter)(VOID);
  178. VOID (__cdecl * Reboot)(ULONG);
  179. VOID (__cdecl * DetectHardware)(ULONG, ULONG, PVOID, PULONG, PCHAR, ULONG);
  180. VOID (__cdecl * HardwareCursor)(ULONG,ULONG);
  181. VOID (__cdecl * GetDateTime)(PULONG,PULONG);
  182. VOID (__cdecl * ComPort)(LONG,ULONG,UCHAR);
  183. ULONG (__cdecl * GetStallCount)(VOID);
  184. VOID (__cdecl * InitializeDisplayForNt)(VOID);
  185. VOID (__cdecl * GetMemoryDescriptor)(P820FRAME);
  186. NTSTATUS (__cdecl * GetEddsSector)(UCHAR,ULONG,ULONG,USHORT,PUCHAR,UCHAR);
  187. NTSTATUS (__cdecl * GetElToritoStatus)(PUCHAR,UCHAR);
  188. BOOLEAN (__cdecl * GetExtendedInt13Params)(PUCHAR,UCHAR);
  189. USHORT (__cdecl * NetPcRomServices)(ULONG,PVOID);
  190. VOID (__cdecl * ApmAttemptReconnect)(VOID);
  191. ULONG (__cdecl * BiosRedirectService)(ULONG);
  192. } EXTERNAL_SERVICES_TABLE, *PEXTERNAL_SERVICES_TABLE;
  193. extern PEXTERNAL_SERVICES_TABLE ExternalServicesTable;
  194. //**
  195. // SEE NOTE AT TOP OF STRUCTURE
  196. //**
  197. //
  198. // External Services Macros
  199. //
  200. #define REBOOT_PROCESSOR (*ExternalServicesTable->RebootProcessor)
  201. #define GET_SECTOR (*ExternalServicesTable->DiskIOSystem)
  202. #define RESET_DISK (*ExternalServicesTable->DiskIOSystem)
  203. #define BIOS_IO (*ExternalServicesTable->DiskIOSystem)
  204. #define GET_KEY (*ExternalServicesTable->GetKey)
  205. #define GET_COUNTER (*ExternalServicesTable->GetCounter)
  206. #define REBOOT (*ExternalServicesTable->Reboot)
  207. #define DETECT_HARDWARE (*ExternalServicesTable->DetectHardware)
  208. #define HW_CURSOR (*ExternalServicesTable->HardwareCursor)
  209. #define GET_DATETIME (*ExternalServicesTable->GetDateTime)
  210. #define COMPORT (*ExternalServicesTable->ComPort)
  211. #define GET_STALL_COUNT (*ExternalServicesTable->GetStallCount)
  212. #define SETUP_DISPLAY_FOR_NT (*ExternalServicesTable->InitializeDisplayForNt)
  213. #define GET_MEMORY_DESCRIPTOR (*ExternalServicesTable->GetMemoryDescriptor)
  214. #define GET_EDDS_SECTOR (*ExternalServicesTable->GetEddsSector)
  215. #define GET_ELTORITO_STATUS (*ExternalServicesTable->GetElToritoStatus)
  216. #define GET_XINT13_PARAMS (*ExternalServicesTable->GetExtendedInt13Params)
  217. #define NETPC_ROM_SERVICES (*ExternalServicesTable->NetPcRomServices)
  218. #define APM_ATTEMPT_RECONNECT (*ExternalServicesTable->ApmAttemptReconnect)
  219. #define BIOS_REDIRECT_SERVICE (*ExternalServicesTable->BiosRedirectService)
  220. //
  221. // Define special key input values
  222. //
  223. #define DOWN_ARROW 0x5000
  224. #define UP_ARROW 0x4800
  225. #define HOME_KEY 0x4700
  226. #define END_KEY 0x4F00
  227. #define LEFT_KEY 0x4B00
  228. #define RIGHT_KEY 0x4D00
  229. #define INS_KEY 0x5200
  230. #define DEL_KEY 0x5300
  231. #define BKSP_KEY 0x0E08
  232. #define TAB_KEY 0x0009
  233. #define BACKTAB_KEY 0x0F00
  234. #define F1_KEY 0x3B00
  235. #define F2_KEY 0x3C00
  236. #define F3_KEY 0x3D00
  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. #endif // _BLDRX86_