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

📄 ri61fx1.asm

📁 <BIOS研发技术剖析>书的源代码,包括完整的BIOS汇编语言源程序.
💻 ASM
📖 第 1 页 / 共 2 页
字号:
        page    ,132
        title.  ITE8661F Common Routines for COMA/COMB/LPT/Floppy/Ir
;*****************************************************************;
;*****************************************************************;
;**                                                             **;
;**      (C)Copyright 1985-1998, American Megatrends, Inc.      **;
;**                                                             **;
;**                     All Rights Reserved.                    **;
;**                                                             **;
;**           6145-F Northbelt Pkwy, Norcross, GA 30071         **;
;**                                                             **;
;**                     Phone (770)-246-8600                    **;
;**                                                             **;
;*****************************************************************;
;*****************************************************************;
;*****************************************************************;
; $Header: /BIOS/PORTING/IO.112/IT8661F/RI61FX1.ASM 1   98/06/04 12:00a $
;
; $Revision: 1 $
;
; $Date: 98/06/04 12:00a $
;*****************************************************************;
;*****************************************************************;
; Revision History
; ----------------
; $Log: /BIOS/PORTING/IO.112/IT8661F/RI61FX1.ASM $
; 
; 1     98/06/04 12:00a Chung
; Initial release.
; 
;*****************************************************************;
;---------------------------------------;
        include devnode.equ
        include io.equ
;---------------------------------------;
        extrn   get_cmos_item:near
;---------------------------------------;
        public  IT8661FCommonRegisterInit
        public  IT8661FReadIO
        public  IT8661FWriteIO
        public  IT8661FRead6061
        public  IT8661FWrite6061
;---------------------------------------;
        extrn   IoIndexPort             :near
        extrn   IoDataPort              :near
        extrn   RegisterInitTableStart  :near
        extrn   REGINITCOUNT            :abs
;---------------------------------------;

;---------------------------------------;
;       C O D E     S E G M E N T       ;
;---------------------------------------;
.386
cgroup  group   _text
_text segment word public USE16 'CODE'
         assume cs:CGROUP


IOKey           label   byte
        db      86h, 61h, 55h,  55h     ;For 3F0
        db      86h, 61h, 55h,  0AAh    ;For 3BD
        db      86h, 61h, 0AAh, 55h     ;For 370

ConfigKey       label   byte
        db      06ah, 0b5h, 0dah, 0edh, 0f6h
        db      0fbh, 07dh, 0beh, 0dfh, 06fh
        db      037h, 01bh, 00dh, 086h, 0c3h
        db      061h, 0b0h, 058h, 02ch, 016h
        db      08bh, 045h, 0a2h, 0d1h, 0e8h
        db      074h, 03ah, 09dh, 0ceh, 0e7h
        db      073h, 039h
ConfigKeyEnd:


;---------------------------------------;
; IT8661FCommonRegisterInit             ;
;---------------------------------------;-------------------------------------;
; This function initializes the peripheral chip's registers to power on       ;
; defaults and prepares the chip for configuration.                           ;
;                                                                             ;
; Input:  Nothing                                                             ;
;         Stack available                                                     ;
;                                                                             ;
; Output: Nothing                                                             ;
;                                                                             ;
; Destroys: Nothing                                                           ;
;-----------------------------------------------------------------------------;
IT8661FCommonRegisterInit       proc near
        pusha
        pushf                           ; Save CLI/STI state
        cli

        mov     dx, 3F2h                ; Disable int and dma bits in primary port
        xor     al, al
        out     dx, al

        mov     cx, REGINITCOUNT
        mov     si, offset cgroup:RegisterInitTableStart

reg_init_next:
        db      2eh                     ; CS:
        lodsb           
        mov     bl, al                  ; BL = Logical Device Number
        db      2eh                     ; CS:
        lodsw                           ; AH = Data, AL = Register Number
        call    IT8661FWriteIO
        loop    reg_init_next

        popf                            ; Restore CLI/STI state
        popa
        ret
IT8661FCommonRegisterInit       endp


;---------------------------------------;
; IT8661FReadIO                         ;
;---------------------------------------;-------------------------------------;
; This routine reads a given IT8661F register.                                ;
;                                                                             ;
; Input:  AL = Register number to read                                        ;
;         BL = Logical Device Number                                          ;
;         Stack available                                                     ;
;                                                                             ;
; Output: AL = Byte read from register                                        ;
;                                                                             ;
; Destroys: Nothing                                                           ;
;-----------------------------------------------------------------------------;
IT8661FReadIO   proc near
        push    dx
        call    EnterConfig
        call    SelectLogicalDevice
        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
        in      al, dx                          ;AL = data
        jcxz    short $+2
        call    ExitConfig
        pop     dx
        ret
IT8661FReadIO   endp


;---------------------------------------;
; IT8661FWriteIO                        ;
;---------------------------------------;-------------------------------------;
; This routine writes to a given IT8661F register.                            ;
;                                                                             ;
; Input:  AL = Register number to write                                       ;
;         AH = Data to write                                                  ;
;         BL = Logical Device Number                                          ;
;         Stack available                                                     ;
;                                                                             ;
; Output: Nothing                                                             ;
;                                                                             ;
; Destroys: Nothing                                                           ;
;-----------------------------------------------------------------------------;
IT8661FWriteIO  proc near
        push    dx
        call    EnterConfig
        call    SelectLogicalDevice
        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
        ret
IT8661FWriteIO  endp


;---------------------------------------;
; SelectLogicalDevice                   ;
;---------------------------------------;-------------------------------------;
; This routine selects the logical device of the IT8661F.                     ;
;                                                                             ;
; Input:  BL = Logical Device Number                                          ;
;         Stack available                                                     ;
;                                                                             ;
; Output: None                                                                ;
;                                                                             ;
; Destroys: None                                                              ;
;-----------------------------------------------------------------------------;
SelectLogicalDevice     proc near private
        push    ax
        push    dx
        mov     dx, word ptr cs:IoIndexPort     ;DX = index port address
        mov     al, 07h                         ;Logical device register
        out     dx, al
        jcxz    short $+2
        mov     dx, word ptr cs:IoDataPort      ;DX = data port address
        mov     al, bl
        out     dx, al
        pop     dx
        pop     ax
        ret
SelectLogicalDevice     endp

⌨️ 快捷键说明

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