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

📄 ri61fx1.asm

📁 <BIOS研发技术剖析>书的源代码,包括完整的BIOS汇编语言源程序.
💻 ASM
📖 第 1 页 / 共 2 页
字号:


;---------------------------------------;
; IT8661FReadGlobal                     ;
;---------------------------------------;-------------------------------------;
; This routine reads a given IT8661F register.                                ;
;                                                                             ;
; Input:  AL = Register number to read                                        ;
;         Stack available                                                     ;
;                                                                             ;
; Output: AL = Byte read from register                                        ;
;                                                                             ;
; Destroys: Nothing                                                           ;
;-----------------------------------------------------------------------------;
IT8661FReadGlobal       proc near
        push    dx
        call    EnterConfig
        mov     dx, word ptr cs:IoIndexPort     ;DX = index port address
        out     dx, al
        jcxz    short $+2
        mov     dx, word ptr cs:IoDataPort      ;DX = data port address
        in      al, dx
        call    ExitConfig
        pop     dx
        ret
IT8661FReadGlobal       endp


;---------------------------------------;
; IT8661FWriteGlobal                    ;
;---------------------------------------;-------------------------------------;
; This routine writes to a given IT8661F register.                            ;
;                                                                             ;
; Input:  AL = Register number to write                                       ;
;         AH = Data to write                                                  ;
;         Stack available                                                     ;
;                                                                             ;
; Output: Nothing                                                             ;
;                                                                             ;
; Destroys: Nothing                                                           ;
;-----------------------------------------------------------------------------;
IT8661FWriteGlobal      proc near
        push    ax
        push    dx
        call    EnterConfig
        mov     dx, word ptr cs:IoIndexPort     ;DX = index port address
        out     dx, al                          ; Select I/O register
        jcxz    short $+2
        mov     dx, word ptr cs:IoDataPort      ;DX = data port address
        xchg    al, ah                          ; AH = Reg #, AL = Data to write
        out     dx, al
        jcxz    short $+2
        xchg    al, ah                          ; AH = Data, AL = Reg #
        call    ExitConfig
        pop     dx
        pop     ax      
        ret
IT8661FWriteGlobal      endp


;---------------------------------------;
; EnterConfig                           ;
;---------------------------------------;-------------------------------------;
; This routine puts the IT8661F into MB PnP Mode.                             ;
;                                                                             ;
; Input:  Nothing                                                             ;
;         Stack available                                                     ;
;                                                                             ;
; Output: None                                                                ;
;                                                                             ;
; Destroys: None                                                              ;
;-----------------------------------------------------------------------------;
EnterConfig     proc near private
        cli
        pusha

        xor     bx, bx
        cmp     word ptr cs:IoIndexPort, 03F0h
        je      @F
        add     bx, 4
        cmp     word ptr cs:IoIndexPort, 03BDh
        je      @F
        add     bx, 4                           ;Must be 0370h
@@:
        mov     dx, 279h
        mov     cx, 4

SelectIndexPort:
        mov     al, cs:IOKey[bx]
        out     dx, al
        inc     bx
        loop    SelectIndexPort
        
        mov     dx, word ptr cs:IoIndexPort
        xor     bx, bx
        mov     cx, offset ConfigKeyEnd - offset ConfigKey
        
SendConfigKey:
        mov     al, cs:ConfigKey[bx]
        out     dx, al
        inc     bx
        loop    SendConfigKey
        
        popa
        ret
EnterConfig     endp


;---------------------------------------;
; ExitConfig                            ;
;---------------------------------------;-------------------------------------;
; This routine takes the IT8661F out of MB PnP Mode.                          ;
;                                                                             ;
; Input:  Stack available                                                     ;
;                                                                             ;
; Output: Nothing                                                             ;
;                                                                             ;
; Destroys: Nothing                                                           ;
;-----------------------------------------------------------------------------;
ExitConfig      proc near private
        push    ax
        push    dx
        mov     dx, word ptr cs:IoIndexPort     ;DX = index port address
        mov     al, 2                           ;CR 02
        out     dx, al
        inc     dx
        jmp     short $+2
        out     dx, al                          ;Escape configuration mode
        pop     dx
        pop     ax
        ret
ExitConfig      endp


;---------------------------------------;
; IT8661FWrite6061                      ;
;---------------------------------------;-------------------------------------;
; This routine writes to IT8661F register 60 and 61.                          ;
;                                                                             ;
; Input:  AH = Data to write to register 60                                   ;
;         AL = Data to write to register 61                                   ;
;         BL = Logical Device Number                                          ;
;         Stack available                                                     ;
;                                                                             ;
; Output: Nothing                                                             ;
;                                                                             ;
; Destroys: Nothing                                                           ;
;-----------------------------------------------------------------------------;
IT8661FWrite6061                proc near
        push    cx
        mov     cx, ax
        mov     al, 60h                 ; Write to register CR60
        call    IT8661FWriteIO
        mov     ah, cl
        inc     al                      ; Write to register CR61
        call    IT8661FWriteIO
        mov     ax, cx
        pop     cx
        ret
IT8661FWrite6061                endp


;---------------------------------------;
; IT8661FRead6061                       ;
;---------------------------------------;-------------------------------------;
; This routine reads IT8661F register 60 and 61.                              ;
;                                                                             ;
; Input:  Nothing                                                             ;
;         BL = Logical Device Number                                          ;
;         Stack available                                                     ;
;                                                                             ;
; Output: AX = Data in register 60 and 61                                     ;
;                                                                             ;
; Destroys: Nothing                                                           ;
;-----------------------------------------------------------------------------;
IT8661FRead6061         proc near
        mov     al, 60h                 ; Read from register CR60
        call    IT8661FReadIO
        mov     ah, al
        mov     al, 61h                 ; Read from register CR61
        call    IT8661FReadIO
        ret
IT8661FRead6061         endp


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

⌨️ 快捷键说明

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