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

📄 hci.asm

📁 惠普公司bios完整源代码大机密!
💻 ASM
📖 第 1 页 / 共 5 页
字号:
	; Set control QH/TD address

	mov	ax, offset ControlQH1
	mov	wControlQHAddr1, ax
	mov	ax, offset ControlTD1
	mov	wControlTDAddr1, ax

	mov	ax, offset ControlQH2
	mov	wControlQHAddr2, ax
	mov	ax, offset ControlTD2
	mov	wControlTDAddr2, ax

	ret

else	;TWO_USB_HOST

	; Get host controllers PCI address

	call	Ct_USB_ID
	mov	wHostID, ax

	; Get host controller I/O space

	mov	cx, wHostID
	add	cx, (USBBASE+1)
	F000_call	Get_PCI
	push	ax
	mov	cx, wHostID
	add	cx, USBBASE
	F000_call	Get_PCI
	pop	dx
	mov	ah, dl
	and	al, 0FCh
	mov	ds:wHostIoBase, ax

	; Set frame list address

	xor	edx, edx
	mov	dx, ds
	shl	edx, 4
	mov	eax, offset FrameList
	mov	ds:wFrameListAddr, ax
	add	eax, edx
	mov	ds:dFrameListAddr, eax

	; Set control QH/TD address

	mov	ax, offset ControlQH
	mov	wControlQHAddr, ax
	mov	ax, offset ControlTD
	mov	wControlTDAddr, ax

	ret

endif	;TWO_USB_HOST
;R65 - end

;R35 - start
else	;SMIHANDLE_IN_YGROUP
;[]========================================================================[]
;Procedure:	Usb_Init
;Function:	USB initialization
;Input:		none
;Output:	none
;[]========================================================================[]

	public	Usb_Init
Usb_Init	proc	near
	push	ds
	push	es
	pushad

	call	Ct_USB_Init
;R37	jnc	short @f
;R37	call	Record_USB_Disabled
;R37	stc
;R37	jmp	short Usb_Init_Exit
;R37@@:
	jc	short Usb_Init_Exit		;R37
	call	Record_USB_Enabled		;R37

	call	Allocate_USBRAM			
	call	Ex_Get_USBRAM
	mov	ds, ax
	mov	es, ax
	mov	bUsbFlag, USBKBSUPPORT		;R65
;R61 - start
ifdef	USB_MOUSE_SUPPORT
	call	Ct_Check_USB_Disabled
	and	al, USBMSSUPPORT
;R65	and	byte ptr bUsbFlag, not USBMSSUPPORT
	or	byte ptr bUsbFlag, al
endif	;USB_MOUSE_SUPPORT
;R61 - end
;R65 - start
	call	Init_Host_Data
ifdef	TWO_USB_HOST
	mov	al, 1
	call	Ex_Set_HostData
	call	Host_Init
	call	System_Control_Init
	call	Init_Timer			;R83
	mov	al, 2
	call	Ex_Set_HostData
	call	Host_Init
	call	System_Control_Init
else	;TWO_USB_HOST
;R65 - end

	call	Host_Init

	call	System_Control_Init
	call	Init_Timer			;R83
endif	;TWO_USB_HOST				;R65

	call	Ex_Resume_Tasks	

	call	Ex_Host_Run			

	clc

Usb_Init_Exit:
	popad
	pop	es
	pop	ds
	ret
Usb_Init	endp

;[]========================================================================[]
;Procedure:	Usb_Final_Init
;Function:	Re-initialize USB for reallocating USB_RAM to shadow
;Input:		none
;Output:	none
;[]========================================================================[]

	public	Usb_Final_Init
Usb_Final_Init	proc	near
	push	ds
	push	es
	pushad

	call	Ex_Check_USB_Disabled		
	jnz	Usb_Final_Init_Exit

	call	Ex_Get_USBRAM			
	mov	ds, ax
	mov	es, ax

;R36 - start
ifdef	ACPI_SUPPORT
ifdef	S4_SUPPORT
	extrn	Check_S4_Resume:near
	F000_call	DGROUP:Check_S4_Resume
;R36A	jnz	short USB_KB_DISABLED
;R36A - start
	jz	short Usb_Final_Init_Cont
	call	Ct_Check_USB_Disabled
	jc	short USB_KB_DISABLED
ifdef	USB_MOUSE_SUPPORT			;R41
	push	ax				;R41
endif	;USB_MOUSE_SUPPORT			;R41
	call	Ex_Disable_Host
	jmp	short Usb_Final_Init_End
Usb_Final_Init_Cont:
;R36A - end
endif	;S4_SUPPORT
endif	;ACPI_SUPPORT
;R36 - end

	call	Ct_Check_USB_Disabled
	jnc	short @f
USB_KB_DISABLED:				;R36 
	call	Record_USB_Disabled
