⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 epp.inc

📁 <BIOS研发技术剖析>书的源代码,包括完整的BIOS汇编语言源程序.
💻 INC
📖 第 1 页 / 共 2 页
字号:
;;	page	,132
;;	title	EPP support routines
.386
;*****************************************************************;
;*****************************************************************;
;**								**;
;**	(C)Copyright 1985-1995, American Megatrends Inc.	**;
;**								**;
;**			All Rights Reserved.			**;
;**								**;
;**		6145-F, Northbelt Parkway, Norcross,		**;
;**								**;
;**		Georgia - 30071, USA. Phone-(770)-263-8181.	**;
;**								**;
;*****************************************************************;
;*****************************************************************;
;*****************************************************************;
; $Header: /BIOS/CORE/627/IO/epp.inc 7     1/13/97 10:36a Davidd $
;
; $Revision: 7 $
;
; $Date: 1/13/97 10:36a $
;*****************************************************************;
;*****************************************************************;
; Revision History
; ----------------
; $Log: /BIOS/CORE/627/IO/epp.inc $
; 
; 7     1/13/97 10:36a Davidd
; Changes for SCT test. Moved register init, IRQ, DMA routing tables to
; porting file.
; 
; 5     2/12/96 1:00p Davidd
; Added for the IO.106 release.
; 
; 3     2/07/96 5:22p Davidd
; Replaced DOS INT21 call with code in "epp_11" routine.
; 
; 2     1/12/96 4:33p Dickh
; Added SourceSafe keywords to track revision history.
;  
;*****************************************************************;
;---------------------------------------;
;	IO_DELAY MACRO			;
;---------------------------------------;
io_delay	macro
	jcxz	short $+2
	jcxz	short $+2
endm

parallel_time_max	equ	78h

;---------------------------------------;
; Error code:

epp_Successful		equ	00h
epp_io_timeout		equ	01h
epp_cmd_not_supported	equ	02h
epp_mux_locked		equ	10h
epp_mux_not_present	equ	20h
;---------------------------------------;

version_string	db	'American Megatrends, Inc. EPP BIOS 00.32',0
version_id	db	03h		; version 0.3

epp_call_table	label	word
	dw	offset cgroup:epp_00	; Query Config
	dw	offset cgroup:epp_01	; Set Mode
	dw	offset cgroup:epp_02	; Get Mode
	dw	offset cgroup:epp_03	; Interrupt Control
	dw	offset cgroup:epp_04	; EPP Reset
	dw	offset cgroup:epp_05	; Address Write
	dw	offset cgroup:epp_06	; Address Read
	dw	offset cgroup:epp_07	; Write Byte
	dw	offset cgroup:epp_08	; Write Block
	dw	offset cgroup:epp_09	; Read Byte
	dw	offset cgroup:epp_0A	; Read Block
	dw	offset cgroup:epp_0B	; Address/Byte Read
	dw	offset cgroup:epp_0C	; Address/Byte Write
	dw	offset cgroup:epp_0D	; Address/Block Read
	dw	offset cgroup:epp_0E	; Address/Block Write
	dw	offset cgroup:epp_0F	; Lock Port
	dw	offset cgroup:epp_10	; Unlock Port
	dw	offset cgroup:epp_11	; Device Interrupt
	dw	offset cgroup:epp_12	; Real Time Mode
;---------------------------------------;

;-----------------------------------------------------------------------
; int_17_epp	Installation Check
;
;		Installation Check is used to test for the present of
;		an EPP port. This call returns a far pointer to the
;		EPP BIOS entry point - the EPP Vector.
;-----------------------------------------------------------------------
;
; Input:	Int 17
;		AH = 2
;		AL = 0
;		CH = 45 ('E')
;		BH = 50 ('P')
;		BL = 50 ('P')
;		DX = LPT port number (0-2)
;
; Output:	AH = 0
;		If EPP present
;			AL = 45 ('E')
;			CL = 50 ('P')
;			CH = 50 ('P')
;		DX:BX = EPP BIOS entry point - EPP Vector
;
; Register Usage: AX, BX, CX, DX
;
; Note: This added for EPP support hook in INT-17, MUST BE HOOKED
;	INTO PM.INC (set_int17_flag).
;
;-----------------------------------------------------------------------
;	public	int_17_epp
int_17_epp	proc	near	private
	cmp	ax,0200h		; check if function 2, subfunction 0
	jne	int_17_epp_exit		; no, continue with INT 17h
	cmp	ch,45h			; CH = 'E' ?
	jne	int_17_epp_exit		; no, continue with INT 17h
	cmp	bx,5050h		; BX = 'PP' ?
	jne	int_17_epp_exit		; no, continue with INT 17h
	call	get_io_lpt_port_addr	; DX = I/O LPT port address
	or	dx,dx
	jz	int_17_epp_exit		; LPT address = 0, continue with INT 17h
	cmp	dx,3bch
	je	int_17_epp_exit		; can not run EPP at 3BC
