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.

780 lines
14 KiB

  1. /*++
  2. Copyright (c) 1992 Microsoft Corporation
  3. Module Name:
  4. setupldr.h
  5. Abstract:
  6. Common header file for the setupldr module
  7. Author:
  8. John Vert (jvert) 6-Oct-1993
  9. Environment:
  10. ARC environment
  11. Revision History:
  12. --*/
  13. #include "bldr.h"
  14. #include "haldtect.h"
  15. #include "setupblk.h"
  16. #include "msgs.h"
  17. #include "stdio.h"
  18. #include "stdarg.h"
  19. //
  20. // OEM source device types
  21. //
  22. #define SL_OEM_SOURCE_DEVICE_TYPE_LOCAL 0x00008000
  23. #define SL_OEM_SOURCE_DEVICE_TYPE_REMOVABLE 0x00000001
  24. #define SL_OEM_SOURCE_DEVICE_TYPE_FIXED 0x00000002
  25. #define SL_OEM_SOURCE_DEVICE_TYPE_PREINSTALL 0x10000000
  26. #define SL_OEM_SOURCE_DEVICE_TYPE_DYN_UPDATE 0x20000000
  27. #define SL_OEM_SOURCE_DEVICE_TYPE_VIRTUAL 0x40000000
  28. #define SL_OEM_SOURCE_DEVICE_TYPE_REMOTE 0x80000000
  29. //
  30. // OEM source device media states
  31. //
  32. #define SL_OEM_SOURCE_MEDIA_ABSENT 0x00000001
  33. #define SL_OEM_SOURCE_MEDIA_NO_DRIVERS 0x00000002
  34. #define SL_OEM_SOURCE_MEDIA_HAS_MSD 0x00000004
  35. #define SL_OEM_SOURCE_MEDIA_HAS_HAL 0x00000008
  36. #define SL_OEM_SOURCE_MEDIA_HAS_DEFAULT 0x20000000
  37. #define SL_OEM_SOURCE_MEDIA_HAS_DRIVERS 0x40000000
  38. #define SL_OEM_SOURCE_MEDIA_PRESENT 0x80000000
  39. //
  40. // OEM source device processing states
  41. //
  42. #define SL_OEM_SOURCE_DEVICE_NOT_PROCESSED 0x00000000
  43. #define SL_OEM_SOURCE_DEVICE_PROCESSED 0x00000001
  44. #define SL_OEM_SOURCE_DEVICE_SKIPPED 0x00000002
  45. #define SL_OEM_SOURCE_DEVICE_SCANNED 0x00000004
  46. #define SL_OEM_SOURCE_DEVICE_HAL_LOADED 0x00000008
  47. #define SL_OEM_SOURCE_DEVICE_MSD_LOADED 0x00000010
  48. #define SL_OEM_SOURCE_DEVICE_DRIVERS_LOADED 0x40000000
  49. #define SL_OEM_SOURCE_DEVICE_PROCESSING 0x80000000
  50. typedef struct _OEM_SOURCE_DEVICE {
  51. CHAR ArcDeviceName[128];
  52. ULONG DeviceType;
  53. ULONG MediaType;
  54. ULONG DeviceState;
  55. ULONG DeviceId;
  56. PVOID InfHandle;
  57. PCSTR DriverDir;
  58. struct _OEM_SOURCE_DEVICE *Next;
  59. } OEM_SOURCE_DEVICE, *POEM_SOURCE_DEVICE;
  60. #define SL_OEM_SOURCE_DEVICE_TYPE(DevicePtr, Type) \
  61. ((DevicePtr)->DeviceType & (Type))
  62. #define SL_OEM_SET_SOURCE_DEVICE_TYPE(DevicePtr, Type) \
  63. ((DevicePtr)->DeviceType = (Type))
  64. #define SL_OEM_SOURCE_MEDIA_TYPE(DevicePtr, Type) \
  65. ((DevicePtr)->MediaType & (Type))
  66. #define SL_OEM_SET_SOURCE_MEDIA_TYPE(DevicePtr, Type) \
  67. ((DevicePtr)->MediaType = (Type))
  68. #define SL_OEM_SOURCE_DEVICE_STATE(DevicePtr, Type) \
  69. ((DevicePtr)->DeviceState & (Type))
  70. #define SL_OEM_SET_SOURCE_DEVICE_STATE(DevicePtr, Type) \
  71. ((DevicePtr)->DeviceState = (Type))
  72. ARC_STATUS
  73. SlInitOemSourceDevices(
  74. IN OUT POEM_SOURCE_DEVICE *OemSourceDevices,
  75. IN OUT POEM_SOURCE_DEVICE *DefaultSourceDevice
  76. );
  77. //
  78. //
  79. // Functions for managing the display
  80. //
  81. //
  82. VOID
  83. SlSetCurrentAttribute(
  84. IN UCHAR Attribute
  85. );
  86. ARC_STATUS
  87. SlWriteString(
  88. IN _PTUCHAR s
  89. );
  90. ARC_STATUS
  91. SlPositionCursor(
  92. IN unsigned x,
  93. IN unsigned y
  94. );
  95. VOID
  96. SlGetCursorPosition(
  97. OUT unsigned *x,
  98. OUT unsigned *y
  99. );
  100. ARC_STATUS
  101. SlClearClientArea(
  102. VOID
  103. );
  104. ARC_STATUS
  105. SlClearToEol(
  106. VOID
  107. );
  108. VOID
  109. SlInitDisplay(
  110. VOID
  111. );
  112. VOID
  113. SlWriteHeaderText(
  114. IN ULONG MsgId
  115. );
  116. VOID
  117. SlSetStatusAttribute(
  118. IN UCHAR Attribute
  119. );
  120. BOOLEAN
  121. SlGetStatusBarStatus(
  122. VOID
  123. );
  124. VOID
  125. SlEnableStatusBar(
  126. IN BOOLEAN Enable
  127. );
  128. VOID
  129. SlWriteStatusText(
  130. IN PTCHAR Text
  131. );
  132. VOID
  133. SlGetStatusText(
  134. OUT PTCHAR Text
  135. );
  136. VOID
  137. SlClearDisplay(
  138. VOID
  139. );
  140. VOID
  141. SlPrint(
  142. IN PTCHAR FormatString,
  143. ...
  144. );
  145. VOID
  146. SlConfirmExit(
  147. VOID
  148. );
  149. BOOLEAN
  150. SlPromptForDisk(
  151. IN PTCHAR DiskName,
  152. IN BOOLEAN IsCancellable
  153. );
  154. BOOLEAN
  155. SlGetDisk(
  156. IN PCHAR Filename
  157. );
  158. //
  159. // Menuing support
  160. //
  161. typedef struct _SL_MENU {
  162. ULONG ItemCount;
  163. ULONG Width;
  164. LIST_ENTRY ItemListHead;
  165. } SL_MENU, *PSL_MENU;
  166. typedef struct _SL_MENUITEM {
  167. LIST_ENTRY ListEntry;
  168. PTCHAR Text;
  169. PVOID Data;
  170. ULONG Attributes;
  171. } SL_MENUITEM, *PSL_MENUITEM;
  172. PSL_MENU
  173. SlCreateMenu(
  174. VOID
  175. );
  176. ULONG
  177. SlAddMenuItem(
  178. PSL_MENU Menu,
  179. PTCHAR Text,
  180. PVOID Data,
  181. ULONG Attributes
  182. );
  183. PVOID
  184. SlGetMenuItem(
  185. IN PSL_MENU Menu,
  186. IN ULONG Item
  187. );
  188. ULONG
  189. SlDisplayMenu(
  190. IN ULONG HeaderId,
  191. IN PSL_MENU Menu,
  192. IN OUT PULONG Selection
  193. );
  194. BOOLEAN
  195. SlGetMenuItemIndex(
  196. IN PSL_MENU Menu,
  197. IN PTCHAR Text,
  198. OUT PULONG Index
  199. );
  200. //
  201. // Bullet character and macro to make a beep at the console
  202. //
  203. #ifndef EFI
  204. #define BULLET "*"
  205. #define BEEP { ULONG c; ArcWrite(ARC_CONSOLE_OUTPUT,"",1,&c); }
  206. #if 0
  207. #define BULLET ""
  208. #define BEEP HWCURSOR(0x80000000,0xe07); // int 10 func e, char 7
  209. #endif
  210. #endif
  211. //
  212. // Character attributes used for various purposes.
  213. //
  214. UCHAR
  215. SlGetDefaultAttr(
  216. VOID
  217. );
  218. UCHAR
  219. SlGetDefaultInvAttr(
  220. VOID
  221. );
  222. #define ATT_FG_BLACK 0
  223. #define ATT_FG_RED 1
  224. #define ATT_FG_GREEN 2
  225. #define ATT_FG_YELLOW 3
  226. #define ATT_FG_BLUE 4
  227. #define ATT_FG_MAGENTA 5
  228. #define ATT_FG_CYAN 6
  229. #define ATT_FG_WHITE 7
  230. #define ATT_BG_BLACK (ATT_FG_BLACK << 4)
  231. #define ATT_BG_BLUE (ATT_FG_BLUE << 4)
  232. #define ATT_BG_GREEN (ATT_FG_GREEN << 4)
  233. #define ATT_BG_CYAN (ATT_FG_CYAN << 4)
  234. #define ATT_BG_RED (ATT_FG_RED << 4)
  235. #define ATT_BG_MAGENTA (ATT_FG_MAGENTA << 4)
  236. #define ATT_BG_YELLOW (ATT_FG_YELLOW << 4)
  237. #define ATT_BG_WHITE (ATT_FG_WHITE << 4)
  238. #define ATT_FG_INTENSE 8
  239. #define ATT_BG_INTENSE (ATT_FG_INTENSE << 4)
  240. #define DEFATT SlGetDefaultAttr()
  241. #define INVATT SlGetDefaultInvAttr()
  242. #define DEFIATT (ATT_FG_WHITE | ATT_BG_BLUE | ATT_FG_INTENSE)
  243. // intense red on blue doesn't show up on all monitors.
  244. //#define DEFERRATT (ATT_FG_RED | ATT_BG_BLUE | ATT_FG_INTENSE)
  245. #define DEFERRATT DEFATT
  246. #define DEFSTATTR (ATT_FG_BLACK | ATT_BG_WHITE)
  247. #define DEFDLGATT (ATT_FG_RED | ATT_BG_WHITE)
  248. //
  249. // Function to flush keyboard buffer
  250. //
  251. VOID
  252. SlFlushConsoleBuffer(
  253. VOID
  254. );
  255. //
  256. // Function to retrieve a keystroke
  257. //
  258. ULONG
  259. SlGetChar(
  260. VOID
  261. );
  262. //
  263. // Virtualized contants for various keystrokes
  264. //
  265. #define ASCI_BS 8
  266. #define ASCI_CR 13
  267. #define ASCI_LF 10
  268. #define ASCI_ESC 27
  269. #define SL_KEY_UP 0x00010000
  270. #define SL_KEY_DOWN 0x00020000
  271. #define SL_KEY_HOME 0x00030000
  272. #define SL_KEY_END 0x00040000
  273. #define SL_KEY_PAGEUP 0x00050000
  274. #define SL_KEY_PAGEDOWN 0x00060000
  275. #define SL_KEY_F1 0x01000000
  276. #define SL_KEY_F2 0x02000000
  277. #define SL_KEY_F3 0x03000000
  278. #define SL_KEY_F5 0x05000000
  279. #define SL_KEY_F6 0x06000000
  280. #define SL_KEY_F7 0x07000000
  281. #define SL_KEY_F8 0x08000000
  282. #define SL_KEY_F9 0x09000000
  283. #define SL_KEY_F10 0x0A000000
  284. #define SL_KEY_F11 0x0B000000
  285. #define SL_KEY_F12 0x0C000000
  286. //
  287. // Standard error handling functions
  288. //
  289. extern TCHAR MessageBuffer[1024];
  290. VOID
  291. SlFriendlyError(
  292. IN ULONG uStatus,
  293. IN PCHAR pchBadFile,
  294. IN ULONG uLine,
  295. IN PCHAR pchCodeFile
  296. );
  297. ULONG
  298. SlDisplayMessageBox(
  299. IN ULONG MessageId,
  300. ...
  301. );
  302. VOID
  303. SlGenericMessageBox(
  304. IN ULONG MessageId, OPTIONAL
  305. IN va_list *args, OPTIONAL
  306. IN PTCHAR Message, OPTIONAL
  307. IN OUT PULONG xLeft, OPTIONAL
  308. IN OUT PULONG yTop, OPTIONAL
  309. OUT PULONG yBottom, OPTIONAL
  310. IN BOOLEAN bCenterMsg
  311. );
  312. VOID
  313. SlMessageBox(
  314. IN ULONG MessageId,
  315. ...
  316. );
  317. VOID
  318. SlFatalError(
  319. IN ULONG MessageId,
  320. ...
  321. );
  322. //
  323. // Routines for parsing the setupldr.ini file
  324. //
  325. #define SIF_FILENAME_INDEX 0
  326. extern PVOID InfFile;
  327. extern PVOID WinntSifHandle;
  328. ARC_STATUS
  329. SlInitIniFile(
  330. IN PCHAR DevicePath,
  331. IN ULONG DeviceId,
  332. IN PCHAR INFFile,
  333. OUT PVOID *pINFHandle,
  334. OUT PVOID *pINFBuffer OPTIONAL,
  335. OUT PULONG INFBufferSize OPTIONAL,
  336. OUT PULONG ErrorLine
  337. );
  338. PCHAR
  339. SlGetIniValue(
  340. IN PVOID InfHandle,
  341. IN PCHAR SectionName,
  342. IN PCHAR KeyName,
  343. IN PCHAR Default
  344. );
  345. PCHAR
  346. SlGetKeyName(
  347. IN PVOID INFHandle,
  348. IN PCHAR SectionName,
  349. IN ULONG LineIndex
  350. );
  351. ULONG
  352. SlGetSectionKeyOrdinal(
  353. IN PVOID INFHandle,
  354. IN PCHAR SectionName,
  355. IN PCHAR Key
  356. );
  357. PCHAR
  358. SlGetSectionKeyIndex (
  359. IN PVOID INFHandle,
  360. IN PCHAR SectionName,
  361. IN PCHAR Key,
  362. IN ULONG ValueIndex
  363. );
  364. PCHAR
  365. SlCopyStringA(
  366. IN PCSTR String
  367. );
  368. PTCHAR
  369. SlCopyString(
  370. IN PTCHAR String
  371. );
  372. PCHAR
  373. SlGetSectionLineIndex (
  374. IN PVOID INFHandle,
  375. IN PCHAR SectionName,
  376. IN ULONG LineIndex,
  377. IN ULONG ValueIndex
  378. );
  379. ULONG
  380. SlCountLinesInSection(
  381. IN PVOID INFHandle,
  382. IN PCHAR SectionName
  383. );
  384. BOOLEAN
  385. SpSearchINFSection (
  386. IN PVOID INFHandle,
  387. IN PCHAR SectionName
  388. );
  389. PCHAR
  390. SlSearchSection(
  391. IN PCHAR SectionName,
  392. IN PCHAR TargetName
  393. );
  394. //
  395. // functions for querying the ARC configuration tree
  396. //
  397. typedef
  398. BOOLEAN
  399. (*PNODE_CALLBACK)(
  400. IN PCONFIGURATION_COMPONENT_DATA FoundComponent
  401. );
  402. BOOLEAN
  403. SlSearchConfigTree(
  404. IN PCONFIGURATION_COMPONENT_DATA Node,
  405. IN CONFIGURATION_CLASS Class,
  406. IN CONFIGURATION_TYPE Type,
  407. IN ULONG Key,
  408. IN PNODE_CALLBACK CallbackRoutine
  409. );
  410. BOOLEAN
  411. SlFindFloppy(
  412. IN ULONG FloppyNumber,
  413. OUT PCHAR ArcName
  414. );
  415. //
  416. // Routines for detecting various hardware
  417. //
  418. VOID
  419. SlDetectScsi(
  420. IN PSETUP_LOADER_BLOCK SetupBlock
  421. );
  422. VOID
  423. SlDetectVideo(
  424. IN PSETUP_LOADER_BLOCK SetupBlock
  425. );
  426. //
  427. // Routines for dealing with OEM disks.
  428. //
  429. extern BOOLEAN PromptOemHal;
  430. extern BOOLEAN PromptOemScsi;
  431. extern BOOLEAN PromptOemVideo;
  432. //
  433. // Variable indicating whether we are booting into
  434. // WinPE (aka MiniNT) or not
  435. //
  436. extern BOOLEAN WinPEBoot;
  437. typedef struct _OEMSCSIINFO {
  438. struct _OEMSCSIINFO *Next;
  439. //
  440. // Address where the SCSI driver was loaded
  441. //
  442. PVOID ScsiBase;
  443. //
  444. // Name of the SCSI driver
  445. //
  446. PCHAR ScsiName;
  447. } OEMSCSIINFO, *POEMSCSIINFO;
  448. VOID
  449. SlPromptOemVideo(
  450. IN POEM_SOURCE_DEVICE VideoSourceDevice,
  451. IN BOOLEAN AllowUserSelection,
  452. OUT PVOID *VideoBase,
  453. OUT PCHAR *VideoName
  454. );
  455. VOID
  456. SlPromptOemHal(
  457. IN POEM_SOURCE_DEVICE HalSourceDevice,
  458. IN BOOLEAN AllowUserSelection,
  459. OUT PVOID *HalBase,
  460. OUT PCHAR *ImageName
  461. );
  462. VOID
  463. SlPromptOemScsi(
  464. IN POEM_SOURCE_DEVICE ScsiSourceDevice,
  465. IN BOOLEAN AllowUserSelection,
  466. OUT POEMSCSIINFO *pOemScsiInfo
  467. );
  468. BOOLEAN
  469. SlLoadOemScsiDriversUnattended(
  470. IN POEM_SOURCE_DEVICE OemSourceDevice,
  471. IN PVOID InfHandle,
  472. IN PCHAR ParamsSectionName,
  473. IN PCHAR RootDirKeyName,
  474. IN PCHAR BootDriversKeyName,
  475. IN POEMSCSIINFO* ScsiInfo,
  476. OUT PPNP_HARDWARE_ID* HardwareIdDatabase
  477. );
  478. #if defined(_X86_) || defined(_IA64_)
  479. VOID
  480. BlInitializeTerminal(
  481. VOID
  482. );
  483. #endif
  484. //
  485. // Routine to find the ARC name of a floppy
  486. //
  487. BOOLEAN
  488. SlpFindFloppy(
  489. IN ULONG Number,
  490. OUT PCHAR ArcName
  491. );
  492. //
  493. // Are all the floppies only removable ATAPI super floppies
  494. //
  495. BOOLEAN
  496. SlpIsOnlySuperFloppy(
  497. void
  498. );
  499. //
  500. // Enums for controlling setupldr process
  501. //
  502. typedef enum _SETUP_TYPE {
  503. SetupInteractive,
  504. SetupRepair,
  505. SetupCustom,
  506. SetupUpgrade,
  507. SetupExpress
  508. } SETUP_TYPE;
  509. typedef enum _MEDIA_TYPE {
  510. MediaInteractive,
  511. MediaFloppy,
  512. MediaCdRom,
  513. MediaDisk
  514. } MEDIA_TYPE;
  515. //
  516. // Enum for status of inserting a new SCSI device
  517. //
  518. typedef enum _SCSI_INSERT_STATUS {
  519. ScsiInsertError,
  520. ScsiInsertNewEntry,
  521. ScsiInsertExisting
  522. } SCSI_INSERT_STATUS;
  523. //
  524. // Routine to insert a DETECTED_DEVICE into its
  525. // correct position in the ScsiDevices linked list.
  526. //
  527. SCSI_INSERT_STATUS
  528. SlInsertScsiDevice(
  529. IN ULONG Ordinal,
  530. OUT PDETECTED_DEVICE *pScsiDevice
  531. );
  532. BOOLEAN
  533. SlRemoveInboxDriver(
  534. IN PCHAR DriverToRemove
  535. );
  536. PDETECTED_DEVICE
  537. SlCheckForInboxDriver(
  538. IN PCHAR DriverToCheck
  539. );
  540. BOOLEAN
  541. SlConfirmInboxDriverReplacement(
  542. IN PTCHAR DriverName,
  543. IN PTCHAR AdditionalInfo
  544. );
  545. typedef enum _VERSION_COMP_RESULT {
  546. VersionError,
  547. VersionOemNew,
  548. VersionInboxNew,
  549. VersionSame
  550. } VERSION_COMP_RESULT;
  551. VERSION_COMP_RESULT
  552. SlCompareDriverVersion(
  553. IN ULONG InboxDeviceId,
  554. IN PDETECTED_DEVICE InboxDriver,
  555. IN ULONG OemDeviceId,
  556. IN PDETECTED_DEVICE OemDriver
  557. );
  558. //
  559. // Variables dealing with pre-installation.
  560. //
  561. typedef struct _PREINSTALL_DRIVER_INFO {
  562. struct _PREINSTALL_DRIVER_INFO *Next;
  563. //
  564. // String that describes the driver to preinstall
  565. //
  566. PTCHAR DriverDescription;
  567. //
  568. // Name of the SCSI driver
  569. //
  570. BOOLEAN OemDriver;
  571. } PREINSTALL_DRIVER_INFO, *PPREINSTALL_DRIVER_INFO;
  572. extern BOOLEAN PreInstall;
  573. extern PTCHAR ComputerType;
  574. extern BOOLEAN OemHal;
  575. // extern PCHAR OemBootPath;
  576. extern PPREINSTALL_DRIVER_INFO PreinstallDriverList;
  577. PCHAR
  578. SlPreInstallGetComponentName(
  579. IN PVOID Inf,
  580. IN PCHAR SectionName,
  581. IN PTCHAR TargetName
  582. );
  583. ARC_STATUS
  584. SlLoadSection(
  585. IN PVOID Inf,
  586. IN PCSTR SectionName,
  587. IN BOOLEAN IsScsiSection,
  588. IN BOOLEAN AppendLoadSuffix,
  589. IN OUT PULONG StartingIndexInsert
  590. );
  591. #define WINPE_AUTOBOOT_FILENAME "$WINPE$.$$$"
  592. BOOLEAN
  593. SlIsWinPEAutoBoot(
  594. IN PSTR LoaderDeviceName
  595. );
  596. ARC_STATUS
  597. SlGetWinPEStartupParams(
  598. IN PSTR DeviceName,
  599. IN PSTR StartupDirectory
  600. );
  601. ARC_STATUS
  602. SlLoadWinPESection(
  603. IN POEM_SOURCE_DEVICE OemSourceDevice,
  604. IN PVOID OemInfHandle,
  605. IN PCSTR OemSectionName,
  606. IN PVOID InboxInfHandle,
  607. IN PCSTR InboxSectionName,
  608. IN BOOLEAN IsScsiSection,
  609. IN POEMSCSIINFO* ScsiInfo, OPTIONAL
  610. OUT PPNP_HARDWARE_ID* HardwareIdDatabase OPTIONAL
  611. );
  612. ARC_STATUS
  613. SlLoadOemScsiDriversFromOemSources(
  614. IN POEM_SOURCE_DEVICE OemSourceDevices,
  615. IN OUT PPNP_HARDWARE_ID *HardwareIds,
  616. OUT POEMSCSIINFO *OemScsiInfo
  617. );
  618. ARC_STATUS
  619. SlInitVirtualOemSourceDevices(
  620. IN PSETUP_LOADER_BLOCK SetupLoaderBlock,
  621. IN POEM_SOURCE_DEVICE OemSourceDevices
  622. );
  623. #if defined(ARCI386)
  624. BOOLEAN
  625. SlDetectSifPromVersion(
  626. IN PSETUP_LOADER_BLOCK SetupBlock
  627. );
  628. #endif
  629. #define VGA_DRIVER_FILENAME "vga.sys"
  630. #define VIDEO_DEVICE_NAME "VGA"
  631. extern ULONG BootFontImageLength;