home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ddrivers.zip / MMAP / TEST32.C < prev    next >
C/C++ Source or Header  |  1992-12-29  |  2KB  |  74 lines

  1. #define INCL_DOS
  2. #include <os2.h>
  3.  
  4. #define  EABUF       0L
  5. #define  OUR_CAT  0x91L
  6. #define  BUS_TYPE 0x01L
  7. #define  GET_PTR  0x02L
  8. #define  GET_POS  0x03L
  9.  
  10. typedef struct _ADDR_STRUCT {
  11.     void     * _Seg16 mapped_addr;
  12.     ULONG    board_addr;
  13.     } ADDR_STRUCT;
  14. typedef ADDR_STRUCT *PADDR_STRUCT;
  15.  
  16.  
  17. char     buf[100] = {0};
  18. USHORT   BytesRead;
  19. ULONG    ActionTaken;               /* for file opens                      */
  20. APIRET   rc;                        /* return code for driver open         */
  21. ULONG    FileSize=0;                /* NULL file size                      */
  22. ULONG    FileAttribute;             /* attribute bits                      */
  23. HFILE    handle=0;
  24. UCHAR    parmbuf [20];
  25. UCHAR    databuf[20];
  26. ULONG    plength,dlength;
  27. PADDR_STRUCT paddr_ptr;
  28. UCHAR    * _Seg16 myptr;
  29.  
  30. main()
  31. {
  32.     rc = DosOpen("MMAP$   ",
  33.     &handle,
  34.     &ActionTaken,
  35.     FileSize,
  36.     FileAttribute,
  37.     OPEN_ACTION_OPEN_IF_EXISTS,
  38.     OPEN_ACCESS_READWRITE | OPEN_SHARE_DENYNONE | OPEN_FLAGS_NOINHERIT, 
  39.     EABUF);
  40.       if (rc) {
  41.         printf("\nDosOpen failed, error = %ld",rc);
  42.         DosExit(EXIT_PROCESS,0);    /* exit gracefully                     */
  43.        }
  44.  
  45.      printf ("Bus Type              = ");
  46.  
  47.      rc = DosDevIOCtl(handle,OUR_CAT,BUS_TYPE,0,0L,&plength,databuf,8L,&dlength);
  48.  
  49.      if (rc & 0x01)
  50.         printf ("Micro Channel (tm)\n");
  51.      else
  52.         printf ("ISA\n");
  53.  
  54.      rc = DosDevIOCtl(handle,OUR_CAT,GET_PTR,0,0L,&plength,databuf,8L,&dlength); 
  55.  
  56.     if (rc)
  57.      {
  58.       printf ("DevIOCtl failed, error code = %ld\n",rc);
  59.         DosExit(EXIT_PROCESS,0);
  60.      }    
  61.  
  62.     paddr_ptr = (PADDR_STRUCT) databuf;
  63.  
  64.      printf ("Memory Mapped Address = %p\nPhysical Address      = %lx\n",
  65.             paddr_ptr->mapped_addr,paddr_ptr->board_addr);
  66.  
  67.      myptr = paddr_ptr->mapped_addr; 
  68.  
  69.      printf ("First Byte Of Adapter = %x\n",*myptr);
  70.  
  71.     DosClose(handle);
  72.  
  73.