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

📄 bootrom.asm

📁 award bios 源代码,喜欢汇编程序及想研究主板BIOS程序的人可以参考哦.我是费了老大的劲才找到的哦.
💻 ASM
📖 第 1 页 / 共 5 页
字号:
		pop	word ptr TgtSegment

Expand_Over:						;R137
; clean up temp target buffer, so that no garbage left in user's base memory
; if data decompression stub is called before memory testing, then
; we don't need to call this cleanup routine.
		call	CleanUpBaseMemory

		pop	ecx		;return compressed total size
		pop	edx		;R148

; done, exit.

		clc
@@:
		pop	es
		pop	bx
		pop	ax
		ret

expand	endp
;R108A end
;R108D start
MakeCRCTable	proc	near
;
; Input : None
; Destroy : None
; Modify Global Variable : CRCTABLE[]
;

		push    cx
		push    bx
		push    ax
		push    si

		mov     si,offset crctable
		mov     cx,100h         ; for (i = 0; i <= 0xff; i++)
MCRCT_1:
		mov     ax,100h
		sub     ax,cx           ; r = i;
		push    ax              ; save index

MCRCT_2:
		mov     bx,0            ; for (j = 0; j < 8; j++)
MCRCT_2_1:
		test    ax,1            ; (r & 1)
		jz      short MCRCT_3

		shr     ax,1
		xor     ax,CRCPOLY
		jmp     short MCRCT_4
MCRCT_3:
		shr     ax,1
MCRCT_4:
		inc     bx
		cmp     bx,8
		jb      short MCRCT_2_1

		pop     bx	; pop out saved index to !!! REG BX !!! so that
				; we won't destroy AX

		mov     word ptr [si+bx],ax
		inc	si	; since this is an array of word, we increase bx
				; and si respectively so that totaly make up a 2
				; bytes increment.

		loop    short MCRCT_1

		pop     si
		pop     ax
		pop     bx
		pop     cx

		ret

MakeCRCTable	endp

FreadCRC	proc	near
;
; Globally parameters passing : Header, Headersize, InpFileHandle
; Modify global variable: origsize
;

		push	ax
		push	bx
		push	cx
		push	dx

		movzx   cx,byte ptr Headersize

		push	es
		push	si
		mov	ax,word ptr SrcSegment
		mov	es,ax
		mov	bx,word ptr SrcOffset
		mov	si,offset Header
FCRC_0:
		movzx	ax,byte ptr es:[bx]
		mov	byte ptr ds:[si],al
		inc	bx
		inc	si
		loop	short FCRC_0

		mov	ax,bx
		sub	ax,word ptr ds:SrcOffset	; how many bytes we have read ?
		mov	word ptr ds:SrcOffset,bx
		pop	si
		pop	es

		mov     byte ptr Headersize,al
		mov     cx,ax           		; save a copy
		add     word ptr origsize,ax
		inc     cx
		mov     bx,offset Header
FCRC_1:
		movzx	ax,byte ptr [bx]
		dec     cx
		jcxz    short FCRC_2

		UpdateCRC

		inc     bx				; increment pointer
		jmp     short FCRC_1
FCRC_2:

		pop	dx
		pop	cx
		pop	bx
		pop	ax

		ret

FreadCRC	endp

CalcHeadersum	proc	near
;
; Input : None
; Output : AX
; Destroy : AX
; Global variable : None
;
		push	bx
		push	cx
		push	dx

		mov	ax,0	; clear sum
		movzx	cx,byte ptr headersize
CH_1:
		movzx	bx,byte ptr headersize
		sub	bx,cx
		movzx	dx,byte ptr header[bx]
		add	ax,dx
		loop	short CH_1

		pop	dx
		pop	cx
		pop	bx

		and	ax,0ffh

		ret

CalcHeadersum	endp

GetFromHeader	proc	near
;
; Input	  : BX -- from
;	    CX -- count
; Output  : EAX
; Destroy : EAX
;

		push	bx
		push	edx
		push	si

		xor	eax,eax	; prepare unsigned long variable output

		dec	bx
		inc	cx

