Windows NT 4.0 source code leak
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.

668 lines
12 KiB

4 years ago
  1. /*++
  2. Copyright (c) 1991 Microsoft Corporation
  3. Module Name:
  4. fwp.h
  5. Abstract:
  6. This module contains extensions to the firmware.h header file.
  7. Author:
  8. David M. Robinson (davidro) 29-Aug-1991
  9. Revision History:
  10. --*/
  11. #ifndef _FWP_
  12. #define _FWP_
  13. #include "bldr.h"
  14. #include "firmware.h"
  15. #include "kbdmouse.h"
  16. #ifndef DUO
  17. #include "jazzdef.h"
  18. #include "jazzprom.h"
  19. #ifndef _PPC_
  20. #include "jazzdma.h"
  21. #else
  22. #include "ppcdef.h"
  23. #endif
  24. #else
  25. #include "duodef.h"
  26. #include "duoprom.h"
  27. #include "duodma.h"
  28. #endif
  29. //
  30. // TEMPTEMP Temporary defines.
  31. //
  32. #define SECONDARY_CACHE_SIZE (1 << 20)
  33. #define SECONDARY_CACHE_INVALID 0x0
  34. #define SECONDARY_CACHE_DIRTY_EXCLUSIVE 0x5
  35. #define TAGLO_SSTATE 0xA
  36. //
  37. // Current version and revision numbers.
  38. //
  39. #define ARC_VERSION 1
  40. #define ARC_REVISION 2
  41. //
  42. // Define the firmware vendor specific entry point numbers.
  43. //
  44. typedef enum _VENDOR_ENTRY {
  45. AllocatePoolRoutine,
  46. StallExecutionRoutine,
  47. PrintRoutine,
  48. SetDisplayAttributesRoutine,
  49. OutputCharacterRoutine,
  50. ScrollVideoRoutine,
  51. BootRestartRoutine,
  52. MaximumVendorRoutine
  53. } VENDOR_ENTRY;
  54. //
  55. // Define vendor specific routine types.
  56. //
  57. typedef
  58. PVOID
  59. (*PVEN_ALLOCATE_POOL_ROUTINE) (
  60. IN ULONG NumberOfBytes
  61. );
  62. typedef
  63. VOID
  64. (*PVEN_STALL_EXECUTION_ROUTINE) (
  65. IN ULONG Microseconds
  66. );
  67. typedef
  68. ULONG
  69. (*PVEN_PRINT_ROUTINE) (
  70. IN PCHAR Format,
  71. ...
  72. );
  73. typedef
  74. VOID
  75. (*PVEN_SET_DISPLAY_ATTRIBUTES_ROUTINE) (
  76. IN ULONG ForegroundColor,
  77. IN ULONG BackgroundColor,
  78. IN BOOLEAN HighIntensity,
  79. IN BOOLEAN Underscored,
  80. IN BOOLEAN ReverseVideo,
  81. IN ULONG CharacterWidth,
  82. IN ULONG CharacterHeight
  83. );
  84. typedef
  85. VOID
  86. (*PVEN_OUTPUT_CHARACTER_ROUTINE) (
  87. IN PVOID Character,
  88. IN ULONG Row,
  89. IN ULONG Column
  90. );
  91. typedef
  92. VOID
  93. (*PVEN_SCROLL_VIDEO_ROUTINE) (
  94. VOID
  95. );
  96. typedef
  97. VOID
  98. (*PVEN_BOOT_RESTART_ROUTINE) (
  99. IN PRESTART_BLOCK RestartBlock
  100. );
  101. //
  102. // Define vendor specific prototypes.
  103. //
  104. PVOID
  105. FwAllocatePool (
  106. IN ULONG NumberOfBytes
  107. );
  108. VOID
  109. FwStallExecution (
  110. IN ULONG Microseconds
  111. );
  112. ULONG
  113. FwPrint (
  114. IN PCHAR Format,
  115. ...
  116. );
  117. VOID
  118. FwSetDisplayAttributes (
  119. IN ULONG ForegroundColor,
  120. IN ULONG BackgroundColor,
  121. IN BOOLEAN HighIntensity,
  122. IN BOOLEAN Underscored,
  123. IN BOOLEAN ReverseVideo,
  124. IN ULONG CharacterWidth,
  125. IN ULONG CharacterHeight
  126. );
  127. VOID
  128. FwOutputCharacter (
  129. IN PVOID Character,
  130. IN ULONG Row,
  131. IN ULONG Column
  132. );
  133. VOID
  134. FwScrollVideo (
  135. VOID
  136. );
  137. //
  138. // Define vendor specific functions.
  139. //
  140. #define VenRestartBlock(RestartBlock) \
  141. ((PVEN_BOOT_RESTART_ROUTINE)(SYSTEM_BLOCK->VendorVector[BootRestartRoutine])) \
  142. ((RestartBlock))
  143. #define VenAllocatePool(NumberOfBytes) \
  144. ((PVEN_ALLOCATE_MEMORY_ROUTINE)(SYSTEM_BLOCK->VendorVector[AllocatePoolRoutine])) \
  145. ((NumberOfBytes))
  146. #define VenStallExecution(Microseconds) \
  147. ((PVEN_STALL_EXECUTION_ROUTINE)(SYSTEM_BLOCK->VendorVector[StallExecutionRoutine])) \
  148. ((Microseconds))
  149. #define VenPrint(x) \
  150. ((PVEN_PRINT_ROUTINE)(SYSTEM_BLOCK->VendorVector[PrintRoutine])) \
  151. ((x))
  152. #define VenPrint1(x,y) \
  153. ((PVEN_PRINT_ROUTINE)(SYSTEM_BLOCK->VendorVector[PrintRoutine])) \
  154. ((x), (y))
  155. #define VenPrint2(x,y,z) \
  156. ((PVEN_PRINT_ROUTINE)(SYSTEM_BLOCK->VendorVector[PrintRoutine])) \
  157. ((x), (y), (z))
  158. #define VenSetDisplayAttributes(ForegroundColor, BackgroundColor, HighIntensity, Underscored, ReverseVideo, CharacterWidth, CharacterHeight) \
  159. ((PVEN_SET_DISPLAY_ATTRIBUTES_ROUTINE)(SYSTEM_BLOCK->VendorVector[SetDisplayAttributesRoutine])) \
  160. ((ForegroundColor), (BackgroundColor), (HighIntensity), \
  161. (Underscored), (ReverseVideo), (CharacterWidth), (CharacterHeight))
  162. #define VenOutputCharacter(Character, Row, Column) \
  163. ((PVEN_OUTPUT_CHARACTER_ROUTINE)(SYSTEM_BLOCK->VendorVector[OutputCharacterRoutine])) \
  164. ((Character), (Row), (Column))
  165. #define VenScrollVideo() \
  166. ((PVEN_SCROLL_VIDEO_ROUTINE)(SYSTEM_BLOCK->VendorVector[ScrollVideoRoutine])) ()
  167. //
  168. // Define the Lookup table. At initialization, the driver must fill this table
  169. // with the device pathnames it can handle.
  170. //
  171. typedef struct _DRIVER_LOOKUP_ENTRY {
  172. PCHAR DevicePath;
  173. PBL_DEVICE_ENTRY_TABLE DispatchTable;
  174. } DRIVER_LOOKUP_ENTRY, *PDRIVER_LOOKUP_ENTRY;
  175. #define SIZE_OF_LOOKUP_TABLE BL_FILE_TABLE_SIZE
  176. extern DRIVER_LOOKUP_ENTRY DeviceLookupTable[SIZE_OF_LOOKUP_TABLE];
  177. //
  178. // Define the Device Pathname. This table is indexed with the FileId.
  179. // FwOpen tries to match the OpenPath with the entries in this table, and
  180. // if it finds a match it increments the reference counter. If it doesn't
  181. // find a match it tries to match an entry in the DRIVER_LOOKUP_TABLE
  182. // and then calls the Open routine of that driver.
  183. //
  184. #define SIZE_OF_ARC_DEVICENAME 64
  185. typedef struct _OPENED_PATHNAME_ENTRY {
  186. ULONG ReferenceCounter;
  187. CHAR DeviceName[SIZE_OF_ARC_DEVICENAME];
  188. } OPENED_PATHNAME_ENTRY, *POPENED_PATHNAME_ENTRY;
  189. #define SIZE_OF_OPENED_PATHNAME_TABLE BL_FILE_TABLE_SIZE
  190. extern OPENED_PATHNAME_ENTRY OpenedPathTable[SIZE_OF_OPENED_PATHNAME_TABLE];
  191. //
  192. // Driver initialization routines.
  193. //
  194. VOID
  195. FwInitializeMemory(
  196. IN VOID
  197. );
  198. VOID
  199. FwResetMemory(
  200. IN VOID
  201. );
  202. VOID
  203. DisplayInitialize(
  204. IN OUT PDRIVER_LOOKUP_ENTRY LookupTableEntry,
  205. IN ULONG Entries
  206. );
  207. VOID
  208. KeyboardInitialize(
  209. IN OUT PDRIVER_LOOKUP_ENTRY LookupTableEntry,
  210. IN ULONG Entries
  211. );
  212. VOID
  213. SerialInitialize(
  214. IN OUT PDRIVER_LOOKUP_ENTRY LookupTableEntry,
  215. IN ULONG Entries
  216. );
  217. VOID
  218. HardDiskInitialize(
  219. IN OUT PDRIVER_LOOKUP_ENTRY LookupTable,
  220. IN ULONG Entries
  221. );
  222. VOID
  223. FloppyInitialize(
  224. IN OUT PDRIVER_LOOKUP_ENTRY LookupTableEntry,
  225. IN ULONG Entries
  226. );
  227. //
  228. // Define the private configuration packet structure, which contains a
  229. // configuration component as well as pointers to the component's parent,
  230. // peer, child, and configuration data.
  231. //
  232. typedef struct _CONFIGURATION_PACKET {
  233. CONFIGURATION_COMPONENT Component;
  234. struct _CONFIGURATION_PACKET *Parent;
  235. struct _CONFIGURATION_PACKET *Peer;
  236. struct _CONFIGURATION_PACKET *Child;
  237. PVOID ConfigurationData;
  238. } CONFIGURATION_PACKET, *PCONFIGURATION_PACKET;
  239. //
  240. // The compressed configuration packet structure used to store configuration
  241. // data in NVRAM.
  242. //
  243. typedef struct _COMPRESSED_CONFIGURATION_PACKET {
  244. UCHAR Parent;
  245. UCHAR Class;
  246. UCHAR Type;
  247. UCHAR Flags;
  248. ULONG Key;
  249. UCHAR Version;
  250. UCHAR Revision;
  251. USHORT ConfigurationDataLength;
  252. USHORT Identifier;
  253. USHORT ConfigurationData;
  254. } COMPRESSED_CONFIGURATION_PACKET, *PCOMPRESSED_CONFIGURATION_PACKET;
  255. //
  256. // Defines for Identifier index.
  257. //
  258. #define NO_CONFIGURATION_IDENTIFIER 0xFFFF
  259. //
  260. // Defines for the volatile and non-volatile configuration tables.
  261. //
  262. #define NUMBER_OF_ENTRIES 40
  263. #define LENGTH_OF_IDENTIFIER (1024 - (40*16) - 8)
  264. #define LENGTH_OF_DATA 2048
  265. #define LENGTH_OF_ENVIRONMENT 1024
  266. #define LENGTH_OF_EISA_DATA 2044
  267. #define MAXIMUM_ENVIRONMENT_VALUE 256
  268. //
  269. // The volatile configuration table structure.
  270. //
  271. typedef struct _CONFIGURATION {
  272. CONFIGURATION_PACKET Packet[NUMBER_OF_ENTRIES];
  273. UCHAR Identifier[LENGTH_OF_IDENTIFIER];
  274. UCHAR Data[LENGTH_OF_DATA];
  275. UCHAR EisaData[LENGTH_OF_EISA_DATA];
  276. } CONFIGURATION, *PCONFIGURATION;
  277. //
  278. // The non-volatile configuration table structure.
  279. //
  280. typedef struct _NV_CONFIGURATION {
  281. //
  282. // First Page
  283. //
  284. COMPRESSED_CONFIGURATION_PACKET Packet[NUMBER_OF_ENTRIES];
  285. UCHAR Identifier[LENGTH_OF_IDENTIFIER];
  286. UCHAR Data[LENGTH_OF_DATA];
  287. UCHAR Checksum1[4];
  288. UCHAR Environment[LENGTH_OF_ENVIRONMENT];
  289. UCHAR Checksum2[4];
  290. //
  291. // Second Page
  292. //
  293. UCHAR EisaData[LENGTH_OF_EISA_DATA];
  294. UCHAR Checksum3[4];
  295. } NV_CONFIGURATION, *PNV_CONFIGURATION;
  296. //
  297. // Define identifier index, data index, pointer to configuration table.
  298. //
  299. extern ULONG IdentifierIndex;
  300. extern ULONG DataIndex;
  301. extern ULONG EisaDataIndex;
  302. extern PCONFIGURATION Configuration;
  303. //
  304. // Non-volatile ram layout.
  305. //
  306. #define NVRAM_CONFIGURATION NVRAM_VIRTUAL_BASE
  307. #define NVRAM_SYSTEM_ID (NVRAM_VIRTUAL_BASE + 0x00002000)
  308. //
  309. // Memory size. The MctadrRev2 is used to interpret the memory size value
  310. // in the configuration register.
  311. //
  312. extern ULONG MemorySize;
  313. #define MEMORY_SIZE (MemorySize << 20)
  314. extern BOOLEAN MctadrRev2;
  315. //
  316. // Memory layout.
  317. //
  318. #ifndef _PPC_
  319. #define FW_POOL_BASE 0xa07ed000
  320. #define FW_POOL_SIZE 0xf000
  321. #else
  322. #define FW_POOL_BASE 0xe80000
  323. #define FW_POOL_SIZE 0x3000
  324. #endif
  325. //
  326. // Define special character values. TEMPTEMP These should go somewhere else.
  327. //
  328. #define ASCII_NUL 0x00
  329. #define ASCII_BEL 0x07
  330. #define ASCII_BS 0x08
  331. #define ASCII_HT 0x09
  332. #define ASCII_LF 0x0A
  333. #define ASCII_VT 0x0B
  334. #define ASCII_FF 0x0C
  335. #define ASCII_CR 0x0D
  336. #define ASCII_CSI 0x9B
  337. #define ASCII_ESC 0x1B
  338. #define ASCII_SYSRQ 0x80
  339. //
  340. // Define screen colors.
  341. //
  342. typedef enum _ARC_SCREEN_COLOR {
  343. ArcColorBlack,
  344. ArcColorRed,
  345. ArcColorGreen,
  346. ArcColorYellow,
  347. ArcColorBlue,
  348. ArcColorMagenta,
  349. ArcColorCyan,
  350. ArcColorWhite,
  351. MaximumArcColor
  352. } ARC_SCREEN_COLOR;
  353. //
  354. // Define video board types for Jazz.
  355. //
  356. typedef enum _JAZZ_VIDEO_TYPE {
  357. JazzVideoG300,
  358. JazzVideoG364,
  359. JazzVideoVxl,
  360. Reserved3,
  361. Reserved4,
  362. Reserved5,
  363. Reserved6,
  364. Reserved7,
  365. Reserved8,
  366. Reserved9,
  367. ReservedA,
  368. ReservedB,
  369. ReservedC,
  370. ReservedD,
  371. ReservedE,
  372. ReservedF,
  373. MipsVideoG364,
  374. MaximumJazzVideo
  375. } JAZZ_VIDEO_TYPE, *PJAZZ_VIDEO_TYPE;
  376. //
  377. // Define firmware routine prototypes.
  378. //
  379. VOID
  380. FwIoInitialize1 (
  381. VOID
  382. );
  383. VOID
  384. FwIoInitialize2 (
  385. VOID
  386. );
  387. BOOLEAN
  388. FwGetPathMnemonicKey(
  389. IN PCHAR OpenPath,
  390. IN PCHAR Mnemonic,
  391. OUT PULONG Key
  392. );
  393. PCHAR
  394. FwEnvironmentLoad(
  395. VOID
  396. );
  397. VOID
  398. FwPrintVersion (
  399. VOID
  400. );
  401. ARC_STATUS
  402. DisplayBootInitialize(
  403. VOID
  404. );
  405. ARC_STATUS
  406. FwGetVideoData (
  407. OUT PMONITOR_CONFIGURATION_DATA MonitorData
  408. );
  409. VOID
  410. FwSetVideoData (
  411. IN PMONITOR_CONFIGURATION_DATA MonitorData
  412. );
  413. VOID
  414. FwTerminationInitialize(
  415. IN VOID
  416. );
  417. VOID
  418. FwHalt(
  419. IN VOID
  420. );
  421. VOID
  422. FwMonitor(
  423. IN ULONG
  424. );
  425. VOID
  426. FwExceptionInitialize(
  427. IN VOID
  428. );
  429. VOID
  430. ResetSystem (
  431. IN VOID
  432. );
  433. VOID
  434. FwpFreeStub(
  435. IN PVOID Buffer
  436. );
  437. typedef enum _GETSTRING_ACTION {
  438. GetStringSuccess,
  439. GetStringEscape,
  440. GetStringUpArrow,
  441. GetStringDownArrow,
  442. GetStringMaximum
  443. } GETSTRING_ACTION, *PGETSTRING_ACTION;
  444. GETSTRING_ACTION
  445. FwGetString(
  446. OUT PCHAR String,
  447. IN ULONG StringLength,
  448. IN PCHAR InitialString OPTIONAL,
  449. IN ULONG CurrentRow,
  450. IN ULONG CurrentColumn
  451. );
  452. ARC_STATUS
  453. FwConfigurationCheckChecksum (
  454. VOID
  455. );
  456. ARC_STATUS
  457. FwEnvironmentCheckChecksum (
  458. VOID
  459. );
  460. VOID
  461. FwpReservedRoutine(
  462. VOID
  463. );
  464. VOID
  465. FwWaitForKeypress(
  466. VOID
  467. );
  468. VOID
  469. JzShowTime (
  470. BOOLEAN First
  471. );
  472. VOID
  473. JxBmp (
  474. VOID
  475. );
  476. ULONG
  477. JxDisplayMenu (
  478. IN PCHAR Choices[],
  479. IN ULONG NumberOfChoices,
  480. IN LONG DefaultChoice,
  481. IN ULONG CurrentLine
  482. );
  483. BOOLEAN
  484. FwGetVariableSegment (
  485. IN ULONG SegmentNumber,
  486. IN OUT PCHAR Segment
  487. );
  488. ARC_STATUS
  489. FwSetVariableSegment (
  490. IN ULONG SegmentNumber,
  491. IN PCHAR VariableName,
  492. IN OUT PCHAR Segment
  493. );
  494. ARC_STATUS
  495. JzAddProcessor (
  496. IN ULONG ProcessorNumber
  497. );
  498. //
  499. // Print macros.
  500. //
  501. extern BOOLEAN DisplayOutput;
  502. extern BOOLEAN SerialOutput;
  503. extern BOOLEAN FwConsoleInitialized;
  504. extern BOOLEAN SetupIsRunning;
  505. ULONG
  506. FwPrint (
  507. PCHAR Format,
  508. ...
  509. );
  510. #define FwClearScreen() \
  511. FwPrint("%c2J", ASCII_CSI)
  512. #define FwSetScreenColor(FgColor, BgColor) \
  513. FwPrint("%c3%dm", ASCII_CSI, (UCHAR)FgColor); \
  514. FwPrint("%c4%dm", ASCII_CSI, (UCHAR)BgColor)
  515. #define FwSetScreenAttributes( HighIntensity, Underscored, ReverseVideo ) \
  516. FwPrint("%c0m", ASCII_CSI); \
  517. if (HighIntensity) { \
  518. FwPrint("%c1m", ASCII_CSI); \
  519. } \
  520. if (Underscored) { \
  521. FwPrint("%c4m", ASCII_CSI); \
  522. } \
  523. if (ReverseVideo) { \
  524. FwPrint("%c7m", ASCII_CSI); \
  525. }
  526. #define FwSetPosition( Row, Column ) \
  527. FwPrint("%c%d;%dH", ASCII_CSI, (Row + 1), (Column + 1))
  528. #define FwMoveCursorLeft(Spaces) \
  529. FwPrint ("%c%dD", ASCII_CSI, Spaces)
  530. #define FwMoveCursorToColumn(Spaces) \
  531. FwPrint( "\r" ); \
  532. if ( Spaces > 1 ) \
  533. FwPrint( "%c%dC", ASCII_CSI, Spaces - 1)
  534. #endif // _FWP_