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

📄 pmupost.asm

📁 惠普公司bios完整源代码大机密!
💻 ASM
📖 第 1 页 / 共 5 页
字号:
ifdef	VT8371					;R04
VT694X	EQU	VT8371				;R04
VT694X_PP	EQU	VT8371_PP		;R04B
endif;	VT8371					;R04

ifdef	VT601					;R04
VT694X	EQU	VT601				;R04
VT694X_PP	EQU	VT601_PP		;R04B
endif;	VT601					;R04

ifdef	VT8605					;R04C
VT694X	EQU	VT8605				;R04C
VT694X_PP	EQU	VT8605_PP		;R04C
endif;	VT8605					;R04C


RSM		MACRO
		db     0FH,0AAH 	; Not defined in MASM.
		ENDM

FIXOFST 	MACRO	ADDRESS
		dw	offset ADDRESS - offset SMI_Handler_Start
		ENDM

;[]-----------------------------------------------------------------------[]
;     GGGGGGGG		   RRRRRRRR	    AA	     MMM       MMM
;   GGGGGGGGGGG 	   RRRRRRRRR	   AAAA      MMMMM   MMMMM
;  GGGG 		   RRR	  RRR	  AAAAAA     MMMMMM MMMMMM
;  GGG	  GGGGG 	   RRRRRRRRR	 AAA  AAA    MMM MMMMM MMM
;  GGGG     GGGG	   RRRRRRRR	AAAAAAAAAA   MMM MMMMM MMM
;   GGGGGGGGGGGG	   RRR	 RRR   AAAAAAAAAAAA  MMM  MMM  MMM
;    GGGGGGGGGG  ========  RRR	  RRR AAA	 AAA MMM  MMM  MMM
;[]-----------------------------------------------------------------------[]
G_RAM		SEGMENT USE16 AT 0

		ORG	04H*4
		include SEG_0.INC

		ORG	400H
		include G_RAM.INC

G_RAM		ENDS
;OEM02 if	STD_Function		EQ	1
if	ACPI_RESUME	EQ	1		;OEM02
SM_RAM		SEGMENT USE16 AT 0
		INCLUDE SM_RAM.INC
SM_RAM		ENDS
ZV_Temp_Stack	SEGMENT USE16 AT 0
		org	1000h
VIDEO_BUFFER	LABEL	WORD
		org	2000h
VMode_BUFFER	LABEL	WORD
		org	0FFF0h
ZV_STACK_TOP	LABEL	DWORD
ZV_Temp_Stack	ENDS
;OEM02 endif	;STD_Function		EQ	1
endif	;ACPI_RESUME	EQ	1		;OEM02


;OEM05		COMPILE_FOR_CYRIXSMI	=	1
;OEM05		include	cyrixsmi.inc	;include SMI_STRUCT

;[]-----------------------------------------------------------------------[]
;  PPPPPPPPP  MMM	MMM	  RRRRRRRR	   AA	    MMM       MMM
;  PPP	  PPP MMMMM   MMMMM	  RRRRRRRRR	  AAAA	    MMMMM   MMMMM
;  PPPPPPPPP  MMMMMM MMMMMM	  RRR	 RRR	 AAAAAA     MMMMMM MMMMMM
;  PPPPPPPP   MMM MMMMM MMM	  RRRRRRRRR	AAA  AAA    MMM MMMMM MMM
;  PPP	      MMM MMMMM MMM	  RRRRRRRR     AAAAAAAAAA   MMM MMMMM MMM
;  PPP	      MMM  MMM	MMM	  RRR	RRR   AAAAAAAAAAAA  MMM  MMM  MMM
;  PPP	      MMM  MMM	MMM ===== RRR	 RRR AAA	AAA MMM  MMM  MMM
;[]-----------------------------------------------------------------------[]
PM_RAM		SEGMENT USE16 AT 0

		ORG	0

PM_RAM_START	LABEL	BYTE
		include 		PM_RAM.INC
		include 		CT_PMRAM.INC
PM_RAM_LEN	EQU	$-Offset PM_RAM:PM_RAM_START

PM_RAM		ENDS

DGROUP		GROUP	FCODE
FCODE		SEGMENT USE16 PARA Public 'CODE'
		ASSUME	CS:DGROUP

ifdef	S3_SUPPORT
                ALIGN   4
