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

📄 hci.asm

📁 惠普公司bios完整源代码大机密!
💻 ASM
📖 第 1 页 / 共 5 页
字号:
	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

;R20 - start
;[]========================================================================[]
;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
;R32 - start
	mov	cl, dh
	sub	cl, 0C8h
	mov	edi, 0FFFFFFF0h
	rol	edi, cl
	and	LMEM_RESOURCE[bp], edi
	and	LMEM_RESERVED[bp], edi
;R32 - end

	mov	word ptr ds:[0],0		;R56

	F000_call	Ct_Disable_Shadow
Close_USBRAM_Exit:
	ret
;R20 - end

;************************************************************************
;*									*
;*	UHCI POST INTERFACE MODULE					*
;*									*
;************************************************************************

;[]========================================================================[]
;Procedure:	Init_USBRAM
;Function:	Initialize USB_RAM to default value
;Input:		DS,ES=USB_RAM
;Output:	none
;[]========================================================================[]

Init_USBRAM:
;R08	xor	ax, ax
;R08	mov	cx, 1000h
;R08	xor	di, di
;R08	rep	stosw
;R60	mov	cx, 2000h			;R08
	mov	cx, 4000h			;R60
	xor	si, si				;R08
	call	Clear_Buffer			;R08

;R60;R21 - start
;R60;set the upper 8Kb content of shadow RAM to prevent SCT testing error
;R60	push	es
;R60	push	di
;R60	mov	ax,ds
;R60	mov	es,ax
;R60	mov	ax,0ffffh		;pattern to fill
;R60	mov	di,2000h		;start from 8Kb address
;R60	mov	cx,2000h		;8Kb to fill
;R60;R21A	rep	stosw
;R60	rep	stosb			;R21A
;R60	pop	di	
;R60	pop	es
;R60;R21 - end

ifndef	PATACH_AMIDIAG				;R42
	mov	word ptr ds:[0], 0AA55h
endif	;PATACH_AMIDIAG				;R42
;R60	mov	word ptr ds:[2], 0CB10h
	mov	word ptr ds:[2], 0CB20h		;R60
	mov	dword ptr ds:[4], 'BSU$'

	mov	ax, ds
	shl	eax, 4
	mov	ds:dUsbRamAddr, eax
;R65	add	eax, offset FrameList
;R65	mov	ds:dFrameListAddr, eax

	call	Init_FL

	mov	word ptr wTaskLink, 0FFFFh	;task terminated
	mov	word ptr DevAddrMap+2, 0080h	;root hub device
;R65 - start
ifdef	TWO_USB_HOST
	mov	word ptr DevAddrMap+4, 0080h	;root hub device
endif	;TWO_USB_HOST
;R65 - end

	xor	ax, ax				;R65
	mov	bLedStatus, al			;R65

;R39 - start
;R83 - start
	mov	byte ptr bDelayRate,  125	;default typematic delay
	mov	byte ptr bRepeatRate, 25	;default typematic repeat rate
;R83 - end
;R83	mov	byte ptr bDelayRate,  31	;default typematic delay
;R83	mov	byte ptr bRepeatRate, 6		;default typematic repeat rate

;R65	mov	bUsbFlag, USBKBSUPPORT+USBMSSUPPORT	;R41
ifdef	USB_MOUSE_SUPPORT				;R65
	mov	bDevCtrl, MSDISABLE			;R41
endif	;USB_MOUSE_SUPPORT				;R65

ifdef	IOTRAP_SUPPORT
;R83	mov	bMsStatus1, 0FAh		;dummy code
;R83	mov	bMsDataPacket1, 0FAh		;dummy code

	mov	bMsStatus, 00h			;stream mode
						;disabled
						;scaling 1:1
						;no mouse button pressed
	mov	bResolution, 02h		;4 counts/mm resolution
	mov	bSampleRate, 64h		;100 times/s sample rate

	mov	bCipFlag, 0
	mov	bEmuCmdByte, 65h		;emulated commnad byte
	mov	bRealCmdByte, 65h		;physical command byte
	mov	bTrapEnabled, TRAPENABLE
	mov	wKcCmdProc, offset NullProc SMI_OFFSET
	mov	wKbCmdProc, offset NullProc SMI_OFFSET
	mov	wMsCmdProc, offset NullProc SMI_OFFSET
ENDIF	;IOTRAP_SUPPORT
;R39 - end
ifdef	USB_STORAGE_SUPPORT			;R75
	mov	WAIT_ACK_COUNT, 50		;R75
endif	;USB_STORAGE_SUPPORT			;R75

	ret

;[]========================================================================[]
;Procedure:	System_Control_Init
;Function:	Initialize system control task
;Input:		none
;Output:	none
;[]========================================================================[]

System_Control_Init:

	; Initialize Root Hub task

;R65	xor	ax, ax
;R65	mov	wPort1Status, ax
;R65	mov	wPort2Status, ax
;R65	mov	bLedStatus, al

;R65 - start
ifdef	TWO_USB_HOST
	cmp	byte ptr bHostNum, 1
	jne	Init_ControlQH
endif	;TWO_USB_HOST
;R65 - end

	mov	si, offset SysCtrlQH
	call	Init_QH
	mov	si, offset SysCtrlTD
	call	Init_TD
	or	byte ptr [si].bTdControl, ISS_IOC

	mov	si, offset SysCtrlTask
	call	Init_Task
	mov	byte ptr [si].bTkDevStatus, TK_WFP
	mov	byte ptr [si].bTkDevAddr, 1
	mov	byte ptr [si].bTkParentHost, 1		;R65
;R02	mov	word ptr [si].wTkInterval, 512
	mov	word ptr [si].wTkInterval, 1024			;R02
	mov	word ptr [si].wTkQueueHead, offset SysCtrlQH
	mov	word ptr [si].wTkTransDesp, offset SysCtrlTD
	mov	word ptr [si].wTkProc, offset System_Control SMI_OFFSET
	call	Link_Task

;R83;R06 - start
;R83	; Initialize Timer task, and no link at this stage until
;R83	; the USB keyboard is attached.
;R83
;R83	mov	si, offset TimerQH
;R83	call	Init_QH
;R83	mov	si, offset TimerTD
;R83	call	Init_TD
;R83;R47	or	byte ptr [si].bTdControl, ISS_IOC
;R83	call	Init_TimerTD				;R47
;R83
;R83	mov	si, offset TimerTask
;R83	call	Init_Task
;R83	mov	byte ptr [si].bTkDevStatus, TK_WFP
;R83	mov	byte ptr [si].bTkDevAddr, 1
;R83	mov	byte ptr [si].bTkParentHost, 1		;R65
;R83;R41	mov	word ptr [si].wTkInterval, 64
;R83
;R83ifdef	USB_MOUSE_SUPPORT				;R74
;R83	mov	word ptr [si].wTkInterval, 6	;6ms	;R74
;R83else;	USB_MOUSE_SUPPORT				;R74
;R83	mov	word ptr [si].wTkInterval, 16	;16ms	;R41
;R83endif;	USB_MOUSE_SUPPORT				;R74
;R83
;R83	mov	word ptr [si].wTkQueueHead, offset TimerQH
;R83	mov	word ptr [si].wTkTransDesp, offset TimerTD
;R83	mov	word ptr [si].wTkProc, offset Proc_Timer SMI_OFFSET
;R83;R06 - end
;R83
;R83;R50 - start
;R83ifdef   IOTRAP_SUPPORT
;R83        ; Initialize Response task, and no link at this stage until
;R83        ; the keyboard command process need respond to system.
;R83
;R83        mov     si, offset ResponseQH
;R83        call    Init_QH
;R83        mov     [si].wQhInterval, 4                     ;2ms interval
;R83        call    Link_QH_to_FL
;R83        mov     si, offset ResponseTD
;R83        call    Init_TD
;R83;R50A        call    Init_ResponseTD
;R83;R50A        mov     di, offset ResponseQH
;R83;R50A        mov     si, offset ResponseTD
;R83;R50A        call    Link_TD_to_QH
;R83
;R83        mov     si, offset ResponseTask
;R83        call    Init_Task
;R83        mov     byte ptr [si].bTkDevStatus, TK_WFP
;R83        mov     byte ptr [si].bTkDevAddr, 1             ;dummy device address
;R83	mov	byte ptr [si].bTkParentHost, 1		;R65
;R83        mov     word ptr [si].wTkInterval, 4            ;2ms interval
;R83        mov     word ptr [si].wTkQueueHead, offset ResponseQH
;R83        mov     word ptr [si].wTkTransDesp, offset ResponseTD
;R83        mov     word ptr [si].wTkProc, offset Proc_Response SMI_OFFSET
;R83endif   ;IOTRAP_SUPPORT
;R83;R50 - end

Init_ControlQH:					;R65
	; Link Control Transfer Queue Head for future using
	; and no TD link

;R65	mov	si, offset ControlQH
	mov	si, wControlQHAddr		;R65
	call	Init_QH
	mov	word ptr [si].wQhInterval, 1
	call	Link_QH_to_FL

	ret

;R83 - start
;[]========================================================================[]
;Procedure:	Init_Timer
;Function:	Initialize Timer task, and skip at this stage until
;		the timer is necessary.
;Input:		none
;Output:	none
;[]========================================================================[]

Init_Timer:
	mov	si, offset TimerQH
	call	Init_QH
	mov	si, offset TimerTD
	call	Init_TD

	mov	si, offset TimerTask
	call	Init_Task
	mov	byte ptr [si].bTkDevAddr, 1             ;dummy device address
	mov	byte ptr [si].bTkParentHost, 1
	mov	word ptr [si].wTkInterval, 4            ;4ms interval
	mov	word ptr [si].wTkQueueHead, offset TimerQH
	mov	word ptr [si].wTkTransDesp, offset TimerTD
	mov	word ptr [si].wTkProc, offset Proc_Timer SMI_OFFSET
	call	Link_Task
	ret
;R83 - end

;[]========================================================================[]
;Procedure:	Host_Init
;Function:	Initialize host controller
;Input:		none
;Output:	none
;[]========================================================================[]

Host_Init:

;R65	call	Ct_USB_ID
;R65	mov	wHostID, ax

;R38 - start
	; Turn on bus master and io space decoding,
	; avoid that these two bits are not turn-on
	; by PCI kernel.
	mov	cx, wHostID
	add	cx, 4				;command register
	F000_call	Get_PCI
	or	al, 00000111b			;bus master/io space
	F000_call	Set_PCI
;R38 - end

	mov	cx, wHostID
	add	cx, LEGACY_LO
	F000_call	Get_PCI
ifdef	IOTRAP_SUPPORT				;R22A
;R39	or	al, USBSMIEN+0Fh		;R22A;Enable Trap/SMI on USB IRQ
;R65 - start
ifdef	TWO_USB_HOST
	or	al, USBSMIEN
	cmp	byte ptr bHostNum, 1
	jne	short Not_Enable_IoTrap
	or	al, A20PASSEN+TRAPENABLE
Not_Enable_IoTrap:
else	;TWO_USB_HOST
;R65 - end
	or	al, USBSMIEN+A20PASSEN+TRAPENABLE	;R39;Enable SMI
endif	;TWO_USB_HOST				;R65
else	;IOTRAP_SUPPORT				;R22A
	or	al, USBSMIEN			;Enable Trap/SMI on USB IRQ
endif	;IOTRAP_SUPPORT				;R22A
	F000_call	Set_PCI

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

	; Global Reset

	call	Global_Reset

	; Clear USB Status Register

	mov	ax, 0FFFFh			;write clear
	mov	dx, USBSTS
	call	Set_Host_Word

	; USB Interrupt Enable Register

	mov	ax, IOC				;interrupt on complete
	mov	dx, USBINTR
	call	Set_Host_Word

	; Frame Number Register

	mov	ax, 0				;Starting from frame 0
	mov	dx, FRNUM
	call	Set_Host_Word

	; Frame List Base Address Register

;R65	mov	ax, ds
;R65	shl	eax, 4
;R65	add	eax, offset FrameList
	mov	eax, dFrameListAddr		;R65
	mov	dx, FRBASEADD
	call	Set_Host_Dword

	ret

;[]========================================================================[]
;Procedure:	Global_Reset
;Function:	Global host controller reset
;Input:		none
;Output:	none
;[]========================================================================[]

Global_Reset:
	pusha

	; Issue global reset and set maximum packet size to 64

	mov	al, GRESET+MAX_PACKET		;Global reset/max packet=64
	mov	dx, USBCMD
	call	Set_Host_Byte

	; Minimum delay time 10ms

	call	Delay_12ms

	; Clear reset signal

	mov	al, MAX_PACKET			;max packet=64
	mov	dx, USBCMD
	call	Set_Host_Byte

	popa
	ret

;R14 - start
;[]========================================================================[]
;Procedure:	Host_Reset
;Function:	Host controller reset
;Input:		none
;Output:	none
;[]========================================================================[]

Host_Reset:
	pusha

	; Issue host controller reset

	mov	al, HCRESET			;Host controller reset
	mov	dx, USBCMD
	call	Set_Host_Byte

	popa
	ret
;R14 - end

;R65 - start
;[]========================================================================[]
;Procedure:	Init_Host_Data
;Function:	Initialize host controller specific data
;Input:		none
;Output:	none
;[]========================================================================[]
Init_Host_Data:
ifdef	TWO_USB_HOST

	; Get host controllers PCI address

	call	Ct_USB_ID
	mov	wHostID1, ax
	mov	wHostID2, dx

	; Get host controller I/O space

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

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

	; Set frame list address

	xor	edx, edx
	mov	dx, ds
	shl	edx, 4
	mov	eax, offset FrameList1
	mov	ds:wFrameListAddr1, ax
	add	eax, edx
	mov	ds:dFrameListAddr1, eax
	mov	eax, offset FrameList2
	mov	ds:wFrameListAddr2, ax
	add	eax, edx
	mov	ds:dFrameListAddr2, eax

⌨️ 快捷键说明

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