home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / cdisk.zip / MMAP / TEST32A.C < prev    next >
C/C++ Source or Header  |  1992-12-29  |  2KB  |  75 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. #define  GET_LIN  0x04L
  10.  
  11. typedef struct _ADDR_STRUCT {
  12.     void     *mapped_addr;
  13.     ULONG    board_addr;
  14.     } ADDR_STRUCT;
  15. typedef ADDR_STRUCT *PADDR_STRUCT;
  16.  
  17.  
  18. char     buf[100] = {0};
  19. USHORT   BytesRead;
  20. ULONG    ActionTaken;               /* for file opens                      */
  21. APIRET   rc;                        /* return code for driver open         */
  22. ULONG    FileSize=0;                /* NULL file size                      */
  23. ULONG    FileAttribute;             /* attribute bits                      */
  24. HFILE    handle=0;
  25. UCHAR    parmbuf [20];
  26. UCHAR    databuf[20];
  27. ULONG    plength,dlength;
  28. PADDR_STRUCT paddr_ptr;
  29. UCHAR    *myptr;
  30.  
  31. main()
  32. {
  33.     rc = DosOpen("MMAP$   ",
  34.     &handle,
  35.     &ActionTaken,
  36.     FileSize,
  37.     FileAttribute,
  38.     OPEN_ACTION_OPEN_IF_EXISTS,
  39.     OPEN_ACCESS_READWRITE | OPEN_SHARE_DENYNONE | OPEN_FLAGS_NOINHERIT, 
  40.     EABUF);
  41.       if (rc) {
  42.         printf("\nDosOpen failed, error = %ld",rc);
  43.         DosExit(EXIT_PROCESS,0);    /* exit gracefully                     */
  44.        }
  45.  
  46.      printf ("Bus Type              = ");
  47.  
  48.      rc = DosDevIOCtl(handle,OUR_CAT,BUS_TYPE,0,0L,&plength,databuf,8L,&dlength);
  49.  
  50.      if (rc & 0x01)
  51.         printf ("Micro Channel (tm)\n");
  52.      else
  53.         printf ("ISA\n");
  54.  
  55.      rc = DosDevIOCtl(handle,OUR_CAT,GET_LIN,0,0L,&plength,databuf,8L,&dlength); 
  56.  
  57.     if (rc)
  58.      {
  59.       printf ("DevIOCtl failed, error code = %ld\n",rc);
  60.         DosExit(EXIT_PROCESS,0);
  61.      }    
  62.  
  63.     paddr_ptr = (PADDR_STRUCT) databuf;
  64.  
  65.      printf ("Memory Mapped Address = %p\nPhysical Address      = %lx\n",
  66.             paddr_ptr->mapped_addr,paddr_ptr->board_addr);
  67.  
  68.      myptr = paddr_ptr->mapped_addr; 
  69.  
  70.      printf ("First Byte Of Adapter = %x\n",*myptr);
  71.  
  72.     DosClose(handle);
  73.  
  74.