STR_Change_SMBase	Label	Near

		mov	dx,ACPI_Port+28h
		mov	al,0ffh
		out 	dx,al

        ; Change SMBase

                mov     eax,0A0000h
                mov     di,0FEF8h               ;SMBASE location
                mov     dword ptr cs:[di], eax
		mov	dx,ACPI_Port+2dh
		mov	al,01h
		out 	dx,al

		DB	0EAH
		DW	offset Change_SM_RET
		DW	0F000h
Change_SM_RET:
;R72		POST_FUNC_Call	End_Pmi_Handler
		FAR_CAll   <offset E000_End_Pmi_Handler>, 0E000h		;R72

                RSM

STR_Change_SMBase_L EQU     $ - offset STR_Change_SMBase

Set_PMWORD_Clear:
		mov	dx,ACPI_Port
;R39		mov	cl,dl
		mov	dl,cl			;R39
		mov	ax,0FFFFh
		out	dx,ax
		ret

Clear_PM_Status	Proc	Near
		mov	cl, 00h
		call	Set_PMWORD_Clear
		mov	cl, 30h
		call	Set_PMWORD_Clear
		mov	cl, 28h
		call	Set_PMWORD_Clear
		mov	cl, 20h
		call	Set_PMWORD_Clear
		ret

Clear_PM_Status	Endp

Resume_Stack1	EQU	0AFFEh

   		Public	S2_RESUME
S2_RESUME:
   		Public	S3_RESUME
S3_RESUME:
mov al,92h
out 80h,al
		mov	ax,cs
		mov	ss,ax

; Enable SMRAM can be access
;R21 - starts
ifdef	VT8371
		RDMSR_K7	SYS_CFG
		or	eax,MtrrFixDramModEn
		WRMSR_K7

	 	wbinvd
	 	xor	eax,eax
	 	mov	edx,eax
 		WRMSR_K7	MTRRfix16k_A000

		wbinvd

	;Disable the MTRRFixDramModEn
		RDMSR_K7	SYS_CFG
		and	eax,NOT MtrrFixDramModEn
		WRMSR_K7


;NOTE: There are two methods to handle SMI in K7. We are using the remapping
;      method in this BIOS, meanning no SMbase is changed.
;      The initialization process is:
;      1. copy SMI handler into B8000h using MTRRfix16k_A000
;      2. enable K7 remapping function using SMMLocalAddr, SMMDestAddr and
;         HWCR

;Enable the MTRRFixDramModEn
		RDMSR_K7	SYS_CFG
		or	eax,MtrrFixDramModEn
		WRMSR_K7

;Change the Attributes of A000 & B000 segments to uncacheable
	 	wbinvd
 		RDMSR_K7	MTRRfix16k_A000
	 	mov	eax,18181818h	;UC and R/W enabled
	 	mov	edx,18181818h
 		WRMSR_K7
endif;	VT8371
;R21 - ends
		mov	cx, VT694X + 63h   ;Enable a000:0 - b000:ffff read/write to DRAM
		Rom_Call       Get_PMU
		or	al, 01h
		Rom_Call       Set_PMU

		cld
		mov	ax,0A000h
		mov	es,ax
		xor	di,di

		mov	ax,03800h
		mov	ds,ax
		xor	si,si
ifndef	MP_Support					;R67
		mov	cx,3000h/4			;Save 12K
else	;MP_Support					;R67
		mov	cx,2000h/4			;R67;Save 8K
endif	;MP_Support					;R67
		rep	movsd

		mov	si,0E000h - 8000h
		mov	cx,2000h/4   			;Save 8K
		rep	movsd

ifdef	MP_Support					;R67
		mov	ax,CPU2_SEGMENT			;R67
		mov	ds,ax				;R67
		xor	si,si				;R67
		mov	cx,1000h/4			;R67Save 4K
		rep	movsd				;R67
endif	;MP_Support					;R67

	;;;;	setup stack

		mov	ax,3000h
		mov	ss,ax
		mov	sp,Resume_Stack1

;R21 - starts
ifdef	VT8371
		wbinvd
		mov	cx,VT8371 + 63h		;R04
		mov	bx, 0fch		;R04
		call	Get_Set_PMU		;R04
		xor	eax, eax		;UC and R/W disable
		mov	edx, eax
		WRMSR_K7	MTRRfix16k_A000

