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

📄 pmupost.asm

📁 AWARD BIOS源代码,支持的CHIPSET请看文件,有同型号的板子烧上去就可以跑
💻 ASM
📖 第 1 页 / 共 5 页
字号:
;R11 _GdtSave	df	1 dup (?)
;R11 _GdtNew		dw	1 dup (?)
;R11 		dd	1 dup (?)
;R11 _IdtSave	df	1 dup (?)
;R11 _RealModeIdt	dw	1 dup (?)
;R11 		dd	1 dup (?)
;R11 SMI_STRUCT	ENDS


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

;R78 - starts
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:
		POST_FUNC_Call	End_Pmi_Handler

                RSM

STR_Change_SMBase_L EQU     $ - offset STR_Change_SMBase

Set_PMWORD_Clear:
		mov	dx,ACPI_Port
		mov	cl,dl
		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	ax,cs
		mov	ss,ax

; Enable SMRAM can be access
		mov	cx, VT692 + 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
		mov	cx,3000h/4			;Save 12K
		rep	movsd

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

	;;;;	setup stack

		mov	ax,3000h
		mov	ss,ax
		mov	sp,Resume_Stack1
						
		push	bx
		extrn	Get_PM_RAM_Seg:near
		call	Get_PM_RAM_Seg
		mov	ds,ax		
		Call	OPEN_PM_RAM
		pop	bx
		mov	byte ptr ds:[Software_SMI_Type],S3_RESTORE_REQ
                Call	Close_PM_RAM

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

		Call	Clear_PM_Status

                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

		POST_FUNC_Call	E000_Ct_Enable_SMI
;R78A		POST_FUNC_Call	E000_Check_If_M1	
;R78A                je      short yes_M1_Cpu		

        	call	Issue_SW_SMI    ;Change SMBASE
		xor	cx, cx			
		loop	$
;R78AYes_M1_Cpu:						
;R78A		mov	cx,VT692 + 63h
;R78A		mov	bl, 03h
;R78A		call	Get_Set_PMU_OR
;R78A
;R78A
;R78A		Call	Disable_E000_ROM_Shadow
;R78A	;;;;	3. issue software smi again to restore CPU state
;R78A@@:
;R78A		Call	Issue_SW_SMI
;R78A		jmp	short @B

endif	;S3_SUPPORT
;R78 - ends

;[]-------------------------------------------------------------------[]
;
; PPPPPPPP	 AA	  RRRRRRRR   TTTTTTTTTTT	       111
; PPPPPPPPP	AAAA	  RRRRRRRRR  TTTTTTTTTTT    ***       1111
; PPP	 PPP   AAAAAA	  RRR	 RRR	 TTT	    ***      11111
; PPPPPPPPP   AAA  AAA	  RRRRRRRRR	 TTT		       111
; PPPPPPPP   AAAAAAAAAA   RRRRRRRR	 TTT	    ***        111
; PPP	    AAAAAAAAAAAA  RRR	RRR	 TTT	    ***        111
; PPP	   AAA	      AAA RRR	 RRR	 TTT		       111
;
;
;   1. Standard routines that must be filled in to let the BIOS KERNAL
;      to program the PMU registers
;   2. Called during POST & after POST
;
;[]-------------------------------------------------------------------[]
;R38 - start
;[]==============================================================[]
; Disable_E000_ROM_Shadow : (POST 63h)
;	Disable E000 ROM Shadow (Direct Access to ISA)
; Input : None
; Output: None
; Save: all
;[]==============================================================[]
		public	Disable_E000_ROM_Shadow
Disable_E000_ROM_Shadow	proc	near

	;disable E0000 shadow RAM
		
		mov	cx,VT692 + 63h
		mov	bl,NOT 0c0H
		call	Get_Set_Ct_AND

	;disable onboard E0000 ROM
		mov	cx,VT586 + 43h
		mov	bl,NOT 30H
		call	Get_Set_Ct_AND

		ret