;R36A 	call	Ex_Host_Stop			
;R36A 	call	Host_Reset			;host controller reset
;R36A 	mov	cx, wHostID
;R36A 	add	cx, LEGACY_LO
;R36A 	F000_CALL	Get_Pci
;R36A ifdef	IOTRAP_SUPPORT				
;R36A 	and	al, not (USBSMIEN+0Fh)		
;R36A else	;IOTRAP_SUPPORT				
;R36A 	and	al, not USBSMIEN
;R36A endif	;IOTRAP_SUPPORT				
;R36A 	F000_CALL	Set_Pci
;R36A 	mov	cx, wHostID
;R36A 	add	cx, LEGACY_HI
;R36A 	F000_CALL	Get_Pci
;R36A 	or	al, USBPIRQDEN
;R36A 	F000_CALL	Set_Pci
;R36A 	mov	ax, 0FFFFh			;clear all pending status
;R36A 	mov	dx, USBSTS
;R36A 	call	Ex_Set_Host_Word		
	call	Ex_Disable_Host			;R36A 
	call	Close_USBRAM			
	jmp	short Usb_Final_Init_Exit
@@:

;R61 - start
ifdef	USB_MOUSE_SUPPORT 
	push	ax	  
endif	;USB_MOUSE_SUPPORT
Usb_Final_Init_End:
ifdef	USB_MOUSE_SUPPORT
	pop	ax
	and	al, USBKBSUPPORT
	or	al, REMOVEDEV
	and	byte ptr bUsbFlag, not USBKBSUPPORT
	or	byte ptr bUsbFlag, al
else	;USB_MOUSE_SUPPORT
	or	byte ptr bUsbFlag, USBKBSUPPORT
endif	;USB_MOUSE_SUPPORT
;R61 - end
ifdef	PNP_BIOS
	xor	edi,edi
	mov	di,ds
	shl	edi,4
ifndef	SMIHANDLE_IN_XGROUP
	call	Build_UsbRamNode	;build device node for USB RAM
else	;SMIHANDLE_IN_XGROUP		
	POST_func_call	Build_UsbRamNode
endif	;SMIHANDLE_IN_XGROUP		
endif;	PNP_BIOS

Usb_Final_Init_Exit:
	popad
	pop	es
	pop	ds
	ret
Usb_Final_Init	endp

;R36A - start
;[]========================================================================[]
;Procedure:	Disable_Host
;Function:	Disable host controller for legacy supporting
;		No data is recorded in USBRAM
;Input:		none
;Output:	none
;[]========================================================================[]

Ex_Disable_Host	proc	near
	call	Ex_Host_Stop			;R20
;R65 - start
ifdef	TWO_USB_HOST
	mov	cx, 2
	mov	al, 1
Disable_Host_Loop:
	push	ax
	push	cx
	call	Ex_Set_HostData
endif	;TWO_USB_HOST
;R65 - end
	call	Host_Reset			;R14host controller reset
	mov	cx, wHostID
	add	cx, LEGACY_LO
	F000_CALL	Get_Pci
ifdef	IOTRAP_SUPPORT				;R22A
;R44	and	al, not (USBSMIEN+0Fh)		;R22A
	and	al, not (USBSMIEN+A20PASSEN+0Fh)	;R44
else	;IOTRAP_SUPPORT				;R22A
	and	al, not USBSMIEN
endif	;IOTRAP_SUPPORT				;R22A
	F000_CALL	Set_Pci
	mov	cx, wHostID
	add	cx, LEGACY_HI
	F000_CALL	Get_Pci
	or	al, USBPIRQDEN
	F000_CALL	Set_Pci
	mov	ax, 0FFFFh			;clear all pending status
	mov	dx, USBSTS
	call	Ex_Set_Host_Word
;R65 - start
ifdef	TWO_USB_HOST
	pop	cx
	pop	ax
	inc	al
	loop	Disable_Host_Loop
endif	;TWO_USB_HOST
;R65 - end
	ret
Ex_Disable_Host	endp
;R36A  - end
;[]========================================================================[]
;Procedure:	Report_USB_Keyboard
;Function:	Report the status of the USB keyboard's existence.
;Input:		none
;Output:	CF = 0 USB keyboard presented
;		CF = 1 no USB keyboard presented
;[]========================================================================[]
	public	Report_USB_Keyboard
Report_USB_Keyboard	proc	near
	pushad
	push	ds

	call	Ex_Check_USB_Disabled		;host or legacy support disabled?
	jnz	short Report_USB_Fail

	call	Ex_Get_USBRAM			
	mov	ds, ax

	test	word ptr ds:wKbdDevMap, 0FFFFh	;keyboard present?
	jz	short Report_USB_Fail

	clc					;keyboard present
	jmp	short Report_USB_Exit