;enable K7 SMM remapping function
;K7-Bx has different MSRs to support SM remapping function, so we do CPUID
;to support both K7-Ax and K7-Bx

		K7_CPUID	1		;get model & stepping
		and	ax,0fffh
		cmp	ax,602h
		jbe	SMM_K7_Ax_1
		cmp	ax,604h			;K7-A3?
		jne	SMM_K7_Bx_1		;no, it's a K7-Bx
SMM_K7_Ax_1:
		mov	eax,020000h		;set SMMLocal=20000h
		mov	edx,0
		WRMSR_K7	SMMLocalAddr
		mov	eax,0A0000h
		mov	edx,18000000h
		WRMSR_K7	SMMDestAddr
		RDMSR_K7	HWCR
		or	eax,601h		;enable SRE
		WRMSR_K7	HWCR

		jmp	SMM_remapping_end_1
SMM_K7_Bx_1:
		xor	edx,edx
		mov	eax,0b0000h
		WRMSR_K7	SMM_BASE
		xor	edx,edx
		mov	eax,1			;AVA=1, AMD=UC(000b), no Tseg
		WRMSR_K7	SMMMASKHL

		mov	eax,cr3
		mov	cr3,eax

SMM_remapping_end_1:
endif;	VT8371
;R21 - ends

		push	bx
		extrn	Get_PM_RAM_Seg:near
		call	Get_PM_RAM_Seg
		mov	ds,ax
	ifdef	VT8371			;R21
		Call	Not_Protect_RW	;R21 OPEN_PM_RAM
	else;	VT8371			;R21
		Call	OPEN_PM_RAM
	endif;	VT8371			;R21
		pop	bx
		mov	byte ptr ds:[Software_SMI_Type],S3_RESTORE_REQ
;OEM13 - start
		push	ds
		push	si
		pusha
		mov	ax, 0f000h
		mov	ds, ax
		mov	si, offset ACPI_Info_Byte
		and	byte ptr ds:[si],not 02h

		mov	dx, ACPI_PORT
		in	ax, dx
		and	ax, 400h
		or	ax, ax
		jz	short NotWakeupFromRTC1

		or	byte ptr ds:[si], 02h
	NotWakeupFromRTC1:
		popa
		pop	si
		pop	ds
;OEM13 - end
	ifdef	VT8371			;R21
                Call	Not_Protect	;R21 Close_PM_RAM
	else;	VT8371			;R21
                Call	Close_PM_RAM
	endif;	VT8371			;R21

	;;;;	2. issue software smi to change CPU SMBASE

		Call	E000_Shadow_R

		Call	Clear_PM_Status

ifndef	VT8371			;R21
ifndef	Not_Init_Cyrix			;R35
		Call	StrCheckCyrix	;R35
		jne	short Cyrix1	;R35
endif	 ;Not_Init_Cyrix		;R35

                mov     ax,SEG STR_Change_SMBase
                mov     ds,ax
                mov     ax,03800h               ; orginal CPU SMBase
                mov     es,ax
                mov     cx,STR_Change_SMBase_L      ;dword length
                mov     si,offset STR_Change_SMBase
                xor     di,di
                rep     movsb
Cyrix1:				;R35

;R72		POST_FUNC_Call	Ct_Close_SM_RAM		;R13
		FAR_CAll   <offset E000_Ct_Close_SM_RAM>, 0E000h		;R72
endif;	VT8371			;R21

	;;;;	3. CPU L1/L2 cache

		push	ds
		mov	ax,G_RAM
		mov	ds,ax
		ASSUME	DS:G_RAM
ifndef	Not_Init_Cyrix			;R35
		call	StrCheckCyrix	;R35
		jnz	short Cyrix2	;R35
endif	 ;Not_Init_Cyrix		;R35

;R72		post_func_call	ConfigurePProL2Cache 	;L2 cache initialization
		FAR_CAll   <offset E000_ConfigurePProL2Cache>, 0E000h		;R72

Cyrix2:					;R35
	      	pop	ds
		invd

		mov	eax,cr0
		and	eax,not 60000000h		;Enable L1 cache
		mov	cr0,eax				;to speed up resume

		call	Reset_8237			;initialize 8254,8237