GFH_1:

		dec	cx
		jcxz	short GFH_2

		shl	eax,8
		mov	si,bx
		add	si,cx
		movzx	edx,byte ptr header[si]
		add	eax,edx		; little endian
		jmp	short GFH_1

GFH_2:

		pop	si
		pop	edx
		pop	bx

		ret

GetFromHeader	endp


ReadHeader	proc	near
;
; Input : None
; Output : Carry Set - several reason might cause the carry flag be set
;			1. header size is 0
;			2. header check sum is not correct
;			3. data pattern does not match in some specific
;			   location.
;        : Carry clear - header size is not 0
;


		pusha

; read in headersize byte


		push	es
		mov	ax,word ptr SrcSegment
		mov	es,ax
		mov	bx,ds:SrcOffset
		movzx	ax,byte ptr es:[bx]
		inc	word ptr ds:SrcOffset
		mov	byte ptr headersize,al
		pop	es

		cmp     byte ptr headersize,0
		jne     short   RH_2

RH_1:
		stc
		jmp     RH_Exit

RH_2:

		; read in headersum byte

		push	es
		mov	ax,word ptr SrcSegment
		mov	es,ax
		mov	bx,ds:SrcOffset
		movzx	ax,byte ptr es:[bx]
		inc	word ptr ds:SrcOffset
		mov	byte ptr headersum,al
		pop	es


		call    FreadCRC       ; CRC not used

		call    CalcHeadersum

; compare headersum and result of CalcHeadersum

		cmp	al,byte ptr headersum
		je	short @F
		jmp	short RH_1

@@:
		mov	bx,5
		mov	cx,4
		call	GetFromHeader
		mov	dword ptr compsize,eax

		mov	bx,9
		mov	cx,4
		call	GetFromHeader
		mov	dword ptr origsize,eax

		mov	bx,13
		mov	cx,2
		call	GetFromHeader
		mov	word ptr ExpOffset,ax

		mov	bx,15
		mov	cx,2
		call	GetFromHeader
		mov	word ptr ExpSegment,ax

		cmp	byte ptr Header[17],20h	; check specific spot of header
		jne	short RH_1

		cmp	byte ptr Header[18],01h ; check specific spot of header
		jne	short RH_1

		movzx	bx,byte ptr headersize
		sub	bx,5
		mov	cx,2
		call	GetFromHeader
		mov	word ptr file_crc,ax	; truncate upper word

		mov	bx,NAMELENIDX
		mov	bl,byte ptr Header[bx]
		mov	ax,OUTFILENAME
		add	bx,ax
		mov	byte ptr Header[bx],'$'	; assembly version
		mov	byte ptr Header[bx+1],0	; assembly version

		clc

RH_Exit:

		popa

		ret

ReadHeader	endp
;R108D end

		public	Bootrom_C000_End
Bootrom_C000_End:
;R108 start
		align	16		;R140
		db	'*BBSS*'	;Boot Block structure signature
BootExt_Off	EQU	0
DecmpCode_Off	EQU	2
Extract_Off	EQU	10
CleanUpBaseMemory_Off	EQU	12
Expand_Off	EQU	14				;R108A
		dw	External_BootRom_Seg
		dw	Decompress_Code_Seg
		dw	WholeBootRomStart_Seg
		dw	ROMDrive_Limit_Seg
		dw	ESCD_Data_Seg
		dw	offset DGROUP:Extract
		dw	offset DGROUP:CleanUpBaseMemory
		dw	offset DGROUP:Expand		;R108A
;R108 end
ifdef	Flash_2M_support					;R116
		dw	offset DGROUP:Enable_Extra_1MBIOS_Hook	;R116
		dw	offset DGROUP:Disable_Extra_1MBIOS_Hook	;R116
else	;Flash_2M_support						;R149
		dw	?						;R149
		dw	?						;R149
