📄 rominit.asm
字号:
;**************************************************************************
;*
;* ROMINIT.ASM
;*
;* Copyright (c) 1998-2000 National Semiconductor Corporation.
;* All Rights Reserved.
;*
;* Function:
;* Code to load and initialize VSA and system ROMs.
;*
;* $Revision:: 5 $
;*
;**************************************************************************
.386
INCLUDE MACROS.INC
INCLUDE ROMSORT.INC
INCLUDE DEF.INC
INCLUDE PORT80.INC
INCLUDE CPU.INC
INCLUDE STRINGS.INC
INCLUDE OPTIONS.INC
INCLUDE BDA.INC
;
; VSA Initialization
;
SMI_INIT_SEG EQU 6000h ; Low RAM where SMI code is copied to
_TEXT SEGMENT PUBLIC use16 'CODE'
ASSUME CS:SEGGROUP
EXTERN preUncompress:NEAR
EXTERN postUncompress:NEAR
EXTERN TV_Init:near
EXTERN lcdInit:NEAR
EXTERN OPT_HOLE_MAP:NEAR
EXTERN virtualRegInit:NEAR
EXTERN rle_decompress_rom:NEAR
EXTERN findNextImage:NEAR
EXTERN cx92xxinit:near
EXTERN shadowExtVGARom:NEAR
EXTERN CpuMemRegRead:NEAR
EXTERN CpuMemRegWrite:NEAR
EXTERN optionRomChecksum:NEAR
EXTERN keyboardInit:NEAR
smiInitPointer DW 0020h, SMI_INIT_SEG
VideoRomPointer DW 0003h, 0c000h
;**************************************************************************
;*
;* romCopy
;*
;* Initialize the Soft A20, Power Management, Soft VGA, and Virtual
;* Audio SMM system.
;*
;* Entry:
;* Exit:
;* Destroys:
;*
;**************************************************************************
romCopy PROC NEAR PUBLIC
pusha ; Save return address
PORT80 POST_ROM_PREUNCOMPRESS ; post_D0h
call preUncompress ; Turn on SHADOW r/w for C000-EFFF
mov ax, 0
push ax
pop es ; 4gb selector
call checkExtVga
mov ax, 0
push ax
pop es ; 4gb selector
PORT80 POST_ROM_UNCOMPRESS ; post_d1h
call setStartROMAddr ; Starting physical address of ROM
mov ax, 'GM'
ror eax, 16
mov ax, 'I$'
nextImageLoc:
call findNextImage ; find all $IMG's and Decompress them
cmp eax, 0 ; No img found? Done
je noMoreImages
; check if this is SoftVGA if so then check if
; we have and ISA VGA if so don't load SoftVGA
cmp dword ptr es:[EDI+5], 000c0000h ; is this oneSoft Vga?
jne notSoftVga ; nope
test byte ptr es:[(BDA_SEG SHL 4)+BDA_VIDEO_BOARDS_B], 006h ; have external video?
jnz skipImage ; have ext video - skip soft vga
notSoftVga:
cmp dword ptr es:[EDI+5], 0ff000000h ; test to see if this is an auxiliary rom
jnb skipImage
call rle_decompress_rom ; decompress image found
skipImage:
add edi, 010h ; go to next paragraph so we dont
; find same image again.
jmp nextImageLoc
noMoreImages:
; VSA INIT
PORT80 POST_ROM_SMM_INIT ; post_D2h
xor ebx, ebx
mov bx, OFFSET OPT_HOLE_MAP ;ebx gets offset to holes list
or ebx, 0f0000h
call DWORD PTR cs:[smiInitPointer] ; VSA INIT
mov al, 056h ;
out 043h, al ; Just in case our
mov al, 012h ; Favorite VSA
out 041h, al ; Decided it liked TIMER 1 Shutoff
; This calls the VSA2 virtual register initialization. For VSA1,
; this routine is stubbed out in ..\INTSRV\VSA1BACK.ASM
call virtualRegInit
;
; clear memory used by VSA load as some boards require ram to be 0
;
pushad
push es
mov ax, 6000H
mov es, ax
xor eax, eax
xor edi, edi
mov cx, 4000H
cld
rep stosd
mov ax, 7000H
mov es, ax
xor eax, eax
xor edi, edi
mov cx, 4000H
cld
rep stosd
mov ax, 8000H
mov es, ax
xor eax, eax
xor edi, edi
mov cx, 4000H
cld
rep stosd
mov ax, 9000H
mov es, ax
xor eax, eax
xor edi, edi
mov cx, 3C00H
cld
rep stosd
pop es
popad
PORT80 POST_keyboardInit ; post_14h
NOSTACK bx, keyboardInit ; Wakeup the keyboard controller
; VIDEO BIOS, and Option ROM Init
PORT80 POST_ROM_VID_BIOS ; post_d3h
push BDA_SEG ; get bda segment
pop es ; to es (also needed by init call below)
mov al, es:[BDA_VIDEO_BOARDS_B]
or al, al ; have video?
jz noVideoBios
push es ; save es since video bios may change it.
sti
push 0h
pop ds
cld
push cs
push OFFSET VideoRomReturn
push DWORD PTR cs:[VideoRomPointer]
retf
VideoRomReturn:
pop es
test byte ptr es:[BDA_VIDEO_BOARDS_B], 006h ; have external video?
jz testLCDInit
mov ax, 003h
int 010h ; clear the screen and change to text mode
jmp noVideoBios ; have ext video - skip lcdinit and splash screen
testLCDInit:
mov al, TFT
cmp al, 0 ; Do LCD init?
je nolcdinit
PORT80 POST_ROM_LCDINIT ;post_d4h
mov al, LCDRES
call lcdInit
mov al, DSTN
cmp al, 0 ; Do DSTN init?
je nolcdinit
call cx92xxInit ; Call cx92xx DSTN Init, if not present call it's stub
nolcdinit:
PORT80 POST_ROM_SPLASH ;post_d5h
mov ax, 003h ; set display mode
int 010h
mov ax, 0
push ax
pop es ; 4gb selector
;
; init tv if it is there
;
call TV_Init ; init tv output
noVideoBios:
PORT80 POST_ROM_POSTUNCOMPRESS ;post_deh
; Only try so many times, then bail to avoid hang
mov cx, 30*1000 ; 30 secs max, don't do more than 65!
mov dx, 01F7h
checkDriveRdy:
in al, dx
and al, 080h
cmp al, 080h
jne DriveRdy
EXTERN delay_1_mSec:near
call delay_1_mSec ; Pause 1 msec, try again
loop checkDriveRdy
DriveRdy:
smiInitExit:
call postUncompress ; Turn off SHADOW r/w for ROM'd areas
popa
jmp bx
romCopy ENDP
;**************************************************************************
;*
;* CheckExtVga
;*
;* Entry:
;* Exit:
;* Destroys:
;*
;**************************************************************************
CheckExtVga PROC NEAR PUBLIC
push esi ; save si
push edx
push bx
mov ax, 0
push ax
pop es ; 4gb selector
;
; set if we have soft vga
;
mov byte ptr es:[(BDA_SEG SHL 4)+BDA_VIDEO_BOARDS_B], XPVIDEO
; check if we have a isa vga
checkISAVGA:
; 1st unshadow c000 to see if we have ISA VGA
mov eax, CPU_BC_XMAP_2 ; C000 and D000
NOSTACK bx, CpuMemRegRead
push edx ; Save it.
and edx, 0ffffff00h ; unshadow
NOSTACK bx, CpuMemRegWrite ; unshadow
;
; see if c000 is 55aa
;
cmp word ptr es:[0c0000h], 0aa55h ; isa rom here?
jne checkforpcivga ; no
;
; now do checksum to see if valid
;
mov esi, 0c0000h ; point to video rom
call optionRomChecksum ; checksum
jnz checkforpcivga ; invalid rom
; have valid checksum - set as have ISA VIDEO
or byte ptr es:[(BDA_SEG SHL 4)+BDA_VIDEO_BOARDS_B], 02h
; shadow it
pop edx ; get final register (mod by shadow)
mov esi, 0c0000h ; point to video rom
call ShadowExtVGARom
; restore CPU_BC_XMAP_2
mov eax, CPU_BC_XMAP_2 ; C000 and D000
NOSTACK bx, CpuMemRegWrite ; restore
Jmp exitvgacheck
checkforpcivga:
pop edx ; get orig value back
mov eax, CPU_BC_XMAP_2 ; C000 and D000
NOSTACK bx, CpuMemRegWrite ; restore
exitvgacheck:
pop bx
pop edx
pop esi
ret
CheckExtVga ENDP
;**************************************************************************
;*
;* setStartROMAddr
;*
;* This routines "reason for being" is that with the MDOC solution the
;* ROM contents do not 'appear' at FFFC0000h-FFFFFFFFh anymore. It is
;* in fact shadowed to RAM in the 002C0000h-002FFFFFh range. So, if it
;* is "known" that we are booting from an MDOC then we must alter this
;* starting address so that the ROM images can be found!
;*
;* Entry: Assumes ES is big
;* Exit: EDI is set to starting addr to search from
;* Destroys: EAX
;*
;**************************************************************************
setStartROMAddr PROC NEAR
mov edi, 0FFF00h ; MDOC entry addr
mov eax, es:[edi] ; If we are booting from an MDOC
cmp eax, 'MDOC' ; this will be TRUE!
mov edi, 0FFFC0000h ; Booting from Flash ROM
jne @F
mov edi, 0002C0000h ; Booting from MDOC
@@:
ret
setStartROMAddr ENDP
_TEXT ENDS
END
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -