📄 epp.inc
字号:
ret
epp_06 endp
;-----------------------------------------------------------------------
; epp_07 Write Byte
;
; Write Byte is used to output a single byte via the
; EPP data port.
;-----------------------------------------------------------------------
;
; Input: AH = 07
; AL = data byte
; DX = LPT I/O port base address
;
; Output: AH = Error code
;
; Register Usage: AH
;
;-----------------------------------------------------------------------
epp_07 proc near private
; call lpt_write_enable
add dx,4 ; LPT EPP data port
out dx,al ; write data byte
io_delay
xor ah,ah ; no error code
ret
epp_07 endp
;-----------------------------------------------------------------------
; epp_08 Write Block
;
; Write Block is used to output the contents of a
; client-defined buffer via the EPP data port. This
; can be used in Fast Centronics mode to perform block
; I/O to Centronics printer.
;-----------------------------------------------------------------------
;
; Input: AH = 08
; CX = number of bytes to write (0=64K bytes)
; DX = LPT I/O port base address
; ES:SI = client buffer
;
; Output: AH = Error code
; CX = bytes remaining (=0 if no error)
;
; Register Usage: AH, CX, SI
;
;-----------------------------------------------------------------------
epp_08 proc near private
; call lpt_write_enable
add dx,4 ; LPT EPP data port
cld
rep outs dx,byte ptr es:[si] ; write data block
xor ah,ah ; no error code
ret
epp_08 endp
;-----------------------------------------------------------------------
; epp_09 Read Byte
;
; Read Byte is used to input a single byte via the
; EPP data port.
;-----------------------------------------------------------------------
;
; Input: AH = 09
; DX = LPT I/O port base address
;
; Output: AH = Error code
; AL = data byte read
;
; Register Usage: AX
;
;-----------------------------------------------------------------------
epp_09 proc near private
; call lpt_read_enable
add dx,4 ; LPT EPP data port
in al,dx ; read byte
io_delay
xor ah,ah ; no error code
ret
epp_09 endp
;-----------------------------------------------------------------------
; epp_0A Read Block
;
; Read Block is used to input a stream of bytes into
; a client buffer via the EPP data port.
;-----------------------------------------------------------------------
;
; Input: AH = 0A
; CX = number of bytes to read (0=64K bytes)
; DX = LPT I/O port base address
; ES:DI = client buffer
;
; Output: AH = Error code
; CX = bytes not transferred (=0 if no error)
;
; Register Usage: AX, CX, DI
;
;-----------------------------------------------------------------------
epp_0A proc near private
; call lpt_read_enable
add dx,4 ; LPT EPP data port
cld
rep insb ; read data block
xor ah,ah ; no error code
ret
epp_0A endp
;-----------------------------------------------------------------------
; epp_0B Address/Byte Read
;
; Address/Byte Read combines the Address Write and
; Read Byte APIs into a single call.
;-----------------------------------------------------------------------
;
; Input: AH = 0B
; AL = device address
; DX = LPT I/O port base address
;
; Output: AH = Error code
; AL = data byte read
;
; Register Usage: AX
;
;-----------------------------------------------------------------------
epp_0B proc near private
call epp_05 ; adrress write
; io_delay
call epp_09 ; read byte
ret
epp_0B endp
;-----------------------------------------------------------------------
; epp_0C Address/Byte Write
;
; Address/Byte Write combines the Address Write and
; Write Byte APIs into a single call.
;-----------------------------------------------------------------------
;
; Input: AH = 0C
; AL = device address
; DL = LPT port number (0-2)
; DH = Data byte
;
; Output: AH = Error code
;
; Register Usage: AH
;
;-----------------------------------------------------------------------
epp_0C proc near private
push cx
mov cl,dh ; CL = data byte
call get_io_lpt_port_addr ; DX = LPT address from hardware
call epp_05 ; address write
push ax
mov al,cl
; io_delay
call epp_07 ; write byte
pop ax
xor ah,ah
pop cx
ret
epp_0C endp
;-----------------------------------------------------------------------
; epp_0D Address/Block Read
;
; Address/Block Read combines the Address Write and
; Read Block APIs into a single call.
;-----------------------------------------------------------------------
;
; Input: AH = 0D
; AL = device address
; CX = number of bytes to read (0=64K bytes)
; DX = LPT I/O port base address
; ES:DI = client buffer
;
; Output: AH = Error code
; CX = bytes not tranferred (=0 if no error)
;
; Register Usage: AX, CX, DI
;
;-----------------------------------------------------------------------
epp_0D proc near private
call epp_05 ; address write
; io_delay
call epp_0A ; read block
ret
epp_0D endp
;-----------------------------------------------------------------------
; epp_0E Address/Block Write
;
; Address/Block Write combines the Address Write and
; Write Byte APIs into a single call.
;-----------------------------------------------------------------------
;
; Input: AH = 0E
; AL = device address
; CX = number of bytes to write
; DX = LPT I/O port base address
; ES:SI = client buffer
;
; Output: AH = Error code
; CX = bytes not tranferred (=0 if no error)
;
; Register Usage: AH, CX, SI
;
;-----------------------------------------------------------------------
epp_0E proc near private
call epp_05 ; address write
; io_delay
call epp_08 ; write block
ret
epp_0E endp
;-----------------------------------------------------------------------
; epp_0F Lock Port
; Lock Port is used to serialize I/O access to the I/O
; port. If an EPP multiplexor is not present this call
; will always succeed. If an EPP multiplexor is present
; this call will fail if the port is currently locked.
; Lock port is used to select a multiplexor device port.
;-----------------------------------------------------------------------
;
; Input: AH = 0F
; BL = multiplexor port
; 0 - if EPP multiplexor not present
; otherwise:
; bits 7-4 = Daisy Chain Port #
; bits 3-0 = Mux Device Port #
;
; DX = LPT I/O port base address
;
; Output: AH = Error code
;
; Register Usage: AX, BX
;
;-----------------------------------------------------------------------
epp_0F proc near private
; call lock_port ; routine in EPPIO.INC
xor ah,ah
ret
epp_0F endp
;-----------------------------------------------------------------------
; epp_10 Unlock Port
;
; Unlock Port will release the EPP port resource for
; use by other EPP device drivers.
;-----------------------------------------------------------------------
;
; Input: AH = 10h
; AL = multiplex port
; DX = LPT I/O port base address
;
; Output: AH = Error code
;
; Register Usage: AX, BX
;
; Note: A device driver MUST unlock the port after all EPP I/O
; transactions have been performed.
;
;-----------------------------------------------------------------------
epp_10 proc near private
; call unlock_port ; routine in EPPIO.INC
xor ah,ah ; no error
ret
epp_10 endp
;-----------------------------------------------------------------------
; epp_11 Device Interrupt
;
; Device Interrupt allows an EPP device driver to install
; an interrupt event handler, to be called whenever an
; EPP device interrupt occurs. The handler is called with
; interrupts diabled and should return via an FAR RETURN
; instruction. While operating under device interrupt the
; handler is not required to explicitly lock/unlock the
; EPP BIOS.
; Interrupts are handled in two styles: reentrant and
; non-reentrant servicing. If reentrant servicing is
; specified then the end-of-interrupt (EOI) is sent to
; the interrupt controller before the user's event handler
; is called. For non-reentrant servicing the EOI is sent
; after the user's event handler returns (FAR) to the BIOS.
;-----------------------------------------------------------------------
;
; Input: AH = 11h
; AL = 0 - disable device interrupts
; 1 - enable device interrupts
; DX = LPT I/O port base address
; ES:DI = far pointer to interrupt event handler
;
; Output: AH = Error code
;
; Register Usage: AX, BX
;
; Note: If an EPP multiplexor is present it is the EPP Mux device driver
; that dispatches the handler. The EPP Mux device driver will defer
; calling the handler until the device port causing the interrupt
; can be selected/locked.
;
;-----------------------------------------------------------------------
epp_11 proc near private
push cx
mov ch,al ; CH = interrupt cmd
call get_io_lpt_port_info ; routine in EPPIO.INC
; return: AL = interrupt level
mov ah,epp_cmd_not_supported
cmp al,5 ; LPT IRQ 5 ?
je epp_11_int_ok
cmp al,7 ; LPT IRQ 7 ?
jne epp_11_exit ; error, exit
epp_11_int_ok:
push bx
push ds
mov cl,al ;CL = interrupt level
movzx bx,al ;BX = 5/7 for IRQ5/IRQ7
add bl,8 ;For IRQ-5 = INT D, IRQ-7 = INT F
shl bx,2 ;BX = LPT INT Vector offset
; (34h/3Ch for IRQ5/IRQ7)
push 0
pop ds ;DS = 0 segment
mov ds:[bx],di ;Set interupt vector
mov ds:[bx+2],es
pop ds
pop bx
and ch,1 ;keep bit 0 only
shl ch,cl
cli
in al,21h ;read interrupt mask register
cmp cl,5
jne epp_11_irq7
and al,11011111b
jmp short epp_11_00
epp_11_irq7:
and al,01111111b
epp_11_00:
or al,ch ;disable/enable device interupt
out 21h,al
sti
pop cx
xor ah,ah
epp_11_exit:
ret
epp_11 endp
;-----------------------------------------------------------------------
; epp_12 Real Time Mode
;
; Real Time Mode is used to permit a device driver to
; advertise whether it is supporting a peripheral device
; with stringent interrupt latency requirements. Using
; this call a device driver can also query if any real-time
; devices are currently running on a device port. This
; allows drivers to adjust the amount of I/O they perform
; while the channel is locked: If a real-time device is
; present then device drivers use a small I/O block size;
; otherwise they may use a much larger block size,
; maximizing the I/O cahnnel bandwidth.
;-----------------------------------------------------------------------
;
; Input: AH = 12h
; AL = 0 - query if any real time device present
; = 1 - add (advertise) real-time device
; = 2 - remove real-time device
; DX = LPT I/O port base address
;
; Output: AH = Error code
; If input AL = 0 then:
; AL = 0 - if no real-time devices present
; = 1 - if one or more real-time devices present
;
; Register Usage: AX, BX
;
; Note: Block devices that would normally hold the port locked for
; extended periods while performing device I/O should query
; (AL = 0) if any real-time devices are currently operating
; after locking the port. If any real-time devices are present,
; then the block driver should minimize the time the port is
; locked, by unlocking the port whenever possible.
;
;-----------------------------------------------------------------------
epp_12 proc near private
; call real_time_mode
xor ah,ah ; set to no error for now
ret
epp_12 endp
;-----------------------------------------------------------------------
comment !
lpt_write_enable proc near
push dx
add dx,2
push ax
in al,dx
and al,0dfh ; set to write mode
out dx,al
pop ax
pop dx
ret
lpt_write_enable endp
lpt_read_enable proc near
push dx
add dx,2
push ax
in al,dx
or al,020h ; set to read mode
out dx,al
pop ax
pop dx
ret
lpt_read_enable endp
end of comment !
include eppio.inc
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -