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

📄 hci.asm

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

	call	Get_USBRAM
	mov	ds, ax
	mov	es, ax

;R75 start
ifdef	USB_STORAGE_SUPPORT
	test	byte ptr [FDDALetterTable].RMDAttached, 0ffh
	jnz	Usb_Final_Init_Exit
;R77	test	BYTE PTR [FDDBLetterTable].RMDAttached, 0ffh
;R77	jnz	Usb_Final_Init_Exit
endif	;USB_STORAGE_SUPPORT
;R75 end

;R20	call	Host_Stop

;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	Disable_Host
	jmp	short Usb_Final_Init_End
Usb_Final_Init_Cont:
;R36A - end
endif	;S4_SUPPORT
endif	;ACPI_SUPPORT
;R36 - end

;R11 - start
	call	Ct_Check_USB_Disabled
	jnc	short @f

USB_KB_DISABLED:				;R36

	call	Record_USB_Disabled
;R36A	call	Host_Stop			;R20
;R36A	call	Host_Reset			;R14host controller reset
;R36A	mov	cx, wHostID
;R36A	add	cx, LEGACY_LO
;R36A	F000_CALL	Get_Pci
;R36Aifdef	IOTRAP_SUPPORT				;R22A
;R36A	and	al, not (USBSMIEN+0Fh)		;R22A
;R36Aelse	;IOTRAP_SUPPORT				;R22A
;R36A	and	al, not USBSMIEN
;R36Aendif	;IOTRAP_SUPPORT				;R22A
;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	Set_Host_Word
	call	Disable_Host			;R36A
	call	Close_USBRAM			;R20
	jmp	short Usb_Final_Init_Exit
@@:
ifdef	USB_MOUSE_SUPPORT			;R41
	push	ax				;R41
endif	;USB_MOUSE_SUPPORT			;R41
;R11 - end
Usb_Final_Init_End:				;R36A
;R41 - start
ifdef	USB_MOUSE_SUPPORT
	pop	ax
;R46	and	al, USBKBSUPPORT+USBMSSUPPORT
	and	al, USBKBSUPPORT		;R46
	or	al, REMOVEDEV			;R41D
;R46	and	byte ptr bUsbFlag, not (USBKBSUPPORT+USBMSSUPPORT)
	and	byte ptr bUsbFlag, not USBKBSUPPORT	;R46
	or	byte ptr bUsbFlag, al
;R41D	test	al, USBKBSUPPORT
;R41D	jnz	short Check_Ms_Support
;R41D	push	ax
;R41D	call	Remove_KbTask
;R41D	pop	ax
;R41DCheck_Ms_Support:
;R41D;R41A	test	al, USBKBSUPPORT
;R41D	test	al, USBMSSUPPORT		;R41A
;R41D	jnz	short Check_Support_Exit
;R41D	call	Remove_MsTask
;R41DCheck_Support_Exit:
else	;USB_MOUSE_SUPPORT
	or	byte ptr bUsbFlag, USBKBSUPPORT
endif	;USB_MOUSE_SUPPORT
;R41 - end

;R20	call	Allocate_USBRAM
;R20	call	Get_USBRAM
;R03 - start
ifdef	PNP_BIOS
	xor	edi,edi
;R20	mov	di,ax
	mov	di,ds				;R20
	shl	edi,4
ifndef	SMIHANDLE_IN_XGROUP			;R30
	call	Build_UsbRamNode	;build device node for USB RAM
else	;SMIHANDLE_IN_XGROUP			;R30
	POST_func_call	EGROUP:Build_UsbRamNode	;R30
endif	;SMIHANDLE_IN_XGROUP			;R30
endif;	PNP_BIOS
;R03 - start
;R20	mov	ds, ax
;R20	mov	es, ax
;R20
;R20	call	Host_Init
;R20
;R20	call	System_Control_Init
;R20
;R20	call	Resume_Tasks
;R20
;R20	call	Host_Run

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
;[]========================================================================[]

Disable_Host	proc	near
	call	Host_Stop			;R20
;R65 - start
ifdef	TWO_USB_HOST
	mov	cx, 2
	mov	al, 1
Disable_Host_Loop:
	push	ax
	push	cx
	call	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	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
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	Check_USB_Disabled		;host or legacy support disabled?
	jnz	short Report_USB_Fail

	call	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

