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

📄 pcipost.asm

📁 awardbios源文件.供喜欢研究底层技术人员参考学习.
💻 ASM
📖 第 1 页 / 共 5 页
字号:
		ALIGN	4
		Public	Pci_IO_Mem_Init
Pci_IO_Mem_Init Proc	Near

		call	fProc_Pci_IO_Mem_Init
		ret

Pci_IO_Mem_Init Endp

;--------------------------------------------------------------------
;if any shadow segment is not used
;  ---> call hook in PCICHIP.ASM to disable it
;
;if any shadow segment is originally not available for PCI ROM
;  ---> if setup setting is set to ENABLE
;		do nothing
;	else
;		call hook in PCICHIP.ASM to disable it
;--------------------------------------------------------------------
		ALIGN	4
		public	Disable_UnUsed_Shadow
Disable_UnUsed_Shadow	Proc	Near

		POST_FUNC_CALL EDisable_UnUsed_Shadow
		ret

Disable_UnUsed_Shadow	Endp

;---------------------------------------------------------------------------
;
;		copy ROM image from SI:0 --> DI:0
;
;Input	:	SI = source segment
;		DI = Destination segment
;		AL <> 0 : copy size depends on ROM size in SI:2
;		   == 1 : copy size = input CX (no. of 4K)
;
;---------------------------------------------------------------------------
		ALIGN	4
		Public	Copy_ROM
Copy_ROM	Proc	Near

		POST_FUNC_CALL ECopy_Rom
		ret

Copy_ROM	Endp

;R82 ;[]============================================================[]
;R82 ;Input	:	CL = Request Memory spaces with size = CL * 4K
;R82 ;		     e.g. CL = 1 --> request 4K bytes
;R82 ;
;R82 ;Output	:	AL = 1 --> NC : AVAIL_LMEM_ADDR[bp] = availbale address
;R82 ;			   CF : No address available
;R82 ;[]============================================================[]
;R82 		ALIGN	4
;R82 		ASSUME	DS:NOTHING
;R82 		Public	Get_Available_LMEM
;R82 Get_Available_LMEM	Proc	Near
;R82
;R82 		POST_FUNC_CALL EGet_Available_LMEM
;R82 		ret
;R82
;R82 Get_Available_LMEM	Endp

;[]============================================================[]
;Enter Protected Mode with DS point to 00000000h
;[]============================================================[]
		ALIGN	4
		Public	Enter_Protect_Mode
Enter_Protect_Mode	Proc	Near

                mov     ax, cs
                mov     ds, ax
                assume  ds:dgroup

                lgdt    fword ptr GDTR1

                mov     eax, cr0
                or      al, 1
                mov     cr0, eax

                mov     ax, DATA1_INDEX
                mov     ds, ax			; ds = 00000000h

		ret

Enter_Protect_Mode	Endp

;[]============================================================[]
;[]============================================================[]
		ALIGN	4
		Public	Leave_Protect_Mode
Leave_Protect_Mode	Proc	Near

                mov     eax, cr0
                and     al, NOT 1
                mov     cr0, eax
		ret

Leave_Protect_Mode	Endp

;[]============================================================[]
;Input	:	CH - Slot identification Number
;Output :	AX - VENDER ID
;Destroy:	AX
;[]============================================================[]
		Public	fProc_Get_Vendor_ID
fProc_Get_Vendor_ID	Proc	Far
		call	Get_Vendor_ID
		retf
fProc_Get_Vendor_ID	Endp
		ALIGN	4
		ASSUME	DS:NOTHING
		public	Get_Vendor_ID
Get_Vendor_ID	Proc	Near

		push	cx
		xor	cl, cl			;Vendor ID
		call	Get_CfgSpace_Word

		cmp	ax, -1			;valid vendor ID
		stc
		je	Yes_Invalid
		clc
Yes_Invalid:
		pop	cx
		ret

Get_Vendor_ID	Endp

;[]============================================================[]
;Input	:	CH - Slot identification Number
;Output :	AX - DEVICE ID
;Destroy:	AX
;[]============================================================[]
		Public	fProc_Get_Device_ID
fProc_Get_Device_ID	Proc	Far
		call	Get_Device_ID
		retf
fProc_Get_Device_ID	Endp
		ALIGN	4
		ASSUME	DS:NOTHING
		Public	Get_Device_ID
Get_Device_ID	Proc	Near

		push	cx
		mov	cl, 02			;Device ID
		call	Get_CfgSpace_Word
		pop	cx
		ret

Get_Device_ID	Endp

;[]==============================================================[]
;PciRom_After_Init:
;	Force shadow RAM readonly after option ROM initialization
;Saves: all
;Input : none
;Output: None
;[]==============================================================[]
		ALIGN	4
		public	PciRom_After_Init