endif	;Flash_2M_support					;R116
		db	1	;Flag for CBROM.EXE to check		;R149
				; whether it is a old or new BIOS	;R149
				; 0FFh = old BIOS			;R149
;R122 start
;---- 2MB bios external 8k boot block area ----
ifdef	Flash_2M_support
ifdef	Bootblock_16K_Support			;R129
		org	0C000h
COMPILE_FOR_BOOTROM_ASM	=	1		;R129
		include	BOOTROM.INC		;R129
		ret				;R129
COMPILE_FOR_BOOTROM_ASM	=	2		;R129
		include	BOOTROM.INC		;R129
		ret				;R129

		include	btpci1a.inc		;R150

ifdef	Chipboot_In_External_Boot_Block   	;R151
		include	chipboot.asm            ;R151
endif	;Chipboot_In_External_Boot_Block        ;R151

else;	Bootblock_16K_Support			;R129
		org	0E000h			;R129
endif;	Bootblock_16K_Support			;R129

;R129 ;R123 start
;R129 ifdef	Flash_2M_support
;R129 Extern_execute1:
;R129 ifdef	A17_From_KB_Pin						;R124
;R129 		call	Enable_KB_Controller
;R129 endif;	A17_From_KB_Pin						;R124
;R129
;R129 Temp_Extra_BIOS_Addres	EQU	8000h
;R129 		push	2000h
;R129 		call	Enable_Extra_1MBIOS_Hook
;R129 		mov	esi,0
;R129 		jnz	short @F	;real mode address
;R129 		mov	esi,0fff00000h	;protect mode high address
;R129 @@:
;R129 		movzx	ecx,cx
;R129 		shl	ecx,4
;R129 		or	esi,ecx
;R129 		cld
;R129 ;---------------- Enter Protect Mode ----------------
;R129                 mov     ax,cs
;R129                 mov     ds,ax
;R129                 assume  ds:dgroup
;R129
;R129                 lgdt    fword ptr DGROUP:B_GDTR1
;R129
;R129                 mov     eax,cr0
;R129                 or      al,1
;R129                 mov     cr0,eax
;R129
;R129 		jmp	short $+2		;clear prefetch
;R129
;R129                 mov     ax,B_DATA1_INDEX
;R129                 mov     ds,ax                   ; ds = 00000000h
;R129 		mov	es,ax
;R129
;R129 		mov	edi,(Temp_Extra_BIOS_Addres shl 4)
;R129 		mov	ecx,8000h
;R129 		db	67h
;R129 		rep	movsd
;R129
;R129 ;---------------- Leave Protect Mode ----------------
;R129                 mov     eax,cr0
;R129                 and     al, NOT 1
;R129                 mov     cr0,eax
;R129 		jmp	short $+2
;R129 		push	2000h
;R129 		call	Disable_Extra_1MBIOS_Hook
;R129 		ret
;R129
;R129 Extern_execute2:
;R129 ;----- decompress first extra BIOS area (0C000h) -----
;R129 		mov	bx,Temp_Extra_BIOS_Addres
;R129 		mov	es,bx
;R129 		xor	bx,bx
;R129 		xor	cx,cx
;R129 Expand_ROM_loop:
;R129 		add	bx,cx
;R129 		call	BootBlock_Expand
;R129 		jnc	short Expand_ROM_loop
;R129
;R129 ;----- decompress secondary extra BIOS area (0D000h) -----
;R129 		mov	bx,es
;R129 		add	bx,1000h
;R129 		mov	es,bx
;R129 		xor	bx,bx
;R129 		xor	cx,cx
;R129 Expand_ROM_loop1:
;R129 		add	bx,cx
;R129 		call	BootBlock_Expand
;R129 		jnc	short Expand_ROM_loop1
;R129 		ret
;R129 endif	;Flash_2M_support
;R129 ;R123 end



endif	;Flash_2M_support
;R122 end
		org	0E000h

FCODE		ENDS

DGROUP		GROUP	@DATAC
@DATAC		SEGMENT	USE16 DWORD COMMON 'DATAC'
		ASSUME	CS:DGROUP,DS:DGROUP

		org	0
ORG_START:
		PUBLIC	CODE_START
CODE_START:
CopyRit_Msg:
		DB	'Award BootBlock BIOS v1.0',CR,LF
		DB	'Copyright (c) 1997, Award Software, Inc.',CR,LF;R127;R141
CopyRit_Msg_Len	EQU	$ - offset CopyRit_Msg

;R90 start
BBSS_Label:					;R108
		db	'*BBSS*'	;Boot Block structure signature
BBSS_Label_Len	EQU	$-offset BBSS_Label	;R108
ifdef	Flash_2M_support					;R125
		dw	6699h					;R125
		dw	offset DGROUP:Enable_Extra_1MBIOS_Hook	;R125
		dw	offset DGROUP:Disable_Extra_1MBIOS_Hook	;R125
endif	;Flash_2M_support					;R125
;R108		dw	External_BootRom_Seg
;R108		dw	Decompress_Code_Seg
;R108		dw	WholeBootRomStart_Seg
;R108		dw	ROMDrive_Limit_Seg
;R108		dw	ESCD_Data_Seg
;R90 end
;R76 start
		CK_ORG	0E056h
		dw	offset DGROUP:Expand
;R76 end
;R108ifdef FULL_SCREEN_LOGO				;R102C
		CK_ORG	0E058h			;R102C
		db	55h			;R102C
;R108endif ;FULL_SCREEN_LOGO				;R102C
ifdef	Flash_2M_support			;R116
		CK_ORG	0E059h			;R116
		db	5ah			;R116 2M BIOS signature
endif	;Flash_2M_support			;R116

		CK_ORG	0E05Bh
	    	PUBLIC	RST_VECT
RST_VECT	LABEL	NEAR
RST_VECT_NEAR	LABEL	NEAR

;[]==============================================================[]
;
; REDO:
;
;	This routine is called by the reset vector at F000:E05B
;	after a power-up. It determines whether this is a virtual
;	shutdown or a normal boot. If it is a normal boot, we
;	juggle a few cache's and then go on to POST.
;
;Saves:	NONE
;
;Entry:	NONE
;Exit:	NONE
;
;Author: Award
;Date:   04/18/90
;
; Name | Date	    | Description
; ---------------------------------------------------------------
; TIM | 18-Apr-90   | Update to 4.0
;
;[]==============================================================[]
  		align	4
		PUBLIC	REDO
REDO		PROC	NEAR
		mov	gs,dx			; gs = cpu type
;
;	Test if this was a virtual shutdown.
;

		cli
		cld

		mov	ax,cs				;R132
		mov	ss,ax				;R132

ifdef	Very_Very_Early_Init				;R132
		extrn	Ct_Very_Early_Init:Near		;R132
		ROM_CALL Ct_Very_Early_Init		;R132
endif	;Very_Very_Early_Init				;R132

;R78 - start
;Some super IO chips that contain RTC & KBC but they disabled at power on
;BIOS need to program registers as early as possible

		jmp	PWRON_Rtc_Kbc_Init
PWRON_Rtc_Kbc_Exit:
;R78 - end

;R132		mov	ax,cs
;R132		mov	ss,ax
;R132
;R132		in	al,STAT8042		; was this a user or prog reset ?
;R132		NEWIODELAY
;R132		test	al,4
;R132		jnz	short @F

ifdef	PM_SUPPORT
		extrn	CT_Sleep_Detect:near
		rom_call	CT_Sleep_Detect
		jnz	short @F		; virtual shutdown...
endif	;PM_SUPPORT
		mov	dx,gs			; dx = CPU ID
		rom_call	CPU_Detect

ifndef	PCI_RESET_SUPPORT					;R139
;R109 start
		mov	ax,G_RAM
		mov	ds,ax
		mov	word ptr ds:[USER_REBOOT],0
;R109 end
endif	;PCI_RESET_SUPPORT					;R139
@@:

;Program chipset registers before POST

⌨️ 快捷键说明

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