;R67 - start
ifdef	ACPI_SUPPORT
		Public	Force_Disable_USBmouse
Force_Disable_USBmouse	Proc	far

		pushad
		push	ds

		call	Get_USBRAM
		mov	ds, ax
		and	byte ptr bUsbFlag, not USBMSSUPPORT

		pop	ds
		popad
		ret

Force_Disable_USBmouse	endp
endif	;ACPI_SUPPORT
;R67 - end
;R46 - start
;[]========================================================================[]
;Procedure:	Determine_Mouse_Trap
;Function:	Determine if to trap PS/2 mouse command before "Ms_Instal".
;Input:		none
;Output:	none
;[]========================================================================[]
	public	Determine_Mouse_Trap
;R55 Determine_Mouse_Trap	proc	near
Determine_Mouse_Trap	proc	far		;R55
	pushad
	push	ds

	call	Check_USB_Disabled		;host or legacy support disabled?
	jnz	short Determine_Mouse_Trap_Exit

	call	Get_USBRAM
	mov	ds, ax

	call	Ct_Check_USB_Disabled

	and	byte ptr bUsbFlag, not USBMSSUPPORT

	and	al, USBMSSUPPORT		;usb mouse support enabled?
	jz	short Determine_Mouse_Trap_Exit

	test	word ptr ds:wMsDevMap, 0FFFFh	;mouse present?
	jz	short Determine_Mouse_Trap_Exit

	or	bUsbFlag, al			;trap command enabled

Determine_Mouse_Trap_Exit:

	pop	ds
	popad
	ret
Determine_Mouse_Trap	endp

;[]========================================================================[]
;Procedure:	Report_USB_Mouse_Support
;Function:	Report the status of the USB mouse's supporting.
;Input:		none
;Output:	CF = 0 USB mouse support
;		CF = 1 no USB mouse support
;[]========================================================================[]
	public	Report_USB_Mouse_Support
;R55 Report_USB_Mouse_Support	proc	near
Report_USB_Mouse_Support	proc	far	;R55
	pushad
	push	ds

	call	Check_USB_Disabled		;host or legacy support disabled?
	jnz	short Report_USB_Mouse_Fail

	call	Get_USBRAM
	mov	ds, ax

	call	Ct_Check_USB_Disabled
	and	al, USBMSSUPPORT		;usb mouse support enabled
	and	byte ptr bUsbFlag, not USBMSSUPPORT
	or	byte ptr bUsbFlag, al
	test	al, USBMSSUPPORT
	jz	short Report_USB_Mouse_Fail

	clc					;mouse present
	jmp	short Report_USB_Mouse_Exit

Report_USB_Mouse_Fail:
	stc					;mouse absent

Report_USB_Mouse_Exit:
	pop	ds
	popad
	ret
Report_USB_Mouse_Support	endp
;R46 - end

;[]========================================================================[]
;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_Post_USBRAM
;Function:	Allocate USB_RAM for POST usage
;Input:		none
;Output:	none
;[]========================================================================[]

;R20Allocate_Post_USBRAM	proc	near
;R20	push	es
;R20	push	ds
;R20	pushad
;R20
;R20	mov	ax, 9000h
;R20
;R20	call	Record_USBRAM
;R20
;R20	mov	ds, ax
;R20	mov	es, ax
;R20	call	Init_USBRAM
;R20
;R20	popad
;R20	pop	ds
;R20	pop	es
;R20	ret
;R20Allocate_Post_USBRAM	endp

;[]========================================================================[]
;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]
;R20	mov	dx, 0C800h
;R31	mov	dx, 0DC00h			;R20;start from DC00h
;R31	mov	edi, 00F00000h			;R20;mask value
	mov	dx, 0C800h			;R31;start from C800h
	mov	edi, 0000000Fh			;R31;mask value
	mov	cx, 6
@@:
;R20	test	al, 0Fh
	test	eax, edi			;R20
	jz	short Use_Shadow
;R20	shr	eax, 4
;R20	add	dx, 400h
;R31	shr	edi, 4				;R20
;R31	sub	dx, 400h			;R20;next backward 16KB
	shl	edi, 4				;R31
	add	dx, 400h			;R31;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		;R20
	mov	LMEM_RESERVED[bp], edi		;R20
;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

⌨️ 快捷键说明

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