Disable_E000_ROM_Shadow	endp
;R38A ;[]==============================================================[]
;R38A ; Get_Set_Ct_AND(Get_Set_PCI_AND):
;R38A ;	AND a value in the chipset register.
;R38A ; Input  :	CX = Index register to change.
;R38A ;		bl = Value to change (AND)
;R38A ; Output :	None
;R38A ; Destory:	EAX, ECX, DX
;R38A ;
;R38A ;[]==============================================================[]
;R38A 		Public	Get_Set_Ct_AND, Get_Set_PMU_AND
;R38A Get_Set_Ct_AND	proc	near
;R38A Get_Set_PMU_AND:
;R38A 		extrn	Get_Ct:near
;R38A 		extrn	Set_Ct:near
;R38A 		call    Get_Ct
;R38A 		and     al, bl			;AND data
;R38A 		call    Set_Ct
;R38A 		ret
;R38A Get_Set_Ct_AND	endp

;[]==============================================================[]
;E000_Shadow_R:
;	Set video BIOS(E000-E800) shadow readonly
;Input : none
;Output: none
;[]==============================================================[]
		Public	E000_Shadow_R
E000_Shadow_R   proc    near
		extrn	GET_SET_CT:near
		mov     cx,VT692 + 63h
		mov	bx,803fh
		call    GET_SET_CT
		ret
E000_Shadow_R   endp

		Public	E000_64k_Shadow_R
E000_64k_Shadow_R   proc    near
		jmp	E000_Shadow_R
E000_64k_Shadow_R   endp
;R38 - end

;[]========================================================================[]
;Procedure:	Get_PM_IRQ
;
;Function :	Tell BIOS which IRQ is PMI using
;
;Input	  :	None
;
;Output   :	NC:
;			AL = 1	- PMI using IRQ 15
;			AL = 2	- PMI using NMI
;			AL = 3	- PMI using SMI
;		CF:
;			No IRQ or NMI or SMI is available
;
;Preserve :	All except AX & FLAG
;
;Note	  :	1. Stack available
;		2. called from PM_Init
;[]========================================================================[]
		Public	Get_PM_IRQ
Get_PM_IRQ	Proc	Near
		mov	al,03h		;always SMI for PENTIUM CPU
		clc
		ret
Get_PM_IRQ	Endp

;[]========================================================================[]
;Procedure:	Check_PM_Using_NMI
;
;Function :	To handle the NMI which is caused by a PMU
;
;Input	  :	None
;
;Output   :	None
;
;Saves	  :	Please save all registers
;
;[Note]   :	1. Called every time a NMI is occured
;		2. check to see if this SMI is issue by PMU
;
;		     if PMI ;  Serve the PMI then
;
;			       sti
;			       iret
;
;		     if not PMI : jump back to a external label(near)
;				  named "NMI_Original" & do nothing!
;
;		   So if your chip never use NMI, just "jmp NMI_Original"!
;
;[]========================================================================[]
		Public	Check_PM_Using_NMI
Check_PM_Using_NMI:
PM_Not_NMI:
		extrn	NMI_Original:near
		jmp	NMI_Original

;[]-------------------------------------------------------------------[]
;
; PPPPPPPP	 AA	  RRRRRRRR   TTTTTTTTTTT	       2222222
; PPPPPPPPP	AAAA	  RRRRRRRRR  TTTTTTTTTTT    ***       22222222
; PPP	 PPP   AAAAAA	  RRR	 RRR	 TTT	    ***      222  222
; PPPPPPPPP   AAA  AAA	  RRRRRRRRR	 TTT			 222
; PPPPPPPP   AAAAAAAAAA   RRRRRRRR	 TTT	    *** 	222
; PPP	    AAAAAAAAAAAA  RRR	RRR	 TTT	    ***        2222222
; PPP	   AAA	      AAA RRR	 RRR	 TTT		      22222222
;
;
;		Called during POST Only
;
;[]-------------------------------------------------------------------[]

