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

📄 asm.asm

📁 ATI GRAPHICS CARD BIOS FOR RV100,RV200,R200,RV250,R300 SERIES VER:8.4.8
💻 ASM
字号:
.386p
;************************segment definitions*******************************
_TEXT       segment para public USE16 'CODE'
_TEXT       ends

 CGROUP     group   _TEXT

Assume   CS:CGROUP

_TEXT	segment para public

public	_io_outbyte 
public	_io_outword 
public	_io_outdword
public	_io_inbyte
public	_io_inword
public	_io_indword
public	_pci_inword
public	_pci_outword
public	_pci_indword
public	_pci_outdword

public	_readxmsdword
public	_readxmsbuffer
public  _check_for_v86
public  _scprintf

;------------------------------------------------------------------------------
_scprintf		proc far
		push	bp
		mov		bp, sp
		push	es
		mov		dx,[bp+12]
		xchg		dh, dl
		mov		cx,[bp+10]
		mov		bx, 001fh
		mov		ax,[bp+8]
		mov		es, ax
		mov		bp,[bp+6]
		mov		ax, 01301h
		int		010h
		pop		es
		pop		bp
_scprintf		endp
;------------------------------------------------------------------------------
_check_for_v86    proc far
		smsw	ax
		and	ax, 1
		retf
_check_for_v86	  endp
;------------------------------------------------------------------------------
_readxmsbuffer    proc  far
; char far * buffer
; unsigned long addr - linear address to read from
; unsigned short size
		push	bp
		mov	bp, sp
		push    ebx
		push	es
		push	di
		xor	edi, edi
		mov	di,[bp+6]
		mov	ax,[bp+8]
		mov	es, ax
		mov	ebx,[bp+10]
		mov	cx, [bp+14]
		shr	cx, 2
		pushf
		call    EnterProtectedMode
copybuffer:
		mov     eax,fs:[ebx]
		mov	es:[edi], eax
		add	ebx, 4
		add	edi, 4
		loop	copybuffer
		call    ExitProtectedMode
		popf
		pop	di
		pop	es
		pop     ebx
		pop	bp
		retf
;
_readxmsbuffer   endp
;------------------------------------------------------------------------------
;------------------------------------------------------------------------------
_readxmsdword    proc  far
; unsigned long addr - linear address to read from
		push	bp
		mov		bp,	sp
		mov		ebx,[bp+6]
		pushf
		push    ebx
		call    EnterProtectedMode
		mov     eax,fs:[ebx]
		call    ExitProtectedMode
		pop     ebx
		popf
		pop		bp
		mov		edx, eax
		shr		edx, 16
		retf
;
_readxmsdword   endp
;------------------------------------------------------------------------------
;------------------------------------------------------------------------------
EnterProtectedMode  proc    near
        push    eax
		push    ebx
		call	SaveA20Status
		cli                                     ; disable ints for the duration
		call    EnableA20Line                   ; or do at program init time
		sub     eax,eax                         ;
		mov     ax,cs                           ; make linear address of cs:GDT
		shl     eax,4                           ; make into linear address
		sub     ebx,ebx                         ; clr high word
                mov     bx,offset GDT_Data      ; get Global Descriptor Table offset
		add     eax,ebx                         ; add into CS
                mov     [dword ptr cs:GDT_Pointer+2],eax ; put our GDT address into 6 byte struc
                sgdt    [fword ptr cs:SaveGDT]  ; save old GDT value
		lgdt    [fword ptr cs:GDT_Pointer]      ; load ours
                mov     eax,CR0                 ; get CR0 value
                or      eax,1                   ; enable protected mode bit
		mov     CR0,eax                         ; do it
		jmp     $+2                             ; clear instruction queue
		mov     ax,8                            ;
		mov     fs,ax                           ; load FS with descriptor to FC000000h
                                                ; where flash chip is mapped
        pop     ebx
        pop     eax
        ret
;
EnterProtectedMode     endp
;------------------------------------------------------------------------------
SaveGDT         dw  ?,?,?
GDT_Pointer     dw  10h,?,?						; size of GDT is 10h (null entry and 1 real entry)
GDT_Data        db  00,00,00,00,00,00,00,00
				db  0FFh, 0FFh, 00h, 00h, 00h, 092H, 0CFh, 00h
PCIBusDevFunc   dw  0							; got thru BIOS calls
;------------------------------------------------------------------------------
ExitProtectedMode   proc   near
        push    eax
        mov     eax, CR0                ; get Control Register
		and     eax,0FFFFfffeh          ; clr Protected Mode bit
		mov     CR0, eax                ; back into Control Register
		jmp     $+2                     ; clear instruction queue
		lgdt    [fword ptr cs:SaveGDT]  ; restore old GDT value
		call	RestoreA20Status
		pop     eax
		ret
ExitProtectedMode   endp
;------------------------------------------------------------------------------
WaitKeyControllerReady  proc    near
        push    ax
        push    ecx
		mov     ecx,100000h
CheckBusy:      
		in      al,64h
        test    al,2
        jz      NotBusy
        dec     ecx
        jnz     CheckBusy
NotBusy:
		pop     ecx
        pop     ax
        ret
WaitKeyControllerReady     endp
;------------------------------------------------------------------------------
DisableA20Line  proc  near
;
; BUGBUG: need to look up correct value to restore A20 line
;
        mov     al,0DDh                 ; disable A20 line
        call    WritePortP2
        ret