PciRom_After_Init	proc	near

		POST_FUNC_CALL EPciRom_After_Init
		ret

PciRom_After_Init	endp

;[]==============================================================[]
;PciRom_Before_Init:
;	special treatment before option initialization
;Saves: all
;Input : none
;Output: None
;[]==============================================================[]
		ALIGN	4
		public	PciRom_Before_Init
PciRom_Before_Init	proc	near

		call	fProc_PciRom_Before_Init

		ret

PciRom_Before_Init	endp

ifdef	SUPPORT_PCISLOT_IDE
		Public	Open_8673
Open_8673	proc	near

		mov	dx, 108h
		mov	al, 04Ah
		out	dx, al
		NEWIODELAY
		mov	al, 06Ch
		out	dx, al
		NEWIODELAY

		mov	al, cl
		out	dx, al
		NEWIODELAY
		inc	dl
		in	al, dx
		NEWIODELAY

		ret

Open_8673	endp

		Public	Set_8673
Set_8673	proc	near

		xchg	al, cl
		mov	dx, 108h
		out	dx, al
		NEWIODELAY
		inc	dl
		xchg	al, cl
		out	dx, al
		NEWIODELAY
		mov	dx, 108h
		mov	al, 034h
		out	dx, al
		NEWIODELAY

		ret

Set_8673	endp
endif;	SUPPORT_PCISLOT_IDE

endif	;PCI_BUS

FCODE		ENDS

;--------------------------------------------------------------
;--------------------------------------------------------------
;----- The following codes will be located at E000 ! ----------
;----- The following codes will be located at E000 ! ----------
;----- The following codes will be located at E000 ! ----------
;----- The following codes will be located at E000 ! ----------
;--------------------------------------------------------------
;--------------------------------------------------------------
EGROUP		GROUP	ECODE
ECODE		SEGMENT USE16 PARA PUBLIC 'ECODE'
		ASSUME	CS:EGROUP, DS:G_RAM, ES:EGROUP

ifdef	PCI_BUS

;--------------------------------------------------------
;Input	:	SI = C800 - DF80
;		CL =  number of 4K to mark
;--------------------------------------------------------
		ALIGN	4
		ASSUME	DS:NOTHING
		Public	Mark_Addr_Not_Available
Mark_Addr_Not_Available	Proc	Near

		mov	eax, 1
		shl	eax, cl
		dec	eax

		mov	cx, si
		mov	cl, ch
		sub	cl, 0C8h
		shl	eax, cl
		or	LMEM_RESOURCE[bp], eax

		ret

Mark_Addr_Not_Available	Endp

;---------------------------------------
;Input : SI - segment to check
;Output: zero set  - ROM existed
;	 not zero  - ROM no existed
;---------------------------------------
		Public	Check_ROM_Exist
Check_ROM_Exist	proc	near
		mov	ds, si
		mov	ax, ds:[0]
		iodelay
		cmp	ax, 0AA55h			;ROM signature?
		ret
Check_ROM_Exist	endp

		Public	Rom_In_Terms_of_4K
Rom_In_Terms_of_4K	Label	Near

		mov	cl, ds:[2]			;ROM size in 512K
		test	cl, 07h				;size < 4K
		jz	@F				;no, continue!
		add	cl, 08h				;  to 4K
	@@:
		shr	cl, 3				;in terms of 4K
		ret

;-------------------------------------------
;-------------------------------------------
		ALIGN	4
		Public	Invalidate_Shadow_Seg
Invalidate_Shadow_Seg	Proc	Near
;R82 - starts
ifdef	SHADOW_UNIT_64K

		mov	eax, LMEM_RESOURCE[bp]
;R90		xor	al, al			;Free C8 - CF
		test	eax, 00FFFF00h		;D0-DF contain legacy stuff?
		jz	No_Legacy_At_D
		or	eax, 00FFFF00h		;invalidate the whole D Segment

	No_Legacy_At_D:

		mov	LMEM_RESOURCE[bp], eax
		ret

else	;SHADOW_UNIT_64K
;R82 - ends
		F000_CALL Ct_Shadow_Unit
		mov	edi, 00Fh
		cmp	cx, 4000h
		mov	cl, 4
		je	@F
		mov	edi, 0FFh
		mov	cl, 8
	@@:

	;------------------------------------
	_A_A:
		test	LMEM_RESOURCE[bp], edi
		jz	_B_B
		or	LMEM_RESOURCE[bp], edi
	_B_B:

		shl	edi, cl
		test	edi, 0FF000000h
		jz	_A_A
	;------------------------------------

		ret
