📄 flsnvrg.asm
字号:
page ,132
title PnP NVRam Runtime Functions support for Flash
;*****************************************************************;
;*****************************************************************;
;** **;
;** (C)Copyright 1985-1996, American Megatrends, Inc. **;
;** **;
;** All Rights Reserved. **;
;** **;
;** 6145-F Northbelt Pkwy, Norcross, GA 30071 **;
;** **;
;** Phone (770)-246-8600 **;
;** **;
;*****************************************************************;
;*****************************************************************;
;---------------------------------------;
include mbiosmac.mac
include rt.equ
include pci.equ
include dim.equ
include silent.equ ; (CORE0072+)
;---------------------------------------;
public rthnvr_read_nvr_byte
public rthnvr_read_nvr_word
public rthnvr_write_nvr_byte
public rthnvr_write_nvr_word
public rthnvr_write
public rt_pnp_inst_check_start
public rth_nvram_size
public rth_nvram_base
extrn rt_pnp_entry:byte
extrn rt_pnp_entry_prot:byte
extrn flash_found_table:byte
extrn flash_write_enable:near
extrn flash_write_disable:near
;---------------------------------------;
; C O D E S E G M E N T ;
;---------------------------------------;
cgroup group _text
_text segment para public 'CODE'
assume cs:CGROUP
.486p
;---------------------------------------;
; Plug and Play Installation Check ;
;---------------------------------------;--------------------------------------;
; This structure signals runtime software that this BIOS supports the Plug and ;
; Play BIOS interface. Runtime software will search F0000 to FFFF0 for this ;
; structure on each paragraph boundary. After validating this structure, ;
; runtime software will either the real mode or 16 bit protected mode entry ;
; points given below to make calls to Plug and Play runtime functions. ;
;------------------------------------------------------------------------------;
rt_pnp_inst_check_start label byte
PnPIC_Signature db '$PnP'
PnPIC_Revision db 10h
PnPIC_Length db offset CGROUP:rt_pnp_inst_check_end - CGROUP:rt_pnp_inst_check_start
PnPIC_ControlFlags dw 00h
PnPIC_CheckSum db 00h
PnPIC_EventFlagAddr dd 00000000h
PnPIC_RMEntryOffset dw offset CGROUP:rt_pnp_entry
PnPIC_RMEntrySegment dw 0F000h
PnPIC_PMEntryOffset dw offset CGROUP:rt_pnp_entry_prot
PnPIC_PMEntryBase dd 000F0000h
PnPIC_OEMDevID dd 00000000h
PnPIC_RMDataSegment dw 0F000h
PnPIC_PMDataBase dd 000F0000h
rt_pnp_inst_check_end label byte
;-----------------------------------------------------------------------;
; RTH_NVRAM_BASE and RTH_NVRAM_SIZE will get updated according to the ;
; flash part present in the system. for example, for Intel 28F001BX-T ;
; these values are FFFFD000 and 1000 respectively but for AMD29F010 ;
; these values are FFFF8000 and 4000 respectively. ;
;-----------------------------------------------------------------------;
rth_nvram_base dd 0FFFFD000h ;The 32 bit physical address of the
;memory (Flash) that is used for NVRam.
;This is needed so that protected mode
;callers can build a proper descriptor
;that the BIOS can use to access that
;memory. Make this 0 if this system
;has no NVRam or NVRam is accessed via
;I/O ports.
rth_nvram_size dw 1000h ;NVRam size is 4k bytes
;Make this 0 if this system has no NVRam
;---------------------------------------;
; rthnvr_read_nvr_byte ;
;---------------------------------------;--------------------------------------;
; This function reads one byte from NVRam and returns it in AL. ;
; ;
; Input: SI = Offset of byte to read from NVRam ;
; DS = Segment/Selector needed to access NVRam ;
; ;
; Output: CF = Set if error, cleared otherwise ;
; AL = Byte that was read from NVRam ;
; ;
; Destroys: AL ;
;------------------------------------------------------------------------------;
rthnvr_read_nvr_byte proc near
push cx
push ax
mov al,00h ; AL = 00 -> read a byte
call read_word_nvram ; NC, AL = byte read
pop cx
jc rthnvr_rnb_00 ; error
mov ah,ch ; restore original AH, AL = byte read
rthnvr_rnb_00:
pop cx
ret
rthnvr_read_nvr_byte endp
;---------------------------------------;
; rthnvr_read_nvr_word ;
;---------------------------------------;--------------------------------------;
; This function reads one word from NVRam and returns it in AX. ;
; ;
; Input: SI = Offset of byte to read from NVRam ;
; DS = Segment/Selector needed to access NVRam ;
; ;
; Output: CF = Set if error, cleared otherwise ;
; AX = Word that was read from NVRam ;
; ;
; Destroys: AX ;
;------------------------------------------------------------------------------;
rthnvr_read_nvr_word proc near
mov al,0ffh ; AL <> 00 -> read a word
call read_word_nvram ; AX = word read
ret
rthnvr_read_nvr_word endp
;---------------------------------------;
; read_word_nvram ;
;---------------------------------------;--------------------------------------;
; This function reads one word from NVRam and returns it in AX. ;
; ;
; Input: SI = Offset of byte to read from NVRam ;
; DS = Segment/Selector needed to access NVRam ;
; AL = 00 read a byte ;
; AL <>00 read a word ;
; ;
; Output: CF = Set if error, cleared otherwise ;
; AL/AX = Byte/Word that was read from NVRam ;
; ;
; Destroys: AX ;
;------------------------------------------------------------------------------;
read_word_nvram proc near
call check_flash_presence ; flash found ?
jc rwn_err ; error
pushf
cli
push es
push ds
push esi
movzx esi,si
call go_to_big_mode ; call go_to_flat_mode_stack
pushf ; NC/CY = not/yes real mode when the routine was invoked
; if CY then ZR/NZ = GA20 status (dis/en)abled
jnc rw_00 ; not in real mode
add esi,cgroup:rth_nvram_base
; read from NVRAM..
rw_00:
or al,al ; read a byte/word
mov al,ds:[esi] ; read a byte from ROM
jz rw_02 ; read byte
mov ax,ds:[esi] ; read a word from ROM
rw_02:
popf ; CY = real mode
; if CY then ZR/NZ = GA20 status (dis/en)abled
jnc rw_01 ; no, so assume protected mode
; real mode..come back to real mode..
call comeback_from_big_mode ; call comeback_from_flat_mode_stack
rw_01:
; AL/AX = read byte/word..
pop esi
pop ds
pop es
popf
clc
rwn_err:
ret
read_word_nvram endp
;---------------------------------------;
; rthnvr_write_nvr_byte ;
;---------------------------------------;--------------------------------------;
; This function writes one byte to NVRam. This function should only be ;
; supported if NVRam may be written one byte at a time. If Flash is being ;
; used for NVRam, then this function should just return with CF set. ;
; ;
; Input: AL = Byte to write to NVRam ;
; DI = Offset into NVRam where byte should be written ;
; ES = Segment/Selector needed to access NVRam ;
; ;
; Output: CF = Set if error, cleared otherwise ;
; ;
; Destroys: Nothing ;
;------------------------------------------------------------------------------;
rthnvr_write_nvr_byte proc near
stc
ret
rthnvr_write_nvr_byte endp
;---------------------------------------;
; rthnvr_write_nvr_word ;
;---------------------------------------;--------------------------------------;
; This function writes one word to NVRam. This function should only be ;
; supported if NVRam may be written one word at a time. If Flash is being ;
; used for NVRam, then this function should just return with CF set. ;
; ;
; Input: AX = Word to write to NVRam ;
; DI = Offset into NVRam where word should be written ;
; ES = Segment/Selector needed to access NVRam ;
; ;
; Output: CF = Set if error, cleared otherwise ;
; ;
; Destroys: Nothing ;
;------------------------------------------------------------------------------;
rthnvr_write_nvr_word proc near
stc
ret
rthnvr_write_nvr_word endp
;---------------------------------------;
; rthnvr_write ;
;---------------------------------------;--------------------------------------;
; This function writes the entire contents of NVRam from a buffer supplied by ;
; the caller. ;
; ;
; Input: DS:(E)SI = Buffer of data to write to NVRam ;
; ES:(E)DI = Seg/Offset of NVRam (caller passes in whatever is returned ;
; by the rtnvr_get_escd_size function) ;
; ;
; Output: CF = Set if error, cleared otherwise ;
; AX = Non zero return code if CF set (see RT.EQU) ;
; ;
; Destroys: Nothing ;
;------------------------------------------------------------------------------;
rthnvr_write proc near
;;stc ;These two lines may be added during
;;ret ;development, so that it is possible to
;boot the system without NVRam code.
push ecx
push esi
push edi
mov cx, cs:rth_nvram_size ;Get size defined
mov ax, RT_ESCD_INVALID ;Error code for no ESCD
stc ;Set CF in case following jcxz jumps
jcxz write_nvram_done ;Br if no NVRam on this system
push bx
push cx
push si
pushf
xor bl, bl ;BL will accumulate checksum
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -