home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / windr440.zip / windrive.zip / WinDriver / samples / shared / isapnp_diag_lib.c < prev    next >
C/C++ Source or Header  |  2000-03-30  |  2KB  |  81 lines

  1. ////////////////////////////////////////////////////////////////
  2. // File - ISAPNP_DIAG_LIB.C
  3. //
  4. // Utility functions for printing card information,
  5. // detecting PCI cards, and accessing PCI configuration
  6. // registers.
  7. // 
  8. ////////////////////////////////////////////////////////////////
  9.  
  10. #include "../../include/windrvr.h"
  11. #ifdef _USE_SPECIFIC_KERNEL_DRIVER_
  12.     #undef WD_Open
  13.     #define WD_Open WD_OpenKernelHandle
  14.     #if defined(UNIX)
  15.         #undef WD_FUNCTION
  16.         #define WD_FUNCTION(wFuncNum,h,pParam,dwSize,fWait) ((ULONG) ioctl((int)(h), wFuncNum, pParam))
  17.     #endif
  18. #endif
  19. #include "print_struct.h"
  20. #include <stdio.h>
  21. #include "isapnp_diag_lib.h"
  22.  
  23. BOOL ISAPNP_Get_WD_handle(HANDLE *phWD)
  24. {
  25.     WD_VERSION ver;
  26.  
  27.     *phWD = WD_Open();
  28.  
  29.     // Check whether handle is valid and version OK
  30.     if (*phWD==INVALID_HANDLE_VALUE) 
  31.     {
  32.         printf("Failed opening " WD_PROD_NAME " device\n");
  33.         return FALSE;
  34.     }
  35.  
  36.     BZERO(ver);
  37.     WD_Version(*phWD,&ver);
  38.     if (ver.dwVer<WD_VER) 
  39.     {
  40.         printf("Incorrect " WD_PROD_NAME " version\n");
  41.         WD_Close (*phWD);
  42.         *phWD = INVALID_HANDLE_VALUE;
  43.         return FALSE;
  44.     }
  45.  
  46.     return TRUE;
  47. }
  48.  
  49. void ISAPNP_Print_all_cards_info()
  50. {
  51.     HANDLE hWD;
  52.     WD_ISAPNP_SCAN_CARDS scanCards;
  53.     WD_ISAPNP_CARD_INFO cardInfo;
  54.     DWORD i, j;
  55.  
  56.     if (!ISAPNP_Get_WD_handle (&hWD)) return;
  57.  
  58.     printf ("ISA PnP bus scan:\n\n");
  59.     BZERO(scanCards);
  60.     WD_IsapnpScanCards (hWD, &scanCards);
  61.     for (i=0; i<scanCards.dwCards; i++)
  62.     {
  63.         printf ("Card %d: %s\n", i, scanCards.Card[i].cIdent);
  64.         for (j=0; j<scanCards.Card[i].dwLogicalDevices; j++)
  65.         {
  66.             BZERO(cardInfo);
  67.             cardInfo.cardId = scanCards.Card[i].cardId;
  68.             cardInfo.dwLogicalDevice = j;
  69.             WD_IsapnpGetCardInfo(hWD, &cardInfo);
  70.             if (strlen(cardInfo.cIdent))
  71.                 printf ("Device %d: %s, ", j, cardInfo.cIdent);
  72.             printf ("Vendor ID: %s, ", scanCards.Card[i].cardId.cVendor );
  73.             printf ("Serial number: %x\n", scanCards.Card[i].cardId.dwSerial );
  74.             WD_CARD_print(&cardInfo.Card, "   ");
  75.             printf ("\n");
  76.         }
  77.     }
  78.     WD_Close (hWD);
  79. }
  80.  
  81.