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

📄 9346c.asm

📁 93C46 EEPROM sourcecode for RTL8019 Plug-And-Play Card
💻 ASM
📖 第 1 页 / 共 2 页
字号:
        out     dx,al
        Slow    SK

        mov     al,ChipSelectLo
        out     dx,al

        Slow    SK

        mov     al,ChipSelectHi
        out     dx,al

        Slow    SK

;       mov     cx,0
WaitForReady:
;       mov     al,SerialClkLo
;       out     dx,al
;       Slow    SK

        in      al,dx
        test    al,01
        jne     WriteOK

;       mov     al,SerialClkHi
;       out     dx,al
;       slow    SK
;       loop    WaitForReady
        jmp     WaitForReady

WriteOK:

        mov     al,ChipSelectLo
        out     dx,al

        Slow    SK

        mov     bl,EwdsCmd
        call    WrCmd

        Slow    SK

        mov     al,SerialClkLo
        out     dx,al
        Slow    SK

        mov     al,ChipSelectLo
        out     dx,al

        Slow    SK


        pop     ax
        pop     bx
        pop     cx
        ret
W_9346  ENDP


WrCmd1  PROC
        clc
        WrBit1

        stc
        WrBit1

        mov     cx,8
WrCmd1_lp:

        shl     bl,1

        WrBit1
        loop    WrCmd1_lp

        ret
WrCmd1  ENDP

WrCmd   PROC
        clc
        WrBit

        stc
        WrBit

        mov     cx,8
WrCmd_lp:

        shl     bl,1

        WrBit
        loop    WrCmd_lp

        ret
WrCmd   ENDP

ResetCard       PROC    C
        push    si                      ; Save SI is enough
        mov     dx,PnPAddress
        mov     al,ConfigCtrl
        out     dx,al
        mov     dx,PnPWrite
        mov     al,06h
        out     dx,al                   ; Force back to Wait & CSN=0

        mov     dx,PnPAddress
        xor     al,al
        out     dx,al
        out     dx,al                   ; 2 successive 0 for reset Key
        mov     cx,32
        cld
        mov     si,OFFSET RTInitKey
SendKey:
        lodsb
        out     dx,al
        loop    SendKey

        mov     dx,PnPAddress           ; Reset all CSN=0
        mov     al,ConfigCtrl
        out     dx,al
        mov     dx,PnPWrite
        mov     al,04h
        out     dx,al

        mov     dx,PnPAddress
        mov     al,Wake                 ; Wake 0
        out     dx,al
        mov     dx,PnPWrite
        xor     al,al
        out     dx,al

        mov     dx,PnPAddress
        mov     al,SetRD
        out     dx,al
        mov     dx,PnPWrite
        mov     al,84h                  ; Set I/O Read Port to 213h
        out     dx,al

        mov     dx,PnPAddress
        mov     al,Isolation
        out     dx,al
        Slow    1000                    ; Wait 1ms
        mov     cx,72                   ; 72 pairs of Read
        mov     dx,213h
Isolation_lp:
        in      al,dx
        in      al,dx
        Slow    250                     ; Wait 250 us
        loop    Isolation_lp

        mov     dx,PnPAddress
        mov     al,CSN
        out     dx,al
        mov     dx,PnPWrite
        mov     al,1                    ; Set our card to CSN==1
        out     dx,al
                                        ; Now our card is in Config mode
        mov     dx,PnPAddress           ; Set Card I/O address to 300h
        mov     al,SetIO_1
        out     dx,al
        mov     dx,PnPWrite
        mov     al,3h
        out     dx,al
        mov     dx,PnPAddress
        mov     al,SetIO_0
        out     dx,al
        mov     dx,PnPWrite
        mov     al,00h
        out     dx,al

        mov     dx,PnPAddress           ; Set Card IRQ to IRQ 3
        mov     al,IRQLevel
        out     dx,al
        mov     dx,PnPWrite
        mov     al,3
        out     dx,al

        mov     dx,PnPAddress           ; Disable I/O Range Check
        mov     al,IOCheck              ; before we activate the Card
        out     dx,al
        mov     dx,PnPWrite
        xor     al,al
        out     dx,al

        mov     dx,PnPAddress           ; Activate as this new configuration
        mov     al,Activate
        out     dx,al
        mov     dx,PnPWrite
        mov     al,1
        out     dx,al

        mov     dx,PnPAddress           ; Set back to WAIT FOR KEY
        mov     al,ConfigCtrl
        out     dx,al
        mov     dx,PnPWrite
        mov     al,02
        out     dx,al

        mov     dx,300h                 ; Check Chip's ID
        mov     al,21h
        out     dx,al
        add     dx,0ah
        in      al,dx
        cmp     al,'P'
        jne     ResetBad
        inc     dx
        in      al,dx
        cmp     al,'p'
        jne     ResetBad
        mov     al,0
        pop     si
        ret
ResetBad:
        mov     al,0FFh
        pop     si
        ret
ResetCard       ENDP

;----------------------------------------------------------------------
;ResetCard      PROC   C    WDFlag:WORD
;       jmp     ResetCardStart
;ResetCardTmp   db      ?
;WDTmp          db      ?
;Tmp_IO         dw      ?
;ResetCardStart:
;
;       push    bp
;       mov     bp, 300h
;       mov     ResetCardTmp,0
;ResetRED_lp:                               ; begin to search RED Board
;
;       lea     dx,[bp+Command]
;       mov     al,21h
;       out     dx,al
;
;       lea     dx,[bp+RED_NE_ID0]          ; if RED board exist, RED board
;       in      al,dx                       ;  ID will be found at base empty
;       ;cmp    al,'P'                      ;  block.
;       cmp     al,'r'
;       jne     ResetREDNext                ; Test ID for both Novell
;       lea     dx,[bp+RED_NE_ID1]          ;   and Western Digital
;       in      al,dx                       ;
;       ;cmp    al,'p'                      ;
;       cmp     al,'l'
;       jne     ResetREDNext                ;
;;      pop     bp
;       jmp     ResetDone                   ;
;ResetREDNext:
;       pop     bp
;       add     bp,20h                      ;   test if there is a RED board
;       inc     cx
;       cmp     cx,8
;       je      ResetNoRED
;       push    bp
;       jmp     ResetRED_lp                  ;
;ResetNoRED:
;
;       mov     al,0ffh
;       ret
;ResetDone:
;       pop     bp
;
;       mov     al,0
;       ret
;ResetCard      ENDP


AutoLoad    PROC    C	IOBASE:WORD, ROMADDRESS:WORD
	jmp	AutoLoadStart
BROMTmp dw  ?
AutoLoadStart:
        push    bp

;       push    si                      ; Save SI
;       mov     dx,PnPAddress
;       xor     al,al
;       out     dx,al
;       out     dx,al                   ; 2 successive 0 for reset Key
;       mov     cx,32
;       cld
;       mov     si,OFFSET RTInitKey
;AutoLoad_SendKey:
;       lodsb
;       out     dx,al
;       loop    AutoLoad_SendKey
;       pop     si                      ; Restore SI
;
;       mov     dx,PnPAddress
;       mov     al,Wake                 ; Wake 1
;       out     dx,al
;       mov     dx,PnPWrite
;       mov     al,1
;       out     dx,al
;
;       mov     dx,PnPAddress
;       mov     al,40h                  ; PROM address [20:16]
;       out     dx,al
;       mov     dx,PnPWrite
;       mov     al,0C0h                 ; Force a write to fix a bug in 8019
;       out     dx,al
;
;       mov     dx,PnPAddress           ; Set back to WAIT FOR KEY
;       mov     al,ConfigCtrl
;       out     dx,al
;       mov     dx,PnPWrite
;       mov     al,02
;	out	dx,al

	mov	ax,ROMADDRESS
	mov	BROMTmp,ax

        mov     bp,IOBASE
        lea     dx,[bp+Command]
        mov     al,0E1h
        out     dx,al

        lea     dx,[bp+EepromCR]
        in      al,dx
        and     al,3fh
        or      al,40h
        out     dx,al

        mov     cx,2
        call    Second

        lea     dx,[bp+EepromCR]
        in      al,dx
        and     al,3fh
        out     dx,al

        lea     dx,[bp+Command]
        mov     al,21h
        out     dx,al

        push    si                      ; Save SI
        mov     dx,PnPAddress
        xor     al,al
        out     dx,al
        out     dx,al                   ; 2 successive 0 for reset Key
        mov     cx,32
        cld
        mov     si,OFFSET RTInitKey
AutoLoad_SendKey:
        lodsb
        out     dx,al
        loop    AutoLoad_SendKey
	pop	si		      ; Restore SI

	pop	bp

        mov     dx,PnPAddress
        mov     al,Wake                 ; Wake 1
        out     dx,al
        mov     dx,PnPWrite
        mov     al,1
	out	dx,al

	mov	bx, BROMTmp
	mov	cl, 4
	shr	bx, cl

        mov     dx,PnPAddress
        mov     al,40h                  ; PROM address [20:16]
        out     dx,al
        mov     dx,PnPWrite
	mov	al,bh		       ; Force a write to fix a bug in 8019
        out     dx,al

        mov     dx,PnPAddress
	mov	al,41h			; PROM address [15:0]
        out     dx,al
        mov     dx,PnPWrite
	mov	al,bl			 ; Force a write to fix a bug in 8019
        out     dx,al

        mov     dx,PnPaddress          ;set activate
        mov     al,Activate
        out     dx,al
        mov     dx,PnPWrite
        mov     al,1
        out     dx,al

        mov     dx,PnPAddress           ; Set back to WAIT FOR KEY
        mov     al,ConfigCtrl
        out     dx,al
        mov     dx,PnPWrite
        mov     al,02
        out     dx,al

	ret

AutoLoad    ENDP
; Jasper 7/12/95 {
ResetCSN	PROC	C
        push    si                      ; Save SI is enough
        mov     dx,PnPAddress
        mov     al,ConfigCtrl
        out     dx,al
        mov     dx,PnPWrite
        mov     al,06h
        out     dx,al                   ; Force back to Wait & CSN=0

        mov     dx,PnPAddress
        xor     al,al
        out     dx,al
        out     dx,al                   ; 2 successive 0 for reset Key
        mov     cx,32
        cld
        mov     si,OFFSET RTInitKey
SendKey1:
        lodsb
        out     dx,al
	loop	SendKey1

        mov     dx,PnPAddress           ; Reset all CSN=0
        mov     al,ConfigCtrl
        out     dx,al
        mov     dx,PnPWrite
        mov     al,04h
	out	dx,al

	pop	si

	ret
ResetCSN    ENDP
; } Jasper 7/12/95

;  Jasper 4/12/96 {
Get8019Version PROC	C  IOBASE:WORD

	push	bp

	mov	bp,IOBASE

        lea     dx,[bp+Command]
        mov     al,0E1h
        out     dx,al

        lea     dx,[bp+EepromCR]
        mov     al,ProgramMode
        out     dx,al

	lea	dx,[bp+Boundry]
	in	al, dx
	test	al, 0c0h
	jnz	Is8019

	or	al, 0c0h
	out	dx, al
	Slow	2
	in	al, dx
	test	al, 0c0h
	jz	Is8019A

Is8019AS:
	and	al, 3fh
	out	dx, al

	mov	ax, 02
	jmp	ExitGet8019Version

Is8019A:

	mov	ax, 01
	jmp	ExitGet8019Version

Is8019:

	mov	ax, 0

ExitGet8019Version:
	push	ax

	lea	dx,[bp+EepromCR]
        mov     al,NormalMode
        out     dx,al

	lea	dx,[bp+Command]
	mov	al,021h
        out     dx,al

	pop	ax
        pop bp
        ret
Get8019Version ENDP
; } Jasper 4/12/96

        END

⌨️ 快捷键说明

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