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

📄 runvuma.asm

📁 <BIOS研发技术剖析>书的源代码,包括完整的BIOS汇编语言源程序.
💻 ASM
📖 第 1 页 / 共 2 页
字号:
;              boot for all VUMA devices in units of 64KB                      ;
;                                                                              ;
; Destroys: AL, AH (if successful)                                             ;
;------------------------------------------------------------------------------;
VumaGetNextBootAllMemSize	proc near
	call	VumaGetNextBootDeviceMemSize ;See above
	ret
VumaGetNextBootAllMemSize	endp


;---------------------------------------;
; VumaGetCurrentMemSize (05)            ;
;---------------------------------------;--------------------------------------;
; This function returns the current size and address of VUMA frame buffer      ;
; memory for a given VUMA device or for all VUMA devices.                      ;
;                                                                              ;
; Input: CL = PCI Device/Function number of VUMA device (FF means all devices) ;
;                Bits 7-3: PCI device number                                   ;
;                Bits 2-0: Function number within the device                   ;
;        CH = PCI Bus number of VUMA device (FF means all devices)             ;
;                                                                              ;
; Output: CF = Set if error, clear if successful                               ;
;         AH = Nonzero return code if function was not successful              ;
;              (value is "don't care" if function is successful)               ;
;         DX = Size of VUMA frame buffer memory that is currently active       ;
;              in units of 64KB                                                ;
;         BH = 00: VUMA memory is not visible to the CPU                       ;
;              01: VUMA memory is visible to the CPU                           ;
;         CX = Memory banks in use by VUMA frame buffer                        ;
;               Bit 0: Set if bank 0 is used                                   ;
;               Bit 1: Set if bank 1 is used                                   ;
;               ...                                                            ;
;               Bit 15: Set if bank 15 is used                                 ;
;         SI = Upper 16 bits VUMA frame buffer's physical address              ;
;         DI = Lower 16 bits VUMA frame buffer's physical address              ;
;                                                                              ;
; Destroys: AL, AH (if successful)                                             ;
;------------------------------------------------------------------------------;
VumaGetCurrentMemSize	proc near

	call	FrameBufGetCurSize	;Returns DX = cur frame buf size in 64k
	or	dx,dx
	mov	ah,05h			; FrameBuffer not support error
	jz	func_05_error

	call	FrameBufGetCurAddress	;Returns EAX = cur addr of frame buffer
	mov	ebx,eax
	mov	ah,04h
	jc	func_05_error
	mov	di, bx			;DI = lower half of addr
	shr	ebx, 16
	mov	si, bx			;SI = upper half of addr

	call	FrameBufGetVisibility	;Returns BH = 0/1 for invisible/visible
	call	FrameBufGetCurBanks	;Returns CX = bitmap of banks in use as frame buffer

	clc
	jmp	short func_05_done

func_05_error:
	stc

func_05_done:
	ret
VumaGetCurrentMemSize	endp


;---------------------------------------;
; VumaGetMemorySpeedType (06)           ;
;---------------------------------------;--------------------------------------;
; This function returns information on the memory installed in a given bank.   ;
;                                                                              ;
; Input: CX = Memory bank number                                               ;
;             Bit 0: Set if bank 0 is requested                                ;
;             Bit 1: Set if bank 1 is requested                                ;
;             ...                                                              ;
;             Bit 15: Set if bank 15 is requested                              ;
;        DX = Iteration number for the above bank                              ;
;                                                                              ;
; Output: CF = Set if error, clear if successful                               ;
;         AH = Nonzero return code if function was not successful              ;
;              (value is "don't care" if function is successful)               ;
;         EBX = Bit 31-18: Reserved                                            ;
;               Bit 17-16: External buffering of DRAM bank                     ;
;                            00 = Unknown                                      ;
;                            01 = Bank has external buffer                     ;
;                            10 = Bank does not have external buffer           ;
;                            11 = Reserved                                     ;
;               Bit 15:    Reserved                                            ;
;               Bit 14:    Set if bank (or this portion of bank) is used as    ;
;                          VUMA memory                                         ;
;               Bit 13-7:  Speed of memory in nanoseconds (00=unknown)         ;
;               Bit 6-0:   Reserved                                            ;
;         ECX = Bit 31-24: If bank contains asymetrical DRAM, number of rows   ;
;               Bit 23-16: If bank contains asymetrical DRAM, number of columns;
;               Bit 15-9:  Memory supply voltage in tenths of a volt (00 =     ;
;                          unknown)                                            ;
;               Bit 8:     Burst order                                         ;
;                            0 = Interleave burst order                        ;
;                            1 = Sequential burst order                        ;
;               Bit 7-6:   Burst size                                          ;
;                            00 = 1 Byte                                       ;
;                            01 = 2 Bytes                                      ;
;                            10 = 4 Bytes                                      ;
;                            11 = Unknown                                      ;
;               Bit 5-4:   CAS latency in CPU clocks                           ;
;               Bit 3-0:   Type of memory                                      ;
;                            0 = Unknown                                       ;
;                            1 = Fast page mode                                ;
;                            2 = EDO                                           ;
;                            3 = SDRAM                                         ;
;                            4 = PN EDO (Burst EDO)                            ;
;                            5-F = Reserved                                    ;
;         EDX = Amount of memory installed in bank in units of 64kb            ;
;         SI = Upper 16 bits memory bank's physical address                    ;
;         DI = Lower 16 bits memory bank's physical address                    ;
;                                                                              ;
; Destroys: AL, AH (if successful)                                             ;
;------------------------------------------------------------------------------;
VumaGetMemorySpeedType	proc near
	push	bp
	push	eax

;; SiS VUMA not support iteration
;	push	dx			;Save iteration value


;; SiS VUMA using RAS0 if not then return error message
	bsf	cx, cx			;CL = Bank number
	or	cx,cx
	jnz	GetMemError

; EDX[32:24]/[23:16] = Asynchronous mem row/col count
; EBX[31:28] = MA scrambling table selection[3:0]

	call	FrameBufGetAsymMemInfo	;Returns BL=MA table, DL=cols, DH=rows for bank CL
	shl	edx, 16			;EDX[31:24]/[23:16] = asym rows/cols
	shl	ebx, 28			; EBX[31:28] = MA table

; EBX[14] = Main VUMA memory
	or	ebx,4000h

; SiS reserved
; EBX[17:16] = Ext buffer flags
; EDX[15:9]  = Bank voltage
;	call	FrameBufGetBankVoltage	;Returns AL=Voltage, AH=Ext buffer flags for bank CL
;	and	ah, 00000011b
;	movzx	ebx, ah
;	shl	ebx, 16			;EBX[17:16] = Ext buffer flags

;	and	al, 01111111b		;Limit voltage info to 7 bits
;	shl	ax, 9			;AX[15:9] = Voltage
;	or	dx, ax			;EDX[15:9] = Voltage

; EDX[8]/[7:6]/[5:4] = Burst order, burst size, and CAS latency

	call	FrameBufGetBankTimingInfo ;Returns AL[4],[3:2],[1:0] = timing info for bank CL
	and	ax, 001Fh		;Limit timing info to 5 bits
	shl	ax, 4
	or	dx, ax			;EDX[8]/[7:6]/[5:4] = timing info

; EDX[3:0] = Type of memory

	call	FrameBufGetBankMemType	;Returns AL=mem type for bank CL
	and	al, 0Fh			;Limit mem type to 4 bits
	or	dl, al			;EDX[3:0] = mem type

; EBX[5:4] = DRAM controller write/read cycle
	call	dram_control_cycle	;Returns AH[1:0]= write/read cycle
	shl	ah,4
	or	bl,ah

; EBX[3:0] = M/B frequency
	call	find_frequency		;Returns AH=0/1/2/3/4 60/66/75/83/100 MHz
	or	bl,ah

; SiS reserved
; EBX[13:7] = Memory speed in ns
;	call	FrameBufGetBankMemSpeed	;Returns AL=mem speed for bank CL
;	and	ax, 007Fh		;Limit mem speed to 7 bits
;	shl	ax, 7			;AX[13:7] = mem speed
;	or	bx, ax			;EBX[13:7] = mem speed, EBX ready to return

;; SI/DI = Start address of bank's memory
;	call	FrameBufGetBankAddress	;Returns EAX = start addr of bank CL
;	mov	di, ax			;DI = lower half of addr
;	shr	eax, 16
;	mov	si, ax			;SI = upper half of addr

; EDX = Amount of memory installed in bank
;	call	FrameBufGetBankMemSize	;Returns AX = size of mem in bank CL in 64k

	mov	bp, cx			;BP = bank number
	mov	ecx, edx		;ECX = memory bank info ready to return

; Check the iteration value passed in by the caller.  If it is non-zero, then
; this bank should be the bank that contains the frame buffer (return error
; if this is not true).  Also if the iteration value is higher than 0001h, it
; is an illegal value, so return an error.  If the iteration value is 0001h and
; the frame buffer is using this bank of memory then update the start address
; in SI/DI and set bit 14 in EBX.

;	pop	ax			;Restore iteration value
;	push	cx			;Save values ready to be returned
;
;	call	FrameBufGetCurBanks	;Returns CX = bitmap of banks in use as frame buffer

;	or	ax, ax
;	jz	GetMemFirstIteration	;Br if iteration value is zero
;	cmp	ax, 1
;	ja	GetMemError		;Br if iteration value is > 1

;	bts	cx, bp			;Sets CF = bit number BP of CX
;	jnc	GetMemError		;Br if this bank is not frame buffer bank

; EDX = Amount of memory installed in bank(RAS0 - share)
; SI/DI = Start address of memory
	call	FrameBufGetCurAddress	;Returns EAX = cur addr of frame buffer
	mov	di, ax			;DI = lower half of addr
	shr	eax, 16
	mov	si, ax			;SI = upper half of addr
	movzx	edx, ax			;EDX = amount of mem ready to return

GetMemDone:
;; for TV out
	push	ax
	mov	al,Q_MONITOR_DEVICE
	extrn	get_cmos_item:near
	call	get_cmos_item
	ror	ebx,24
	and	bx,not 07h
	or	bl,al
	rol	ebx,24
	pop	ax
	clc				;Indicate success
GetMemExit:
;	pop	cx			;Restore CX return value

	pop	bp			;Lower half of EAX on entry (discard this)
	pop	bp			;Upper half of EAX on entry (put this back)
	ror	eax, 16
	mov	ax, bp
	ror	eax, 16
	pop	bp
	ret

; If the frame buffer starts in this memory bank, return with CF set and AH=80h
; This will inform the caller to make another call with iteration value = 01h

;GetMemFirstIteration:
;	bts	cx, bp			;Sets CF = bit number BP of CX
;	jnc	GetMemDone		;Br if this bank is not frame buffer bank
;	mov	ah, 080h		;Indicate another iteration is needed
;	stc
;	jmp	short GetMemExit

GetMemError:
	mov	ah, 004h		;Error return code.......................
	stc
	jmp	short GetMemExit

VumaGetMemorySpeedType	endp


;---------------------------------------;
; VumaMemoryEnableDisable (07)          ;
;---------------------------------------;--------------------------------------;
; This function enables or disables CPU access to the VUMA frame buffer memory.;
;                                                                              ;
; Input: BH = Bit 0: Set if memory should me made visible to the CPU           ;
;                    Clear if memory should me made invisible to the CPU       ;
;             Bit 1-7: Reserved                                                ;
;                                                                              ;
; Output: CF = Set if error, clear if successful                               ;
;         AH = Nonzero return code if function was not successful              ;
;              (value is "don't care" if function is successful)               ;
;                                                                              ;
; Destroys: AL, AH (if successful)                                             ;
;------------------------------------------------------------------------------;
VumaMemoryEnableDisable	proc near

	test	bh, 1
	jnz	@f			;Br if frame buffer should be enabled
	call	FrameBufMakeInvisible
	jmp	short EnableDisableDone
@@:	call	FrameBufMakeVisible

EnableDisableDone:
	clc
	ret
VumaMemoryEnableDisable	endp


_text	ends
	end
;*****************************************************************;
;*****************************************************************;
;**                                                             **;
;**      (C)Copyright 1985-1995, American Megatrends, Inc.      **;
;**                                                             **;
;**                     All Rights Reserved.                    **;
;**                                                             **;
;**           6145-F Northbelt Pkwy, Norcross, GA 30071         **;
;**                                                             **;
;**                     Phone (770)-263-8181                    **;
;**                                                             **;
;*****************************************************************;
;*****************************************************************;

⌨️ 快捷键说明

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