;
DisableA20Line  endp
;------------------------------------------------------------------------------
EnableA20Line   proc   near
;
        mov     al,0DFh                 ; enable A20 line
        call    WritePortP2
        ret
;
EnableA20Line   endp
;------------------------------------------------------------------------------
WritePortP2		proc     near
;
; AL has value to write to KeyBoard Controllers Output Port P2
; 0DFh will enable the A20 line
;
		push    ax                      ; save parameter to output
		call    WaitKeyControllerReady
		mov     al,0D1h                 ; cmd to send next byte to P2
		out     64h,al                  ; send cmd to keyboard controller
		call    WaitKeyControllerReady
; next byte written to 60h will go to the controllers output port P2
		pop     ax                      ; restore passed value
		out     60h,al
		call    WaitKeyControllerReady
		ret
WritePortP2		endp
;------------------------------------------------------------------------------
SaveA20Status	proc	near
		push	ax
		call	GetA20
		mov	word ptr cs:A20Status,ax
		pop	ax
		ret
SaveA20Status	endp
;------------------------------------------------------------------------------
RestoreA20Status	proc near
		push	ax
		cmp	word ptr cs:A20Status,1
		jne	DisableA20
		jmp	ExitRestoreA20Status
DisableA20:
		call	DisableA20Line
ExitRestoreA20Status:
		pop	ax
		ret
RestoreA20Status	endp
;------------------------------------------------------------------------------
;  Get A20 Status
;	Called with: nothing
;
;	returns:	ax = 0	A20 disabled
;				ax = 1	A20 enabled

GetA20	proc	near
		pushf
		push	di
		push	si
		push	ds
		push	es
		cli
		mov	di,10h
		mov	ax,0ffffh
		mov	es,ax
		xor	ax,ax
		mov	si,ax
		mov	ds,ax
		not	word ptr ds:[si]
		cld
		cmpsw
		je	GetA20_skip
		inc	ax
getA20_skip:
		not	word ptr ds:[si]
		pop	es
		pop	ds
		pop	si
		pop	di
		popf
		ret
GetA20	endp
;------------------------------------------------------------------------------
A20Status       dw ?

;----------------------------------------------------------------------
_io_outbyte proc far 
;unsigned short port, unsigned char data
	push	bp
	mov		bp,		sp
	mov		dx,		[bp+6]
	mov		al,		[bp+8]
	out		dx,		al
	pop		bp
	retf
_io_outbyte endp

;----------------------------------------------------------------------
_io_outword proc far 
;unsigned short port, unsigned short data
	push	bp
	mov		bp,		sp
	mov		dx,		[bp+6]
	mov		ax,		[bp+8]
	out		dx,		ax
	pop		bp
	retf
_io_outword endp

;----------------------------------------------------------------------
_io_outdword proc far 
;unsigned short port, unsigned long data
	push	bp
	mov		bp,		sp
	mov		dx,		[bp+6]
	mov		eax,	[bp+8]
	out		dx,		eax
	pop		bp
	retf
_io_outdword endp

;----------------------------------------------------------------------
_io_inbyte proc far 
;unsigned short port
	push	bp
	mov		bp,		sp
	mov		dx,		[bp+6]
	in		al,		dx
	pop		bp
	retf
_io_inbyte endp

;----------------------------------------------------------------------
_io_inword proc far 
;unsigned short port
	push	bp
	mov		bp,		sp
	mov		dx,		[bp+6]
	in		ax,		dx
	pop		bp
	retf
_io_inword endp

;----------------------------------------------------------------------
_io_indword proc far 
;unsigned short port
	push	bp
	mov		bp,		sp
	mov		dx,		[bp+6]
	in		eax,	dx
	mov		edx,	eax
	shr		edx,	16
	pop		bp
	retf
_io_indword endp

;----------------------------------------------------------------------
_pci_inword	proc far
;unsigned short busdevfnc,unsigned short offs
	push	bp
	mov		bp, sp
	push	di
	mov		ax, 0b109h
	mov		bx, [bp+6]
	mov		di, [bp+8]
	int		01ah
	mov		ax, cx
	pop		di
	pop		bp
	retf
_pci_inword	endp

;----------------------------------------------------------------------
_pci_outword	proc far
;unsigned short busdevfnc,unsigned short offs, unsigned short data
	push	bp
	mov		bp, sp
	push	di
	mov		ax, 0b10ch
	mov		bx, [bp+6]
	mov		di, [bp+8]
	mov		cx, [bp+10]
	int		01ah
	pop		di
	pop		bp
	retf
_pci_outword	endp

;----------------------------------------------------------------------
_pci_indword	proc far
;unsigned short busdevfnc,unsigned short offs
	push	bp
	mov	bp, sp
	push	di
	mov	ax, 0b10ah
	mov	bx, [bp+6]
	mov	di, [bp+8]
	int	01ah
	mov	ax, cx
	shr	ecx, 16
	mov	dx, cx
	pop	di
	pop	bp
	retf
_pci_indword	endp

;----------------------------------------------------------------------
_pci_outdword	proc far
;unsigned short busdevfnc,unsigned short offs, unsigned long data
	push	bp
	mov		bp, sp
	push	di
	mov		ax, 0b10dh
	mov		bx, [bp+6]
	mov		di, [bp+8]
	mov		ecx, [bp+10]
	int		01ah
	pop		di
	pop		bp
	retf
_pci_outdword	endp
;----------------------------------------------------------------------


_TEXT	ends
end

⌨️ 快捷键说明

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