📄 flsnvrid.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 rt.equ
include pci.equ
include dim.equ
;---------------------------------------;
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 get_chipset_values:near
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 ; These should match rth_nvram_base
PnPIC_PMDataBase dd 000F0000h
rt_pnp_inst_check_end label byte
rth_nvram_base dd 000F0000h ;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: Nothing ;
;------------------------------------------------------------------------------;
rthnvr_read_nvr_byte proc near
push cx
push ax
call read_word_nvram ; AX = word 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: Nothing ;
;------------------------------------------------------------------------------;
rthnvr_read_nvr_word proc near
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 ;
; ;
; Output: CF = Set if error, cleared otherwise ;
; AX = Word that was read from NVRam ;
; ;
; Destroys: AX ;
;------------------------------------------------------------------------------;
read_word_nvram proc near
push ds
push si
push dx
push cx
push bx
call check_flash_presence ; flash found ?
jc rwn_err ; error
; AX = start offset of NVRAM..
add si,ax ; DS:SI = ptr to byte in NVRAM
;---------------------------------------; 01/06/96
; DS = ESCD Segment/Selector
; input in (GS) to this routine contains the BIOS Segment/Selector.
;
; Since this routine does not access NVRAM area below 4GB address,
; use GS to access NVRAM area BECAUSE some test softwares (e.g. NVRAM.EXE,
; NSP BIOSTEST.EXE, etc.) do not pass ESCD Segment/Selector (which should
; be used to access NVRAM area) properly
mov ax,gs
mov ds,ax
mov ax,cs
cmp ax,0f000h
jnz x1 ; protected mode
mov ax,0f000h
mov ds,ax
x1:
;---------------------------------------; 01/06/96
call get_chipset_values
jc rwn_err ; error
; BX, DX = index port, data port..
; AH = value to disable F000 shadow RAM..
; AL = value to restore F000 shadow RAM..
; CL = register index..
pushf
cli
push cs
push offset cgroup:read_byte_end
push dx ; DX = data port
push ax ; AL = value to restore F000 shadow
xchg dx,bx ; DX = index port
mov al,cl ; AL = register index
out dx,al ; output index
pusha
mov dx,bx ; DX = data port
mov al,ah ; AL = F000 shadow disable
jmp read_word
read_byte_end:
popf
mov ax,cx ; AX = word read
clc
rwn_err:
pop bx
pop cx
pop dx
pop si
pop ds
ret
read_word_nvram endp
;---------------------------------------;
align 16
public read_word
read_word:
out dx,al ; output data, disable F0000-FFFFF shadow
popa
pusha ; delay
popa
mov cx,[si] ; read word from ROM
out dx,al ; output index
pop ax ; AL = data
pop dx ; DX = data port
out dx,al ; output data, restore F0000-FFFFF shadow
pusha ; delay
popa
retf
;---------------------------------------;
; rthnvr_write_nvr_byte ;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -