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.

1880 lines
36 KiB

  1. /*++
  2. Copyright (c) 1991 Microsoft Corporation
  3. Module Name:
  4. bldr.h
  5. Abstract:
  6. This module is the header file for the NT boot loader.
  7. Author:
  8. David N. Cutler (davec) 10-May-1991
  9. Revision History:
  10. --*/
  11. #ifndef _BLDR_
  12. #define _BLDR_
  13. #include "ntos.h"
  14. #include "arccodes.h"
  15. #include "setupblk.h"
  16. #include "hdlsblk.h"
  17. #include "remboot.h"
  18. #include "oscpkt.h"
  19. #include "bootstatus.h"
  20. #include <TCHAR.H>
  21. #ifndef _PTUCHAR
  22. typedef _TUCHAR *_PTUCHAR;
  23. #endif
  24. #pragma warning(disable:4200) // unsized array
  25. //
  26. // DoApmAttemptReconnect does nothing on non x86 machines.
  27. // On x86 machines, it attempts an APM reconnect, and lives in initx86.c
  28. //
  29. #if defined(_X86_)
  30. VOID DoApmAttemptReconnect();
  31. #else
  32. #define DoApmAttemptReconnect()
  33. #endif
  34. //
  35. // The Alpha OS Loader and Setup Loader run in the environment of the host
  36. // firmware. This environment is restricted to a 32-bit address space and
  37. // cannot result in pointer significance greater than 32-bits. The 64-bit
  38. // OS Loader, however, is compiled using 64-bit pointers for non-firmware
  39. // interfaces and constructs data structures used to pass information to the
  40. // NT kernel using 64-bit pointers. This leads to a large number of false
  41. // pointer truncation warnings. Therefore, pointer truncation warnings are
  42. // turned off in the OS and Setup Loaders for 64-bit Alpha systems.
  43. //
  44. #if defined(_AXP64_)
  45. #pragma warning(4:4244) // turn off pointer trunction
  46. #endif
  47. //
  48. // Define boot file id.
  49. //
  50. #define BOOT_FILEID 2 // boot partition file id
  51. //
  52. // Define image type.
  53. //
  54. #if defined(_X86_)
  55. #define ICEBP __asm { __emit 0xf1 }
  56. //
  57. // Things related to Amd64 support follow
  58. //
  59. #define TARGET_IMAGE ((BlAmd64UseLongMode == FALSE) ? \
  60. IMAGE_FILE_MACHINE_I386 : IMAGE_FILE_MACHINE_AMD64)
  61. ARC_STATUS
  62. BlAmd64CheckForLongMode(
  63. IN ULONG LoadDeviceId,
  64. IN OUT PCHAR KernelPath,
  65. IN PCHAR KernelFileName
  66. );
  67. //
  68. // BlUseAmd64Longmode is set when we have made the decision to use long
  69. // mode.
  70. //
  71. extern BOOLEAN BlAmd64UseLongMode;
  72. #else
  73. #define BlAmd64UseLongMode FALSE
  74. #endif // _X86_
  75. #if defined(_ALPHA_)
  76. #if defined(_AXP64_)
  77. #define TARGET_IMAGE IMAGE_FILE_MACHINE_AXP64
  78. #else
  79. #define TARGET_IMAGE IMAGE_FILE_MACHINE_ALPHA
  80. #endif
  81. #endif
  82. #if defined(_IA64_)
  83. #define TARGET_IMAGE IMAGE_FILE_MACHINE_IA64
  84. #endif
  85. //
  86. // Make headless defines
  87. //
  88. #if defined(_X86_)
  89. #define BlIsTerminalConnected() BlTerminalConnected
  90. #endif
  91. #if defined(_ALPHA_)
  92. #if defined(_AXP64_)
  93. #define BlIsTerminalConnected() FALSE
  94. #else
  95. #define BlIsTerminalConnected() FALSE
  96. #endif
  97. #endif
  98. #if defined(_IA64_)
  99. #define BlIsTerminalConnected() BlTerminalConnected
  100. #endif
  101. BOOLEAN
  102. BlTerminalHandleLoaderFailure(
  103. VOID
  104. );
  105. //
  106. // Define size of sector.
  107. //
  108. #define SECTOR_SIZE 512 // size of disk sector
  109. #define SECTOR_SHIFT 9 // sector shift value
  110. #define STALE_GPT_PARTITION_ENTRY 0xEE // The stale MBR partition entry for GPT disks
  111. //
  112. // Define heap allocation block granularity.
  113. //
  114. #define BL_GRANULARITY 8
  115. //
  116. // Define number of entries in file table.
  117. //
  118. #define BL_FILE_TABLE_SIZE 48
  119. //
  120. // Define size of memory allocation table.
  121. //
  122. #define BL_MEMORY_TABLE_SIZE 16
  123. //
  124. // Define number of loader heap and stack pages.
  125. //
  126. #if DBG
  127. #define BL_HEAP_PAGES 32
  128. #else
  129. #define BL_HEAP_PAGES 16
  130. #endif
  131. #define BL_STACK_PAGES 8
  132. //
  133. // Define buffer alignment macro.
  134. //
  135. #define ALIGN_BUFFER(Buffer) (PVOID) \
  136. ((((ULONG_PTR)(Buffer) + BlDcacheFillSize - 1)) & (~((ULONG_PTR)BlDcacheFillSize - 1)))
  137. #define ALIGN_BUFFER_WITH_SIZE(Buffer, Size) (PVOID) \
  138. ((((ULONG_PTR)(Buffer) + (Size) - 1)) & (~((ULONG_PTR)(Size) - 1)))
  139. //
  140. // Define kernel names right here.
  141. // We'll use these when we're trying to figure out
  142. // which kernel to load (see BlDetectHalAndKernel).
  143. //
  144. #define LEGACY_KERNEL_NAME "ntoskrnl.exe"
  145. #define UP_KERNEL_NAME "ntkrnlup.exe"
  146. #define MP_KERNEL_NAME "ntkrnlmp.exe"
  147. #define UP_PAE_KERNEL_NAME "ntkrnlpa.exe"
  148. #define MP_PAE_KERNEL_NAME "ntkrpamp.exe"
  149. //
  150. // Define various memory page boundaries
  151. //
  152. #define _1MB ((1*1024*1024) >> PAGE_SHIFT)
  153. #define _4MB (4 * _1MB)
  154. #define _8MB (8 * _1MB)
  155. #define _12MB (12 * _1MB)
  156. #define _16MB (16 * _1MB)
  157. #define _24MB (24 * _1MB)
  158. #define _32MB (32 * _1MB)
  159. #define _48MB (48 * _1MB)
  160. #define _64MB (64 * _1MB)
  161. #define _80MB (80 * _1MB)
  162. #define _96MB (96 * _1MB)
  163. #define _128MB (128 * _1MB)
  164. #define _256MB (256 * _1MB)
  165. #define _512MB (512 * _1MB)
  166. #define _1024MB (1024 * _1MB)
  167. #define _2048MB (2048 * _1MB)
  168. #define _4096MB (4096 * _1MB)
  169. //
  170. // Useful defines for COM ports.
  171. //
  172. #define COM1_PORT (0x3f8)
  173. #define COM2_PORT (0x2f8)
  174. #define COM3_PORT (0x3e8)
  175. #define COM4_PORT (0x2e8)
  176. #define BD_150 150
  177. #define BD_300 300
  178. #define BD_600 600
  179. #define BD_1200 1200
  180. #define BD_2400 2400
  181. #define BD_4800 4800
  182. #define BD_9600 9600
  183. #define BD_14400 14400
  184. #define BD_19200 19200
  185. #define BD_57600 57600
  186. #define BD_115200 115200
  187. // macros to help check overflow issues
  188. //
  189. #define TRUNCATE_SIZE_AT_VALUE(_sz, _vl) (( _sz > _vl ) ? _vl : _sz)
  190. #define RESET_SIZE_AT_VALUE(_sz, _vl) (( _sz > _vl ) ? 0 : _sz)
  191. #define TRUNCATE_SIZE_AT_UCHAR_MAX(_sz) ((UCHAR) TRUNCATE_SIZE_AT_VALUE(_sz, (UCHAR)-1))
  192. #define RESET_SIZE_AT_UCHAR_MAX(_sz) ((UCHAR) RESET_SIZE_AT_VALUE(_sz, (UCHAR)-1))
  193. #define TRUNCATE_SIZE_AT_USHORT_MAX(_sz) ((USHORT) TRUNCATE_SIZE_AT_VALUE(_sz, (USHORT)-1))
  194. #define RESET_SIZE_AT_USHORT_MAX(_sz) ((USHORT) RESET_SIZE_AT_VALUE(_sz, (USHORT)-1))
  195. #define TRUNCATE_SIZE_AT_ULONG_MAX(_sz) ((ULONG) TRUNCATE_SIZE_AT_VALUE(_sz, (ULONG)-1))
  196. #define RESET_SIZE_AT_ULONG_MAX(_sz) ((ULONG) RESET_SIZE_AT_VALUE(_sz, (ULONG)-1))
  197. #define BL_INVALID_FILE_ID (ULONG)-1
  198. typedef
  199. ARC_STATUS
  200. (*PRENAME_ROUTINE)(
  201. IN ULONG FileId,
  202. IN CHAR * FIRMWARE_PTR NewName
  203. );
  204. typedef struct _BOOTFS_INFO {
  205. WCHAR * FIRMWARE_PTR DriverName;
  206. } BOOTFS_INFO, * FIRMWARE_PTR PBOOTFS_INFO;
  207. //
  208. // Device entry table structure.
  209. //
  210. typedef struct _BL_DEVICE_ENTRY_TABLE {
  211. PARC_CLOSE_ROUTINE Close;
  212. PARC_MOUNT_ROUTINE Mount;
  213. PARC_OPEN_ROUTINE Open;
  214. PARC_READ_ROUTINE Read;
  215. PARC_READ_STATUS_ROUTINE GetReadStatus;
  216. PARC_SEEK_ROUTINE Seek;
  217. PARC_WRITE_ROUTINE Write;
  218. PARC_GET_FILE_INFO_ROUTINE GetFileInformation;
  219. PARC_SET_FILE_INFO_ROUTINE SetFileInformation;
  220. PRENAME_ROUTINE Rename;
  221. PARC_GET_DIRECTORY_ENTRY_ROUTINE GetDirectoryEntry;
  222. PBOOTFS_INFO BootFsInfo;
  223. } BL_DEVICE_ENTRY_TABLE, *PBL_DEVICE_ENTRY_TABLE;
  224. //
  225. // Many functions in the boot loader take a set of paths. Every path is divided
  226. // into two parts, a "Source" and a "PathOffset".
  227. //
  228. // A source is described by the PATH_SOURCE structure. This structure contains
  229. // three parts, the device handle to use for I/O, the ARC name of the device,
  230. // and the offset off the root for that ARC device.
  231. //
  232. // The PATH_SET structures encapsulates up to three different sources. The
  233. // field AliasName optionally points to a PE namespace description of the
  234. // sources (eg \SystemRoot).
  235. //
  236. // Finally, the biggest PATH_SET structure (FULL_PATH_SET) is limited to
  237. // MAX_PATH_COUNT sources so that those using this structure can manipulate
  238. // local stack copies.
  239. //
  240. // Putting it all together, during a last known good boot the PATH_SET
  241. // describing \Winnt\System32 would be:
  242. // PathCount = 3
  243. // AliasName = \SystemRoot\
  244. // PathOffset = System32\
  245. // Source[0].DirectoryPath = \Winnt\LastGood.tmp
  246. // Source[1].DirectoryPath = \Winnt\LastGood
  247. // Source[2].DirectoryPath = \Winnt\
  248. //
  249. #define MAX_PATH_SOURCES 3
  250. typedef struct {
  251. ULONG DeviceId;
  252. LPCSTR DeviceName;
  253. PSTR DirectoryPath; // Should have trailing '\'
  254. } PATH_SOURCE, *PPATH_SOURCE;
  255. typedef struct {
  256. ULONG PathCount;
  257. LPCSTR AliasName;
  258. CHAR PathOffset[256]; // Should have trailing '\' if non-empty
  259. PATH_SOURCE Source[0];
  260. } SPARSE_PATH_SET, *PSPARSE_PATH_SET;
  261. typedef struct {
  262. ULONG PathCount;
  263. LPCSTR AliasName;
  264. CHAR PathOffset[256]; // Should have trailing '\' if non-empty
  265. PATH_SOURCE Source[MAX_PATH_SOURCES];
  266. } FULL_PATH_SET, *PFULL_PATH_SET;
  267. //
  268. // A PPATH_SET points to a path set with an undetermined count of paths. We
  269. // make this an alias of PFULL_PATH_SET so as to cut down on casting.
  270. //
  271. typedef PFULL_PATH_SET PPATH_SET;
  272. //
  273. // Define transfer entry of loaded image.
  274. //
  275. typedef
  276. VOID
  277. (*PTRANSFER_ROUTINE) (
  278. PLOADER_PARAMETER_BLOCK LoaderBlock
  279. );
  280. //
  281. // Define main entrypoint.
  282. //
  283. ARC_STATUS
  284. BlOsLoader (
  285. IN ULONG Argc,
  286. IN CHAR * FIRMWARE_PTR * FIRMWARE_PTR Argv,
  287. IN CHAR * FIRMWARE_PTR * FIRMWARE_PTR Envp
  288. );
  289. ARC_STATUS
  290. BlInitStdio (
  291. IN ULONG Argc,
  292. IN CHAR * FIRMWARE_PTR * FIRMWARE_PTR Argv
  293. );
  294. extern UCHAR OsLoaderVersion[];
  295. extern WCHAR OsLoaderVersionW[];
  296. extern UCHAR OsLoaderName[];
  297. extern CHAR KernelFileName[8+1+3+1];
  298. extern CHAR HalFileName[8+1+3+1];
  299. //
  300. // Define boot debugger function prototype.
  301. //
  302. VOID
  303. BdInitDebugger (
  304. IN PCHAR LoaderName,
  305. IN PVOID LoaderBase,
  306. IN PCHAR Options
  307. );
  308. extern LOGICAL BdDebuggerEnabled;
  309. VOID
  310. BdInitializeTraps (
  311. VOID
  312. );
  313. ULONG
  314. BdComPortNumber (
  315. VOID
  316. );
  317. ARC_STATUS
  318. BdPullRemoteFile(
  319. IN PCHAR FileName,
  320. IN ULONG FileAttributes,
  321. IN ULONG CreateDisposition,
  322. IN ULONG CreateOptions,
  323. IN ULONG FileId
  324. );
  325. //
  326. // Define com port I/O prototypes.
  327. //
  328. LOGICAL
  329. BlPortInitialize(
  330. IN ULONG BaudRate,
  331. IN ULONG PortNumber,
  332. IN PUCHAR PortAddress OPTIONAL,
  333. IN BOOLEAN ReInitialize,
  334. OUT PULONG BlFileId
  335. );
  336. VOID
  337. BlInitializeHeadlessPort(
  338. VOID
  339. );
  340. ULONG
  341. BlPortGetByte (
  342. IN ULONG BlFileId,
  343. OUT PUCHAR Input
  344. );
  345. VOID
  346. BlPortPutByte (
  347. IN ULONG BlFileId,
  348. IN UCHAR Output
  349. );
  350. ULONG
  351. BlPortPollByte (
  352. IN ULONG BlFileId,
  353. OUT PUCHAR Input
  354. );
  355. ULONG
  356. BlPortPollOnly (
  357. IN ULONG BlFileId
  358. );
  359. VOID
  360. BlSetHeadlessRestartBlock(
  361. IN PTFTP_RESTART_BLOCK RestartBlock
  362. );
  363. VOID
  364. BlGetHeadlessRestartBlock(
  365. IN PTFTP_RESTART_BLOCK RestartBlock,
  366. IN BOOLEAN RestartBlockValid
  367. );
  368. LOGICAL
  369. BlRetrieveBIOSRedirectionInformation();
  370. extern HEADLESS_LOADER_BLOCK LoaderRedirectionInformation;
  371. //
  372. // Define file I/O prototypes.
  373. //
  374. ARC_STATUS
  375. BlIoInitialize (
  376. VOID
  377. );
  378. ARC_STATUS
  379. BlClose (
  380. IN ULONG FileId
  381. );
  382. PBOOTFS_INFO
  383. BlGetFsInfo(
  384. IN ULONG DeviceId
  385. );
  386. ARC_STATUS
  387. BlMount (
  388. IN PCHAR MountPath,
  389. IN MOUNT_OPERATION Operation
  390. );
  391. ARC_STATUS
  392. BlOpen (
  393. IN ULONG DeviceId,
  394. IN PCHAR OpenPath,
  395. IN OPEN_MODE OpenMode,
  396. OUT PULONG FileId
  397. );
  398. ARC_STATUS
  399. BlRead (
  400. IN ULONG FileId,
  401. OUT PVOID Buffer,
  402. IN ULONG Length,
  403. OUT PULONG Count
  404. );
  405. ARC_STATUS
  406. BlReadAtOffset(
  407. IN ULONG FileId,
  408. IN ULONG Offset,
  409. IN ULONG Length,
  410. OUT PVOID Data
  411. );
  412. ARC_STATUS
  413. BlRename (
  414. IN ULONG FileId,
  415. IN PCHAR NewName
  416. );
  417. ARC_STATUS
  418. BlGetReadStatus (
  419. IN ULONG FileId
  420. );
  421. ARC_STATUS
  422. BlSeek (
  423. IN ULONG FileId,
  424. IN PLARGE_INTEGER Offset,
  425. IN SEEK_MODE SeekMode
  426. );
  427. ARC_STATUS
  428. BlWrite (
  429. IN ULONG FileId,
  430. IN PVOID Buffer,
  431. IN ULONG Length,
  432. OUT PULONG Count
  433. );
  434. ARC_STATUS
  435. BlGetFileInformation (
  436. IN ULONG FileId,
  437. IN PFILE_INFORMATION FileInformation
  438. );
  439. ARC_STATUS
  440. BlSetFileInformation (
  441. IN ULONG FileId,
  442. IN ULONG AttributeFlags,
  443. IN ULONG AttributeMask
  444. );
  445. #ifdef DBLSPACE_LEGAL
  446. VOID
  447. BlSetAutoDoubleSpace (
  448. IN BOOLEAN Enable
  449. );
  450. #endif
  451. //
  452. // Define image manipulation routine prototyupes.
  453. //
  454. #define BlLoadImage(_id_,_memtype_,_file_,_imagetype_,_base_) \
  455. BlLoadImageEx(_id_,_memtype_,_file_,_imagetype_,0,0,_base_)
  456. ARC_STATUS
  457. BlLoadImageEx(
  458. IN ULONG DeviceId,
  459. IN TYPE_OF_MEMORY MemoryType,
  460. IN PCHAR LoadFile,
  461. IN USHORT ImageType,
  462. IN OPTIONAL ULONG PreferredAlignment,
  463. IN OPTIONAL ULONG PreferredBasePage,
  464. OUT PVOID *ImageBase
  465. );
  466. ARC_STATUS
  467. BlLoadDeviceDriver(
  468. IN PPATH_SET PathSet,
  469. IN PCHAR DriverName,
  470. IN PTCHAR DriverDescription OPTIONAL,
  471. IN ULONG DriverFlags,
  472. OUT PKLDR_DATA_TABLE_ENTRY *DriverDataTableEntry
  473. );
  474. ARC_STATUS
  475. BlLoadNLSData(
  476. IN ULONG DeviceId,
  477. IN PCHAR DeviceName,
  478. IN PCHAR DirectoryPath,
  479. IN PUNICODE_STRING AnsiCodepage,
  480. IN PUNICODE_STRING OemCodepage,
  481. IN PUNICODE_STRING LanguageTable,
  482. OUT PCHAR BadFileName
  483. );
  484. ARC_STATUS
  485. BlLoadOemHalFont(
  486. IN ULONG DeviceId,
  487. IN PCHAR DeviceName,
  488. IN PCHAR DirectoryPath,
  489. IN PUNICODE_STRING OemHalFont,
  490. OUT PCHAR BadFileName
  491. );
  492. PVOID
  493. BlImageNtHeader (
  494. IN PVOID Base
  495. );
  496. ARC_STATUS
  497. BlSetupForNt(
  498. IN PLOADER_PARAMETER_BLOCK BlLoaderBlock
  499. );
  500. ARC_STATUS
  501. BlScanImportDescriptorTable (
  502. IN PPATH_SET PathSet,
  503. IN PKLDR_DATA_TABLE_ENTRY ScanEntry,
  504. IN TYPE_OF_MEMORY MemoryType
  505. );
  506. ARC_STATUS
  507. BlScanOsloaderBoundImportTable (
  508. IN PKLDR_DATA_TABLE_ENTRY ScanEntry
  509. );
  510. VOID
  511. BlTransferToKernel(
  512. PTRANSFER_ROUTINE SystemEntry,
  513. PLOADER_PARAMETER_BLOCK BlLoaderBlock
  514. );
  515. #if defined(_ALPHA_)
  516. ARC_STATUS
  517. BlAllocateAnyMemory (
  518. IN TYPE_OF_MEMORY MemoryType,
  519. IN ULONG BasePage,
  520. IN ULONG PageCount,
  521. OUT PULONG ActualBase
  522. );
  523. ARC_STATUS
  524. BlGeneratePalName(
  525. IN PCHAR PalFIleName
  526. );
  527. ARC_STATUS
  528. BlLoadPal(
  529. IN ULONG DeviceId,
  530. IN TYPE_OF_MEMORY MemoryType,
  531. IN PCHAR LoadPath,
  532. IN USHORT ImageType,
  533. OUT PVOID *ImageBase,
  534. IN PCHAR LoadDevice
  535. );
  536. VOID
  537. BlSetGranularityHints (
  538. IN PHARDWARE_PTE PageTableArray,
  539. IN ULONG PageTableCount
  540. );
  541. #endif
  542. #if defined(_PPC_)
  543. ARC_STATUS
  544. BlPpcInitialize (
  545. VOID
  546. );
  547. #endif // defined(_PPC)
  548. //
  549. // Define configuration allocation prototypes.
  550. //
  551. ARC_STATUS
  552. BlConfigurationInitialize (
  553. IN PCONFIGURATION_COMPONENT Parent,
  554. IN PCONFIGURATION_COMPONENT_DATA ParentEntry
  555. );
  556. //
  557. // define routines for searching the ARC firmware tree
  558. //
  559. typedef
  560. BOOLEAN
  561. (*PNODE_CALLBACK)(
  562. IN PCONFIGURATION_COMPONENT_DATA FoundComponent
  563. );
  564. BOOLEAN
  565. BlSearchConfigTree(
  566. IN PCONFIGURATION_COMPONENT_DATA Node,
  567. IN CONFIGURATION_CLASS Class,
  568. IN CONFIGURATION_TYPE Type,
  569. IN ULONG Key,
  570. IN PNODE_CALLBACK CallbackRoutine
  571. );
  572. VOID
  573. BlGetPathnameFromComponent(
  574. IN PCONFIGURATION_COMPONENT_DATA Component,
  575. OUT PCHAR ArcName
  576. );
  577. BOOLEAN
  578. BlGetPathMnemonicKey(
  579. IN PCHAR OpenPath,
  580. IN PCHAR Mnemonic,
  581. IN PULONG Key
  582. );
  583. ARC_STATUS
  584. BlGetArcDiskInformation(
  585. IN BOOLEAN XInt13Support
  586. );
  587. BOOLEAN
  588. BlReadSignature(
  589. IN PCHAR DiskName,
  590. IN BOOLEAN IsCdRom
  591. );
  592. BOOLEAN
  593. BlGetDiskSignature(
  594. IN PCHAR Name,
  595. IN BOOLEAN IsCdRom,
  596. PARC_DISK_SIGNATURE Signature
  597. );
  598. #if defined(REMOTE_BOOT)
  599. ARC_STATUS
  600. BlCheckMachineReplacement (
  601. IN PCHAR SystemDevice,
  602. IN ULONG SystemDeviceId,
  603. IN ULONGLONG NetRebootParameter,
  604. IN PUCHAR OsLoader
  605. );
  606. #endif
  607. //
  608. // Define memory allocation prototypes.
  609. //
  610. extern ULONG BlUsableBase;
  611. #if defined(_X86_)
  612. extern ULONG BlUsableLimitX86;
  613. extern ULONG BlUsableLimitAmd64;
  614. #define BlUsableLimit (*(BlAmd64UseLongMode ? &BlUsableLimitAmd64 : &BlUsableLimitX86))
  615. #else
  616. extern ULONG BlUsableLimit;
  617. #endif
  618. typedef enum _ALLOCATION_POLICY {
  619. BlAllocateLowestFit,
  620. BlAllocateBestFit,
  621. BlAllocateHighestFit
  622. } ALLOCATION_POLICY, *PALLOCATION_POLICY;
  623. extern ALLOCATION_POLICY BlMemoryAllocationPolicy;
  624. extern ALLOCATION_POLICY BlHeapAllocationPolicy;
  625. VOID
  626. BlSetAllocationPolicy (
  627. IN ALLOCATION_POLICY MemoryAllocationPolicy,
  628. IN ALLOCATION_POLICY HeapAllocationPolicy
  629. );
  630. ARC_STATUS
  631. BlMemoryInitialize (
  632. VOID
  633. );
  634. ARC_STATUS
  635. BlAllocateDataTableEntry (
  636. IN PCHAR BaseDllName,
  637. IN PCHAR FullDllName,
  638. IN PVOID ImageHeader,
  639. OUT PKLDR_DATA_TABLE_ENTRY *Entry
  640. );
  641. ARC_STATUS
  642. BlAllocateFirmwareTableEntry (
  643. IN PCHAR BaseDllName,
  644. IN PCHAR FullDllName,
  645. IN PVOID ImageHeader,
  646. IN ULONG Size,
  647. OUT PKLDR_DATA_TABLE_ENTRY *Entry
  648. );
  649. #define BlAllocateDescriptor(_MemoryType, _BasePage, _PageCount, _ActualBase) \
  650. BlAllocateAlignedDescriptor((_MemoryType), \
  651. (_BasePage), \
  652. (_PageCount), \
  653. 1, \
  654. (_ActualBase))
  655. #if defined (_X86_)
  656. #define BlpCheckMapping(_page,_npages) MempCheckMapping (_page,_npages)
  657. #define BlpFixOSMapping(_page,_npages) MempFixMapping ( _page, _npages )
  658. #else
  659. #define BlpCheckMapping(_page,_npages) ESUCCESS
  660. #define BlpFixOSMapping(_page,_npages) ESUCCESS
  661. #endif
  662. ARC_STATUS
  663. BlAllocateAlignedDescriptor (
  664. IN TYPE_OF_MEMORY MemoryType,
  665. IN ULONG BasePage,
  666. IN ULONG PageCount,
  667. IN ULONG Alignment,
  668. OUT PULONG ActualBase
  669. );
  670. ARC_STATUS
  671. BlFreeDescriptor (
  672. IN ULONG BasePage
  673. );
  674. VOID
  675. BlTruncateDescriptors (
  676. IN ULONG HighestPage
  677. );
  678. PVOID
  679. BlAllocateHeapAligned (
  680. IN ULONG Size
  681. );
  682. PVOID
  683. BlAllocateHeap (
  684. IN ULONG Size
  685. );
  686. BOOLEAN
  687. BlAmd64Setup (
  688. IN PCHAR SetupDevice
  689. );
  690. ULONG
  691. BlAmd64FieldOffset_PO_MEMORY_IMAGE(
  692. ULONG offset32
  693. );
  694. ULONG
  695. BlAmd64FieldOffset_PO_MEMORY_RANGE_ARRAY_LINK(
  696. ULONG offset32
  697. );
  698. ULONG
  699. BlAmd64FieldOffset_PO_MEMORY_RANGE_ARRAY_RANGE(
  700. ULONG offset32
  701. );
  702. ULONG
  703. BlAmd64ElementOffset_PO_MEMORY_RANGE_ARRAY_LINK(
  704. ULONG index
  705. );
  706. ULONG
  707. BlAmd64ElementOffset_PO_MEMORY_RANGE_ARRAY_RANGE(
  708. ULONG index
  709. );
  710. VOID
  711. BlCheckForAmd64Image(
  712. PPO_MEMORY_IMAGE MemImage
  713. );
  714. VOID
  715. BlStartConfigPrompt(
  716. VOID
  717. );
  718. BOOLEAN
  719. BlEndConfigPrompt(
  720. VOID
  721. );
  722. BOOLEAN
  723. BlCheckForLoadedDll (
  724. IN PCHAR DllName,
  725. OUT PKLDR_DATA_TABLE_ENTRY *FoundEntry
  726. );
  727. PMEMORY_ALLOCATION_DESCRIPTOR
  728. BlFindMemoryDescriptor(
  729. IN ULONG BasePage
  730. );
  731. ARC_STATUS
  732. BlInitResources(
  733. IN PCHAR StartCommand
  734. );
  735. PTCHAR
  736. BlFindMessage(
  737. IN ULONG Id
  738. );
  739. //
  740. // Define debug function to write on the display console.
  741. //
  742. VOID
  743. BlPrint(
  744. PTCHAR cp,
  745. ...
  746. );
  747. #if DBG
  748. #define DBGTRACE BlPrint
  749. #else
  750. #define DBGTRACE
  751. #endif
  752. ARC_STATUS
  753. BlGenerateDescriptor (
  754. IN PMEMORY_ALLOCATION_DESCRIPTOR MemoryDescriptor,
  755. IN MEMORY_TYPE MemoryType,
  756. IN ULONG BasePage,
  757. IN ULONG PageCount
  758. );
  759. VOID
  760. BlInsertDescriptor (
  761. IN PMEMORY_ALLOCATION_DESCRIPTOR NewDescriptor
  762. );
  763. #if defined (_X86_)
  764. ARC_STATUS
  765. MempCheckMapping (
  766. ULONG StartPage,
  767. ULONG NumberPages
  768. );
  769. ARC_STATUS
  770. MempFixMapping(
  771. ULONG StartPage,
  772. ULONG NumberPages
  773. );
  774. ARC_STATUS
  775. MempRemoveMapping (
  776. ULONG StartPage,
  777. ULONG NumberPages
  778. );
  779. #endif
  780. #define BlRemoveDescriptor(_md_) RemoveEntryList(&(_md_)->ListEntry)
  781. ARC_STATUS
  782. BlGenerateDeviceNames (
  783. IN PCHAR ArcDeviceName,
  784. OUT PCHAR ArcCanonicalName,
  785. OUT OPTIONAL PCHAR NtDevicePrefix
  786. );
  787. PCHAR
  788. BlGetArgumentValue (
  789. IN ULONG Argc,
  790. IN CHAR * FIRMWARE_PTR * FIRMWARE_PTR Argv,
  791. IN PCHAR ArgumentName
  792. );
  793. PCHAR
  794. BlSetArgumentValue (
  795. IN ULONG Argc,
  796. IN CHAR * FIRMWARE_PTR * FIRMWARE_PTR Argv,
  797. IN PCHAR ArgumentName,
  798. IN PCHAR NewValue
  799. );
  800. //
  801. // Defines for doing console I/O
  802. //
  803. #define ASCII_CR 0x0d
  804. #define ASCII_LF 0x0a
  805. #define ESC 0x1B
  806. #define SGR_INVERSE 7
  807. #define SGR_INTENSE 1
  808. #define SGR_NORMAL 0
  809. extern ULONG ScreenWidth;
  810. extern ULONG ScreenHeight;
  811. //
  812. // Define I/O prototypes.
  813. //
  814. VOID
  815. BlClearScreen(
  816. VOID
  817. );
  818. VOID
  819. BlClearToEndOfScreen(
  820. VOID
  821. );
  822. VOID
  823. BlClearToEndOfLine(
  824. VOID
  825. );
  826. VOID
  827. BlPositionCursor(
  828. IN ULONG Column,
  829. IN ULONG Row
  830. );
  831. VOID
  832. BlSetInverseMode(
  833. IN BOOLEAN InverseOn
  834. );
  835. VOID
  836. BlOutputLoadMessage (
  837. IN PCHAR DeviceName,
  838. IN PCHAR FileName,
  839. IN PTCHAR FileDescription OPTIONAL
  840. );
  841. ULONG
  842. BlCountLines(
  843. IN PTCHAR Lines
  844. );
  845. //
  846. // advanced boot menu prototypes
  847. //
  848. LONG
  849. BlDoAdvancedBoot(
  850. IN ULONG MenuTitleId,
  851. IN LONG DefaultBootOption,
  852. IN BOOLEAN AutoAdvancedBoot,
  853. IN UCHAR Timeout
  854. );
  855. PTSTR
  856. BlGetAdvancedBootDisplayString(
  857. LONG BootOption
  858. );
  859. PSTR
  860. BlGetAdvancedBootLoadOptions(
  861. LONG BootOption
  862. );
  863. VOID
  864. BlDoAdvancedBootLoadProcessing(
  865. LONG BootOption
  866. );
  867. ULONG
  868. BlGetAdvancedBootOption(
  869. VOID
  870. );
  871. //
  872. // Define file structure recognition prototypes.
  873. //
  874. PBL_DEVICE_ENTRY_TABLE
  875. IsCdfsFileStructure (
  876. IN ULONG DeviceId,
  877. IN PVOID StructureContext
  878. );
  879. #ifdef DBLSPACE_LEGAL
  880. PBL_DEVICE_ENTRY_TABLE
  881. IsDblsFileStructure (
  882. IN ULONG DeviceId,
  883. IN PVOID StructureContext
  884. );
  885. #endif
  886. PBL_DEVICE_ENTRY_TABLE
  887. IsFatFileStructure (
  888. IN ULONG DeviceId,
  889. IN PVOID StructureContext
  890. );
  891. PBL_DEVICE_ENTRY_TABLE
  892. IsHpfsFileStructure (
  893. IN ULONG DeviceId,
  894. IN PVOID StructureContext
  895. );
  896. PBL_DEVICE_ENTRY_TABLE
  897. IsNtfsFileStructure (
  898. IN ULONG DeviceId,
  899. IN PVOID StructureContext
  900. );
  901. #if defined(ELTORITO)
  902. PBL_DEVICE_ENTRY_TABLE
  903. IsEtfsFileStructure (
  904. IN ULONG DeviceId,
  905. IN PVOID StructureContext
  906. );
  907. #endif
  908. PBL_DEVICE_ENTRY_TABLE
  909. IsNetFileStructure (
  910. IN ULONG DeviceId,
  911. IN PVOID StructureContext
  912. );
  913. //
  914. // Define registry prototypes
  915. //
  916. ARC_STATUS
  917. BlLoadSystemHive(
  918. IN ULONG DeviceId,
  919. IN PCHAR DeviceName,
  920. IN PCHAR DirectoryPath,
  921. IN PCHAR HiveName
  922. );
  923. ARC_STATUS
  924. BlLoadSystemHiveLog(
  925. IN ULONG DeviceId,
  926. IN PCHAR DeviceName,
  927. IN PCHAR DirectoryPath,
  928. IN PCHAR HiveName,
  929. OUT PULONG_PTR LogData
  930. );
  931. ARC_STATUS
  932. BlLoadAndScanSystemHive(
  933. IN ULONG DeviceId,
  934. IN PCHAR DeviceName,
  935. IN PCHAR DirectoryPath,
  936. IN PWSTR BootFileSystem,
  937. IN OUT BOOLEAN *LastKnownGoodBoot,
  938. OUT BOOLEAN *ServerHive,
  939. OUT PCHAR BadFileName
  940. );
  941. ARC_STATUS
  942. BlLoadAndInitSystemHive(
  943. IN ULONG DeviceId,
  944. IN PCHAR DeviceName,
  945. IN PCHAR DirectoryPath,
  946. IN PCHAR HiveName,
  947. IN BOOLEAN IsAlternate,
  948. OUT PBOOLEAN RestartSetup,
  949. OUT PBOOLEAN LogPresent
  950. );
  951. ARC_STATUS
  952. BlLoadBootDrivers(
  953. IN PPATH_SET DefaultPathSet,
  954. IN PLIST_ENTRY BootDriverListHead,
  955. OUT PCHAR BadFileName
  956. );
  957. PTCHAR
  958. BlScanRegistry(
  959. IN PWSTR BootFileSystemPath,
  960. IN OUT BOOLEAN *LastKnownGoodBoot,
  961. OUT PLIST_ENTRY BootDriverListHead,
  962. OUT PUNICODE_STRING AnsiCodepage,
  963. OUT PUNICODE_STRING OemCodepage,
  964. OUT PUNICODE_STRING LanguageTable,
  965. OUT PUNICODE_STRING OemHalFont,
  966. #ifdef _WANT_MACHINE_IDENTIFICATION
  967. OUT PUNICODE_STRING Biosinfo,
  968. #endif
  969. OUT PSETUP_LOADER_BLOCK SetupLoaderBlock,
  970. OUT BOOLEAN *ServerHive
  971. );
  972. ARC_STATUS
  973. BlAddToBootDriverList(
  974. IN PLIST_ENTRY BootDriverListHead,
  975. IN PWSTR DriverName,
  976. IN PWSTR Name,
  977. IN PWSTR Group,
  978. IN ULONG Tag,
  979. IN ULONG ErrorControl,
  980. IN BOOLEAN InsertAtHead
  981. );
  982. //
  983. // Define hibernation prototypes
  984. //
  985. ULONG
  986. BlHiberRestore (
  987. IN ULONG DriveId,
  988. OUT OPTIONAL PCHAR *BadLinkName
  989. );
  990. VOID
  991. HbAllocatePtes (
  992. IN ULONG NumberPages,
  993. OUT PVOID *PteAddress,
  994. OUT PVOID *MappedAddress
  995. );
  996. VOID
  997. HbInitRemap (
  998. PPFN_NUMBER FreeList
  999. );
  1000. PVOID
  1001. HbMapPte (
  1002. IN ULONG PteToMap,
  1003. IN PFN_NUMBER Page
  1004. );
  1005. PVOID
  1006. HbNextSharedPage (
  1007. IN ULONG PteToMap,
  1008. IN PFN_NUMBER RealPage
  1009. );
  1010. VOID
  1011. HbSetPte (
  1012. IN PVOID Va,
  1013. IN PHARDWARE_PTE Pte,
  1014. IN ULONG Index,
  1015. IN ULONG PageNumber
  1016. );
  1017. ULONG
  1018. HbPageDisposition (
  1019. IN PFN_NUMBER Page
  1020. );
  1021. #define HbPageNotInUse 0
  1022. #define HbPageInUseByLoader 1
  1023. #define HbPageInvalid 2
  1024. VOID
  1025. HiberSetupForWakeDispatch (
  1026. VOID
  1027. );
  1028. typedef
  1029. VOID
  1030. (*PHIBER_WAKE_DISPATCH)(
  1031. VOID
  1032. );
  1033. //
  1034. // PTEs reserved for hiberfile (one set used while in
  1035. // the loader, and another set provided in the kernels
  1036. // memory image)
  1037. //
  1038. #define PTE_SOURCE 0 // Attention! These defines and
  1039. #define PTE_DEST 1 // equates in ntos\boot\lib\i386\wakea.asm
  1040. #define PTE_MAP_PAGE 2 // must be the same !!!
  1041. #define PTE_REMAP_PAGE 3
  1042. #define PTE_HIBER_CONTEXT 4
  1043. #define PTE_TRANSFER_PDE 5
  1044. #define PTE_WAKE_PTE 6
  1045. #define PTE_DISPATCHER_START 7
  1046. #define PTE_DISPATCHER_END 8
  1047. #define PTE_XPRESS_DEST_FIRST 9
  1048. #define PTE_XPRESS_DEST_LAST (PTE_XPRESS_DEST_FIRST + XPRESS_MAX_PAGES)
  1049. // Attention: should be the same as POP_MAX_MDL_SIZE in ntos\po\pop.h !!!
  1050. #define HIBER_PTES (16 + XPRESS_MAX_PAGES)
  1051. extern PUCHAR HiberBuffer;
  1052. extern PVOID HiberPtes;
  1053. extern PUCHAR HiberVa;
  1054. extern PVOID HiberIdentityVa;
  1055. extern ULONG64 HiberIdentityVaAmd64;
  1056. extern ULONG HiberPageFrames[HIBER_PTES];
  1057. //
  1058. // Define routines for secrets.
  1059. //
  1060. #define SECPKG_CRED_OWF_PASSWORD 0x00000010
  1061. #if defined(REMOTE_BOOT)
  1062. ARC_STATUS
  1063. BlOpenRawDisk(
  1064. PULONG FileId
  1065. );
  1066. ARC_STATUS
  1067. BlCloseRawDisk(
  1068. ULONG FileId
  1069. );
  1070. ARC_STATUS
  1071. BlCheckForFreeSectors (
  1072. ULONG FileId
  1073. );
  1074. ARC_STATUS
  1075. BlReadSecret(
  1076. ULONG FileId,
  1077. PRI_SECRET Secret
  1078. );
  1079. ARC_STATUS
  1080. BlWriteSecret(
  1081. ULONG FileId,
  1082. PRI_SECRET Secret
  1083. );
  1084. #endif // defined(REMOTE_BOOT)
  1085. VOID
  1086. BlInitializeSecret(
  1087. IN PUCHAR Domain,
  1088. IN PUCHAR User,
  1089. IN PUCHAR LmOwfPassword1,
  1090. IN PUCHAR NtOwfPassword1,
  1091. #if defined(REMOTE_BOOT)
  1092. IN PUCHAR LmOwfPassword2 OPTIONAL,
  1093. IN PUCHAR NtOwfPassword2 OPTIONAL,
  1094. #endif // defined(REMOTE_BOOT)
  1095. IN PUCHAR Sid,
  1096. IN OUT PRI_SECRET Secret
  1097. );
  1098. #if defined(REMOTE_BOOT_SECURITY)
  1099. VOID
  1100. BlParseSecret(
  1101. IN OUT PUCHAR Domain,
  1102. IN OUT PUCHAR User,
  1103. IN OUT PUCHAR LmOwfPassword1,
  1104. IN OUT PUCHAR NtOwfPassword1,
  1105. IN OUT PUCHAR LmOwfPassword2,
  1106. IN OUT PUCHAR NtOwfPassword2,
  1107. IN OUT PUCHAR Sid,
  1108. IN PRI_SECRET Secret
  1109. );
  1110. #endif // defined(REMOTE_BOOT_SECURITY)
  1111. VOID
  1112. BlOwfPassword(
  1113. IN PUCHAR Password,
  1114. IN PUNICODE_STRING UnicodePassword,
  1115. IN OUT PUCHAR LmOwfPassword,
  1116. IN OUT PUCHAR NtOwfPassword
  1117. );
  1118. //
  1119. // Define external references.
  1120. //
  1121. extern ULONG BlConsoleOutDeviceId;
  1122. extern ULONG BlConsoleInDeviceId;
  1123. extern ULONG BlDcacheFillSize;
  1124. extern PLOADER_PARAMETER_BLOCK BlLoaderBlock;
  1125. extern ULONG DbcsLangId;
  1126. extern BOOLEAN BlRebootSystem;
  1127. extern ULONG BlVirtualBias;
  1128. extern BOOLEAN BlBootingFromNet;
  1129. extern BOOLEAN BlUsePae;
  1130. extern BOOLEAN BlOldKernel;
  1131. extern BOOLEAN BlKernelChecked;
  1132. extern BOOLEAN BlRestoring;
  1133. #if defined(_ALPHA_) || defined(_IA64_)
  1134. extern ULONG HiberNoMappings;
  1135. extern ULONG HiberFirstRemap;
  1136. extern ULONG HiberLastRemap;
  1137. extern BOOLEAN HiberOutOfRemap;
  1138. extern BOOLEAN HiberIoError;
  1139. #endif
  1140. //
  1141. // Special linker-defined symbols. osloader_EXPORTS is the RVA of the
  1142. // export table in the osloader.exe image.
  1143. // header is the base address of the osloader image.
  1144. //
  1145. // This allows the OsLoader to export entry points for SCSI miniport drivers.
  1146. //
  1147. #if defined(_X86_)
  1148. extern ULONG OsLoaderBase;
  1149. extern ULONG OsLoaderExports;
  1150. #endif
  1151. #if defined(_IA64_)
  1152. extern LONG_PTR OsLoaderBase;
  1153. extern LONG_PTR OsLoaderExports;
  1154. #endif
  1155. //
  1156. // Routine to get graphics characters.
  1157. //
  1158. typedef enum {
  1159. GraphicsCharDoubleRightDoubleDown = 0,
  1160. GraphicsCharDoubleLeftDoubleDown,
  1161. GraphicsCharDoubleRightDoubleUp,
  1162. GraphicsCharDoubleLeftDoubleUp,
  1163. GraphicsCharDoubleVertical,
  1164. GraphicsCharDoubleHorizontal,
  1165. #ifdef EFI
  1166. GraphicsCharFullBlock,
  1167. GraphicsCharLightShade,
  1168. #endif
  1169. GraphicsCharMax
  1170. } GraphicsChar;
  1171. _TUCHAR
  1172. GetGraphicsChar(
  1173. IN GraphicsChar WhichOne
  1174. );
  1175. _TUCHAR
  1176. TextGetGraphicsCharacter(
  1177. IN GraphicsChar WhichOne
  1178. );
  1179. //
  1180. // Control sequence introducer.
  1181. //
  1182. // On x86 machines the loaders support dbcs and so using
  1183. // 0x9b for output is no good (that value is a dbcs lead byte
  1184. // in several codepages). Escape-leftbracket is a synonym for CSI
  1185. // in the emulated ARC console on x86 (and on many ARC machines too
  1186. // but since we can't be sure all the machines out there support
  1187. // this we use the old-style csi on non-x86).
  1188. //
  1189. // We ignore this issue for characters read from the ARC console
  1190. // since we don't ask for any text to be typed in, just arrow keys,
  1191. // escape, F#, enter, etc.
  1192. //
  1193. #define ASCI_CSI_IN 0x9b
  1194. #if defined(_X86_) || defined(_IA64_)
  1195. #define ASCI_CSI_OUT TEXT("\033[") // escape-leftbracket
  1196. #else
  1197. #define ASCI_CSI_OUT TEXT("\233") // 0x9b
  1198. #endif
  1199. //
  1200. // Define OS/2 executable resource information structure.
  1201. //
  1202. #define FONT_DIRECTORY 0x8007
  1203. #define FONT_RESOURCE 0x8008
  1204. typedef struct _RESOURCE_TYPE_INFORMATION {
  1205. USHORT Ident;
  1206. USHORT Number;
  1207. LONG Proc;
  1208. } RESOURCE_TYPE_INFORMATION, *PRESOURCE_TYPE_INFORMATION;
  1209. //
  1210. // Define OS/2 executable resource name information structure.
  1211. //
  1212. typedef struct _RESOURCE_NAME_INFORMATION {
  1213. USHORT Offset;
  1214. USHORT Length;
  1215. USHORT Flags;
  1216. USHORT Ident;
  1217. USHORT Handle;
  1218. USHORT Usage;
  1219. } RESOURCE_NAME_INFORMATION, *PRESOURCE_NAME_INFORMATION;
  1220. //
  1221. // Support for reading compressed files directly (single-file MS-ZIP cabinets)
  1222. //
  1223. VOID
  1224. DecompEnableDecompression(
  1225. IN BOOLEAN Enable
  1226. );
  1227. ULONG
  1228. DecompPrepareToReadCompressedFile(
  1229. IN LPCSTR Filename,
  1230. IN ULONG FileId
  1231. );
  1232. BOOLEAN
  1233. DecompGenerateCompressedName(
  1234. IN LPCSTR Filename,
  1235. OUT LPSTR CompressedName
  1236. );
  1237. //
  1238. // Define debug logging macros and functions.
  1239. //
  1240. #if !DBG && !BLLOGENABLED
  1241. #define BlLogInitialize(_x_)
  1242. #define BlLogTerminate()
  1243. #define BlLog(_x_)
  1244. #define BlLogArcDescriptors(_x_)
  1245. #define BlLogMemoryDescriptors(_x_)
  1246. #define BlLogWaitForKeystroke()
  1247. #else
  1248. VOID
  1249. BlLogInitialize (
  1250. IN ULONG LogfileDeviceId
  1251. );
  1252. VOID
  1253. BlLogTerminate (
  1254. VOID
  1255. );
  1256. #define BlLog(_x_) BlLogPrint _x_
  1257. #define LOG_DISPLAY 0x0001
  1258. #define LOG_LOGFILE 0x0002
  1259. #define LOG_DEBUGGER 0x0004
  1260. #define LOG_WAIT 0x8000
  1261. #define LOG_ALL (LOG_DISPLAY | LOG_LOGFILE | LOG_DEBUGGER)
  1262. #define LOG_ALL_W (LOG_ALL | LOG_WAIT)
  1263. VOID
  1264. BlLogPrint (
  1265. ULONG Targets,
  1266. PCHAR Format,
  1267. ...
  1268. );
  1269. VOID
  1270. BlLogArcDescriptors (
  1271. ULONG Targets
  1272. );
  1273. VOID
  1274. BlLogMemoryDescriptors (
  1275. ULONG Targets
  1276. );
  1277. VOID
  1278. BlLogWaitForKeystroke (
  1279. VOID
  1280. );
  1281. #endif // DBG
  1282. VOID
  1283. BlWaitForReboot (
  1284. VOID
  1285. );
  1286. //
  1287. // Machine identification related functions.
  1288. //
  1289. #ifdef _WANT_MACHINE_IDENTIFICATION
  1290. #define BlLoadBiosinfoInf(id,n,d,f,i,is,bn) BlLoadFileImage(id,n,d,f,LoaderRegistryData,i,is,bn)
  1291. #endif
  1292. #define BlLoadDrvDB(id,n,d,f,i,is,bn) BlLoadFileImage(id,n,d,f,LoaderRegistryData,i,is,bn)
  1293. ARC_STATUS
  1294. BlLoadFileImage(
  1295. IN ULONG DeviceId,
  1296. IN PCHAR DeviceName,
  1297. IN PCHAR Directory,
  1298. IN PUNICODE_STRING FileName,
  1299. IN TYPE_OF_MEMORY MemoryType,
  1300. OUT PVOID *Image,
  1301. OUT PULONG ImageSize,
  1302. OUT PCHAR BadFileName
  1303. );
  1304. #if defined(_X86_)
  1305. BOOLEAN
  1306. BlFindDiskSignature(
  1307. IN PCHAR DiskName,
  1308. IN PARC_DISK_SIGNATURE Signature
  1309. );
  1310. VOID
  1311. AETerminateIo(
  1312. VOID
  1313. );
  1314. BOOLEAN
  1315. BlDetectLegacyFreeBios(
  1316. VOID
  1317. );
  1318. #endif
  1319. //
  1320. //
  1321. // N.B. We can speed up the boot time, by not
  1322. // querying the device for all the possible file systems
  1323. // for every open call. This saves approximately 30 secs
  1324. // on CD-ROM / DVD-ROM boot time. To disable this feature
  1325. // just undef CACHE_DEVINFO below
  1326. //
  1327. //
  1328. #define CACHE_DEVINFO 1
  1329. #ifdef CACHE_DEVINFO
  1330. //
  1331. // NB: make sure that the arc close now invalidates the
  1332. // device to filesystem cache entry
  1333. //
  1334. #ifdef ArcClose
  1335. ARC_STATUS
  1336. ArcCacheClose(
  1337. IN ULONG DeviceId
  1338. );
  1339. //
  1340. // Redefine the arc close
  1341. //
  1342. #undef ArcClose
  1343. #define ArcClose(_x) ArcCacheClose(_x)
  1344. //
  1345. // File system cache clearing hook
  1346. //
  1347. typedef
  1348. VOID
  1349. (*PARC_DEVICE_CLOSE_NOTIFICATION) (
  1350. IN ULONG DeviceId
  1351. );
  1352. //
  1353. // Maximum entities which can register for device close
  1354. // notification
  1355. //
  1356. #define MAX_DEVICE_CLOSE_NOTIFICATION_SIZE 5
  1357. extern PARC_DEVICE_CLOSE_NOTIFICATION
  1358. DeviceCloseNotify[MAX_DEVICE_CLOSE_NOTIFICATION_SIZE];
  1359. ARC_STATUS
  1360. ArcRegisterForDeviceClose(
  1361. PARC_DEVICE_CLOSE_NOTIFICATION FlushRoutine
  1362. );
  1363. ARC_STATUS
  1364. ArcDeRegisterForDeviceClose(
  1365. PARC_DEVICE_CLOSE_NOTIFICATION FlushRoutine
  1366. );
  1367. #endif //ArcClose
  1368. #endif // CACHE_DEVINFO
  1369. //
  1370. // progress bar functions
  1371. // (in blload.c)
  1372. //
  1373. VOID
  1374. BlUpdateBootStatus(
  1375. VOID
  1376. );
  1377. VOID
  1378. BlRedrawProgressBar(
  1379. VOID
  1380. );
  1381. VOID
  1382. BlUpdateProgressBar(
  1383. ULONG fPercentage
  1384. );
  1385. VOID
  1386. BlOutputStartupMsg(
  1387. ULONG uMsgID
  1388. );
  1389. VOID
  1390. BlOutputStartupMsgStr(
  1391. PCTSTR MsgStr
  1392. );
  1393. VOID
  1394. BlOutputTrailerMsg(
  1395. ULONG uMsgID
  1396. );
  1397. VOID
  1398. BlOutputTrailerMsgStr(
  1399. PCTSTR MsgStr
  1400. );
  1401. VOID
  1402. BlSetProgBarCharacteristics(
  1403. IN ULONG FrontCharMsgID,
  1404. IN ULONG BackCharMsgID
  1405. );
  1406. //
  1407. // The following routines are used by the loader to translate signature-based
  1408. // arcnames to scsi-based names.
  1409. //
  1410. PCONFIGURATION_COMPONENT
  1411. ScsiGetFirstConfiguredTargetComponent(
  1412. IN ULONG ScsiNumber
  1413. );
  1414. PCONFIGURATION_COMPONENT
  1415. ScsiGetNextConfiguredTargetComponent(
  1416. IN PCONFIGURATION_COMPONENT TargetComponent
  1417. );
  1418. PCONFIGURATION_COMPONENT
  1419. ScsiGetFirstConfiguredLunComponent(
  1420. IN PCONFIGURATION_COMPONENT TargetComponent
  1421. );
  1422. PCONFIGURATION_COMPONENT
  1423. ScsiGetNextConfiguredLunComponent(
  1424. IN PCONFIGURATION_COMPONENT LunComponent
  1425. );
  1426. BOOLEAN
  1427. ScsiGetDevicePath(
  1428. IN ULONG ScsiNumber,
  1429. IN PCONFIGURATION_COMPONENT TargetComponent,
  1430. IN PCONFIGURATION_COMPONENT LunComponent,
  1431. OUT PCHAR DevicePath
  1432. );
  1433. //
  1434. // Boot Status Data support functions.
  1435. //
  1436. ULONG
  1437. BlGetLastBootStatus(
  1438. IN PVOID DataHandle,
  1439. OUT BSD_LAST_BOOT_STATUS *LastBootStatus
  1440. );
  1441. VOID
  1442. BlAutoAdvancedBoot(
  1443. IN OUT PCHAR *LoadOptions,
  1444. IN BSD_LAST_BOOT_STATUS LastBootStatus,
  1445. IN ULONG AdvancedMode
  1446. );
  1447. VOID
  1448. BlWriteBootStatusFlags(
  1449. IN ULONG SystemPartitionId,
  1450. IN PUCHAR SystemDirectory,
  1451. IN BOOLEAN LastBootGood,
  1452. IN BOOLEAN LastBootShutdown
  1453. );
  1454. ARC_STATUS
  1455. BlLockBootStatusData(
  1456. IN ULONG SystemPartitionId,
  1457. IN PCHAR SystemPartition,
  1458. IN PCHAR SystemDirectory,
  1459. OUT PVOID *DataHandle
  1460. );
  1461. ARC_STATUS
  1462. BlGetSetBootStatusData(
  1463. IN PVOID DataHandle,
  1464. IN BOOLEAN Get,
  1465. IN RTL_BSD_ITEM_TYPE DataItem,
  1466. IN PVOID DataBuffer,
  1467. IN ULONG DataBufferLength,
  1468. OUT PULONG BytesReturned OPTIONAL
  1469. );
  1470. VOID
  1471. BlUnlockBootStatusData(
  1472. IN PVOID DataHandle
  1473. );
  1474. #if defined(_IA64_) || defined(_X86_)
  1475. #define EFI_PARTITION_SUPPORT 1
  1476. #endif
  1477. #if defined(_IA64_)
  1478. extern BOOLEAN BlUsePrivateDescriptor;
  1479. #endif
  1480. //
  1481. // Boot Flags. These are passed from the startup module (startup.com,
  1482. // startrom.com or any of the other flavors) to NTLDR. NTDLR will use
  1483. // this flag to control different boot options, such as, whether
  1484. // to reboot on an NTDLR failure.
  1485. //
  1486. // upon any startup / ntldr failures the machine will reboot
  1487. // instead of waiting for a key press
  1488. #define BOOTFLAG_REBOOT_ON_FAILURE 0x000000001
  1489. #endif // _BLDR_