📄 smbrun.asm
字号:
page ,132
title SMBIOS RUNTIME PnP FUNCTIONS 5Xh
;---------------------------------------------------------------;
;*****************************************************************;
;*****************************************************************;
;** **;
;** (C)Copyright 1985-1999, American Megatrends Inc. **;
;** **;
;** All Rights Reserved. **;
;** **;
;** 6145-F, Northbelt Parkway, Norcross, **;
;** **;
;** Georgia - 30071, USA. Phone-(770)-246-8600. **;
;** **;
;*****************************************************************;
;*****************************************************************;
;---------------------------------------;
include mbiosequ.equ
include rt.equ
include ri.equ
include gpnv.equ
include smb.cfg
include smb.equ
include smbstruc.def
include biosdata.dat
include makeflag.equ ; (CORE0218+)
; (CORE0221+)>
include cf.equ
include silent.equ
; <(CORE0221+)
;---------------------------------------;
extrn smbios_table_entry_point_struc:byte
extrn smbios_internal_data:byte
extrn runtime_interface_routine:byte
extrn gpnv_interface_routine:byte
extrn GetStrucLen:near
extrn get_structure_details:near
extrn copy_string:near
extrn get_string_details:near
extrn update_ieps_checksum:near
extrn update_eps_checksum:near
extrn get_smbios_structures_details:near
extrn get_ebda:near
;---------------------------------------;
cgroup group _text
_text segment word public 'CODE'
assume cs:cgroup
.486
;---------------------------------------;
public _SMBRUN_STARTS
_SMBRUN_STARTS label byte ; marks start of module
;-----------------------------------------------------------------------;
; SMBIOS PnP RUNTIME FUNCTIONS ;
;-----------------------------------------------------------------------;
; SMBIOS_RT_FUNC_ENTRY ;
; This routine is invoked from thr runtime PnP functions if it is not ;
; handled by the generic BIOS module (e.g. if it is a SMBIOS function). ;
; Input: [EBP+00] = Function number (00h) ;
; Other values in Stack are according to the function number ;
; Output: All output is written directly to buffers provided by caller. ;
; AX = Zero if success, non-zero return code if non successful ;
; Destroys: AX ;
;-----------------------------------------------------------------------;
public smbios_rt_func_entry
smbios_rt_func_entry proc far
pushf
push bx
mov bx,[ebp+00h] ; get the function number
sub bx,50h
mov ax,RT_INVALID_FUNC ; Return code for unknown func
cmp bx,(smbios_func_table_end - smbios_func_table_start) / 2
jae short srfe_00 ; invalid function
shl bx,1
call cgroup:word ptr [smbios_func_table_start+bx]; Call proper PnP function
srfe_00:
pop bx
popf
retf
smbios_rt_func_entry endp
;-----------------------------------------------------------------------;
; SMBIOS_FUNC_TABLE ;
;-----------------------------------------------------------------------;
smbios_func_table_start label byte
dw offset cgroup:rt_get_smbios_info ;SMBIOS func 50h
dw offset cgroup:rt_get_smbios_struc ;SMBIOS func 51h
dw offset cgroup:rt_set_smbios_struc ;SMBIOS func 52h
dw offset cgroup:rt_get_smbios_struc_change_info ;SMBIOS func 53h
dw offset cgroup:rt_smbios_control ;SMBIOS func 54h
smbios_func_table_end label byte
;-----------------------------------------------------------------------;
; Func 50h..RT_GET_SMBIOS_INFO ;
;-----------------------------------------------------------------------;
; This function returns information about the SMBIOS extensions such as ;
; the number of structures present and the size of the largest one. This;
; function is presently called only during RUNTIME. ;
; Input: [EBP+00] = Function number (50h) ;
; [EBP+02] = BYTE FAR *DmiBiosVersion ;
; [EBP+06] = WORD FAR *NumStructures ;
; [EBP+0A] = WORD FAR *StructureSize ;
; [EBP+0E] = DWORD FAR *DMIStorageBase ;
; [EBP+12] = WORD FAR *DMIStorageSize ;
; [EBP+16] = WORD BiosSelector ;
; Output: AX = Zero if successful, non-zero return code if non successful ;
; [EBP+02] = BYTE FAR *DmiBiosVersion filled in with the version of ;
; the DMI BIOS spec that this code supports. ;
; [EBP+06] = WORD FAR *NumStructures filled with total number of DMI ;
; structures that are present in the system. ;
; [EBP+0A] = WORD FAR *StructureSize filled with the size in bytes of ;
; the largest DMI structure. ;
; [EBP+0E] = WORD FAR *DMIStorageBase filled with the absolute ;
; 32Bit address of any memory-mapped structure ;
; [EBP+12] = WORD FAR *DMIStorageSize filled with the buffer ;
; size needed in Func 52h/54h. ;
; Destroys: Nothing ;
;-----------------------------------------------------------------------;
rt_get_smbios_info proc near
push si
push ds
push eax
lds si,dword ptr [ebp+02h] ; DS:SI = *DmiBiosVersion
mov byte ptr [si],SMBIOS_VERSION
mov di,offset cgroup:smbios_table_entry_point_struc
mov ax,cgroup:(SMB_TABLE_HEADER_STRUC ptr [di]).wNumSMBStruc; AX = #of DMI structures present
lds si,dword ptr [ebp+06h] ; DS:SI = *NumStructures
mov word ptr [si],ax ; Fill in structure count in caller's buffer
mov ax,cgroup:(SMB_TABLE_HEADER_STRUC ptr [di]).wMaxStrucSize; AX = size of largest structure
lds si,dword ptr [ebp+0Ah] ; DS:SI = *StructureSize
mov word ptr [si],ax ; Fill in max structure size in caller's buffer
%Out Fill up DmiStorageBase and DmiStorageSize properly
mov eax,cgroup:dword ptr (SMB_INTERNAL_DATA_STRUC ptr smbios_internal_data).dSMBStorageBase
lds si,dword ptr [ebp+0Eh] ; DS:SI = *DMIStorageBase
mov dword ptr [si],eax ; Fill in DMI Storage Base address
mov ax,cgroup:word ptr (SMB_INTERNAL_DATA_STRUC ptr smbios_internal_data).dSMBStorageSize
lds si,dword ptr [ebp+12h] ; DS:SI = *DMIStorageSize
mov word ptr [si],ax ; Fill in DMI Storage Size
pop eax
xor ax,ax ; Indicate success
pop ds
pop si
ret
rt_get_smbios_info endp
;-----------------------------------------------------------------------;
; Func 51h..RT_GET_SMBIOS_STRUC ;
;-----------------------------------------------------------------------;
; This function copies one DMI structure into the buffer provided by the;
; caller. The caller's DMI structure number is then updated with next ;
; DMI structure number (or FFFF if no more DMI structures are present). ;
; Input: [EBP+00] = Function number (51h) ;
; [EBP+02] = WORD FAR *StructureNum ;
; [EBP+06] = WORD DAR *DmiStructureBuffer ;
; [EBP+0A] = WORD DmiSelector ;
; [EBP+0C] = WORD BiosSelector ;
; ;
; Output: AX = Zero if success, non-zero return code if non successful
; [EBP+02] = WORD FAR *StructureNum updated to contain the next DMI
; structure number or FFFF if no more structures exist
; [EBP+06] = WORD FAR *DmiStructureBuffer pointer to buffer that is
; filled in with the requested DMI structure. ;
; ;
; Destroys: AX ;
;-----------------------------------------------------------------------;
rt_get_smbios_struc proc near
push ds
push es
pusha
lds si,dword ptr [ebp+02h] ; DS:SI = pointer to SMBIOS Structure
mov cx,word ptr ds:[si] ; given DMI Structure# (0-based)
call get_structure_details ; DS:SI = ptr to concerned structure
; CX = length of structure
; AX = next structure#
jc short rgss_01 ; error
push ax
les di,dword ptr [ebp+06] ; ES:DI = ptr to destn buffer
rep movs es:byte ptr [di],ds:byte ptr [si]; copy into destn buffer
pop ax
lds si,dword ptr [ebp+02h] ; DS:SI = pointer to SMBIOS Structure
mov word ptr ds:[si],ax ; return next Structure#
popa
xor ax,ax ; AX = 00, successful
rgss_02:
pop es
pop ds
ret
rgss_01:
popa
mov ax,RT_DMI_INVALID_HANDLE
jmp short rgss_02
rt_get_smbios_struc endp
;-----------------------------------------------------------------------;
; Func 52h..RT_SET_SMBIOS_STRUC ;
;-----------------------------------------------------------------------;
; This function sets the SMBIOS structure identified by the type and ;
; possibly handle, found in the SMBIOS structure header in the given ;
; buffer. ;
; Input: [EBP+00] = Function number (52h) ;
; [EBP+02] = WORD FAR *DmiDataBuffer ;
; [EBP+06] = WORD FAR *DmiWorkBuffer ;
; [EBP+0A] = WORD Control ;
; [EBP+0C] = WORD DmiSelector ;
; [EBP+0E] = WORD BiosSelector ;
; Output: AX = Zero if successful ;
; non-zero return code if unsuccessful ;
; Destroys: Nothing ;
;-----------------------------------------------------------------------;
rt_set_smbios_struc proc near
push es
push ds
pushad
lds si,dword ptr [ebp+02h] ; DS:SI = ptr to given data buffer
test byte ptr [ebp+0ah],01h ; Bit-0 = 0, validate parameter
; 1, Set structure immediately
jnz short rsss_00 ; set structure immediately
; validate paremeter
%OUT Need to Implement the validate parameter subfunction properly
jmp rsss_02_00
rsss_00:
; set structure
mov al,ds:byte ptr (SMBIOS_FUNC52_BUFFER_STRUC ptr [si]).bCommand; AL = command byte
; (CORE0072)>
;; cmp al,05h ; valid command ?
;; ja short rsss_02_00 ; invalid command, error
;; jz short rsss_cmd_0125 ; command 05h
;; cmp al,03h ; command 00h/01h/02h ?
;; jb short rsss_cmd_0125 ; yes
;; jz short rsss_05 ; command 03h
;; jmp rsss_cmd_04 ; command 04h
cmp al,06h ; valid command ?
ja rsss_02_00 ; invalid command, error
cmp al,05h
jae short rsss_cmd_0125 ; command 05h/06h
cmp al,03h ; command 00h/01h/02h ?
jb short rsss_cmd_0125 ; yes
jz short rsss_05 ; command 03h
jmp rsss_cmd_04 ; command 04h
; <(CORE0072)
rsss_05:
jmp rsss_cmd_03 ; command 03h
;---------------------------------------;
; command code 00h/01h/02h/05h/06h
rsss_cmd_0125:
; AL = command code 00h/01h/02h/05h/06h
push ax
add si,offset SMBIOS_FUNC52_BUFFER_STRUC.dStructureHeader; DS:SI = ptr to given structure header
push ds
push si
mov cx,ds:word ptr (DMIHDR_STRUC ptr [si]).wHandle; CX= given structure#
call get_structure_details ; get the concerned structure details
pop di
pop es
pop ax
jc short rsss_03_00 ; error
; ES:DI = ptr to given structure header
; DS:SI = ptr to concerned structure in Shadow RAM
; CX = structure length including the terminator
; AL = command code 00h/01h/02h/05h/06h
mov bx,es:word ptr (DMIHDR_STRUC ptr [di]).bType; BH = Fixed Length, BL = Type
cmp bx,ds:word ptr (DMIHDR_STRUC ptr [si]).bType; match with the information in Shadow
jnz short rsss_02_00 ; no match, error
push ds
push si
push cx
les di,dword ptr [ebp+06h] ; ES:DI = ptr to work buffer
; copy the structure to temp work buffer
push di
rep movs es:byte ptr [di],ds:byte ptr [si]; DS:SI, CX -> ES:DI
pop di
; AL = command code 00h/01h/02h/05h/06h
lds si,dword ptr [ebp+02h] ; DS:SI = ptr to given data buffer
movzx bx,ds:byte ptr (SMBIOS_FUNC52_BUFFER_STRUC ptr [si]).bFieldOffset ; BX = offset of the field to be changed
cmp al,05h ; command 05h/06h ?
; (CORE0072)>
; jnz short rsss_cmd_012 ; no
jb short rsss_cmd_012 ; no
jz rsss_cmd_5
; comamnd 06h, block change
; ES:DI = ptr to work buffer containing the original structure from Shadow RAM
; BX = offset of the field in the structure to be changed
mov cx,ds:word ptr (SMBIOS_FUNC52_BUFFER_STRUC ptr [si]).wDataLength; get the given data length
add si,offset SMBIOS_FUNC52_BUFFER_STRUC.bStructuredata; DS:SI = ptr to structure data containing the new block data
push di
add di,bx ; ES:DI = ptr to starting address of the to-be-changed item
rep movs es:byte ptr [di],ds:byte ptr [si]; move the data to F000 Shadow
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -