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

  1. #define      INCL_DOSFILEMGR
  2. #define      INCL_DOS
  3. #define      INCL_DOSDEVICES
  4. #define      INCL_DOSDEVIOCTL
  5. #include     <os2.h>
  6. #include     <stdio.h>
  7. #include     "test.h"
  8. HFILE         driver_handle=0; 
  9. USHORT       err;
  10. UCHAR        far *myptr=0;
  11. USHORT       ActionTaken;
  12. USHORT       rc;
  13. ULONG        FileSize=0;
  14. USHORT       FileAttribute;
  15. ULONG        Reserved=0L;
  16. UCHAR        Data1[8]={0};
  17. UCHAR        Data2=0;
  18. PADDR_STRUCT paddr_ptr;
  19.  
  20. void main()
  21. {
  22.  
  23.           // open the driver
  24.  
  25.         if ((rc = DosOpen("MMAP$   ",
  26.         &driver_handle,
  27.         &ActionTaken,
  28.         FileSize,
  29.         FileAttribute,
  30.         FILE_OPEN,
  31.         OPEN_SHARE_DENYNONE | OPEN_FLAGS_FAIL_ON_ERROR | OPEN_ACCESS_READWRITE,
  32.         Reserved)) !=0) 
  33.           {
  34.             printf("\nDosOpen failed, error = %d",rc);
  35.                 DosExit(EXIT_PROCESS,0);
  36.           }
  37.  
  38.           printf ("Bus Type              = ");
  39.  
  40.         rc = DosDevIOCtl(&Data1,&Data2,0x01,OUR_CAT,driver_handle);
  41.           
  42.           if (rc & 0x01)
  43.              printf ("Micro Channel (tm)\n");
  44.           else
  45.              printf ("ISA\n");
  46.  
  47.         if (rc = DosDevIOCtl(&Data1,&Data2,0x02,OUR_CAT,driver_handle))
  48.           {
  49.              printf ("DevIOCtl failed, error code = %d\n",rc);
  50.               DosExit(EXIT_PROCESS,0);
  51.           }
  52.  
  53.           // pointer to data buffer
  54.  
  55.           paddr_ptr = (PADDR_STRUCT) Data1;
  56.  
  57.           printf ("Memory Mapped Address = %p\nPhysical Address      = %lx\n",
  58.                  paddr_ptr->mapped_addr,paddr_ptr->board_addr);
  59.  
  60.           myptr = (void far *) paddr_ptr->mapped_addr;
  61.  
  62.           printf ("First Byte Of Adapter = %x\n",*myptr);
  63.  
  64.           // close driver
  65.  
  66.           DosClose(driver_handle);
  67. }
  68.