Report_USB_Fail:
	stc					;keyboard absent

Report_USB_Exit:
	pop	ds
	popad
	ret
Report_USB_Keyboard	endp

;[]========================================================================[]
;Procedure:	Record_USB_Disabled
;Function:	Record USB legacy support disabled to USB_STATUS
;Input:		none
;Output:	none
;[]========================================================================[]

Record_USB_Disabled	proc	near
	push	ds
	push	ax

	F000_CALL	F000_Shadow_W
	mov	ax, 0F000h
	mov	ds, ax
	assume	ds:DGROUP
	mov	al, 01
	or	ds:USB_STATUS, al
	F000_CALL	F000_Shadow_R

	pop	ax
	pop	ds
	assume	ds:USB_RAM
	ret
Record_USB_Disabled	endp

;R37 - start
;[]========================================================================[]
;Procedure:	Record_USB_Enabled
;Function:	Record USB legacy support enabled to USB_STATUS
;Input:		none
;Output:	none
;[]========================================================================[]

Record_USB_Enabled	proc	near
	push	ds
	push	ax

	F000_CALL	F000_Shadow_W
	mov	ax, 0F000h
	mov	ds, ax
	assume	ds:DGROUP
	mov	al, 0FEh
	and	ds:USB_STATUS, al
	F000_CALL	F000_Shadow_R

	pop	ax
	pop	ds
	assume	ds:USB_RAM
	ret
Record_USB_Enabled	endp
;R37 - end

;[]========================================================================[]
;Procedure:	Allocate_USBRAM
;Function:	Allocate USB_RAM for run-time usage, may be shadow RAM or
;		base memory.
;Input:		none
;Output:	none
;[]========================================================================[]

Allocate_USBRAM	proc	near
	push	ds
	push	es
	pushad

	mov	eax, LMEM_RESOURCE[bp]
	mov	dx, 0C800h			;start from C800h
	mov	edi, 0000000Fh			;mask value
	mov	cx, 6
@@:
	test	eax, edi
	jz	short Use_Shadow
	shl	edi, 4				
	add	dx, 400h			;next upward 16KB
	loop	short @b

Use_Base_Mem:
	mov	ax, G_RAM
	mov	ds, ax
	assume	ds:G_RAM
	mov	ax, ds:SIZE_SYSRAM
;R81	sub	ax, 8				;top 8K basemem as temp USBRAM
	sub	ax, URAMSIZE_1K			;R81 top "URAMSIZE_1K" basemem as temp USBRAM
	and	ax, 0FFFCh			;4K boundary
	mov	ds:SIZE_SYSRAM, ax
	shl	ax, 6				;translate to segment address
	jmp	short Move_USB_RAM

Use_Shadow:
	or	LMEM_RESOURCE[bp], edi		
	mov	LMEM_RESERVED[bp], edi		
;R48  - starts
ifdef	SHADOW_UNIT_64K
	cmp	dh, 0D0h
;R51	ja	short USB_RAM_At_D
	jae	short USB_RAM_At_D		;R51
	push	dx
	F000_call C000_Shadow_RW
	pop	ax
	jmp	short Move_USB_RAM
USB_RAM_At_D:
endif	;SHADOW_UNIT_64K
;R48  - ends
	push	dx
	F000_CALL	Ct_Shadow_RW
	pop	ax

Move_USB_RAM:
	call	Record_USBRAM

	mov	ds, ax
	mov	es, ax
	call	Init_USBRAM

	popad
	pop	es
	pop	ds
	ret
Allocate_USBRAM	endp

;[]========================================================================[]
;Procedure:	Record_USBRAM
;Function:	Record USB_RAM segment address to USB_RAM_SEG at F000 segment.
;Input:		AX = segment address
;Output:	none
;[]========================================================================[]

Record_USBRAM	proc	near
	push	ds
	push	ax

	push	ax
	F000_CALL	F000_Shadow_W
	mov	ax, 0F000h
	mov	ds, ax
	assume	ds:DGROUP
	pop	ax
	mov	ds:USB_RAM_SEG, ax
	F000_CALL	F000_Shadow_R

	pop	ax
	pop	ds
	assume	ds:USB_RAM
	ret
Record_USBRAM	endp

;[]========================================================================[]
;Procedure:	Close_USBRAM
;Function:	Close USB_RAM if Shadow RAM
;Input:		DS = point to USB_RAM
;Output:	none
;[]========================================================================[]

Close_USBRAM:
	mov	dx, ds
	cmp	dx, 0A000h			;base memory?
	jb	short Close_USBRAM_Exit
	mov	cl, dh
	sub	cl, 0C8h
	mov	edi, 0FFFFFFF0h
	rol	edi, cl
	and	LMEM_RESOURCE[bp], edi
	and	LMEM_RESERVED[bp], edi

⌨️ 快捷键说明

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