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

📄 runtime.asm

📁 <BIOS研发技术剖析>书的源代码,包括完整的BIOS汇编语言源程序.
💻 ASM
📖 第 1 页 / 共 4 页
字号:
                db   16                  ; 12*11
                db   64                 ; 10*9
                db   64                 ; 11*9
                db   128                ; 11*10
                db   8                  ; 11*10
sdram_size_translate_table_end label   byte
;*******************************************************************************
if (MKF_TREND_ANTI_VIRUS)
	extrn	read_pci_byte:near
	extrn	write_pci_byte:near
align 16
	db	'$CHWY'			; signature for ChipAway to disable shadow write
disable_e800_shadow	proc	far
	push	ax
	mov	ah,75h
	call	read_pci_byte
	and	al,NOT 20h
	call	write_pci_byte
	pop	ax
	retf
disable_e800_shadow	endp
endif;	if (MKF_TREND_ANTI_VIRUS)
;-----------------------------------------------------------------------;
;			GPNV SUPPORT FOR IO MAPPED NVRAM		;
; Following routines are needed for GPNV support for IO Mapped NVRAM i.e.
; when GPNV_FLASH switch is set to 0 in Make file.			;
; If GPNV is supported as Memory Mapped NVRAM e.g. in Flash Block, these;
; routines are not needed.						;
;-----------------------------------------------------------------------;
IF	MKF_GPNV_SUPPORT
IFE	MKF_GPNV_FLASH
;------------- GPNV supported through IO Mapped NVRAM ------------------;
;-----------------------------------------------------------------------;
; Fill the following variables for the concerned IO Mapped NVRAM.	;
; Note thet GPNV Size must be a multiple of paragraph.			;
;-----------------------------------------------------------------------;
	public	gpnv_io_base
	public	gpnv_io_size
gpnv_io_base	dw	0000h		; start offset of GPNV
gpnv_io_size	dw	0000h		; GPNV Size in Bytes, this size must be
					; a multiple of paragraph
;-----------------------------------------------------------------------;
;			READ_GPNV_BYTE					;
; this routine is called both in real mode and protected mode to read a	;
; byte from GPNV.							;
; input :								;
;	AX	offset of GPNV from where the byte to be read		;
;	stack	available						;
; output:								;
;	AL	read byte						;
; register destroyed : AL						;
; NOTE :								;
; This routine can be called in real and protected mode, so do not assume
; anything about the segment registers.					;
;-----------------------------------------------------------------------;
	public	read_gpnv_byte
read_gpnv_byte:
	ret
;-----------------------------------------------------------------------;
;			READ_GPNV_BYTE					;
; this routine is called both in real mode and protected mode to read a	;
; word from GPNV.							;
; input :								;
;	AX	offset of GPNV from where the word to be read		;
;	stack	available						;
; output:								;
;	AX	read word						;
;		AH,AL = high byte, low byte				;
; register destroyed : AX						;
; NOTE :								;
; This routine can be called in real and protected mode, so do not assume
; anything about the segment registers.					;
;-----------------------------------------------------------------------;
	public	read_gpnv_word
read_gpnv_word:
	ret
;-----------------------------------------------------------------------;
;			WRITE_GPNV_BYTE					;
; this routine is called both in real mode and protected mode to write a;
; byte into GPNV.							;
; input :								;
;	AX	offset of GPNV from where the word to be read		;
;	BL	data to be written					;
;	stack	available						;
; output:								;
;	none								;
; register destroyed : none						;
; NOTE :								;
; This routine can be called in real and protected mode, so do not assume
; anything about the segment registers.					;
;-----------------------------------------------------------------------;
	public	write_gpnv_byte
write_gpnv_byte:
	ret
;-----------------------------------------------------------------------;
;			WRITE_GPNV_WORD					;
; this routine is called both in real mode and protected mode to write a;
; byte into GPNV.							;
; input :								;
;	AX	offset of GPNV from where the word to be read		;
;	BX	data to be written					;
;		BH, BL = high byte, low byte				;
;	stack	available						;
; output:								;
;	none								;
; register destroyed : none						;
; NOTE :								;
; This routine can be called in real and protected mode, so do not assume
; anything about the segment registers.					;
;-----------------------------------------------------------------------;
	public	write_gpnv_word
write_gpnv_word:
	ret
;-----------------------------------------------------------------------;
ENDIF
ENDIF

; (CORE0210+)>
ifdef MKF_CNVRAM
if MKF_CNVRAM
	extrn	go_to_flat_mode_stack	:near
	extrn	comeback_from_flat_mode_stack:near
	extrn   rth_nvram_base		:dword
	extrn   rth_nvram_size		:word
	extrn   scratch_segment		:word
	extrn	flash_write_enable	:near
	extrn	flash_write_disable	:near
	extrn	flash_found_table	:byte
	extrn	rth_nvram_size		:word
	extrn	rth_nvram_base		:dword
	extrn	check_cmos_8e		:near
;-----------------------------------------------------------------------;
;			READ_WHOLE_ESCD					;
;-----------------------------------------------------------------------;
; Only works in 4GB method						;
; Input:								;
;	DI	segment of escd buffer					;
; Output:								;
;	EDI	32-bit address containing read escd data		;
; Registers destroyed:							;
;	None								;
;-----------------------------------------------------------------------;
	public	read_whole_escd
read_whole_escd:
	movzx	edi,di
	shl	edi,4			; edi = 32 bit buffer address
	push	ds
	push	es
	pushad
	call	go_to_flat_mode_stack
	mov	esi,cgroup:rth_nvram_base
	mov	cx,cgroup:rth_nvram_size
;	rep	movsb
rwe_loop:
	mov	al,byte ptr ds:[esi]
	out	0e0h,al
	mov	byte ptr es:[edi],al
	inc	esi
	inc	edi
	loop	rwe_loop
	call	comeback_from_flat_mode_stack
	popad
	pop	es
	pop	ds
	ret
;-----------------------------------------------------------------------;
;			CMOS_TO_CNVRAM					;
;-----------------------------------------------------------------------;
; Check if CNVRAM present, if it is absent then go update it.		;
; If CNVRAM is present ('CMOS' signature), check if it is same as	;
; buffer.  It gets updated if not same.					;
; Only works in 4GB method						;
; Input:								;
;	DI	segment of escd buffer					;
; Output:								;
;	EDI	32-bit address containing read escd data		;
; Registers destroyed:							;
;	All except for EBP,DS,ES,FS,GS					;
;-----------------------------------------------------------------------;
	public	cmos_to_cnvram
cmos_to_cnvram:
	push	ds
	push	es

	mov	di,cgroup:scratch_segment
	call	read_whole_escd		; edi = 32-bit buffer address

	call	go_to_flat_mode_stack	; flat mode
	mov	esi,edi
	add	si,cgroup:rth_nvram_size
	sub	si,90h			; 10h bytes header
	push	esi
	mov	bl,1			; bl=1, need to update
	mov	eax,'SOMC'		; eax = signature
	cmp	[esi],eax		; 'CMOS' ?
	jne	ctc_02		; not existed..
	mov	bl,0			; signature present, no need to update if cmos=cnvram
ctc_02:
	mov	dword ptr [esi],'SOMC'	; put signature 'CMOS'

	; Store CMOS value to buffer
	mov	ah,10h			; cmos register 10h
update_loop:
	mov	al,ah
	call	cmos_data_in_x
	cmp	al,[esi+10h]		; equal ?
	je	ctc_01			; yes..
	mov	bl,1			; not equal, bl=1 (need to update)
ctc_01:
	mov	[esi+10h],al		; put to buffer
	inc	ah			; next cmos register#
	inc	esi			; next buffer
	cmp	ah,80h			; total reached ?
	jb	update_loop		; not yet..

	or	bl,bl			; need to update ?
	pop	esi
	jz	ctc_exit		; no..
	push	esi

	; adjust escd checksum in buffer
	mov	esi,edi			; ds:esi = start address of nvram buffer
	mov	cx,cgroup:rth_nvram_size
	xor	bl, bl			; bl will accumulate checksum
	cld
do_cksum_loop:
	db	67h
	lodsb				; al = next byte from caller's buffer
	add	bl, al
	loop	do_cksum_loop
	neg	bl			; all sum must be zero
	pop	esi
	mov	[esi+4],bl		; value for adjusting checksum

	; write buffer to nvram
	mov	esi,edi
	mov	edi,cgroup:rth_nvram_base
	call	flash_write_enable	; make flash read write
	mov	cx,word ptr cgroup:rth_nvram_size
	mov	bx,cgroup:word ptr flash_found_table
	call	cs:word ptr [bx+2]	; erase
	jc	short flash_erasing_err ; Br. if erasing error
	call	cs:word ptr [bx+4]	; program es:[esi] to ds:[edi]
flash_erasing_err:
	call	flash_write_disable	; make flash read only

	call	comeback_from_flat_mode_stack; back to real mode

ctc_exit:
	pop	es
	pop	ds
	ret
endif;	if MKF_CNVRAM
endif;	ifdef MKF_CNVRAM
; <(CORE0210+)


;*****************************************************************;
;*****************************************************************;
;**                                                             **;
;**     (C)Copyright 1985-1996, American Megatrends Inc.        **;
;**                                                             **;
;**                     All Rights Reserved.                    **;
;**                                                             **;
;**             6145-F, Northbelt Parkway, Norcross,            **;
;**                                                             **;
;**             Georgia - 30071, USA. Phone-(770)-246-8600.     **;
;**                                                             **;
;*****************************************************************;
;*****************************************************************;
;-----------------------------------------------------------------------;
;-----------------------------------------------------------------------;
        public  _RUNTIME_ENDS
_RUNTIME_ENDS   label   byte            ; marks end of module
;---------------------------------------;
_text   ends
        end

⌨️ 快捷键说明

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