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

📄 gapmnsmi.asm

📁 本源码为BIOS研发技术剖析光盘原代码,是SIS530BIOS完整原代码.
💻 ASM
📖 第 1 页 / 共 2 页
字号:
page	60,132
title.		NON-SMI real/16 bit protected/32 bit protected mode code...GAPMNSMI.ASM
.tfcond

;*****************************************************************;
;*****************************************************************;
;**								**;
;**	(C)Copyright 1985-1996, American Megatrends Inc.	**;
;**								**;
;**			All Rights Reserved.			**;
;**								**;
;**		6145-F, Northbelt Parkway, Norcross,		**;
;**								**;
;**		Georgia - 30071, USA. Phone-(770)-246-8600.	**;
;**								**;
;*****************************************************************;
;*****************************************************************;
;-----------------------------------------------;
;	   THIS MODULE HAS THE CODE FOR		;
;	  GREEN PC APM POWER MANAGEMENT		;
;-----------------------------------------------;

cgroup	group	_text
_text	segment word	public	'CODE'
	assume cs:cgroup

;-----------------------------------------------;
;*****************************************************************;
;*****************************************************************;
;**								**;
;**	(C)Copyright 1985-1996, American Megatrends Inc.	**;
;**								**;
;**			All Rights Reserved.			**;
;**								**;
;**		6145-F, Northbelt Parkway, Norcross,		**;
;**								**;
;**		Georgia - 30071, USA. Phone-(770)-246-8600.	**;
;**								**;
;*****************************************************************;
;*****************************************************************;
;-----------------------------------------------;
;     THIS MODULE IS CORE POWER MANAGEMENT	;
;   BIOS MODULE WHICH DOES NOT EXECUTE IN SMI	;
;-----------------------------------------------;
;     CODES ARE REAL/16 BIT PROTECTED MODE/	;
;	     32 BIT PROTECTED MODE		;
;-----------------------------------------------;
;      ROUTINES WILL BE CALLED AS FAR/NEAR	;
;-----------------------------------------------;	
;   ROUTINES & ENTRY POINTS USED FROM OUTSIDE	;
;-----------------------------------------------;

	public	apm_real_mode_entry		;
	public	apm_16bit_prot_mode_entry	;
	public	apm_32bit_prot_mode_entry	;

;-----------------------------------------------;
;		INCLUDE FILE			;
;-----------------------------------------------;

	include	biosdata.dat			; main bios data file
	include	gapm.equ			; APM equate file

;-----------------------------------------------;

.386p
;-----------------------------------------------;
;	   EQUATES USED BY THIS MODULE		;
;-----------------------------------------------;

control_8259_master     equ     020h            ; 8259 master controller control port
control_8259_slave      equ     0a0h            ; 8259 slave controller control port

irr_reg_read_cmd        equ     00001010b       ; interrupt request reg (IRR) read

bios_data_seg		equ	40h		;

;-----------------------------------------------;
;*****************************************************************;
;*****************************************************************;
;**								**;
;**	(C)Copyright 1985-1996, American Megatrends Inc.	**;
;**								**;
;**			All Rights Reserved.			**;
;**								**;
;**		6145-F, Northbelt Parkway, Norcross,		**;
;**								**;
;**		Georgia - 30071, USA. Phone-(770)-246-8600.	**;
;**								**;
;*****************************************************************;
;*****************************************************************;
;---------------------------------------------------------------;
;	     RUN TIME CORE BIOS ROM APM HANDLER CODE		;
;	     RUN TIME CORE BIOS ROM APM HANDLER CODE		;
;	     RUN TIME CORE BIOS ROM APM HANDLER CODE		;
;	     RUN TIME CORE BIOS ROM APM HANDLER CODE		;
;---------------------------------------------------------------;
;	  THIS MODULE WILL RESIDE IN F000 ROM SHADOW		;
;	  THIS MODULE WILL RESIDE IN F000 ROM SHADOW		;
;	  THIS MODULE WILL RESIDE IN F000 ROM SHADOW		;
;	  THIS MODULE WILL RESIDE IN F000 ROM SHADOW		;
;---------------------------------------------------------------;
;			APM_REAL_MODE_ENTRY			;
;---------------------------------------------------------------;

apm_real_mode_entry	proc	near

	add	sp,02h				; bypass caller

	sti					; enable interrupt
	pushfd					; save EFLAGS
	push	ebp				;
	push	ds				;

	push	apm_16_32_bit_data_seg		;
	pop	ds				; (ds) = APM real mode data segment

	mov	ah,00000001b			; set for APM BIOS called in INT 15h mode
	call	apm_real_16bit_common		;

	pop	ds				;
	pop	ebp				;
	jc	short apm_real_mode_entry_00	; error...
	popfd					; restore (EFLAGS)
	clc					; (cy) = 00 for no error
	retf	2

apm_real_mode_entry_00:
	popfd					; restore (EFLAGS)
	stc					; (cy) = 01 for error
	retf	2

apm_real_mode_entry	endp

;---------------------------------------------------------------;
;		     APM_16BIT_PROT_MODE_ENTRY			;
;---------------------------------------------------------------;

apm_16bit_prot_mode_entry	proc	near

	mov	ah,00000010b			; set for APM BIOS called in 16 bit protected mode

	pushfd					; save EFLAGS
	push	ebp				;
	push	ds				;

	call	set_apm_prot_mode_data_seg	; (ds) = APM 16/32 bit protected mode data segment

	call	apm_real_16bit_common		;

	pop	ds				;
	pop	ebp				;
	jc	short apm_16_prot_mode_entry_00	; error...

	popfd					; restore (EFLAGS)
	clc					; (cy) = 00 for no error
	retf

apm_16_prot_mode_entry_00:
	popfd					; restore (EFLAGS)
	stc					; (cy) = 01 for error
	retf

apm_16bit_prot_mode_entry	endp

;---------------------------------------------------------------;
;		     APM_32BIT_PROT_MODE_ENTRY			;
;---------------------------------------------------------------;

apm_32bit_prot_mode_entry	proc	near

;-----------------------------------------------;
; 32 BIT PROTECTED MODE CODE...ASSEMBLED WITH USE16

;;	pushfd					;
	db	09ch				;
;;	push	ebp				;
	db	055h				;

;;	mov	ebp,cs				; (ebp) = 32 bit protected mode CODE segment selector
	db	08ch,0cdh			;
;;	add	ebp,8				; (ebp) = 16 bit protected mode CODE segment selector
	db	083h,0c5h,008h			;

;;	push	ebp				; push 16 bit segment selector
	db	055h				;
	push	offset cgroup:apm_32_prot_mode_entry_01; offset
	dw	00000h				;

;;	mov	bp,dx				;
	db	066h,08bh,0eah			;
;;	shl	ebp,16				; (ebp) upper word = on entry (dx)
	db	0c1h,0e5h,010h			;
;;	mov	ah,00000100b			; set for APM BIOS called in 32 bit protected mode
	db	0b4h,004h			;
;;	mov	bp,ax				; (ebp) lower word = on entry (ax)
	db	066h,08bh,0e8h			;
;;	mov	ah,53h				; restore on entry (ah)
	db	0b4h,053h			;

	retf					; start executing in 16 bit protected mode code

;-----------------------------------------------;
; 16 BIT PROTECTED MODE CODE...ASSEMBLED WITH USE16

apm_32_prot_mode_entry_01:
	push	ds				;

	call	set_apm_prot_mode_data_seg	; (ds) = APM 16/32 bit protected mode data segment

	call	apm_real_16bit_32bit_common	;

	pop	ds				;
	pushfd					;
	mov	bp,cs				; (bp) = 16 bit protected mode CODE segment selector
	sub	bp,8				; (bp) = 32 bit protected mode CODE segment selector
	popfd					;

	push	bp				; push 32 bit segment selector
	push	offset cgroup:apm_32_prot_mode_entry_02; offset
	retf					; start executing in 32 bit protected mode

;-----------------------------------------------;
; 32 BIT PROTECTED MODE CODE...ASSEMBLED WITH USE16

apm_32_prot_mode_entry_02:
;;	pop	ebp				;
	db	05dh				;
	jc	short apm_32_prot_mode_entry_00	; error...

;;	popfd					; restore (EFLAGS)
	db	09dh				;
	clc					; (cy) = 00 for no error
	retf

apm_32_prot_mode_entry_00:
;;	popfd					; restore (EFLAGS)
	db	09dh				;
	stc					; (cy) = 01 for error
	retf

apm_32bit_prot_mode_entry	endp

;---------------------------------------------------------------;
;		      APM_REAL_16BIT_COMMON			;
;---------------------------------------------------------------;
;	Input :	(AH) bit 0 1 called in real mode (INT 15H)	;
;		     bit 1 1 called in 16 bit protected mode	;
;		     bit 2 1 called in 32 bit protected mode	;
;		     bit 3 1 called in real mode (SMB CALL FAR)	;
;			(bit 3...not used for GREEN PC)		;
;		(AL) APM function no.				;
;			Registers as defined by the APM document;
;			for related function.			;
;	Output: (CY) 01 for error & (AH) has error code		;
;		(CY) 00 for no error				;
;			Registers as defined by the APM document;
;			for related func.			;
;	Register destroyed : As defined by the related function	;
;---------------------------------------------------------------;

apm_real_16bit_common	proc	near

	mov	bp,dx				;
	shl	ebp,16				; (ebp) upper word = on entry (dx)
	mov	bp,ax				; (ebp) lower word = on entry (ax)
	mov	ah,53h				; restore on entry (ah)

;---------------------------------------------------------------;
;		  APM_REAL_16BIT_32BIT_COMMON			;
;---------------------------------------------------------------;
;	Input :	(BP) bit 8 1 called in real mode (INT 15H)	;
;		     bit 9 1 called in 16 bit protected mode	;
;		     bit 10 1 called in 32 bit protected mode	;
;		     bit 11 1 called in real mode (SMB CALL FAR);
;			(bit 11...not used for GREEN PC)	;
;		(AL) APM function no.				;
;			Registers as defined by the APM document;
;			for related function.			;
;	Output: (CY) 01 for error & (AH) has error code		;
;		(CY) 00 for no error				;
;			Registers as defined by the APM document;
;			for related func.			;
;	Register destroyed : As defined by the related function	;
;---------------------------------------------------------------;

apm_real_16bit_32bit_common	proc	near

	call	current_apm_func_in_rom		; current APM function will be executed in ROM ?
	jc	short apm_common_05		; no...
	call	exec_apm_func_in_rom		; execute current APM function in ROM
	ret

apm_common_05:
	call	rom_generate_sw_smi_for_apm	; generate software SMI for executing APM code in SMI
apm_common_06:
	ret

apm_real_16bit_32bit_common	endp
apm_real_16bit_common		endp

;---------------------------------------------------------------;
;		   SET_APM_PROT_MODE_DATA_SEG			;
;---------------------------------------------------------------;
;	Input : NONE						;
;	Output: (DS) APM 16/32 bit protected mode data segment	;
;	Register destroyed : NONE				;
;---------------------------------------------------------------;

set_apm_prot_mode_data_seg	proc	near

	push	ax				;
	mov	ax,cs				; (ax) = 16 bit protected mode code segment selector
	add	ax,8				; (ax) = 16/32 bit protected mode data segment selector
	mov	ds,ax				; (ds) = APM 16/32 bit protected mode data segment
	pop	ax				;
	ret

set_apm_prot_mode_data_seg	endp

;---------------------------------------------------------------;
;*****************************************************************;
;*****************************************************************;
;**								**;
;**	(C)Copyright 1985-1996, American Megatrends Inc.	**;
;**								**;
;**			All Rights Reserved.			**;
;**								**;
;**		6145-F, Northbelt Parkway, Norcross,		**;
;**								**;
;**		Georgia - 30071, USA. Phone-(770)-246-8600.	**;
;**								**;
;*****************************************************************;
;*****************************************************************;
;---------------------------------------------------------------;
;		    CURRENT_APM_FUNC_IN_ROM			;
;---------------------------------------------------------------;
;	Input : (AL) APM function no.				;
;	Output: (CY) 01 means current APM func will not be	;
;			executed in ROM				;
;		(CY) 00 means current APM func will be executed	;
;			in ROM					;
;	Register destroyed : NONE				;
;---------------------------------------------------------------;

current_apm_func_in_rom	proc	near

	cmp	al,apm_func_05			; APM CPU IDLE call ?
	jz	short current_apm_func_in_rom_00; yes...execute in ROM...(CY) = 00
	cmp	al,apm_func_06			; APM CPU BUSY call ?
	jz	short current_apm_func_in_rom_00; yes...execute in ROM...(CY) = 00
	cmp	al,apm_func_0a			; APM get power status call ?
	jz	short current_apm_func_in_rom_20; yes...may execute in ROM...(CY) = 00
	cmp	al,apm_func_0b			; APM get PM event call ?
	jz	short current_apm_func_in_rom_10; yes...may execute in ROM...(CY) = 00
current_apm_func_in_rom_01:
	stc					; (cy) = 01 means current APM function will not be executed in ROM
current_apm_func_in_rom_00:
	ret

current_apm_func_in_rom_20:
	cmp	bx,all_power_managed_device_id	; valid device ID ?
	jnz	short current_apm_func_in_rom_01; no...may be v1.2 interface call
	ret					; (cy) = 00 for executing in ROM

⌨️ 快捷键说明

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