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

📄 virkbc.inc

📁 dos下的USB源码(包括UHCI
💻 INC
字号:
	ECHO	-- Including: VIRKBC.INC
	TITLE	VIRKBC.INC -- Legacy free virtual keyboard controller code

;***************************************************************************;
;***************************************************************************;
;**                                                                       **;
;**           (C)Copyright 1985-2002, American Megatrends, Inc.           **;
;**                                                                       **;
;**                          All Rights Reserved.                         **;
;**                                                                       **;
;**                6145-F Northbelt Pkwy, Norcross, GA 30071              **;
;**                                                                       **;
;**                          Phone (770)-246-8600                         **;
;**                                                                       **;
;***************************************************************************;
;***************************************************************************;
;***************************************************************************;
; $Header: /BIOS/Corebin/800/Modules/USB2/Template/Core/VIRKBC.INC 5     3/25/03 5:25p Sivagarn $
;
; $Revision: 5 $
;
; $Date: 3/25/03 5:25p $
;***************************************************************************;
; Revision History
; ----------------
; $Log: /BIOS/Corebin/800/Modules/USB2/Template/Core/VIRKBC.INC $
; 
; 5     3/25/03 5:25p Sivagarn
; Updated procedure headers with correct register input values
; 
; 4     11/20/02 5:49p Sivagarn
; - POST hang in a legacy free system, if the USB keyboard keys are
; pressed early in the POST is fixed
; 
; 3     11/08/02 10:50a Sivagarn
; Code added and/or moved to have USB keyboard input support for the
; systems without keyboard controller
; 
; 2     10/29/02 6:59p Sivagarn
; - C type calling convention routines are changed to assembly type
; routines
; - Added dummy routines for port 60h/64h emulation support
;
; 1     9/15/02 5:39p Sivagarn
; Initial AMIUSB 2.20 check-in
;
;***************************************************************************;


;<AMI_PHDR_START>
;----------------------------------------------------------------------------
; Procedure:	USBKBC_GetAndStoreCCB
;
; Description:	This routine will read the CCB from the keyboard controller
;		and store it in a local variable
;
; Input: 	Nothing
;
; Output: 	Nothing
;
; Modified:	Nothing
;
; Referrals:
;
;----------------------------------------------------------------------------
;<AMI_PHDR_END>

USBKBC_GetAndStoreCCB	PROC NEAR SYSCALL PUBLIC

; Set CCB value to default - Scan conversion enabled, mouse disabled,
; keyboard enabled and without system interrupt generation
	mov	bCCB, 064h

; Disable USB mouse. Reset the mouse enable flag
	and	bMouseStatusFlag, NOT MOUSE_ENABLED_BIT_MASK

	ret
USBKBC_GetAndStoreCCB	ENDP

;<AMI_PHDR_START>
;----------------------------------------------------------------------------
; Procedure:	VIRKBC_GetCommandByte
;
; Description:	This routine will update the CCB byte with mouse information
;
; Input: 	Nothing
;
; Output: 	AL	Current CCB
;
; Modified:	AL
;
; Referrals:
;
;----------------------------------------------------------------------------
;<AMI_PHDR_END>

VIRKBC_GetCommandByte	PROC NEAR SYSCALL PUBLIC

	mov	al, bCCB		; Get current state of CCB

; Enable mouse status
	and	al, 11011111y

; Check whether mouse is enabled
	test	bMouseStatusFlag, MOUSE_ENABLED_BIT_MASK
	jnz	VKGCB_MouseEnabled	; NZ = Mouse status enabled

; Disable mouse status
	or	al, 00100000y

VKGCB_MouseEnabled:
	mov	bCCB, al		; Update mouse status in CCB

	ret
VIRKBC_GetCommandByte	ENDP

;<AMI_PHDR_START>
;----------------------------------------------------------------------------
; Procedure:	KBC_SendKeyboardData
;
; Description:	This routine sends the data to the virtual keyboard
;
; Input: 	AL	Data byte to send
;
; Output: 	None
;
; Modified:	Nothing
;
;----------------------------------------------------------------------------
;<AMI_PHDR_END>

KBC_SendKeyboardData		PROC NEAR SYSCALL
	push	ax

	push	ds
	push	40h
	pop	ds
	mov	ah, DS:[17h]	; AH - KBD status byte (40:17h).
	pop	ds

	cmp	USBAcquiredByOS, TRUE
	je	vkdo_ExecuteInt09

; Check whether we already stored address for ProcessBIOSKeys
	cmp	pProcessBIOSKeys_FAR, 0
	je	vkdo_BIOSKey

	push	cs
	push	OFFSET vkdo_ReturnFromProcessBIOSKeys
	push	DWORD PTR ds:pProcessBIOSKeys_FAR
	retf
vkdo_ReturnFromProcessBIOSKeys:
	jc	vkdo_BiosKey    		; Input Key is a BIOS key.

vkdo_ExecuteInt09:
	pushf
	call	int_09

vkdo_BiosKey:
	pop	ax
	ret
KBC_SendKeyboardData		ENDP

;<AMI_PHDR_START>
;----------------------------------------------------------------------------
; Procedure:	KBC_SendMouseData
;
; Description:	This routine sends the data to the mouse through the
;		keyboard controller
;
; Input: 	AL	Data to be sent
;
; Output: 	Nothing
;
; Modified:	Nothing
;
;----------------------------------------------------------------------------
;<AMI_PHDR_END>

KBC_SendMouseData	PROC NEAR SYSCALL PUBLIC
	push	ax

	pushf
	call	int_74

	pop	ax
	ret
KBC_SendMouseData	ENDP


;<AMI_PHDR_START>
;----------------------------------------------------------------------------
; Procedure:	KBC_ReadDataByte
;
; Description:	This routine till the keyboard controller sends a data byte
;
; Input: 	Nothing
;
; Output: 	ZR	If there is no data
;		NZ	If there is data and AL has the data
;			AL	Data byte received from the KBC
;
; Modified:	AL
;
;----------------------------------------------------------------------------
;<AMI_PHDR_END>

KBC_ReadDataByte		PROC NEAR SYSCALL PUBLIC
	ret
KBC_ReadDataByte		ENDP

;<AMI_PHDR_START>
;----------------------------------------------------------------------------
; Procedure:	KBC_WriteCommandByte
;
; Description:	This routine sends the command byte to the keyboard 
;		controller
;
; Input: 	AL	Command byte
;
; Output: 	Nothing
;
; Modified:	Nothing
;
; Notes:	This function does not return the value obtained for the
;		command issued
;
;----------------------------------------------------------------------------
;<AMI_PHDR_END>

KBC_WriteCommandByte		PROC NEAR SYSCALL PUBLIC
	ret
KBC_WriteCommandByte		ENDp

;<AMI_PHDR_START>
;----------------------------------------------------------------------------
; Procedure:	KBC_WriteSubCommandByte
;
; Description:	This routine sends the sub-command byte to the keyboard
;		controller
;
; Input: 	AL	Sub-command byte
;
; Output: 	Nothing
;
; Modified:	Nothing
;
; Notes:	This function does not return the value obtained for the
;		sub-command issued
;
;----------------------------------------------------------------------------
;<AMI_PHDR_END>

KBC_WriteSubCommandByte		PROC NEAR SYSCALL PUBLIC
	ret
KBC_WriteSubCommandByte		ENDp

;<AMI_PHDR_START>
;----------------------------------------------------------------------------
; Procedure:	KBC_UpdateLEDState
;
; Description:	This routine is the dummy routine
;
; Input: 	AL	LED state data
;
; Output: 	Nothing
;
; Modified:	Nothing
;
;----------------------------------------------------------------------------
;<AMI_PHDR_END>

KBC_UpdateLEDState	PROC NEAR SYSCALL PUBLIC

	ret
KBC_UpdateLEDState	ENDP


IF	MKF_USB_KBC_EMULATION
	PUBLIC	_VIRKBC_6064_TRAPPING_START
_VIRKBC_6064_TRAPPING_START	LABEL		BYTE

;----------------------------------------------------------------------------
VIRKBC_VirtualDummyRoutines:
	ret

;----------------------------------------------------------------------------
USBKBC_TrapHandlerTable		LABEL	WORD
	WORD	OFFSET VIRKBC_VirtualDummyRoutines	; I/O port 60h read
	WORD	OFFSET VIRKBC_HandleWritePort60		; I/O port 60h write
	WORD	OFFSET VIRKBC_VirtualDummyRoutines	; I/O port 60h read
	WORD	OFFSET KBC_HandleWritePort64		; I/O port 64h write
;----------------------------------------------------------------------------


;<AMI_PHDR_START>
;----------------------------------------------------------------------------
; Procedure:	VIRKBC_HandleWritePort60
;
; Description:	This routine will handle the trapping caused by port 60h
;		write operation
;
; Input: 	SI	HCStruc structure pointer
;
; Output: 	AL	BIT1	(Trap that is serviced)
;
; Modified:	AX
;
;----------------------------------------------------------------------------
;<AMI_PHDR_END>

VIRKBC_HandleWritePort60		PROC NEAR PUBLIC

; Indicate that port 60h/64h emulation is in progress
	or	wUSBKBC_StatusFlag, KBC_PORT6064_TRAP_BIT_MASK

; Get the value that was output to the port 60h
	call	USBKBD_GetAL

; Check for port 60h handler routine
	cmp	pPort60Handler, 0
	jz	vhw60_Handle60

; Dispatch to the correct routine
	jmp	pPort60Handler

vhw60_Handle60:

; Enable keyboard interface
	and	bCCB, NOT CCB_KEYBOARD_DISABLED

; Dispatch to corresponding routine
	push	ax
	sub	al, 0EDh
	mov	bx, OFFSET CS:KBC_Write60CommandTable
	jnc	vhw60_Proceed		; Commands 0EDh to 0FFh

	mov	al, bKBMSCommandStatus
	and	al, 07h
; Non-zero means command followed by data

	mov	bx, OFFSET CS:KBC_Write60CommandDataTable
vhw60_Proceed:
; Clear the command flag
	and	bKBMSCommandStatus, NOT (BIT0+BIT1+BIT2)

	movzx	ax, al
	shl	ax, 1
	add	bx, ax
	pop	ax

	call	WORD PTR CS:[bx]

	mov	al, BIT1
	ret
VIRKBC_HandleWritePort60		ENDP

	PUBLIC	_VIRKBC_6064_TRAPPING_END
_VIRKBC_6064_TRAPPING_END	LABEL		BYTE

ENDIF	; MKF_USB_KBC_EMULATION

;***************************************************************************;
;***************************************************************************;
;**                                                                       **;
;**           (C)Copyright 1985-2002, American Megatrends, Inc.           **;
;**                                                                       **;
;**                          All Rights Reserved.                         **;
;**                                                                       **;
;**                6145-F Northbelt Pkwy, Norcross, GA 30071              **;
;**                                                                       **;
;**                          Phone (770)-246-8600                         **;
;**                                                                       **;
;***************************************************************************;
;***************************************************************************;

⌨️ 快捷键说明

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