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

  1. /***************************************************************
  2. * C file:   cpuid.h... for cpuinf32 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.  
  40. // VERSION DEFINITION //////////////////////////////////////////
  41. #define VERSION        0x0101        // Must be 2 bytes in length. 
  42.                                 //   First two digits (upper 
  43.                                 //   byte) is the major version.
  44.                                 //   Second two digits (lower
  45.                                 //   byte) is the minor version.
  46.                                 //   i.e. 0x0100  = major version
  47.                                 //   of 1 and minor version 00.
  48.  
  49.  
  50.  
  51. // VARIABLE STRUCTURE DEFINITIONS //////////////////////////////
  52. struct TIME_STAMP
  53. {
  54.     DWORD High;                    // Upper 32-bits of Time Stamp
  55.                                 //   Register value
  56.     
  57.     DWORD Low;                    // Lower 32-bits of Time Stamp
  58. };                                //   Register value
  59.  
  60.  
  61.  
  62. // Function Prototypes /////////////////////////////////////////
  63.  
  64. /***************************************************************
  65. * WORD wincpuidsupport()
  66. * =================================
  67. * Wincpuidsupport() tells the caller whether the host processor
  68. * supports the CPUID opcode or not.
  69. *
  70. * Inputs: none
  71. *
  72. * Returns:
  73. *  1 = CPUID opcode is supported
  74. *  0 = CPUID opcode is not supported
  75. ***************************************************************/
  76.  
  77. WORD wincpuidsupport();
  78.  
  79.  
  80. /***************************************************************
  81. * WORD wincpuid()
  82. * ===============
  83. * This routine uses the standard Intel assembly code to 
  84. * determine what type of processor is in the computer, as
  85. * described in application note AP-485 (Intel Order #241618).
  86. * Wincpuid() returns the CPU type as an integer (that is, 
  87. * 2 bytes, a WORD) in the AX register.
  88. *
  89. * Returns:
  90. *  0 = 8086/88
  91. *  2 = 80286
  92. *  3 = 80386
  93. *  4 = 80486
  94. *  5 = Pentium(R) Processor
  95. *  6 = PentiumPro(R) Processor
  96. *  7 or higher = Processor beyond the PentiumPro6(R) Processor
  97. *
  98. *  Note: This function also sets the global variable clone_flag
  99. ***************************************************************/
  100. WORD  wincpuid();
  101.  
  102.  
  103. /***************************************************************
  104. * WORD wincpuidext()
  105. * ==================
  106. * Similar to wincpuid(), but returns more data, in the order
  107. * reflecting the actual output of a CPUID instruction execution:
  108. *
  109. * Returns:
  110. * AX(15:14) = Reserved (mask these off in the calling code 
  111. *                before using)
  112. * AX(13:12) = Processor type (00=Standard OEM CPU, 01=OverDrive,
  113. *                10=Dual CPU, 11=Reserved)
  114. * AX(11:8)  = CPU Family (the same 4-bit quantity as wincpuid())
  115. * AX(7:4)   = CPU Model, if the processor supports the CPUID 
  116. *                opcode; zero otherwise
  117. * AX(3:0)   = Stepping #, if the processor supports the CPUID 
  118. *                opcode; zero otherwise
  119. *
  120. *  Note: This function also sets the global variable clone_flag
  121. ***************************************************************/
  122. WORD  wincpuidext();
  123.  
  124.  
  125. /***************************************************************
  126. * DWORD wincpufeatures()
  127. * ======================
  128. * Wincpufeatures() returns the CPU features flags as a DWORD 
  129. *    (that is, 32 bits).
  130. *
  131. * Inputs: none
  132. *
  133. * Returns:
  134. *   0 = Processor which does not execute the CPUID instruction.
  135. *          This includes 8086, 8088, 80286, 80386, and some 
  136. *           older 80486 processors.                       
  137. *
  138. * Else
  139. *   Feature Flags (refer to App Note AP-485 for description).
  140. *      This DWORD was put into EDX by the CPUID instruction.
  141. *
  142. *    Current flag assignment is as follows:
  143. *
  144. *        bit31..10   reserved (=0)
  145. *        bit9=1      CPU contains a local APIC (iPentium-3V)
  146. *        bit8=1      CMPXCHG8B instruction supported
  147. *        bit7=1      machine check exception supported
  148. *        bit6=0      reserved (36bit-addressing & 2MB-paging)
  149. *        bit5=1      iPentium-style MSRs supported
  150. *        bit4=1      time stamp counter TSC supported
  151. *        bit3=1      page size extensions supported
  152. *        bit2=1      I/O breakpoints supported
  153. *        bit1=1      enhanced virtual 8086 mode supported
  154. *        bit0=1      CPU contains a floating-point unit (FPU)
  155. *
  156. *    Note: New bits will be assigned on future processors... see
  157. *         processor data books for updated information
  158. *
  159. *    Note: This function also sets the global variable clone_flag
  160. ***************************************************************/
  161. DWORD wincpufeatures();
  162.  
  163.  
  164. /***************************************************************
  165. * struct TIME_STAMP winrdtsc()
  166. * ============================
  167. * Winrdtsc() returns the value in the Time Stamp Counter (if one
  168. * exists).
  169. *
  170. * Inputs: none
  171. *
  172. * Returns:
  173. *   0 = CPU does not support the time stamp register
  174. *
  175. * Else
  176. *   Returns a variable of type TIME_STAMP which is composed of 
  177. *      two DWORD variables. The 'High' DWORD contains the upper
  178. *      32-bits of the Time Stamp Register. The 'Low' DWORD 
  179. *      contains the lower 32-bits of the Time Stamp Register.
  180. *
  181. *  Note: This function also sets the global variable clone_flag
  182. ***************************************************************/
  183. struct TIME_STAMP winrdtsc();
  184.  
  185.  
  186. /***************************************************************
  187. * unsigned short getdllversion()
  188. * ==============================
  189. * Getdllversion() returns the Major and minor version of this
  190. * DLL.
  191. *
  192. * Inputs: none
  193. *
  194. * Returns:  Major and Minor version of this DLL.
  195. *         
  196. *        i.e.    getdllversion() = 0x01 00
  197. *                      Major Version<--|-->Minor Version
  198. *            
  199. ***************************************************************/
  200. unsigned short getdllversion(void);
  201.  
  202.  
  203.  
  204. // Private Function Declarations ///////////////////////////////
  205.  
  206. /***************************************************************
  207. * static WORD check_clone()
  208. *
  209. * Inputs: none
  210. *
  211. * Returns:
  212. *   1      if processor is clone (limited detection ability)
  213. *   0      otherwise
  214. ***************************************************************/
  215. static WORD check_clone();
  216.  
  217.  
  218. /***************************************************************
  219. * static WORD check_8086()
  220. *
  221. * Inputs: none
  222. *
  223. * Returns: 
  224. *   0      if processor 8086
  225. *   0xffff otherwise
  226. ***************************************************************/
  227. static WORD check_8086();
  228.  
  229.  
  230. /***************************************************************
  231. * static WORD check_80286()
  232. *
  233. * Inputs: none
  234. *
  235. * Returns:
  236. *   2      if processor 80286
  237. *   0xffff otherwise
  238. ***************************************************************/
  239. static WORD check_80286();
  240.  
  241.  
  242. /***************************************************************
  243. * static WORD check_80386()
  244. *
  245. * Inputs: none
  246. *
  247. * Returns:
  248. *   3      if processor 80386
  249. *   0xffff otherwise
  250. ***************************************************************/
  251. static WORD check_80386();
  252.  
  253.  
  254. /***************************************************************
  255. * static WORD check_IDProc()
  256. * ==========================
  257. * Check_IDProc() uses the CPUID opcode to find the family type
  258. * of the host processor.
  259. *
  260. * Inputs: none
  261. *
  262. * Returns:
  263. *  CPU Family (i.e. 4 if Intel 486, 5 if Pentium(R) Processor)
  264. *
  265. *  Note: This function also sets the global variable clone_flag
  266. ***************************************************************/
  267. static WORD check_IDProc();
  268.  
  269. #endif cpuid_h
  270.