home *** CD-ROM | disk | FTP | other *** search
/ PC User 1997 April / PCU_APR_97.ISO / utils / cpu / cpuinfo / source / cpuinf16 / cpuid.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-10-23  |  9.0 KB  |  285 lines

  1. /***************************************************************
  2. * C file:   cpuid.h... for cpuinf16 DLL
  3. *
  4. *       This program has been developed by Intel Corporation.  
  5. *        You have Intel's permission to incorporate this code 
  6. *       into your product, royalty free.  Intel has various 
  7. *        intellectual property rights which it may assert under
  8. *       certain circumstances, such as if another manufacturer's
  9. *       processor mis-identifies itself as being "GenuineIntel"
  10. *        when the CPUID instruction is executed.
  11. *
  12. *       Intel specifically disclaims all warranties, express or
  13. *       implied, and all liability, including consequential and
  14. *        other indirect damages, for the use of this code, 
  15. *        including liability for infringement of any proprietary
  16. *        rights, and including the warranties of merchantability
  17. *        and fitness for a particular purpose.  Intel does not 
  18. *        assume any responsibility for any errors which may 
  19. *        appear in this code nor any responsibility to update it.
  20. *
  21. *  * Other brands and names are the property of their respective
  22. *    owners.
  23. *
  24. *  Copyright (c) 1995, Intel Corporation.  All rights reserved.
  25. ***************************************************************/
  26.  
  27. #ifndef cpuid_h
  28. #define cpuid_h
  29.  
  30.  
  31.  
  32. // OPCODE DEFINITIONS //////////////////////////////////////////
  33. #define CPU_ID _asm _emit 0x0f _asm _emit 0xa2     
  34.                                         // CPUID instruction
  35.  
  36. #define RDTSC  _asm _emit 0x0f _asm _emit 0x31    
  37.                                         // RDTSC instruction
  38.  
  39. #define OPND32 _asm _emit 0x66    // Macro for allowing 32-bit 
  40.                                 //   in-line assembly opcodes
  41.  
  42.                                 
  43.                                 
  44. // VERSION DEFINITION //////////////////////////////////////////
  45. #define VERSION        0x0101        // Must be 2 bytes in length. 
  46.                                 //   First two digits (upper 
  47.                                 //   byte) is the major version.
  48.                                 //   Second two digits (lower
  49.                                 //   byte) is the minor version.
  50.                                 //   i.e. 0x0100  = major version
  51.                                 //   of 1 and minor version 00.
  52.                                 
  53.                                 
  54.                                 
  55. // VARIABLE STRUCTURE DEFINITIONS //////////////////////////////
  56. struct TIME_STAMP
  57. {
  58.     DWORD High;                    // Upper 32-bits of Time Stamp
  59.                                 //   Register value
  60.     
  61.     DWORD Low;                    // Lower 32-bits of Time Stamp
  62. };                                //   Register value
  63.  
  64.  
  65.  
  66. // Public Functions ////////////////////////////////////////////
  67.  
  68. /***************************************************************
  69. * WORD FAR PASCAL wincpuidsupport()
  70. * =================================
  71. * Wincpuidsupport() tells the caller whether the host processor
  72. * supports the CPUID opcode or not.
  73. *
  74. * Inputs: none
  75. *
  76. * Returns:
  77. *  1 = CPUID opcode is supported
  78. *  0 = CPUID opcode is not supported
  79. ***************************************************************/
  80.  
  81. WORD FAR PASCAL _export wincpuidsupport();
  82.  
  83.  
  84. /***************************************************************
  85. * WORD FAR PASCAL wincpuid()
  86. * ========================
  87. * This routine uses the standard Intel assembly code to 
  88. * determine what type of processor is in the computer, as
  89. * described in application note AP-485 (Intel Order #241618).
  90. * Wincpuid() returns the CPU type as an integer (that is, 
  91. * 2 bytes, a WORD) in the AX register.
  92. *
  93. * Returns:
  94. *  0 = 8086/88
  95. *  2 = 80286
  96. *  3 = 80386
  97. *  4 = 80486
  98. *  5 = Pentium(R) Processor
  99. *  6 = PentiumPro(R) Processor
  100. *  7 or higher = Processor beyond the PentiumPro6(R) Processor
  101. *
  102. *  Note: This function also sets the global variable clone_flag
  103. ***************************************************************/
  104. WORD FAR PASCAL _export wincpuid();
  105.  
  106.  
  107. /***************************************************************
  108. * WORD FAR PASCAL wincpuidext()
  109. * =============================
  110. * Similar to wincpuid(), but returns more data, in the order
  111. * reflecting the actual output of a CPUID instruction execution:
  112. *
  113. * Inputs: none
  114. *
  115. * Returns:
  116. * AX(15:14) = Reserved (mask these off in the calling code 
  117. *                before using)
  118. * AX(13:12) = Processor type (00=Standard OEM CPU, 01=OverDrive,
  119. *                10=Dual CPU, 11=Reserved)
  120. * AX(11:8)  = CPU Family (the same 4-bit quantity as wincpuid())
  121. * AX(7:4)   = CPU Model, if the processor supports the CPUID 
  122. *                opcode; zero otherwise
  123. * AX(3:0)   = Stepping #, if the processor supports the CPUID 
  124. *                opcode; zero otherwise
  125. *
  126. *  Note: This function also sets the global variable clone_flag
  127. ***************************************************************/
  128. WORD FAR PASCAL _export wincpuidext();
  129.  
  130.  
  131. /***************************************************************
  132. * DWORD FAR PASCAL wincpufeatures()
  133. * ===============================
  134. * Wincpufeatures() returns the CPU features flags as a DWORD 
  135. *    (that is, 32 bits).
  136. *
  137. * Returns:
  138. *   0 = Processor which does not execute the CPUID instruction.
  139. *          This includes 8086, 8088, 80286, 80386, and some 
  140. *           older 80486 processors.                       
  141. *
  142. * Else
  143. *   Feature Flags (refer to App Note AP-485 for description).
  144. *      This DWORD was put into EDX by the CPUID instruction.
  145. *
  146. *    Current flag assignment is as follows:
  147. *
  148. *        bit31..10   reserved (=0)
  149. *        bit9=1      CPU contains a local APIC (iPentium-3V)
  150. *        bit8=1      CMPXCHG8B instruction supported
  151. *        bit7=1      machine check exception supported
  152. *        bit6=0      reserved (36bit-addressing & 2MB-paging)
  153. *        bit5=1      iPentium-style MSRs supported
  154. *        bit4=1      time stamp counter TSC supported
  155. *        bit3=1      page size extensions supported
  156. *        bit2=1      I/O breakpoints supported
  157. *        bit1=1      enhanced virtual 8086 mode supported
  158. *        bit0=1      CPU contains a floating-point unit (FPU)
  159. *
  160. *    Note: New bits will be assigned on future processors... see
  161. *         processor data books for updated information
  162. *
  163. *    Note: This function also sets the global variable clone_flag
  164. ***************************************************************/
  165. DWORD FAR PASCAL _export wincpufeatures();
  166.  
  167.  
  168. /***************************************************************
  169. * struct FAR PASCAL TIME_STAMP winrdtsc()
  170. * =======================================
  171. * Winrdtsc() returns the value in the Time Stamp Counter (if one
  172. * exists).
  173. *
  174. * Inputs: none
  175. *
  176. * Returns:
  177. *   0 = CPU does not support the time stamp register
  178. *
  179. * Else
  180. *   Returns a variable of type TIME_STAMP which is composed of 
  181. *      two DWORD variables. The 'High' DWORD contains the upper
  182. *      32-bits of the Time Stamp Register. The 'Low' DWORD 
  183. *      contains the lower 32-bits of the Time Stamp Register.
  184. *
  185. *  Note: This function also sets the global variable clone_flag
  186. ***************************************************************/
  187. struct TIME_STAMP FAR PASCAL _export winrdtsc();
  188.  
  189.  
  190. /***************************************************************
  191. * unsigned short FAR PASCAL getdllversion()
  192. * =========================================
  193. * Getdllversion() returns the Major and minor version of this
  194. * DLL.
  195. *
  196. * Inputs: none
  197. *
  198. * Returns:  Major and Minor version of this DLL.
  199. *         
  200. *        i.e.    getdllversion() = 0x01 00
  201. *                      Major Version<--|-->Minor Version
  202. *            
  203. ***************************************************************/
  204. unsigned short FAR PASCAL _export getdllversion(void);
  205.  
  206.  
  207. // Private Function Declarations ///////////////////////////////
  208.  
  209. /***************************************************************
  210. * check_clone()
  211. *
  212. * Inputs: none
  213. *
  214. * Returns:
  215. *   1      if processor is clone (limited detection ability)
  216. *   0      otherwise
  217. ***************************************************************/
  218. static WORD check_clone();
  219.  
  220.  
  221. /***************************************************************
  222. * check_8086()
  223. *
  224. * Inputs: none
  225. *
  226. * Returns: 
  227. *   0      if processor 8086
  228. *   0xffff otherwise
  229. ***************************************************************/
  230. static WORD check_8086();
  231.  
  232.  
  233. /***************************************************************
  234. * check_80286()
  235. *
  236. * Inputs: none
  237. *
  238. * Returns:
  239. *   2      if processor 80286
  240. *   0xffff otherwise
  241. ***************************************************************/
  242. static WORD check_80286();
  243.  
  244.  
  245. /***************************************************************
  246. * check_80386()
  247. *
  248. * Inputs: none
  249. *
  250. * Returns:
  251. *   3      if processor 80386
  252. *   0xffff otherwise
  253. ***************************************************************/
  254. static WORD check_80386();
  255.  
  256.  
  257. /***************************************************************
  258. * check_80486()
  259. *
  260. * Inputs: none
  261. *
  262. * Returns:
  263. *   4      if processor 80486
  264. *   0xffff otherwise
  265. ***************************************************************/
  266. static WORD check_80486();
  267.  
  268.  
  269. /***************************************************************
  270. * static WORD check_IDProc()
  271. * ==========================
  272. * Check_IDProc() uses the CPUID opcode to find the family type
  273. * of the host processor.
  274. *
  275. * Inputs: none
  276. *
  277. * Returns:
  278. *  CPU Family (i.e. 4 if Intel 486, 5 if Pentium(R) Processor)
  279. *
  280. *  Note: This function also sets the global variable clone_flag
  281. ***************************************************************/
  282. static WORD check_IDProc();
  283.  
  284. #endif cpuid_h
  285.