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.

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