;[]========================================================================[]
;Procedure:	Ct_Check_Green_VGA
;
;Function :	To tell BIOS kernel that if the VGA adaptor's V/H SYNC
;		signal should be turned off or not when video off.
;		This should refer to the setup setting.
;
;Input    :	None
;
;Output   :	ZF : don't turned off V/H SYNC
;		NZ : V/H SYNC can be turned off
;
;Note	  :	1. Some VGA adaptors use V/H SYNC signals for special
;		   purpose, e.g. TSENG LAB use them for DRAM refresh.
;		   Therefore, these signals must never be turn off
;		   at any time.
;		2. called from POST at POST 82
;[]========================================================================[]
			Public	Ct_Check_Green_VGA
Ct_Check_Green_VGA	Proc	Near
		pushad
		mov	si,offset VGA_Type_Item
		call	GetItem_Value
		or	al,al
		popad
		ret
Ct_Check_Green_VGA	Endp

;[]==============================================================[]
;Input: None
;Function :	To see if it is a SMI
;[]==============================================================[]
			Public	Ct_Check_SMI_Start
Ct_Check_SMI_Start	Proc	Near

		extrn	Not_SMI_Start:near
		jmp	Not_SMI_Start

Ct_Check_SMI_Start	Endp

;[]==============================================================[]
;Procedure:	PM_Option_Check
;
;Function :	Get PM option
;
;Input	  :	None
;
;Output   :	1. ZF  - User Defined!
;			 i.e. use CMOS value to prg PM chip
;
;		   NZ  - Use Pre-defined value to prg PM chip
;			 AL = PM option
;			    i.e. DISBLED
;				 MAX-POWER_SAVING
;				 MIN-POWERING-SAVING....
;			 SI = offset of auto-table
;			    i.e. MIN_PM_SAVING_TABLE
;				 MAX_PM_SAVING_TABLE
;				 PM_DISABLE_TABLE	   in file PFEATURE.ASM
;
;		2. CF  - Global Power Management should be disabled
;
;		   NC  - Global Power Management should be enabled
;
;Registers :	FLAGS, AX, SI - destroyed
;		Others	      - should be preserved
;[]==============================================================[]
		Public	PM_Option_Check
PM_Option_Check Proc	Near
		mov	si,offset cs:PM_Option_Item
		call	GetItem_Value
		mov	cl,al
		xor	ch,ch

		mov	si,offset cs:PM_Auto_Table
		shl	cx,1
		dec	cx
		add	si,cx
		mov	si,cs:[si]

PM_Option_Check_Exit:

		cmp	al,1			;PM disabled?
		je	short @F		;yes

	;if PM option is "user defined" then OEM routine should
	;check here for both items disabled

		or	al,al			;set/clear Zero Flag
		clc
		ret

	@@:
		or	al,al			;set/clear Zero Flag
ifdef Set_APM_According_PM_Setup
		stc				;indicate PM disable
else; Set_APM_According_PM_Setup
		clc				;indicate PM disable
endif; Set_APM_According_PM_Setup

		ret
PM_Option_Check Endp

;[]==================================================================[]
;Procedure:	Ct_Global_PM_Disable
;
;Function :	To disable all power management features
;
;Input	  :	None

;Output   :	None
;
;Registers:	all registers preserved
;
;[Note]   :	called from PM_INIT before PM_RAM is available
;[]==================================================================[]
			Public	Ct_Global_PM_Disable
Ct_Global_PM_Disable	Proc	Near
		pusha
ifdef	USB_SUPPORT				     
		POST_FUNC_CALL	Ct_Check_Usb_Disabled
		jnc	short @f		     
endif	;USB_SUPPORT				     
	@@:
		popa
		ret
Ct_Global_PM_Disable	Endp

;[]==================================================================[]
;Procedure:	Clear_PM_RAM
;
;Function :	Clear power management data area (PM_RAM segment)
;		This routine is used to clear extended BIOS data area
;		in order to provide a clean environment for power
;		management code
;
;Input	  :	ES : PM_RAM

;Output   :	None
;
;Registers:	all registers preserved except FLAGS
;
;[Note]   :	called from PM_INIT
;[]==================================================================[]
		Public	Clear_PM_RAM
Clear_PM_RAM	Proc	Near
		ASSUME	ES:PM_RAM

⌨️ 快捷键说明

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