endif	;SHADOW_UNIT_64K				;R82

Invalidate_Shadow_Seg	Endp

;---------------------------------------
;---------------------------------------
E000_A20_On	Proc	Near
		push	ds
		F000_CALL A20_On
		pop	ds
		ret
E000_A20_On	Endp

;---------------------------------------
;---------------------------------------
		public	E000_A20_Off
E000_A20_Off	Proc	Near
		push	ds
		F000_CALL A20_Off
		pop	ds
		ret
E000_A20_Off	Endp

;[]================================================================[]
;Function : Far call to write PCI double word value
;Input  : CX - device + function number	, CURRENT_BUS_NO[bp] = bus No.
;Output : none
;[]================================================================[]
		Public	F000_Set_CfgSpace_Dword
F000_Set_CfgSpace_Dword	proc	near
		call	fProc_Set_CfgSpace_Dword
		ret
F000_Set_CfgSpace_Dword	endp

;[]================================================================[]
;Function : Far call to write PCI word value
;Input  : CX - device + function number	, CURRENT_BUS_NO[bp] = bus No.
;Output : none
;[]================================================================[]
		Public	F000_Set_CfgSpace_word
F000_Set_CfgSpace_word	proc	near
		call	fProc_Set_CfgSpace_word
		ret
F000_Set_CfgSpace_word	endp

;[]================================================================[]
;Function : Far call to write PCI byte value
;Input  : CX - device + function number	, CURRENT_BUS_NO[bp] = bus No.
;Output : none
;[]================================================================[]
		Public	F000_Set_CfgSpace_Byte
F000_Set_CfgSpace_Byte	proc	near
		call	fProc_Set_CfgSpace_Byte
		ret
F000_Set_CfgSpace_Byte	endp

;[]================================================================[]
;Function : Far call to read PCI double word value
;Input  : CX - device + function number	, CURRENT_BUS_NO[bp] = bus No.
;Output : none
;[]================================================================[]
		Public	F000_Get_CfgSpace_Dword
F000_Get_CfgSpace_Dword	proc	near
		call	fProc_Get_CfgSpace_Dword
		ret
F000_Get_CfgSpace_Dword	endp

;[]================================================================[]
;Function : Far call to read PCI word value
;Input  : CX - device + function number	, CURRENT_BUS_NO[bp] = bus No.
;Output : none
;[]================================================================[]
		Public	F000_Get_CfgSpace_word
F000_Get_CfgSpace_word	proc	near
		call	fProc_Get_CfgSpace_word
		ret
F000_Get_CfgSpace_word	endp

;[]================================================================[]
;Function : Far call to read PCI Byte value
;Input  : CX - device + function number	, CURRENT_BUS_NO[bp] = bus No.
;Output : none
;[]================================================================[]
		Public	F000_Get_CfgSpace_Byte
F000_Get_CfgSpace_Byte	proc	near
		call	fProc_Get_CfgSpace_Byte
		ret
F000_Get_CfgSpace_Byte	endp

;[]============================================================[]
;Input	:	CH - Slot identification Number
;Output :	AX - VENDER ID
;Destroy:	AX
;[]============================================================[]
		ALIGN	4
		ASSUME	DS:NOTHING
		Public	F000_Get_Vendor_ID
F000_Get_Vendor_ID	Proc	Near

		call	fProc_Get_Vendor_ID
		ret

F000_Get_Vendor_ID	Endp

;[]==============================================================[]
;EPciRom_After_Init:
;	Force shadow RAM readonly after option ROM initialization
;Saves: all
;Input : none
;Output: None
;[]==============================================================[]
		ALIGN	4

EPciRom_After_Init	proc	near

		PUSH_ALL

IF	RELEASE_E000_FOR_PCI
	;Enable E0000-E7FFF shadow RAM read/write because we have
	;to release this area for PCI ROM

		F000_CALL E000_64k_Shadow_RW
ENDIF	;RELEASE_E000_FOR_PCI

;R21B - starts
;R68A		push	dword ptr LMEM_BEFORE_ROM[bp]

;R21C		mov	eax, LMEM_BEFORE_ROM[bp]
;R21C		mov	edx, LMEM_RESOURCE[bp]
;R21C		not	eax
;R21C		and	edx, eax
;R21C		mov	LMEM_BEFORE_ROM[bp], edx
;R21C - starts
		mov	eax, LMEM_BEFORE_ROM[bp]
		or	eax, LMEM_RESOURCE[bp]
		mov	LMEM_BEFORE_ROM[bp], eax
;R21C - ends
;R21B - ends

	;init NON-Compliance ROMs on all Buses

		call	Non_PCI_Compliance_ROM

⌨️ 快捷键说明

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