home *** CD-ROM | disk | FTP | other *** search
/ 98 Driver Collection MD-0164 / DRIVER_KING_98.iso / CPU / cyrix / CXID.C < prev    next >
Encoding:
C/C++ Source or Header  |  1997-01-21  |  4.9 KB  |  128 lines

  1. /*****************************************************************************
  2. *   Function:  main ()                                                       *
  3. *                                                                            *
  4. *   Purpose:   1) Display Cyrix CPU revision                                 *
  5. *              2) Display Cyrix FPU detection                                *
  6. *                                                                            *
  7. *   Parameters:   Nothing                                                    *
  8. *   Returns:      Nothing                                                    *
  9. *   Calls:                                                                   *
  10. *              is_cpuid_supported () - 1 if CPUID instruction supported      *
  11. *              cpu_type ()    - Returns int containing CPU identification    *
  12. *              isfpu()        - 1 if fpu is present, 0 if not                *
  13. *              iscyrixfpu()   - 1 if Cyrix fpu, 0 if not                     *
  14. *              get_cpuid_info () - execute CPUID instruction                 *
  15. *              is486()           - 1 if 486 CPU support available            *
  16. *              display_which_cyrix - print CPU type based on dir1 and dir0   *
  17. *****************************************************************************/            
  18. #include <stdio.h>
  19. #include <string.h>
  20. #include "cpu_type.h"
  21. #include "cx_funcs.h"            
  22.  
  23. #define TRUE      1
  24. #define FALSE     0
  25.  
  26. void main (int argc, char *argv[])
  27.    {
  28.    unsigned short x;
  29.    long cpuid_levels, reg_eax, reg_ebx, reg_edx, reg_ecx;
  30.    long vender[4];
  31.    unsigned char dir0, dir1;
  32.    int cpuid_supported;
  33.    unsigned int family, model, stepping;
  34.  
  35.    dir0 = UNKNOWN_VENDER;
  36.    cpuid_supported = FALSE;
  37.  
  38.    if ( is_cpuid_supported () )
  39.       {
  40.       cpuid_supported = TRUE;
  41.  
  42.       reg_eax = reg_ebx= reg_ecx = reg_edx =0;
  43.       get_cpuid_info (0, ®_eax, ®_ebx, ®_ecx, ®_edx);
  44.  
  45.       cpuid_levels = reg_eax;
  46.  
  47.       vender[0] = reg_ebx;
  48.       vender[1] = reg_edx;
  49.       vender[2] = reg_ecx;
  50.       vender[3] = 0;
  51.  
  52.       printf ("\n vender = %s",vender);
  53.       printf ("\n cpuid levels supported %ld",cpuid_levels);
  54.  
  55.       if (cpuid_levels > 0)
  56.          {
  57.          reg_eax = reg_ebx= reg_ecx = reg_edx =0;
  58.          get_cpuid_info (1, ®_eax, ®_ebx, ®_ecx, ®_edx);
  59.  
  60.          family   = (reg_eax & 0xf00) >> 8;
  61.          model    = (reg_eax & 0xf0) >> 4;
  62.          stepping =  reg_eax & 0xf;
  63.  
  64.          if ((strcmp ("CyrixInstead", (char *)vender) == 0))
  65.             {
  66.             if (family == 5)
  67.                printf ("\n Cyrix 6x86 CPU");
  68.  
  69.             if (family == 6)
  70.                printf ("\n Cyrix m2 CPU");
  71.  
  72.             }
  73.  
  74.          printf ("\n  family = %d, model = %d, stepping = %d", family,
  75.                                                              model,
  76.                                                              stepping);
  77.  
  78.          printf ("\n    FPU  %s",  reg_edx & 1        ? "yes": "no");
  79.          printf ("\n    VME  %s",  reg_edx & 2        ? "yes": "no");
  80.          printf ("\n    DE   %s",  reg_edx & 4        ? "yes": "no");
  81.          printf ("\n    PSE  %s",  reg_edx & 8        ? "yes": "no");
  82.          printf ("\n    TSE  %s",  reg_edx & 0x10     ? "yes": "no");
  83.          printf ("\n    MSR  %s",  reg_edx & 0x20     ? "yes": "no");
  84.          printf ("\n    PAE  %s",  reg_edx & 0x40     ? "yes": "no");
  85.          printf ("\n    MCE  %s",  reg_edx & 0x80     ? "yes": "no");
  86.          printf ("\n    CXS  %s",  reg_edx & 0x100    ? "yes": "no");
  87.          printf ("\n    APIC %s",  reg_edx & 0x200    ? "yes": "no");
  88.          printf ("\n    MTRR %s",  reg_edx & 0x1000   ? "yes": "no");
  89.          printf ("\n    PGE  %s",  reg_edx & 0x2000   ? "yes": "no");
  90.          printf ("\n    MCA  %s",  reg_edx & 0x4000   ? "yes": "no");
  91.          printf ("\n    CMOV %s",  reg_edx & 0x8000   ? "yes": "no");
  92.          printf ("\n    MMX  %s",  reg_edx & 0x800000 ? "yes": "no");
  93.          }
  94.  
  95.       }
  96.  
  97.    /* Check for need to use old Cyrix Detection Technique */
  98.    /* or is 'c' on command line forcing old detection     */
  99.    if ( (!cpuid_supported || *argv [1]=='c') && is486() && iscyrix() )                
  100.       {
  101.       /* We are going to use the old Cyrix Detection Method */
  102.       printf ("\n Cyrix CPU detected");
  103.       cpu_type(&dir0, &dir1);
  104.  
  105.       if (dir0 != UNKNOWN_VENDER)
  106.          printf ("\n Device ID Regs, dir0 = %x, dir1 = %x", dir0, dir1);
  107.  
  108.       display_which_cyrix (dir0, dir1);
  109.  
  110.       if (dir0 != UNKNOWN_VENDER && dir0 != Cx486S_a)
  111.          printf ("\n Step=%x, Rev=%x", (dir1 & 0xf0) >> 4, dir1 & 0x0f);
  112.       }
  113.  
  114.  
  115.    if (isfpu())
  116.       {
  117.       if (iscyrixfpu ())
  118.          printf ("\n Cyrix Coprocessor");
  119.       else
  120.          printf ("\n Other Coprocessor");
  121.       }
  122.    else
  123.       printf ("\n No Coprocessor");
  124.  
  125.    }
  126. /****************************************************************************/
  127.  
  128.