home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / c / cl5sr386.zip / GO32 / VCPI.ASM < prev    next >
Assembly Source File  |  1992-04-13  |  4KB  |  267 lines

  1. ;This is file VCPI.ASM
  2. ;
  3. ;Copyright(C) Aug 5th 1991 Y.Shibata
  4. ;This file is distributed under the term of GNU GPL.
  5. ;
  6.     .386P
  7.  
  8.     include build.inc
  9.     include segdefs.inc
  10.     include vcpi.inc
  11.  
  12.     start_data16
  13. emm_name    db    "EMMXXXX0",0
  14.     end_data16
  15.  
  16.     start_code16
  17. ;
  18. ;  EMM Installed Check
  19. ;
  20. ;word16    emm_present(void)
  21. ;
  22. ;result EMS Handle
  23. ;
  24.     public    _emm_present
  25. _emm_present    proc    near
  26.     ;
  27.     push    bp
  28.     mov    bp,sp
  29.     ;
  30.     mov    dx,offset emm_name
  31.     mov    ax,3d00H        ;Open Handle
  32.     int    DOS_REQ
  33.     jc    short no_emm_driver
  34.     mov    bx,ax
  35.     mov    ax,4400H        ;Get IOCTL Data    
  36.     int    DOS_REQ
  37.     jc    short no_emm_driver
  38.     test    dx,80H            ;1 = Device , 0 = File
  39.     jz    short no_emm_driver
  40.     mov    ax,4407H        ;Get Output IOCTL Status
  41.     int    DOS_REQ
  42.     push    ax
  43.     mov    ah,3EH            ;Close Handle
  44.     int    DOS_REQ
  45.     pop    ax
  46.     cmp    al,-1            ;Ready?
  47.     jne    short no_emm_driver
  48.     ;
  49.     mov    ah,40H            ;Get Status
  50.     int    EMS_REQ
  51.     cmp    ah,0
  52.     jne    short no_emm_driver
  53.     mov    ah,42H            ;Get Unallocate Page Count
  54.     int    EMS_REQ
  55.     cmp    ah,0
  56.     jne    short no_emm_driver
  57.     mov    ax,-1            ;Handle = -1(Invalid Handle No.)
  58.     cmp    bx,dx            ;Other Program EMS Page Used?
  59.     jne    short emm_present_end    ;Used!!
  60.     mov    bx,1
  61.     mov    ah,43H            ;Allocate Pages(1 Page Only)
  62.     int    EMS_REQ
  63.     cmp    ah,0
  64.     jne    short no_emm_driver
  65.     mov    ax,dx            ;Handle
  66.     jmp    short emm_present_end
  67.  
  68. no_emm_driver:
  69.     xor    ax,ax            ;Not Installed = 0
  70. emm_present_end:
  71.     pop    bp
  72.     ret
  73.     ;
  74. _emm_present    endp
  75.  
  76. ;
  77. ;  EMS Page Deallocated
  78. ;
  79. ;void ems_free(word16 ems_handle)
  80. ;
  81.     public    _ems_free
  82. _ems_free    proc    near
  83.     ;
  84.     push    bp
  85.     mov    bp,sp
  86.     ;
  87.     mov    dx,4[bp]        ;EMS_Handle
  88.     mov    ah,45H            ;Deallocate Pages
  89.     int    EMS_REQ
  90.     ;
  91.     pop    bp
  92.     ret
  93.     ;
  94. _ems_free    endp
  95.  
  96. ;
  97. ;  VCPI Installed Check
  98. ;
  99. ;word16    vcpi_present(void)
  100. ;
  101. ;result    -1:VCPI Installed 0:VCPI Not Installed
  102. ;
  103.     public    _vcpi_present
  104. _vcpi_present    proc    near
  105.     ;
  106.     push    bp
  107.     mov    bp,sp
  108.     ;
  109.     mov    ax,VCPI_PRESENT        ;VCPI Present
  110.     int    VCPI_REQ
  111.     sub    ah,1
  112.     sbb    ax,ax            ;ah = 0 -> AX = -1
  113.     ;
  114.     pop    bp
  115.     ret
  116.     ;
  117. _vcpi_present    endp
  118.  
  119. ;
  120. ;  VCPI Unallocated Page count
  121. ;
  122. ;word16    vcpi_capacity(void)
  123. ;
  124. ;result    Free VCPI Memory(Pages)
  125. ;
  126.     public    _vcpi_capacity
  127. _vcpi_capacity    proc    near
  128.     ;
  129.     push    bp
  130.     mov    bp,sp
  131.     ;
  132.     mov    ax,VCPI_MEM_CAPACITY
  133.     int    VCPI_REQ
  134.     mov    ax,dx            ;Cut Upper16Bit(CAUTION!!)
  135.     ;
  136.     pop    bp
  137.     ret
  138.     ;
  139. _vcpi_capacity    endp
  140.  
  141. ;
  142. ;  VCPI Memory Allocate
  143. ;
  144. ;word16    vcpi_alloc(void)
  145. ;
  146. ;result    Allocate Page No.
  147. ;
  148.     public    _vcpi_alloc
  149. _vcpi_alloc    proc    near
  150.     ;
  151.     push    bp
  152.     mov    bp,sp
  153.     ;
  154.     mov    ax,VCPI_ALLOC_PAGE
  155.     int    VCPI_REQ
  156.     test    ah,ah
  157.     je    vcpi_alloc_success
  158.     xor    ax,ax            ;Error result = 0
  159.     jmp    short vcpi_alloc_end
  160.     ;
  161. vcpi_alloc_success:
  162.     shr    edx,12
  163.     mov    ax,dx            ;Cut Upper16Bit (CAUTION!!)
  164. vcpi_alloc_end:
  165.     pop    bp
  166.     ret
  167.     ;
  168. _vcpi_alloc    endp
  169.  
  170. ;
  171. ;  VCPI Memory Deallocate
  172. ;
  173. ;void    vcpi_free(word16 page_number)
  174. ;
  175.     public    _vcpi_free
  176. _vcpi_free    proc    near
  177.     ;
  178.     push    bp
  179.     mov    bp,sp
  180.     ;
  181.     movzx    edx,word ptr 4[bp]
  182.     sal    edx,12            ;Address = Page_number * 4KB
  183.     mov    ax,VCPI_FREE_PAGE
  184.     int    VCPI_REQ
  185.     ;
  186.     pop    bp
  187.     ret
  188.     ;
  189. _vcpi_free    endp
  190.  
  191. ;
  192. ;  VCPI Get Interface
  193. ;
  194. ;word32    get_interface(word32 far *page_table,GDT_S *gdt)
  195. ;
  196.     public    _get_interface
  197. _get_interface    proc    near
  198.     ;
  199.     push    bp
  200.     mov    bp,sp
  201.     push    si
  202.     push    di
  203.     ;
  204.     push    es
  205.     mov    si,[bp+8]        ;DS:SI = &GDT[g_vcpicode]
  206.     les    di,[bp+4]        ;ES:DI = Page Table (DI = 0)
  207.     mov    ax,VCPI_INTERFACE
  208.     int    VCPI_REQ
  209.     cmp    di,06c0H
  210.     jbe    short not_use_1b0000h    ;Conflict with handle_screen_swap()
  211.     mov    ebx,-1            ;Invalid Entry Address
  212. not_use_1b0000h:
  213.     mov    eax,ebx
  214.     shld    edx,eax,16        ;DX:AX = EBX
  215.     pop    es
  216.        ;
  217.     pop    di
  218.     pop    si
  219.     pop    bp
  220.     ret    
  221.     ;
  222. _get_interface    endp
  223.  
  224. ;
  225. ;  VCPI Get PIC Vector
  226. ;
  227. ;word16    vcpi_get_pic(void)
  228. ;
  229. ;Result MASTER PIC Vector No.(IRQ0)
  230. ;
  231.     public    _vcpi_get_pic
  232. _vcpi_get_pic    proc    near
  233.     ;
  234.     push    bp
  235.     mov    bp,sp
  236.     mov    ax,VCPI_GET_PIC_VECTOR
  237.     int    VCPI_REQ
  238.     mov    ax,bx            ;MASTER PIC Vector
  239.     pop    bp
  240.     ret
  241.     ;
  242. _vcpi_get_pic    endp
  243.  
  244. ;
  245. ;  VCPI Set PIC Vector
  246. ;
  247. ;void    vcpi_set_pic(word16 master_pic)
  248. ;
  249.     public    _vcpi_set_pic
  250. _vcpi_set_pic    proc    near
  251.     ;
  252.     push    bp
  253.     mov    bp,sp
  254.     mov    bx,4[bp]        ;MASTER PIC Vector
  255.     mov    cx,70H            ;SLAVE PIC Vector
  256.     mov    ax,VCPI_SET_PIC_VECTOR
  257.     int    VCPI_REQ
  258.     pop    bp
  259.     ret
  260.     ;
  261. _vcpi_set_pic    endp
  262.  
  263.  
  264.     end_code16
  265.  
  266.     end
  267.