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.

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