;R13		call	E000_64K_shadow_R
;R13		call	Restore_VGA_State

ifndef	Not_Init_Cyrix			;R35
		Call 	StrCheckCyrix	;R35
		jz	short Cyrix3	;R35

		Call	UNlock_Cyrix   	;R35
		Call	F_Init_Cyrix	;R35
		Call	Lock_Cyrix	;R35
Cyrix3:					;R35
endif	 ;Not_Init_Cyrix		;R35

	;;;;	4. Software SMI.
;R72		POST_FUNC_Call	E000_Ct_Enable_SMI
		FAR_CAll   <offset E_E000_Ct_Enable_SMI>, 0E000h		;R72
	ifdef	VT8371					;R34A
		call	Disable_E000_ROM_Shadow		;R34
	endif;	VT8371					;R34A
@@:
		mov	al,1		;R32
        	call	Issue_SW_SMI    ;Change SMBASE
;R34		call	Disable_E000_ROM_Shadow
		jmp	short @B

;R13Restore_VGA_State proc near
;R13		push	ds
;R13		push	es
;R13		extrn	Get_PM_RAM_Seg:near
;R13		call	Get_PM_RAM_Seg
;R13		mov	es,ax
;R13
;R13; Enable SMRAM can be access
;R13		post_func_call	CT_OPEN_SM_RAM
;R13		post_func_call	Get_SMBASE_SEG
;R13
;R13		shr	eax, 4
;R13		mov	ds, ax  	  	;destination segment address
;R13		mov	si, offset VGA_Data_Save
;R13
;R13;Retore AGP IO/MEM Space
;R13
;R13		mov	cx,(AGP_SLOTID shl 8) + 04h
;R13@@:
;R13		lods	byte ptr ds:[si]
;R13		call	Set_CT
;R13		inc	cl
;R13		cmp	cl,40h
;R13		jne	short @b
;R13
;R13;Retore VGA IO/MEM Space
;R13
;R13		xor	cx,cx
;R13		mov	cl,byte ptr es:[VGA_DEV_ID]
;R13  		shl	cx,11
;R13		add	cx,04h
;R13@@:
;R13		mov	bl,byte ptr es:[VGA_SLOT_ID]
;R13		lods 	byte ptr ds:[si]
;R13		Post_func_call	Set_PCI1
;R13		inc	cl
;R13		cmp	cl,40h
;R13		jne	short @b
;R13
;R13;Disable SM Ram Access
;R13
;R13		post_func_call	Ct_Close_SM_RAM
;R13
;R13;Set Original int 10 Vector
;R13
;R13		xor	ax,ax
;R13		mov	es,ax
;R13		mov	si,40h
;R13		push	Dword ptr es:[si]	;Save interrupt vector
;R13		mov	ax,PM_RAM_Segment
;R13		mov	ds,ax
;R13		mov	eax,ds:[INT10_Save]
;R13		mov	es:[si],eax		;Restore origin vector
;R13
;R13;Enable VGA R/W
;R13
;R13		mov	cx,VT694X + 61h
;R13		mov	bx,0ff0h
;R13		call	GET_SET_CT		;enable vga R/W
;R13
;R13;Call VGA BIOS
;R13
;R13        	post_code	02h
;R13;temp!		FAR_CALL	3, 0c000h
;R13		post_code	03h
;R13
;R13;Restore int 10 vector
;R13
;R13		xor	ax,ax
;R13		mov	es,ax
;R13		mov	si,40h
;R13		pop	eax
;R13		mov	es:[si],eax		;restore int 10 vector
;R13
;R13		pop	es
;R13		pop	ds
;R13
;R13		 ret
;R13Restore_VGA_State endp

F_Save_VGA_State	proc	far
		Call	E000_64K_shadow_R
		far_Call 	<offset Save_VGA_State>,<seg Save_VGA_State>
		Call	Disable_E000_ROM_Shadow
			ret
F_Save_VGA_State	endp

;R13 - start
F_VGABIOS_RUN	proc	far
		Call	E000_64K_shadow_R
		far_Call 	<offset CT_VGABIOS_RUN>,<seg CT_VGABIOS_RUN>
		Call	Disable_E000_ROM_Shadow
			ret
F_VGABIOS_RUN	endp
;R13 - end

⌨️ 快捷键说明

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