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.

627 lines
12 KiB

  1. /*++
  2. Copyright (c) 1989 Microsoft Corporation
  3. Module Name:
  4. detect.h
  5. Abstract:
  6. This module is a global C include file for all the detection
  7. modules.
  8. Author:
  9. Shie-Lin Tzong (shielint) 27-Dec-1991
  10. Revision History:
  11. --*/
  12. #if !defined(_IA64_)
  13. #define i386
  14. #define _X86_
  15. #endif // _IA64_
  16. #define __stdcall
  17. #include "types.h"
  18. #include "ntmisc.h"
  19. #include <ntconfig.h>
  20. #include <arc.h>
  21. //
  22. // Machine type definitions.
  23. //
  24. #define MACHINE_TYPE_ISA 0
  25. #define MACHINE_TYPE_EISA 1
  26. #define MACHINE_TYPE_MCA 2
  27. //
  28. // Interrupt controller register addresses.
  29. //
  30. #define PIC1_PORT0 0x20 // master PIC
  31. #define PIC1_PORT1 0x21
  32. #define PIC2_PORT0 0x0A0 // slave PIC
  33. #define PIC2_PORT1 0x0A1
  34. //
  35. // Commands for interrupt controller
  36. //
  37. #define OCW3_READ_ISR 0xb
  38. #define OCW3_READ_IRR 0xa
  39. //
  40. // Definitions for the data stored in the first page 0x700 area
  41. // The 0x700 is the place vdm loads MS-DOS. It should be very safe
  42. // to pass the data required by vdm.
  43. //
  44. #define DOS_BEGIN_SEGMENT 0x70 // DOS loaded segment address
  45. #define VIDEO_FONT_OFFSET 0 // Video font ptrs stored at 0x700
  46. #define VIDEO_FONT_DATA_SIZE 0x40
  47. #define EBIOS_INFO_OFFSET 0x40 // Extended bios infor:
  48. // EBIOS data area address 4 bytes
  49. // EBIOS data area size 4 byte
  50. #define EBIOS_INFO_SIZE 0x8
  51. //
  52. // Mouse information structure
  53. // N.B. This *must* match the one defined in mouse.inc
  54. //
  55. typedef struct _MOUSE_INFORMATION {
  56. UCHAR MouseType;
  57. UCHAR MouseSubtype;
  58. USHORT MousePort; // if serial mouse, 1 for com1, 2 for com2 ...
  59. USHORT MouseIrq;
  60. USHORT DeviceIdLength;
  61. UCHAR DeviceId[10];
  62. } MOUSE_INFORMATION, *PMOUSE_INFORMATION;
  63. //
  64. // Mouse Type definitions
  65. //
  66. #define UNKNOWN_MOUSE 0
  67. #define NO_MOUSE 0x100 // YES! it is 0x100 *NOT* 0x10000
  68. #define MS_MOUSE 0x200 // MS regular mouses
  69. #define MS_BALLPOINT 0x300 // MS ballpoint mouse
  70. #define LT_MOUSE 0x400 // Logitec Mouse
  71. //
  72. // note last 4 bits of the subtype are reserved subtype specific use
  73. //
  74. #define PS_MOUSE 0x1
  75. #define SERIAL_MOUSE 0x2
  76. #define INPORT_MOUSE 0x3
  77. #define BUS_MOUSE 0x4
  78. #define PS_MOUSE_WITH_WHEEL 0x5
  79. #define SERIAL_MOUSE_WITH_WHEEL 0x6
  80. //#define MOUSE_RESERVE_MASK 0xfffffff
  81. //
  82. // Definitions for the keyboard type returned from
  83. // the detect keyboard function.
  84. //
  85. #define UNKNOWN_KEYBOARD 0
  86. #define OLI_83KEY 1
  87. #define OLI_102KEY 2
  88. #define OLI_86KEY 3
  89. #define OLI_A101_102KEY 4
  90. #define XT_83KEY 5
  91. #define ATT_302 6
  92. #define PCAT_ENHANCED 7
  93. #define PCAT_86KEY 8
  94. #define PCXT_84KEY 9
  95. //
  96. // Redefine the configuration component structures to use FAR pointer type.
  97. //
  98. // Since ntdetect.com running at 16 bit real mode, it has to use FAR pointers
  99. // to access loader heap. Before returning to ntldr, ntdetect must convert
  100. // these far pointers to 32 bit flat addresses such that kernel can acess the
  101. // configuration tree.
  102. //
  103. typedef struct _FWCONFIGURATION_COMPONENT {
  104. CONFIGURATION_CLASS Class;
  105. #if !defined(_IA64_)
  106. USHORT Reserved0;
  107. #endif
  108. CONFIGURATION_TYPE Type;
  109. #if !defined(_IA64_)
  110. USHORT Reserverd1;
  111. #endif
  112. DEVICE_FLAGS Flags;
  113. ULONG Version;
  114. ULONG Key;
  115. ULONG AffinityMask;
  116. ULONG ConfigurationDataLength;
  117. ULONG IdentifierLength;
  118. FPCHAR Identifier;
  119. } FWCONFIGURATION_COMPONENT, far *FPFWCONFIGURATION_COMPONENT;
  120. typedef struct _FWCONFIGURATION_COMPONENT_DATA {
  121. struct _FWCONFIGURATION_COMPONENT_DATA far *Parent;
  122. struct _FWCONFIGURATION_COMPONENT_DATA far *Child;
  123. struct _FWCONFIGURATION_COMPONENT_DATA far *Sibling;
  124. FWCONFIGURATION_COMPONENT ComponentEntry;
  125. FPVOID ConfigurationData;
  126. } FWCONFIGURATION_COMPONENT_DATA, far *FPFWCONFIGURATION_COMPONENT_DATA;
  127. //
  128. // defined the MicroChannel POS data structure
  129. //
  130. typedef CM_MCA_POS_DATA MCA_POS_DATA, far *FPMCA_POS_DATA;
  131. //
  132. // Rom Block Definition
  133. //
  134. typedef CM_ROM_BLOCK ROM_BLOCK, far *FPROM_BLOCK;
  135. #define RESERVED_ROM_BLOCK_LIST_SIZE (((0xf0000 - 0xc0000)/512) * sizeof(ROM_BLOCK))
  136. //
  137. // Other type redefinitions
  138. //
  139. typedef CM_PARTIAL_RESOURCE_DESCRIPTOR HWPARTIAL_RESOURCE_DESCRIPTOR;
  140. typedef HWPARTIAL_RESOURCE_DESCRIPTOR *PHWPARTIAL_RESOURCE_DESCRIPTOR;
  141. typedef HWPARTIAL_RESOURCE_DESCRIPTOR far *FPHWPARTIAL_RESOURCE_DESCRIPTOR;
  142. typedef CM_PARTIAL_RESOURCE_LIST HWRESOURCE_DESCRIPTOR_LIST;
  143. typedef HWRESOURCE_DESCRIPTOR_LIST *PHWRESOURCE_DESCRIPTOR_LIST;
  144. typedef HWRESOURCE_DESCRIPTOR_LIST far *FPHWRESOURCE_DESCRIPTOR_LIST;
  145. #if defined(NEC_98)
  146. #define SYSTEM_SEGMENT 0x00400000
  147. #define SYSTEM_SEGMENT_2 0xf8e80000
  148. #else // PC98
  149. typedef CM_EISA_SLOT_INFORMATION EISA_SLOT_INFORMATION, *PEISA_SLOT_INFORMATION;
  150. typedef CM_EISA_SLOT_INFORMATION far *FPEISA_SLOT_INFORMATION;
  151. typedef CM_EISA_FUNCTION_INFORMATION EISA_FUNCTION_INFORMATION, *PEISA_FUNCTION_INFORMATION;
  152. typedef CM_EISA_FUNCTION_INFORMATION far *FPEISA_FUNCTION_INFORMATION;
  153. #endif // PC98
  154. #define LEVEL_SENSITIVE CM_RESOURCE_INTERRUPT_LEVEL_SENSITIVE
  155. #define EDGE_TRIGGERED CM_RESOURCE_INTERRUPT_LATCHED
  156. #define RESOURCE_PORT 1
  157. #define RESOURCE_INTERRUPT 2
  158. #define RESOURCE_MEMORY 3
  159. #define RESOURCE_DMA 4
  160. #define RESOURCE_DEVICE_DATA 5
  161. #define ALL_PROCESSORS 0xffffffff
  162. #if defined(NEC_98)
  163. //
  164. // BIOS_FLAG5
  165. //
  166. #define ENABLE_FULL_CENTRO 0x02
  167. #define PRTMODE_FULL_CENTRO 0x04
  168. //
  169. // BIOS_FLAG7
  170. //
  171. #define LOCKED_LPT 0x01
  172. #define LOCKED_CCU1 0x02
  173. #define LOCKED_CCU2 0x04
  174. #define LOCKED_FD 0x08
  175. #define LOCKED_PD 0x10
  176. #define SCSI_MAX_ID 7
  177. #define DASCSI 0x20
  178. #define UA_MASK 0x0F
  179. #define COM_ID_L ((USHORT)GetF8E8Seg(0x00))
  180. #define COM_ID_H ((USHORT)GetF8E8Seg(0x01))
  181. #define ROM_FLAG5 ((USHORT)GetF8E8Seg(0x11))
  182. #define ROM_FLAG7 ((USHORT)GetF8E8Seg(0x13))
  183. #define ROM_REV ((USHORT)GetF8E8Seg(0x3F))
  184. #define BIOS_FLAG5 ((USHORT)Get0Seg(0x458))
  185. #define EQUIPS_47Ch ((USHORT)Get0Seg(0x47C))
  186. #define H_EQUIPS ((USHORT)Get0Seg(0x47D))
  187. #define H_DISK_EQUIPS_L ((USHORT)Get0Seg(0x47E))
  188. #define H_DISK_EQUIPS_H ((USHORT)Get0Seg(0x47F))
  189. #define DISK_EQUIPS_SCSI ((USHORT)Get0Seg(0x482))
  190. #define DISK_EQUIPS_FD ((USHORT)Get0Seg(0x55C))
  191. #define DAUA_BOOTED_FROM ((USHORT)Get0Seg(0x584))
  192. #define DISK_2HC ((USHORT)Get0Seg(0x5AE))
  193. #endif // PC98
  194. //
  195. // Note the DATA_HEADER_SIZE counts ONE partial descriptor only.
  196. // if the resource list has more than one descriptors, you must add
  197. // the size of extra descriptors to this value.
  198. //
  199. #define DATA_HEADER_SIZE sizeof(CM_PARTIAL_RESOURCE_LIST)
  200. //
  201. // Defines the structure to store controller information
  202. // (used by ntdetect internally)
  203. //
  204. #define MAXIMUM_DESCRIPTORS 10
  205. typedef struct _HWCONTROLLER_DATA {
  206. UCHAR NumberPortEntries;
  207. UCHAR NumberIrqEntries;
  208. UCHAR NumberMemoryEntries;
  209. UCHAR NumberDmaEntries;
  210. HWPARTIAL_RESOURCE_DESCRIPTOR DescriptorList[MAXIMUM_DESCRIPTORS];
  211. } HWCONTROLLER_DATA, *PHWCONTROLLER_DATA;
  212. //
  213. // Macro definitions for conversion between far and fat pointers
  214. //
  215. #if defined(_IA64_)
  216. #define MAKE_FP(p,a) p = (VOID *)a
  217. #define MAKE_FLAT_ADDRESS(fp) (ULONG_PTR) (fp)
  218. #else
  219. #define MAKE_FP(p,a) FP_SEG(p) = (USHORT)((a) >> 4) & 0xffff; FP_OFF(p) = (USHORT)((a) & 0x0f)
  220. #define MAKE_FLAT_ADDRESS(fp) ( ((ULONG)FP_SEG(fp) * 16 ) + (ULONG)FP_OFF(fp) )
  221. #endif // _IA64_
  222. //
  223. // Calculate the byte offset of a field in a structure of type type.
  224. //
  225. #define FIELD_OFFSET(type, field) ((ULONG_PTR)&(((type *)0)->field))
  226. //
  227. // I/O Port read and write routines.
  228. //
  229. extern
  230. VOID
  231. WRITE_PORT_UCHAR (
  232. PUCHAR PortAddress,
  233. UCHAR Value
  234. );
  235. extern
  236. UCHAR
  237. READ_PORT_UCHAR(
  238. PUCHAR Port
  239. );
  240. extern
  241. VOID
  242. WRITE_PORT_USHORT (
  243. PUSHORT PortAddress,
  244. USHORT Value
  245. );
  246. extern
  247. USHORT
  248. READ_PORT_USHORT(
  249. PUSHORT Port
  250. );
  251. //
  252. // prototype definitions for Heap management routines
  253. //
  254. extern
  255. BOOLEAN
  256. HwInitializeHeap (
  257. ULONG HeapStart,
  258. ULONG HeapSize
  259. );
  260. extern
  261. FPVOID
  262. HwAllocateHeap(
  263. ULONG RequestSize,
  264. BOOLEAN ZeroInitialized
  265. );
  266. extern
  267. VOID
  268. HwFreeHeap(
  269. ULONG Size
  270. );
  271. //
  272. // Misc. prototype definitions
  273. //
  274. extern
  275. FPVOID
  276. HwSetUpResourceDescriptor (
  277. FPFWCONFIGURATION_COMPONENT Component,
  278. PUCHAR Identifier,
  279. PHWCONTROLLER_DATA ControlData,
  280. USHORT SpecificDataLength,
  281. PUCHAR SpecificData
  282. );
  283. extern
  284. VOID
  285. HwSetUpFreeFormDataHeader (
  286. FPHWRESOURCE_DESCRIPTOR_LIST Header,
  287. USHORT Version,
  288. USHORT Revision,
  289. USHORT Flags,
  290. ULONG DataSize
  291. );
  292. extern
  293. BOOLEAN
  294. IsEnhancedKeyboard (
  295. VOID
  296. );
  297. extern
  298. SHORT
  299. GetKeyboardIdBytes (
  300. PCHAR IdBuffer,
  301. SHORT Length
  302. );
  303. extern
  304. USHORT
  305. GetKeyboardId(
  306. VOID
  307. );
  308. extern
  309. FPFWCONFIGURATION_COMPONENT_DATA
  310. SetKeyboardConfigurationData (
  311. IN USHORT KeyboardId
  312. );
  313. #if 0 // Remove video detection
  314. extern
  315. ULONG
  316. GetVideoAdapterType (
  317. VOID
  318. );
  319. extern
  320. FPFWCONFIGURATION_COMPONENT_DATA
  321. SetVideoConfigurationData (
  322. IN ULONG VideoType
  323. );
  324. #endif // Remove video detection
  325. extern
  326. FPFWCONFIGURATION_COMPONENT_DATA
  327. GetComportInformation (
  328. VOID
  329. );
  330. extern
  331. FPFWCONFIGURATION_COMPONENT_DATA
  332. GetLptInformation (
  333. VOID
  334. );
  335. extern
  336. PMOUSE_INFORMATION
  337. GetMouseId (
  338. VOID
  339. );
  340. extern
  341. FPFWCONFIGURATION_COMPONENT_DATA
  342. GetMouseInformation (
  343. VOID
  344. );
  345. extern
  346. FPFWCONFIGURATION_COMPONENT_DATA
  347. GetFloppyInformation(
  348. VOID
  349. );
  350. extern
  351. FPFWCONFIGURATION_COMPONENT_DATA
  352. GetAtDiskInformation(
  353. VOID
  354. );
  355. extern
  356. BOOLEAN
  357. HwIsMcaSystem(
  358. VOID
  359. );
  360. #if defined(NEC_98)
  361. #else // PC98
  362. extern
  363. BOOLEAN
  364. HwIsEisaSystem(
  365. VOID
  366. );
  367. #endif // PC98
  368. extern
  369. BOOLEAN
  370. IsNpxPresent(
  371. VOID
  372. );
  373. extern
  374. USHORT
  375. HwGetProcessorType(
  376. VOID
  377. );
  378. extern
  379. USHORT
  380. HwGetCpuStepping(
  381. USHORT
  382. );
  383. extern
  384. VOID
  385. GetMcaPosData(
  386. FPVOID Entry,
  387. FPULONG DataLength
  388. );
  389. #if defined(NEC_98)
  390. #else // PC98
  391. extern
  392. VOID
  393. GetEisaConfigurationData(
  394. FPVOID Entry,
  395. FPULONG DataLength
  396. );
  397. #endif // PC98
  398. extern
  399. VOID
  400. UpdateConfigurationTree(
  401. FPFWCONFIGURATION_COMPONENT_DATA CurrentEntry
  402. );
  403. extern
  404. PUCHAR
  405. GetMachineId(
  406. VOID
  407. );
  408. #if defined(NEC_98)
  409. #else // PC98
  410. extern
  411. VOID
  412. HwGetEisaSlotInformation (
  413. PEISA_SLOT_INFORMATION SlotInformation,
  414. UCHAR Slot
  415. );
  416. extern
  417. UCHAR
  418. HwGetEisaFunctionInformation (
  419. PEISA_FUNCTION_INFORMATION FunctionInformation,
  420. UCHAR Slot,
  421. UCHAR Function
  422. );
  423. #endif // PC98
  424. extern
  425. VOID
  426. GetBiosSystemEnvironment (
  427. PUCHAR Buffer
  428. );
  429. extern
  430. VOID
  431. GetInt13DriveParameters (
  432. PUCHAR Buffer,
  433. PUSHORT Size
  434. );
  435. extern
  436. VOID
  437. GetRomBlocks(
  438. FPUCHAR ReservedBuff,
  439. PUSHORT Size
  440. );
  441. extern
  442. VOID
  443. GetVideoFontInformation(
  444. VOID
  445. );
  446. extern
  447. BOOLEAN
  448. HwEisaGetIrqFromPort (
  449. USHORT Port,
  450. PUCHAR Irq,
  451. PUCHAR TriggerMethod
  452. );
  453. VOID
  454. HwGetPciSystemData(
  455. PVOID,
  456. BOOLEAN
  457. );
  458. VOID
  459. HwGetBiosDate(
  460. ULONG source,
  461. USHORT Length,
  462. PUSHORT BiosYear,
  463. PUSHORT BiosMonth,
  464. PUSHORT BiosDay
  465. );
  466. BOOLEAN
  467. HwGetPnpBiosSystemData(
  468. IN FPUCHAR *Configuration,
  469. IN PUSHORT Length
  470. );
  471. BOOLEAN
  472. HwGetAcpiBiosData(
  473. IN FPUCHAR *Configuration,
  474. OUT PUSHORT Length
  475. );
  476. #if defined(NEC_98)
  477. USHORT
  478. Get0Seg(
  479. IN USHORT OffsetAddress
  480. );
  481. USHORT
  482. GetF8E8Seg(
  483. IN USHORT OffsetAddress
  484. );
  485. VOID
  486. IoDelay(
  487. USHORT counter
  488. );
  489. #endif // PC98
  490. #if DBG
  491. extern
  492. VOID
  493. BlPrint(
  494. IN PCHAR,
  495. ...
  496. );
  497. extern
  498. VOID
  499. clrscrn (
  500. VOID
  501. );
  502. #endif // DBG
  503. //
  504. // External declarations for global variables
  505. //
  506. extern USHORT HwBusType;
  507. extern FPFWCONFIGURATION_COMPONENT_DATA AdapterEntry;
  508. extern FPMCA_POS_DATA HwMcaPosData;
  509. extern FPUCHAR FpRomBlock;
  510. extern USHORT RomBlockLength;
  511. extern FPUCHAR HwEisaConfigurationData;
  512. extern ULONG HwEisaConfigurationSize;