home *** CD-ROM | disk | FTP | other *** search
/ Team Palmtops 7 / Palmtops_numero07.iso / WinCE / SDKWindowsCE / AutoPC / apcsdk10.exe / data1.cab / Emulation_Include_Files / tuple.h < prev    next >
Encoding:
C/C++ Source or Header  |  1999-05-13  |  13.6 KB  |  586 lines

  1. /*++
  2. THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
  3. ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
  4. THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
  5. PARTICULAR PURPOSE.
  6. Copyright (c) 1995, 1996, 1997  Microsoft Corporation
  7.  
  8. Module Name:  
  9.  
  10.     tuple.h
  11.  
  12. Abstract:  
  13.  
  14.     This file implements the Windows CE PCMCIA metaformat card information
  15.     tuple structure definitions.  This is provided as a sample to platform
  16.     writers and is expected to be able to be used without modification on most
  17.     (if not all) hardware platforms.
  18.  
  19. Functions:
  20.  
  21.  
  22. Notes:
  23.  
  24.     Since the tuples are compressed and must be processed sequentially,
  25.     the definitions provided here are in the form of a union of all
  26.     the elements in the tuple.  This allows a byte pointer to the union
  27.     to be incremented as it references each of the elements of the tuple.
  28.  
  29.     Also described are the parsed structures returned by the function
  30.     CardGetParsedTuple().
  31.  
  32. --*/
  33.  
  34. #ifndef TUPLE_INC
  35. #define TUPLE_INC
  36.  
  37. #pragma pack(1)
  38.  
  39. // Tuple Codes
  40.  
  41. #define CISTPL_NULL         0x00
  42. #define CISTPL_DEVICE       0x01
  43. #define CISTPL_LONGLINK_CB  0x02        // CardBus
  44. #define CISTPL_CONFIG_CB    0x04        // CardBus
  45. #define CISTPL_CFTABLE_ENTRY_CB 0x05    // CardBus
  46. #define CISTPL_LONGLINK_MFC 0x06        // Multiple Function
  47. #define CISTPL_LONG_LINK_MFC 0x06       // Multiple Function
  48. #define CISTPL_CHECKSUM     0x10
  49. #define CISTPL_LONGLINK_A   0x11
  50. #define CISTPL_LONGLINK_C   0x12
  51. #define CISTPL_LINKTARGET   0x13
  52. #define CISTPL_NO_LINK      0x14
  53. #define CISTPL_VERS_1       0x15
  54. #define CISTPL_ALTSTR       0x16
  55. #define CISTPL_DEVICE_A     0x17
  56. #define CISTPL_JEDEC_C      0x18
  57. #define CISTPL_JEDEC_A      0x19
  58. #define CISTPL_CONFIG       0x1A
  59. #define CISTPL_CFTABLE_ENTRY 0x1B
  60. #define CISTPL_DEVICE_OC    0x1C
  61. #define CISTPL_DEVICE_OA    0x1D
  62. #define CISTPL_GEODEVICE    0x1E
  63. #define CISTPL_GEODEVICE_A  0x1F
  64. #define CISTPL_MANFID       0x20
  65. #define CISTPL_FUNCID       0x21
  66. #define CISTPL_FUNCE        0x22
  67. #define CISTPL_VERS_2       0x40
  68. #define CISTPL_FORMAT       0x41
  69. #define CISTPL_GEOMETRY     0x42
  70. #define CISTPL_BYTEORDER    0x43
  71. #define CISTPL_DATE         0x44
  72. #define CISTPL_BATTERY      0x45
  73. #define CISTPL_ORG          0x46
  74. #define CISTPL_END          0xFF
  75.  
  76.  
  77. // Device Information Tuple Definitions
  78.  
  79. typedef union {
  80.     BYTE dt_DevID;
  81.     BYTE dt_ExtDevSpeed;
  82.     BYTE dt_DevSize;
  83. } DEVICE_TPL;
  84.  
  85. // Device ID Definitions
  86.  
  87. #define DEVID_DSPEED 0x07    // Device speed mask
  88. #define DEVID_WPS    0x08    // Device write protect switch bit
  89. #define DEVID_DTYPE  0xF0    // Device type code mask
  90.  
  91. // Device Speed Code Definitions
  92.  
  93. #define DSPEED_NULL  0x00
  94. #define DSPEED_250NS 0x01
  95. #define DSPEED_200NS 0x02
  96. #define DSPEED_150NS 0x03
  97. #define DSPEED_100NS 0x04
  98. #define DSPEED_EXT   0x07
  99.  
  100. // Device Type Code Definitions
  101.  
  102. #define DTYPE_NULL     0x00
  103. #define DTYPE_ROM      0x01
  104. #define DTYPE_OTPROM   0x02
  105. #define DTYPE_EPROM    0x03
  106. #define DTYPE_EEPROM   0x04
  107. #define DTYPE_FLASH    0x05
  108. #define DTYPE_SRAM     0x06
  109. #define DTYPE_DRAM     0x07
  110. #define DTYPE_FUNCSPEC 0x0D
  111. #define DTYPE_EXTEND   0x0E
  112.  
  113. // Extended Device Speed Definitions
  114.  
  115. #define ESPEED_EXP  0x07    // Extended device speed exponent mask
  116. #define ESPEED_MANT 0x71    // Extended device speed mantissa mask
  117. #define ESPEED_EXT  0x80    // Additional ext speed byte follows
  118.  
  119. // Extended Device Speed Code Exponent Definitions
  120.  
  121. #define SPDEXP_1NS   0x00
  122. #define SPDEXP_10NS  0x01
  123. #define SPDEXP_100NS 0x02
  124. #define SPDEXP_1US   0x03
  125. #define SPDEXP_10US  0x04
  126. #define SPDEXP_100US 0x05
  127. #define SPDEXP_1MS   0x06
  128. #define SPDEXP_10MS  0x07
  129.  
  130. // Extended Device Speed Code Mantissa Definitions
  131.  
  132. #define SPDMANT_1_0 0x01
  133. #define SPDMANT_1_2 0x02
  134. #define SPDMANT_1_3 0x03
  135. #define SPDMANT_1_5 0x04
  136. #define SPDMANT_2_0 0x05
  137. #define SPDMANT_2_5 0x06
  138. #define SPDMANT_3_0 0x07
  139. #define SPDMANT_3_5 0x08
  140. #define SPDMANT_4_0 0x09
  141. #define SPDMANT_4_5 0x0A
  142. #define SPDMANT_5_0 0x0B
  143. #define SPDMANT_5_5 0x0C
  144. #define SPDMANT_6_0 0x0D
  145. #define SPDMANT_7_0 0x0E
  146. #define SPDMANT_8_0 0x0F
  147.  
  148. // Device Size Byte Definitions
  149.  
  150. #define DSIZE_CODE  0x07
  151. #define DSIZE_UNITS 0xF1
  152.  
  153. // Device Size Code Definitions
  154.  
  155. #define SCODE_512  0x00
  156. #define SCODE_2K   0x01
  157. #define SCODE_8K   0x02
  158. #define SCODE_32K  0x03
  159. #define SCODE_128K 0x04
  160. #define SCODE_512K 0x05
  161. #define SCODE_2M   0x06
  162.  
  163.  
  164. // Level 1 Version/Product Information Tuple Definitions
  165.  
  166. typedef struct {
  167.     BYTE v1_Major;
  168.     BYTE v1_Minor;
  169.     BYTE v1_Info;
  170. } L1VERS_TPL;
  171.  
  172. // Device Information String Terminator Definition
  173.  
  174. #define TPLL1V_END 0xFF
  175.  
  176.  
  177. // Configuration Tuple Definitions
  178.  
  179. typedef union {
  180.     struct {
  181.     BYTE cc_Sz;
  182.     BYTE cc_Last;
  183.     };
  184.     BYTE cc_RAdr;
  185.     BYTE cc_RMsk;
  186. } CONFIG_TPL;
  187.  
  188. // Configuration Size Field Byte Definitions
  189.  
  190. #define TPCC_RASZ 0x03
  191. #define TPCC_RMSZ 0x3C
  192. #define TPCC_RFSZ_MASK  0xC0
  193. #define TPCCRFSZ(X)     ((X & TPCC_RFSZ_MASK) >> 6)
  194. #define TPCC_RMSZ_MASK  0x3C
  195. #define TPCCRMSZ(X)     ((X & TPCC_RMSZ_MASK) >> 2)
  196. #define TPCC_RASZ_MASK  0x03
  197. #define TPCCRASZ(X)     (X & TPCC_RASZ_MASK)
  198.  
  199. // Configuration Last Entry Index Byte Definitions
  200.  
  201. #define TPCC_LASTINDX 0x3F
  202.  
  203.  
  204. // Configuration Table Entry Tuple Definitions
  205.  
  206. typedef union {
  207.     BYTE ce_Indx;
  208.     BYTE ce_IF;
  209.     BYTE ce_FS;
  210.     union {
  211.     BYTE ce_PD_Selection;
  212.     BYTE ce_PD_NomV;
  213.     BYTE ce_PD_MinV;
  214.     BYTE ce_PD_MaxV;
  215.     BYTE ce_PD_StaticI;
  216.     BYTE ce_PD_AvgI;
  217.     BYTE ce_PD_PeakI;
  218.     BYTE ce_PD_PDwnI;
  219.     };
  220.     BYTE ce_TD;
  221.     union {
  222.     BYTE ce_IO_Parm;
  223.     BYTE ce_IO_RangeDesc;
  224.     BYTE ce_IO_Address;
  225.     BYTE ce_IO_Length;
  226.     };
  227.     union {
  228.     BYTE ce_IR_Parm;
  229.     WORD ce_IR_MASK;
  230.     };
  231.     BYTE ce_MS;
  232.     BYTE ce_MI;
  233. } CFENTRY_TPL;
  234.  
  235. // Configuration Table Index Byte Definitions
  236.  
  237. #define TPCE_ENTRYNUM 0x3F
  238. #define TPCE_DEFAULT  0x40
  239. #define TPCE_INTFACE  0x80
  240.  
  241. // Configuration Table Entry Interface Description Field Definitions
  242.  
  243. #define TPCE_IFTYPE       0x0F
  244. #define TPCE_BVDSACTIVE   0x10
  245. #define TPCE_WPACTIVE     0x20
  246. #define TPCE_RDYBSYACTIVE 0x40
  247. #define TPCE_MWAITREQD    0x80
  248.  
  249. // Configuration Table Entry Feature Selection Byte Definitions
  250.  
  251. #define TPCE_POWER    0x03
  252. #define TPCE_TIMING   0x04
  253. #define TPCE_IOSPACE  0x08
  254. #define TPCE_IRQ      0x10
  255. #define TPCE_MEMSPACE 0x60
  256. #define TPCE_MISC     0x80
  257.  
  258. // Configuration Table Entry Power Desc Parameter Selection Byte Definitions
  259.  
  260. #define TPCE_PD_NOMV    0x01
  261. #define TPCE_PD_MINV    0x02
  262. #define TPCE_PD_MAXV    0x04
  263. #define TPCE_PD_STATICI 0x08
  264. #define TPCE_PD_AVGI    0x10
  265. #define TPCE_PD_PEAKI   0x20
  266. #define TPCE_PD_PDWNI   0x40
  267.  
  268. // Configuration Table Entry Power Description Structure Parameter Definitions
  269.  
  270. #define TPCE_PD_EXP   0x07
  271. #define TPCE_PD_MANT  0x71
  272. #define TPCE_PD_EXT   0x80
  273.  
  274. #define TPCE_PD_EXTEN 0x7F
  275.  
  276. // Configuration Table Entry Power Description Voltage Exponent Definitions
  277.  
  278. #define PDEXP_10UV    0x00
  279. #define PDEXP_100UV   0x01
  280. #define PDEXP_1MV     0x02
  281. #define PDEXP_10MV    0x03
  282. #define PDEXP_100MV   0x04
  283. #define PDEXP_1V      0x05
  284. #define PDEXP_10V     0x06
  285. #define PDEXP_100V    0x07
  286.  
  287. // Configuration Table Entry Power Description Current Exponent Definitions
  288.  
  289. #define PDEXP_100NA   0x00
  290. #define PDEXP_1UA     0x01
  291. #define PDEXP_10UA    0x02
  292. #define PDEXP_100UA   0x03
  293. #define PDEXP_1MA     0x04
  294. #define PDEXP_10MA    0x05
  295. #define PDEXP_100MA   0x06
  296. #define PDEXP_1A      0x07
  297.  
  298. // Configuration Table Entry Power Description Mantissa Definitions
  299.  
  300. #define PDMANT_1_0    0x00
  301. #define PDMANT_1_2    0x01
  302. #define PDMANT_1_3    0x02
  303. #define PDMANT_1_5    0x03
  304. #define PDMANT_2_0    0x04
  305. #define PDMANT_2_5    0x05
  306. #define PDMANT_3_0    0x06
  307. #define PDMANT_3_5    0x07
  308. #define PDMANT_4_0    0x08
  309. #define PDMANT_4_5    0x09
  310. #define PDMANT_5_0    0x0A
  311. #define PDMANT_5_5    0x0B
  312. #define PDMANT_6_0    0x0C
  313. #define PDMANT_7_0    0x0D
  314. #define PDMANT_8_0    0x0E
  315. #define PDMANT_9_0    0x0F
  316.  
  317. // Configuration Table Entry Timing Information Definitions
  318.  
  319. #define TPCE_TD_WAIT   0x03
  320. #define TPCE_TD_RDYBSY 0x1C
  321.  
  322. // Configuration Table Entry I/O Space Address Parameter Definitions
  323.  
  324. #define TPCE_IO_ADDRLINES 0x1F
  325. #define TPCE_IO_BUS8      0x20
  326. #define TPCE_IO_BUS16     0x40
  327. #define TPCE_IO_RANGE     0x80
  328.  
  329. // Configuration Table Entry I/O Space Range Descriptor Definitions
  330.  
  331. #define TPCE_IO_NUMRANGES  0x0F
  332. #define TPCE_IO_ADDRSIZE   0x30
  333. #define TPCE_IO_LENGTHSIZE 0xC0
  334.  
  335. // Configuration Table Entry IRQ Interrupt Request Descriptor Definitions
  336.  
  337. #define TPCE_IR_IRQN  0x0F
  338. #define TPCE_IR_NMI   0x01
  339. #define TPCE_IR_LOCK  0x02
  340. #define TPCE_IR_BERR  0x04
  341. #define TPCE_IR_VEND  0x08
  342. #define TPCE_IR_MASK  0x10
  343. #define TPCE_IR_LEVEL 0x20
  344. #define TPCE_IR_PULSE 0x40
  345. #define TPCE_IR_SHARE 0x80
  346.  
  347.  
  348.  
  349. //******************************************************
  350.  
  351. typedef struct tTPCE_IF
  352. {
  353.     BYTE InterfaceType;
  354.     BYTE BVDsActive;
  355.     BYTE WPActive;
  356.     BYTE RdyBsyActive;
  357.     BYTE MWaitActive;
  358. } tTPCE_IF;
  359.  
  360. typedef struct tTPCE_FS
  361. {
  362.     BYTE Power;
  363.     BYTE Timing;
  364.     BYTE IOSpace;
  365.     BYTE IRQ;
  366.     BYTE MemSpace;
  367.     BYTE Misc;
  368. } tTPCE_FS;
  369.  
  370. typedef struct tTPCE_PD
  371. {
  372.     BYTE   NomVPresent;
  373.     BYTE   MinVPresent;
  374.     BYTE   MaxVPresent;
  375.     BYTE   StaticIPresent;
  376.     BYTE   AvgIPresent;
  377.     BYTE   PeakIPresent;
  378.     BYTE   PDwnIPresent;
  379.     BYTE   RFUPresent;
  380.     double NomV;
  381.     double MinV;
  382.     double MaxV;
  383.     double StaticI;
  384.     double AvgI;
  385.     double PeakI;
  386.     double PDwnI;
  387.     double RFU;
  388. } tTPCE_PD;
  389.  
  390. typedef struct tTPCE_TD
  391. {
  392.     BYTE   WaitScalePresent;
  393.     BYTE   ReadyBusyScalePresent;
  394.     BYTE   ReservedScale7Present;
  395.     double WaitScale;
  396.     double ReadyBusyScale;
  397.     double ReservedScale7;
  398. } tTPCE_TD;
  399.  
  400. typedef struct tTPCE_IO
  401. {
  402.     BYTE IOAddrLines;
  403.     BYTE Bus8;
  404.     BYTE Bus16;
  405.     BYTE Range;
  406.     BYTE NumberIOAddrRanges;
  407.     BYTE AddressSize;
  408.     BYTE LengthSize;
  409. } tTPCE_IO;
  410.  
  411. typedef struct tTPCE_IR
  412. {
  413.     BYTE Irqn;
  414.     BYTE Vend;
  415.     BYTE Berr;
  416.     BYTE Iock;
  417.     BYTE Nmi;
  418.     BYTE Mask0;
  419.     BYTE Level;
  420.     BYTE Pulse;
  421.     BYTE Share;
  422.     BYTE Irq0;
  423.     BYTE Irq1;
  424.     BYTE Irq2;
  425.     BYTE Irq3;
  426.     BYTE Irq4;
  427.     BYTE Irq5;
  428.     BYTE Irq6;
  429.     BYTE Irq7;
  430.     BYTE Irq8;
  431.     BYTE Irq9;
  432.     BYTE Irq10;
  433.     BYTE Irq11;
  434.     BYTE Irq12;
  435.     BYTE Irq13;
  436.     BYTE Irq14;
  437.     BYTE Irq15;
  438. } tTPCE_IR;
  439.  
  440. typedef struct tTPCE_MS
  441. {
  442.     BYTE NumWindows;
  443.     BYTE LengthSize;
  444.     BYTE CardAddrSze;
  445.     BYTE HostAddr;
  446. } tTPCE_MS;
  447.  
  448. typedef struct tTPCE_MI
  449. {
  450.     BYTE MaxTwinCards;
  451.     BYTE Audio;
  452.     BYTE ReadOnly;
  453.     BYTE PwrDown;
  454.     BYTE Reserved;
  455.     BYTE Ext;
  456. } tTPCE_MI;
  457.  
  458. typedef struct tCardEntryTuple
  459. {
  460.     BYTE     ConfigEntryNumber;
  461.     BYTE     DefaultBit;
  462.     BYTE     InterfaceBytePresent;
  463.     tTPCE_IF IF;
  464.     tTPCE_FS FS;
  465.     tTPCE_PD PDVcc;
  466.     tTPCE_PD PDVpp1;
  467.     tTPCE_PD PDVpp2;
  468.     tTPCE_TD TD;
  469.     tTPCE_IO IO;
  470.     tTPCE_IR IR;
  471.     tTPCE_MS MS;
  472.     tTPCE_MI MI;
  473. } tCardEntryTuple;
  474.  
  475. typedef struct tDGTPL
  476. {
  477.     BYTE DGTPL_BUS;
  478.     BYTE DGTPL_EBS;
  479.     BYTE DGTPL_RBS;
  480.     BYTE DGTPL_WBS;
  481.     BYTE DGTPL_PART;
  482.     BYTE DGTPL_HWIL;
  483. } tDGTPL;
  484.  
  485. //
  486. // CISTPL_FUNCID function codes
  487. //
  488. #define PCCARD_TYPE_VENDOR_SPECIFIC 0
  489. #define PCCARD_TYPE_MEMORY        1
  490. #define PCCARD_TYPE_SERIAL        2
  491. #define PCCARD_TYPE_PARALLEL      3
  492. #define PCCARD_TYPE_FIXED_DISK    4
  493. #define PCCARD_TYPE_VIDEO         5
  494. #define PCCARD_TYPE_NETWORK       6
  495. #define PCCARD_TYPE_AIMS          7
  496. #define PCCARD_TYPE_UNKNOWN       0xff
  497.  
  498.  
  499. //
  500. // Parsed structures returned by CardGetParsedTuple
  501. //
  502.  
  503. //
  504. // Note:
  505. //  1) only one byte of the register presence mask is used,
  506. //  2) custom interface subtuples are not parsed
  507. //
  508. typedef struct _PARSED_CONFIG {
  509.     UINT32  ConfigBase;
  510.     UINT8   RegMask;
  511.     UINT8   LastConfigIndex;
  512. } PARSED_CONFIG, * PPARSED_CONFIG;
  513.  
  514.  
  515. //
  516. // Parsed CISTPL_CFTABLE_ENTRY tuples.
  517. //
  518. // All CISTPL_CFTABLE_ENTRY tuples for a given socket/function are parsed
  519. // and the results are returned using the following three structures.
  520. //
  521. // Note: the custom interface subtuples are not parsed
  522. //
  523.  
  524. //
  525. //  If the POWER_DESCR structure is changed, then PARSED_CFTABLE must be realigned
  526. //
  527. // Note:
  528. //  1) The voltages are in 0.1 volt units,
  529. //  2) The currents are in milliAmps,
  530. //
  531. typedef struct _POWER_DESCR {
  532.     UINT16   ValidMask;
  533.                             // (bit 0 set implies NominalV is valid,
  534.                             // bit 1 set implies MinV is valid)
  535.                             // etc
  536.     UINT16   NominalV;
  537.     UINT16   MinV;
  538.     UINT16   MaxV;
  539.     UINT16   StaticI;
  540.     UINT16   AvgI;
  541.     UINT16   PeakI;
  542.     UINT16   PowerDownI;
  543. } POWER_DESCR, * PPOWER_DESCR;
  544.  
  545. //
  546. // POWER_DESCR.ValidMask
  547. // 
  548. #define PWR_DESCR_NOMINALV  0x01
  549. #define PWR_DESCR_MINV      0x02
  550. #define PWR_DESCR_MAXV      0x04
  551. #define PWR_DESCR_STATICI   0x08
  552. #define PWR_DESCR_AVGI      0x10
  553. #define PWR_DESCR_PEAKI     0x20
  554. #define PWR_DESCR_POWERDWNI 0x40
  555.  
  556. #define MAX_IO_RANGES   4   // limit this to 4, it can be as high as 16
  557.  
  558. typedef struct _PARSED_CFTABLE {
  559.     POWER_DESCR VccDescr;
  560.     POWER_DESCR Vpp1Descr;
  561.     POWER_DESCR Vpp2Descr;
  562.  
  563.     UINT32  IOLength[MAX_IO_RANGES];
  564.     UINT32  IOBase[MAX_IO_RANGES];
  565.     UINT8   NumIOEntries;
  566.  
  567.     UINT8   ConfigIndex;
  568.     UINT8   ContainsDefaults;
  569.  
  570.     UINT8   IFacePresent;
  571.     UINT8   IFaceType;
  572.     UINT8   BVDActive;
  573.     UINT8   WPActive;
  574.     UINT8   ReadyActive;
  575.     UINT8   WaitRequired;
  576.  
  577.     UINT8   IOAccess;
  578.  
  579.     UINT8   NumIOAddrLines;
  580.     UINT8   Pad0;
  581. } PARSED_CFTABLE, * PPARSED_CFTABLE;
  582.  
  583. #pragma pack()
  584.  
  585. #endif
  586.