;	mov	al,4			; set I/O LPT port to EPP mode
;	call	set_io_lpt_port_mode
	mov	ax,0045h		; AH = 0, AL = 'E'
	mov	cx,5050h		; 'PP'
	mov	dx,cs
	mov	bx,offset epp_vector	; DX:BX = EPP Vector
int_17_epp_exit:
	jmp	dword ptr cgroup:[OldInt17Vector]
;	ret
int_17_epp	endp

;-----------------------------------------------------------------------
; epp_vector	This procedure serves as the Application Program
;		Interface, API, for all underlying EPP services.
;		All EPP BIOS calls are executed by making a far
;		call to this procedure.
;
; NOTE: Upon entry DL holds LPT port number (0-2) which is used
;	to get the LPT port address from BIOS data area and saved
;	in DX early in this routine before the actual function is
;	called.
;-----------------------------------------------------------------------
epp_vector	proc	far	private
	pushf				; always save flags
	push	dx
	
; Check for valid API function
;	cmp	ah,0eh				; max. func limit
;	ja	epp_no_cmd
	
	cmp	ah,12h				; max. func limit
	ja	epp_no_mux
	
	or	ah,ah
	jnz	ev_func_not0
	call	epp_00
	jmp	short epp_vector_exit

ev_func_not0:
	push	bx
	push	ax
	mov	al,ah				; save API function #
	xor	ah,ah
	mov	bx,ax				; prepare index into call table
	shl	bx,1
	pop	ax
	cmp	ah,0ch				; Address/Byte write call
	jz	epp_vector_call
	
	call	get_io_lpt_port_addr		; DX = LPT address from hardware

epp_vector_call:
	call	cgroup:epp_call_table[bx]	; call each function
	pop	bx
	
epp_vector_exit:
	pop	dx
	popf
	retf
	
epp_no_mux:
	mov	ah,epp_mux_not_present
	jmp	short epp_vector_exit
	
epp_no_cmd:
	mov	ah,epp_cmd_not_supported
	jmp	short epp_vector_exit
	
epp_vector	endp

;-----------------------------------------------------------------------
; epp_00	Query Config
;
;		Returns the EPP port's configuration.
;-----------------------------------------------------------------------
;
; Input:	AH = 0
;		DX = LPT I/O port base address
;
; Output:	AH = error code
;		AL = Interrupt level of EPP port (0-15)
;		   = FF if interrupts not supported
;		BH = EPP BIOS version (MMMMnnnn or M.n)
;					i.e: 10 for version 1.0
;		BL = I/O Capabilities
;			bit 0 = Multiplexor present
;			bit 1 = PS/2 bi-directional capable
;			bit 2 = Daisy chain present
;			bit 3 = ECP capable
;		CX = SPP I/O Base Address
;		ES:DI = EPP BIOS manufacturer's version string (zero terminated)
;
; Register Usage: AX, BX, CX, DI, ES
;
; Note:	Fast Centronics uses the EPP Block Write call to send data to a
;	standard Centronics printer. The Set Mode command is used to
;	enable this I/O mode.
;
;-----------------------------------------------------------------------
epp_00	proc	near	private
	call	get_io_lpt_port_addr	; DX = LPT address from hardware
	mov	cx,dx			; CX = LPT port base address
	call	get_io_lpt_port_info	; routine in EPPIO.INC
					; return: AL interrupt level
					;	     = FF if interrupts not support
					;	  BL.0 Multiplexor present
					;	  BL.1 PS/2 bi-directional capable
					;	  BL.2 Daisy chain present
					;	  BL.3 ECP capable
	xor	ah,ah			; no error
	mov	bh,cgroup:version_id
	push	cs
	pop	es
	mov	di,offset cgroup:version_string
	ret
epp_00	endp

