📄 usbif.asm
字号:
cmp al, 1 ; One or several
je DUD_001
mov bx, cs:[si+2] ; String for plural item
DUD_001:
add al, '0' ; ASCII for a digit
call write_tty_FAR
; String number in BX
call display_token_message_FAR ; Display device type
DUD_DisplayNextDeviceType:
inc di
add si, 4
jmp SHORT DUD_DisplayDeviceLoop
DUD_DisplayDeviceDone:
call display_0d0a_FAR ; CR/LF
pop es
DUD_Exit:
popad
ret
farDisplayUSBDevices ENDP
;<AMI_PHDR_START>
;----------------------------------------------------------------------------
; Procedure: farPrepareUSBForOS
;
; Description: This function is executed before giving control to OS
;
; Input: None
;
; Output: None
;
; Modified: Nothing
;
;----------------------------------------------------------------------------
;<AMI_PHDR_END>
farPrepareUSBForOS PROC FAR
LOCAL stURP:URP_STRUC
push ax
push bx
push ds
push es
; Set DS to usb data area segment
push CS:wUSBDataAreaSegment
pop ds
; Check whether USB mouse is present
test bUSBDeviceList, USB_TYPE_MOUSE
jz fpufo_MouseDone
IF MKF_KBC_SUPPORT
test gs:rt_cmos_byte, rt_cmos_ps2_bit;PS/2-Mouse present.
jnz fpufo_MouseDone
ENDIF
push 040h
pop ds
ASSUME DS:NOTHING
or BYTE PTR machine_config, 00000100b;Mouse present.
in al, i_s_m_port
and al, 11101111b ; Enable IRQ-12 for mouse.
out i_s_m_port, al
call ProgramPS2MouseIRQLevel_FAR; Program edge/level IRQ
; for PS2Mouse.
push 0
pop ds
mov WORD PTR ds:[74h*4], OFFSET RUN_CSEG:int_74;Trap INT-74h vector.
ASSUME DS:USB_DSEG
fpufo_MouseDone:
; Fill URP with proper value
lea bx, stURP
push ss
pop es
mov ax, Q_USB_LEGACY_ENABLE
call check_cmos_data_far
or al, al
jnz PUFO_GoOn ; Legacy enabled - keep HCs running
mov (URP_STRUC PTR es:[bx]).bFuncNumber, USB_API_STOP
mov (URP_STRUC PTR es:[bx]).bSubFunc, 0
INVOKE_USB_API_HANDLER
;;; Hide controller(s) if needed
;; call farUSBPort_DisableUSBInChipset
jmp SHORT PUFO_Exit
PUFO_GoOn:
mov (URP_STRUC PTR es:[bx]).bFuncNumber, USB_API_PREPARE_FOR_OS
mov (URP_STRUC PTR es:[bx]).bSubFunc, 0
INVOKE_USB_API_HANDLER
PUFO_Exit:
pop es
pop ds
pop bx
pop ax
ret
farPrepareUSBForOS ENDP
POST_CSEG ENDS
;----------------------------------------------------------------------------
; R U N T I M E C O D E S E G M E N T
;----------------------------------------------------------------------------
RUN_CSEG SEGMENT WORD PUBLIC 'CODE'
ASSUME CS:RUN_CSEG
ASSUME DS:USB_DSEG
ASSUME GS:RUN_CSEG
;<AMI_PHDR_START>
;----------------------------------------------------------------------------
; Procedure: farUSBCheckMouseSupport
;
; Description: This function check the setup option to confirm whether to
; enable legacy mouse support or not
;
; Input: None
;
; Output: ZR - Legacy mouse support not needed
; NZ - Legacy mouse support needed
;
; Modified: Nothing
;
;----------------------------------------------------------------------------
;<AMI_PHDR_END>
farUSBCheckMouseSupport PROC FAR PUBLIC
IF MKF_USB_DEV_KBD AND MKF_USB_DEV_MOUSE
push ax
mov ax, Q_USB_LEGACY_MOUSE
call check_cmos_data_far
test al, BIT0
pop ax
ELSE
cmp sp, sp ; Set zero flag
ENDIF
ret
farUSBCheckMouseSupport ENDP
IFE MKF_KBC_SUPPORT
; USB data area flag in CS
bUBDataAreaPointer DW 0
;<AMI_PHDR_START>
;----------------------------------------------------------------------------
; Procedure: nDisableUSBMouse
;
; Description: This function disables the USB mouse support
;
; Input: None
;
; Output: None
;
; Modified: Nothing
;
;----------------------------------------------------------------------------
;<AMI_PHDR_END>
nDisableUSBMouse PROC NEAR PUBLIC
push ax
xor al, al
CommonEnDisUSBMouse::
push ds
push gs
push cs
pop gs
push WORD PTR GS:bUBDataAreaPointer
pop ds
cmp al, 2
jne ndum_EnaDisMouse
; Check whether mouse support is enabled or disabled
test bMouseStatusFlag, MOUSE_ENABLED_BIT_MASK
jmp SHORT ndum_MouseDone
ndum_EnaDisMouse:
; Reset the mouse enable flag
and bMouseStatusFlag, NOT MOUSE_ENABLED_BIT_MASK
or al, al
jz ndum_MouseDone
; Set the mouse enable flag
or bMouseStatusFlag, MOUSE_ENABLED_BIT_MASK
ndum_MouseDone:
pop gs
pop ds
pop ax
ret
nDisableUSBMouse ENDP
;<AMI_PHDR_START>
;----------------------------------------------------------------------------
; Procedure: nEnableUSBMouse
;
; Description: This function enables the USB mouse support
;
; Input: None
;
; Output: None
;
; Modified: Nothing
;
;----------------------------------------------------------------------------
;<AMI_PHDR_END>
nEnableUSBMouse PROC NEAR PUBLIC
push ax
mov al, 1
jmp SHORT CommonEnDisUSBMouse
ret
nEnableUSBMouse ENDP
;<AMI_PHDR_START>
;----------------------------------------------------------------------------
; Procedure: nGetUSBMouseStatus
;
; Description: This function disables the USB mouse support
;
; Input: None
;
; Output: ZR - Legacy mouse support disabled
; NZ - Legacy mouse support enabled
;
; Modified: Nothing
;
;----------------------------------------------------------------------------
;<AMI_PHDR_END>
nGetUSBMouseStatus PROC NEAR PUBLIC
push ax
mov al, 2
jmp SHORT CommonEnDisUSBMouse
ret
nGetUSBMouseStatus ENDP
ENDIF
IF MKF_USB_MODE EQ 3
;<AMI_PHDR_START>
;----------------------------------------------------------------------------
; Procedure: USBInterruptHandler
;
; Description: This is the common interrupt service routine which handles
; all the USB HC interrupts. This routine will call individual
; host controller interrupt handlers depending upon the
; interrupt status.
;
; Input: Nothing
;
; Output: Nothing
;
; Modified: Nothing
;
; Referrals: HCStruc
;
;----------------------------------------------------------------------------
;<AMI_PHDR_END>
EXTERN USBMiscFindIRQInService:NEAR
USBInterruptHandler PROC NEAR PUBLIC
cli
push ax
push bx
push cx
push es
UIH_ServiceALL:
call USBMiscFindIRQInService
or ax, ax
jz UIH_LeaveISR
push 0FFFFh
pop es
mov bx, ax
call farUSBRT_InvokeAPI
mov cl, bl
; Send EOI to the interrupt controller
mov al, 20h ;AL = EOI command
cmp cl, 8
jb UIH_EoiPri ;Br if using IRQ 0..7 (2nd 8259 needs no EOI)
out 0A0h, al
jcxz $+2
jcxz $+2
UIH_EoiPri:
out 20h, al
jcxz $+2
jcxz $+2
jmp SHORT UIH_ServiceALL
UIH_LeaveISR:
pop es
pop cx
pop bx
pop ax
iret
USBInterruptHandler ENDP
ENDIF ;; MKF_USB_MODE EQ 3
;<AMI_PHDR_START>
;----------------------------------------------------------------------------
; Procedure: farUSBAPI_Stop
;
; Description: This function stops the USB host controller
;
; Input: DS = 40h
; ES = 0
; FS = POST_DSEG
; GS = RUN_CSEG
;
; Output: None
;
; Modified: Nothing
;
;----------------------------------------------------------------------------
;<AMI_PHDR_END>
farUSBAPI_Stop PROC FAR USES DS ES AX BX
LOCAL stURP:URP_STRUC
; Fill URP with proper value
lea bx, stURP
push ss
pop es
mov (URP_STRUC PTR es:[bx]).bFuncNumber, USB_API_STOP
mov (URP_STRUC PTR es:[bx]).bSubFunc, 0
INVOKE_USB_API_HANDLER
ret
farUSBAPI_Stop ENDP
RUN_CSEG ENDS
;----------------------------------------------------------------------------
; C O D E S E G M E N T
;----------------------------------------------------------------------------
USB_CSEG SEGMENT USE16 PUBLIC 'CODE'
ASSUME cs:USB_CSEG
ASSUME ds:USB_DSEG
.586p
;<AMI_PHDR_START>
;----------------------------------------------------------------------------
; Procedure: farPowerManageUSB
;
; Description: This function is used to send power management command to
; the USB. Thie routine can suspend the USB and set the
; resume events and also can resume the USB from suspend
; state
;
; Input: AL 010h Suspend USB and arm USB for wakeup
; 020h Resume the USB from suspend
;
; Output: None
;
; Modified: Nothing
;
; Notes: This function can only be invoked from SMI module
;
;----------------------------------------------------------------------------
;<AMI_PHDR_END>
farPowerManageUSB PROC FAR PUBLIC
LOCAL stURP:URP_STRUC
push ax
push bx
push es
; Fill URP with proper value
lea bx, stURP
push ss
pop es
mov (URP_STRUC PTR es:[bx]).bFuncNumber, USB_API_POWER_MANAGEMENT
mov (URP_STRUC PTR es:[bx]).bSubFunc, al
; Code will be already in the SMI and in USB_CSEG so directly invoke API handler
call farUSBWrap_ApiHandler
pop es
pop bx
pop ax
ret
farPowerManageUSB ENDP
USB_CSEG ENDS
;----------------------------------------------------------------------------
END
;***************************************************************************;
;***************************************************************************;
;** **;
;** (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 + -