home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / videotlk.zip / SAMPLES / DIAG / OEM.C < prev    next >
Text File  |  1998-06-24  |  14KB  |  401 lines

  1. #include    <stdio.h>
  2. #include    <string.h>
  3. #include    <stdlib.h>
  4. #include    <conio.h>
  5. #include    <doscalls.h>
  6.  
  7.  
  8. //  *********************
  9. //  STATIC FUNCTIONS ONLY
  10. //  *********************
  11.  
  12. typedef unsigned char   UCHAR;
  13. typedef unsigned short  USHORT;
  14. typedef unsigned int    UINT;
  15. typedef unsigned long   ULONG;
  16. typedef unsigned long   RC;
  17. typedef char            CHAR;
  18. typedef char            BYTE;
  19. typedef short           SHORT;
  20. typedef int             INT;
  21. typedef long            LONG;
  22. typedef UCHAR near    *PUCHAR;
  23. typedef UCHAR far    *FPUCHAR;
  24. typedef USHORT near   *PUSHORT;
  25. typedef ULONG near    *PULONG;
  26. typedef char near     *PCHAR;
  27. typedef short near    *PSHORT;
  28. typedef long near     *PLONG;
  29. typedef void near     *POINTER;
  30. typedef POINTER near *PPOINTER;
  31. typedef far           FAR;
  32. typedef far             *FARPOINTER;
  33. typedef FARPOINTER near *PFARPOINTER;
  34. typedef FARPOINTER far *FPFARPOINTER;
  35. #define VOID        void
  36. #define TRUE    (1)
  37. #define FALSE   (0)
  38.  
  39. #include "oem.h"
  40.  
  41. static USHORT oem_open (VOID);
  42. static USHORT oem_ioctl (UCHAR *buffer, UCHAR *param,
  43.                        unsigned funct, unsigned cat);
  44. static USHORT oem_screen_open (VOID);
  45. static USHORT oem_screen_ioctl (UCHAR *buffer, UCHAR *param,
  46.                                 unsigned funct, unsigned cat);
  47. static FILE  *Oem_fd;
  48. static FILE  *Screen_fd;
  49.  
  50. VOID oem_info (OEM *oem)
  51. {
  52.  struct oem0
  53.  {
  54.     UCHAR oem_name[20];
  55.     UCHAR oem_revision[10];
  56.     UCHAR spare[40];
  57.  } oem0;
  58. /*
  59.  struct oem1
  60.  {
  61.     UCHAR oem_man_name[20];
  62.     UCHAR oem_model[10];
  63.     UCHAR oem_rom_revision[10];
  64.     UCHAR spare[40];
  65.  } oem1;
  66. */
  67.  struct oem8
  68.  {
  69.     USHORT oem_adapter;
  70.     USHORT oem_chip_type;
  71.     ULONG  oem_ram_size;
  72.     UCHAR spare[40];
  73.  } oem8;
  74.  struct screenB
  75.  {
  76.     ULONG oem_screen_packetlen;
  77.     ULONG oem_screen_physical;
  78.     ULONG oem_screen_aperturesize;
  79.     ULONG oem_screen_linearaddr;
  80.     ULONG oem_screen_linearflags;
  81.  } screenB1;
  82.  UCHAR unknown_chip_type [20];
  83.  int    count;
  84.  
  85.         if (!oem_open ())
  86.             return;
  87.         if (!oem_screen_open ())
  88.             return;
  89.  
  90.         oem_ioctl ((UCHAR *)&oem0, NULL, 0, 0x80);
  91.         sprintf (oem->oem_name, "%s", oem0.oem_name);
  92.  
  93. /*
  94.         oem_ioctl ((UCHAR *)&oem1, NULL, 1, 0x80);
  95.         printf ("OEM Manufacturer Name %20.20s Model %10.10s Rev. %10.10s\n",
  96.                   oem1.oem_man_name, oem1.oem_model, oem1.oem_rom_revision);
  97. */
  98.  
  99.         oem_ioctl ((UCHAR *)&oem8, NULL, 8, 0x80);
  100.         sprintf (unknown_chip_type, "Unknown (%d)", oem8.oem_chip_type);
  101.         switch (oem8.oem_adapter)
  102.         {
  103.             case 0 :
  104.                 sprintf (oem->oem_hw,
  105.                      "VGA Adapter Indeterminate chip type %d",
  106.                      oem8.oem_chip_type);
  107.                 break;
  108.  
  109.             case 1 :
  110.                 sprintf (oem->oem_hw, "Headland Technology Inc. chip type %s",
  111.                      (oem8.oem_chip_type == 1) ? "HT205" :
  112.                      (oem8.oem_chip_type == 2) ? "HT208" :
  113.                      (oem8.oem_chip_type == 3) ? "HT209" : unknown_chip_type);
  114.                 break;
  115.  
  116.             case 2 :
  117.                 sprintf (oem->oem_hw, "Trident MicroSystems chip type %s",
  118.                      (oem8.oem_chip_type == 1) ? "8800" :
  119.                      (oem8.oem_chip_type == 2) ? "8900" : unknown_chip_type);
  120.                 break;
  121.  
  122.             case 3 :
  123.                 sprintf (oem->oem_hw, "Tseng Labs chip type %s",
  124.                      (oem8.oem_chip_type == 1) ? "ET3000" :
  125.                      (oem8.oem_chip_type == 2) ? "ET4000" :
  126.                      (oem8.oem_chip_type == 3) ? "ET4000W32" :
  127.                      (oem8.oem_chip_type == 4) ? "ET4000W32I" :
  128.                      (oem8.oem_chip_type == 5) ? "ET4000W32IB" :
  129.                      (oem8.oem_chip_type == 6) ? "ET4000W32IC" :
  130.                      (oem8.oem_chip_type == 7) ? "ET4000W32PA" :
  131.                      (oem8.oem_chip_type == 8) ? "ET4000W32PB" :
  132.                      (oem8.oem_chip_type == 9) ? "ET4000W32PC" :
  133.                      (oem8.oem_chip_type ==10) ? "ET4000W32ID" :
  134.                      (oem8.oem_chip_type ==11) ? "ET4000W32PD" :
  135.                      (oem8.oem_chip_type ==12) ? "ET4000W32PX" :
  136.                                                   unknown_chip_type);
  137.                 break;
  138.  
  139.             case 4 :
  140.                 sprintf (oem->oem_hw, "Western Digital chip type %s",
  141.                      (oem8.oem_chip_type == 1) ? "PVGA1A" :
  142.                      (oem8.oem_chip_type == 2) ? "WD9000" :
  143.                      (oem8.oem_chip_type == 3) ? "WD9011" :
  144.                      (oem8.oem_chip_type == 4) ? "WD9030" :
  145.                      (oem8.oem_chip_type == 5) ? "WD9026" :
  146.                      (oem8.oem_chip_type == 6) ? "WD9027" :
  147.                      (oem8.oem_chip_type == 7) ? "WD9031" :
  148.                      (oem8.oem_chip_type == 8) ? "WD9024" :
  149.                      (oem8.oem_chip_type == 9) ? "WD9033" : unknown_chip_type);
  150.                 break;
  151.  
  152.             case 5 :
  153.                 sprintf (oem->oem_hw, "ATI Technologies chip type %s",
  154.                      (oem8.oem_chip_type == 1) ? "VGAWONDER" :
  155.                      (oem8.oem_chip_type == 2) ? "VGAWONDER+XT" :
  156.                      (oem8.oem_chip_type == 3) ? "MACH8 Graphics Ultra" :
  157.                      (oem8.oem_chip_type == 4) ? "MACH32 Graphics Ultra Pro" :
  158.                      (oem8.oem_chip_type == 5) ? "MACH64" :
  159.                      (oem8.oem_chip_type == 6) ? "MACH64CT" :
  160.                                                           unknown_chip_type);
  161.                 break;
  162.  
  163.             case 6 :
  164.                 sprintf (oem->oem_hw, "IBM Technologies chip type");
  165.                 break;
  166.  
  167.             case 7 :
  168.                 sprintf (oem->oem_hw, "Cirrus Logic chip type %s",
  169.                      (oem8.oem_chip_type == 1) ? "5420" :
  170.                      (oem8.oem_chip_type == 2) ? "5422" :
  171.                      (oem8.oem_chip_type == 3) ? "5424" :
  172.                      (oem8.oem_chip_type == 4) ? "5426" :
  173.                      (oem8.oem_chip_type == 5) ? "5428" :
  174.                      (oem8.oem_chip_type == 6) ? "5429" :
  175.                      (oem8.oem_chip_type == 7) ? "543x" :
  176.                      (oem8.oem_chip_type == 8) ? "5434" :
  177.                      (oem8.oem_chip_type == 9) ? "6235" :
  178.                                                           unknown_chip_type);
  179.                 break;
  180.  
  181.             case 8 :
  182.                 sprintf (oem->oem_hw, "S3 chip type %s",
  183.                      (oem8.oem_chip_type == 1) ? "86C805" :
  184.                      (oem8.oem_chip_type == 2) ? "86C928" :
  185.                      (oem8.oem_chip_type == 3) ? "86C911" :
  186.                      (oem8.oem_chip_type == 4) ? "86C864" :
  187.                      (oem8.oem_chip_type == 5) ? "86C964" :
  188.                      (oem8.oem_chip_type == 6) ? "86C868" :
  189.                      (oem8.oem_chip_type == 7) ? "86C968" :
  190.                      (oem8.oem_chip_type == 8) ? "86C732" :
  191.                      (oem8.oem_chip_type == 9) ? "86C764" :
  192.                      (oem8.oem_chip_type == 10) ? "86C765" :
  193.                      (oem8.oem_chip_type == 11) ? "Aurora64V" :
  194.                      (oem8.oem_chip_type == 12) ? "ViRGE" :
  195.                      (oem8.oem_chip_type == 13) ? "ViRGE/vX" :
  196.                      (oem8.oem_chip_type == 14) ? "Trio64UV+" :
  197.                      (oem8.oem_chip_type == 15) ? "Trio64V+" :
  198.                      (oem8.oem_chip_type == 16) ? "86C924" :
  199.                      (oem8.oem_chip_type == 17) ? "86C866" :
  200.                      (oem8.oem_chip_type == 18) ? "86C928 PCI" :
  201.                                                           unknown_chip_type);
  202.                 break;
  203.  
  204.             case 9 :
  205.                 sprintf (oem->oem_hw, "Chips & Technology chip type %x",
  206.                      oem8.oem_chip_type);
  207.                 break;
  208.  
  209.             case 10 :
  210.                 sprintf (oem->oem_hw, "Weitek chip type %s",
  211.                      (oem8.oem_chip_type == 1) ? "P9000" :
  212.                      (oem8.oem_chip_type == 2) ? "W5186" :
  213.                      (oem8.oem_chip_type == 3) ? "W5286" :
  214.                      (oem8.oem_chip_type == 4) ? "P9100" : unknown_chip_type);
  215.                 break;
  216.  
  217.             case 11 :
  218.                 sprintf (oem->oem_hw, "Number 9 chip type %x",
  219.                      oem8.oem_chip_type);
  220.                 break;
  221.  
  222.             case 12 :
  223.                 sprintf (oem->oem_hw, "Generic PCI SVGA chip type %x",
  224.                      oem8.oem_chip_type);
  225.                 break;
  226.  
  227.             case 13 :
  228.                 sprintf (oem->oem_hw, "OAK Technologies chip type %x",
  229.                      oem8.oem_chip_type);
  230.                 break;
  231.  
  232.             case 14 :
  233.                 sprintf (oem->oem_hw, "Matrox chip type %x",
  234.                      oem8.oem_chip_type);
  235.                 break;
  236.  
  237.             case 15 :
  238.                 sprintf (oem->oem_hw, "Brooktree chip type %x",
  239.                      oem8.oem_chip_type);
  240.                 break;
  241.  
  242.             case 16 :
  243.                 sprintf (oem->oem_hw, "NVidia chip type %x",
  244.                      oem8.oem_chip_type);
  245.                 break;
  246.  
  247.             case 17 :
  248.                 sprintf (oem->oem_hw, "Alliance chip type %x",
  249.                      oem8.oem_chip_type);
  250.                 break;
  251.  
  252.             case 18 :
  253.                 sprintf (oem->oem_hw, "Avance chip type %x",
  254.                      oem8.oem_chip_type);
  255.                 break;
  256.  
  257.             case 19 :
  258.                 sprintf (oem->oem_hw, "Mediavision chip type %x",
  259.                      oem8.oem_chip_type);
  260.                 break;
  261.  
  262.             case 20 :
  263.                 sprintf (oem->oem_hw, "Ark Logic chip type %x",
  264.                      oem8.oem_chip_type);
  265.                 break;
  266.  
  267.             case 21 :
  268.                 sprintf (oem->oem_hw, "Radius chip type %x",
  269.                      oem8.oem_chip_type);
  270.                 break;
  271.  
  272.             case 22 :
  273.                 sprintf (oem->oem_hw, "3D Labs chip type %x",
  274.                      oem8.oem_chip_type);
  275.                 break;
  276.  
  277.             case 23 :
  278.                 sprintf (oem->oem_hw, "NCR chip type %x",
  279.                      oem8.oem_chip_type);
  280.                 break;
  281.  
  282.             case 24 :
  283.                 sprintf (oem->oem_hw, "IIT chip type %x",
  284.                      oem8.oem_chip_type);
  285.                 break;
  286.  
  287.             case 25 :
  288.                 sprintf (oem->oem_hw, "Appian chip type %x",
  289.                      oem8.oem_chip_type);
  290.                 break;
  291.  
  292.             case 26 :
  293.                 sprintf (oem->oem_hw, "Sierra chip type %x",
  294.                      oem8.oem_chip_type);
  295.                 break;
  296.  
  297.             case 27 :
  298.                 sprintf (oem->oem_hw, "Cornerstone chip type %x",
  299.                      oem8.oem_chip_type);
  300.                 break;
  301.  
  302.             case 28 :
  303.                 sprintf (oem->oem_hw, "Digital chip type %x",
  304.                      oem8.oem_chip_type);
  305.                 break;
  306.  
  307.             case 29 :
  308.                 sprintf (oem->oem_hw, "Compaq chip type %x",
  309.                      oem8.oem_chip_type);
  310.                 break;
  311.  
  312.             case 30 :
  313.                 sprintf (oem->oem_hw, "Infotronic chip type %x",
  314.                      oem8.oem_chip_type);
  315.                 break;
  316.  
  317.             case 31 :
  318.                 sprintf (oem->oem_hw, "Opti chip type %x",
  319.                      oem8.oem_chip_type);
  320.                 break;
  321.  
  322.             case 32 :
  323.                 sprintf (oem->oem_hw, "NULL chip type %x",
  324.                      oem8.oem_chip_type);
  325.                 break;
  326.             default :
  327.                 sprintf (oem->oem_hw, "Unknown adapter %x chip type %x",
  328.                      oem8.oem_adapter,
  329.                      oem8.oem_chip_type);
  330.                 break;
  331.  
  332.         }
  333.         oem->oem_ram = oem8.oem_ram_size;
  334.  
  335.  
  336.         // Get screen information
  337.         screenB1.oem_screen_packetlen = sizeof (screenB1);
  338.         screenB1.oem_screen_physical = 0xA0000;
  339.         screenB1.oem_screen_aperturesize = 0x10000;
  340.         screenB1.oem_screen_linearaddr = 0;
  341.         screenB1.oem_screen_linearflags = 0x410;
  342.  
  343.         oem_screen_ioctl (NULL, (UCHAR *)&screenB1, 0xB, 0x80);
  344.  
  345.         oem->oem_screen_packetlen        = screenB1.oem_screen_packetlen;
  346.         oem->oem_screen_physical         = screenB1.oem_screen_physical;
  347.         oem->oem_screen_aperturesize     = screenB1.oem_screen_aperturesize;
  348.         oem->oem_screen_linearaddr       = screenB1.oem_screen_linearaddr;
  349.         oem->oem_screen_linearflags      = screenB1.oem_screen_linearflags;
  350. }
  351.  
  352. static USHORT oem_ioctl (UCHAR *buffer, UCHAR *param,
  353.                        unsigned funct, unsigned cat)
  354. {
  355.         if (!Oem_fd)
  356.             return TRUE;
  357.         return DOSDEVIOCTL (buffer, NULL, funct, cat, Oem_fd);
  358. }
  359.  
  360.  
  361. static USHORT oem_screen_ioctl (UCHAR *buffer, UCHAR *param,
  362.                                 unsigned funct, unsigned cat)
  363. {
  364.         if (!Screen_fd)
  365.             return TRUE;
  366.         return DOSDEVIOCTL (buffer, param, funct, cat, Screen_fd);
  367. }
  368.  
  369.  
  370. static USHORT oem_open ()
  371. {
  372.  USHORT result, x, mode;
  373.  
  374.         mode  = 0x42;       // shared open read/write
  375.         mode |= 0x80;       // handle inherited
  376.         x = DOSOPEN ("OEMHLP$", &Oem_fd, &result, 0L, 0, 1, mode, 0L);
  377.         if (x != 0)
  378.         {
  379.                 Oem_fd = NULL;
  380.                 return FALSE;
  381.         }
  382.         return TRUE;
  383. }
  384.  
  385.  
  386. static USHORT oem_screen_open ()
  387. {
  388.  USHORT result, x, mode;
  389.  
  390.         mode  = 0x42;       // shared open read/write
  391.         mode |= 0x80;       // handle inherited
  392.         x = DOSOPEN ("SCREEN$", &Screen_fd, &result, 0L, 0, 1, mode, 0L);
  393.         if (x != 0)
  394.         {
  395.                 Screen_fd = NULL;
  396.                 return FALSE;
  397.         }
  398.         return TRUE;
  399. }
  400.  
  401.