;-----------------------------------------------------------------------
; epp_01	Set Mode
;
;		Set the operating mode for the EPP port.
;-----------------------------------------------------------------------
;
; Input:	AH = 01
;		AL = mode bits
;			0 - compatibility mode
;			1 - Bi-directional mode
;			2 - EPP mode
;			3 - ECP mode
;			4 - EPP software emulation
;		DX = LPT I/O port base address
;
; Output:	AH = error code
;
; Register Usage: AX, BX
;
;-----------------------------------------------------------------------
epp_01	proc	near	private
	call	set_io_lpt_port_mode	; routine in EPPIO.INC
	ret
epp_01	endp

;-----------------------------------------------------------------------
; epp_02	Get Mode
;
;		Returns the current operating mode of the EPP port.
;-----------------------------------------------------------------------
;
; Input:	AH = 02
;		DX = LPT I/O port base address
;
; Output:	AH = Error code
;		AL = current mode (bits)
;			0 - compatibility mode
;			1 - Bi-directional mode
;			2 - Epp mode
;			3 - ECP mode
;			4 - EPP software emulation
;			7 - EPP port interrupts enabled
;
; Register Usage: AX, BX
;
;-----------------------------------------------------------------------
epp_02	proc	near	private
	call	get_io_lpt_port_mode	; routine in EPPIO.INC
	ret
epp_02	endp

;-----------------------------------------------------------------------
; epp_03	Interrupt Control
;
;		Interrupt control is used to enable or disable the
;		interrupt associated with the EPP port. When interrupts
;		are enabled/disabled both the port and the interrupt
;		controller (interrupt mask) are enabled/disabled.
;-----------------------------------------------------------------------
;
; Input:	AH = 03
;		AL = 0	to disable EPP port interrupts
;		   = 1	to enable EPP port interrupts
;		DX = LPT I/O port base address
;
; Output:	AH = Error code
;
; Register Usage: AH
;
;-----------------------------------------------------------------------
epp_03	proc	near	private
	cli
	push	ax
	add	dx,2		; LPT port control
	xchg	ah,al		; save AL
	in	al,dx		; read/modify/write control port
	io_delay
	shl	ah,4		; position to bit 4 (interrupt enable)
	and	al,11101111b
	or	al,ah
	out	dx,al
	pop	ax
	xor	ah,ah		; no error code
	sti
	ret
epp_03	endp

;-----------------------------------------------------------------------
; epp_04	EPP Reset
;
;		EPP Reset is used to reset the peripheral device
;		connected to the EPP port. This is performed by
;		asserting the INIT line on the parallel port.
;-----------------------------------------------------------------------
;
; Input:	AH = 04
;		DX = LPT I/O port base address
;
; Output:	AH = Error code
;
; Register Usage: AH
;
;-----------------------------------------------------------------------
extrn	fixed_delay:near

epp_04	proc	near	private
	cli
	push	ax
	add	dx,2		; LPT port control
	in	al,dx		; read/modify/write control port
	io_delay
	and	al,11111011b	; send INIT signal to LPT port
	out	dx,al
	push	cx
	mov	cx,5		; 5*15us = 75us delay
	call	fixed_delay
	pop	cx
	or	al,00000100b	; reset INIT signal
	out	dx,al
	pop	ax
	xor	ah,ah		; no error code
	sti
	ret
epp_04	endp

;-----------------------------------------------------------------------
; epp_05	Address Write
;
;		Address Write is used to perform an address-write/
;		device-select I/O cycle.
;-----------------------------------------------------------------------
;
; Input:	AH = 05
;		AL = device address
;		DX = LPT I/O port base address
;
; Output:	AH = Error code
;
; Register Usage: AH
;
;-----------------------------------------------------------------------
epp_05	proc	near	private
;	call	lpt_write_enable
	push	dx
	add	dx,3		; address port
	out	dx,al		; send device address to address port
	io_delay
	pop	dx
	xor	ah,ah		; no error code
	ret
epp_05	endp

;-----------------------------------------------------------------------
; epp_06	Address Read
;
;		Address Read is used to perform an address read I/O
;		cycle.
;-----------------------------------------------------------------------
;
; Input:	Ah = 06
;		DX = LPT I/O port base address
;
; Output:	AH = Error code
;		Al = returned address/device data
;
; Register Usage: AH
;
;-----------------------------------------------------------------------
epp_06	proc	near	private
;	call	lpt_read_enable
	add	dx,3		; address port
	in	al,dx		; read device address from address port
	io_delay
	xor	ah,ah		; no error code

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -