home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / cdisk.zip / VDD / PIOUSER.C < prev    next >
C/C++ Source or Header  |  1993-02-24  |  2KB  |  62 lines

  1. /*  file piouser.c */
  2.  
  3. #include "mvdm.h"                         /* VDH services, etc.   */
  4. #include "pio.h"                          /* PIO specific         */
  5. #include "basemid.h"
  6.  
  7. #pragma data_seg(CSWAP_DATA)
  8.  
  9. /* our routines are for 8-bit ports */
  10.  
  11. IOH Ioh = {PIODataIn,PIODataOut,0,0,0};
  12.  
  13. #pragma alloc_text(CSWAP_TEXT,PIOCreate,PIOTerminate)
  14.  
  15. /*----------------------------------------------------------------
  16.  
  17. PIOCreate, entered when the VDM is created 
  18.  
  19. ----------------------------------------------------------------*/
  20.  
  21. BOOL HOOKENTRY PIOCreate(hvdm)
  22. HVDM hvdm;
  23. {
  24.     current_VDM = hvdm;                /* save our vdm handle */
  25.  
  26.      /* install I/O hooks for our three 8-bit ports */
  27.  
  28.     if ((VDHInstallIOHook(hvdm,
  29.                           DIGIO_BASE,
  30.                           3,
  31.                           (PIOH)&Ioh,
  32.                           !VDH_ASM_HOOK)) == 0) {
  33.         PIOTerminate(hvdm);
  34.         return 0;             /* return FALSE               */
  35.     } /* endif */
  36.  
  37.     return CTRUE;
  38. }
  39.  
  40. /*----------------------------------------------------------------
  41.  
  42. PIOTerminate, called when the VDM terminates. This code is 
  43. optional, as the User and IO hooks are removed automatically by 
  44. the system when the VDM terminates. It is shown for example.
  45.  
  46. ----------------------------------------------------------------*/
  47.  
  48. BOOL HOOKENTRY PIOTerminate(hvdm)
  49. HVDM hvdm;
  50. {
  51.  
  52.      owner_VDM = 0;
  53.  
  54.     VDHRemoveIOHook(hvdm,         /* remove the IO hooks        */
  55.                     DIGIO_BASE,
  56.                     3,
  57.                     (PIOH)&Ioh);
  58.  
  59.     return CTRUE;
  60. }
  61.  
  62.