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

📄 ri61fir.asm

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

MatchingConfigEntry:
        cmp     ax, cs:IT8661SerialConfigTable[bx]      ;AX = Ir base address
                                        ;BX = Index into config table
        je      ConfigTableEntryFound
        add     bx, 2                   ;Next config entry index
        cmp     bx, 8
        jle     MatchingConfigEntry
        xor     bl, bl                  ;Invalid config, force to zero

ConfigTableEntryFound:
        mov     al, bl                  ;AL = 2 * Entry number in DeviceConfigTable
        
GetCfgDone:
        shr     al, 1                   ;AL = Entry number in DeviceConfigTable
        pop     bx
        ret
GetHardwareConfig       endp


;---------------------------------------;
; GetHardwareIrqMask                    ;
;---------------------------------------;-------------------------------------;
; This routine determines the current IRQ configuration of the peripheral     ;
; device by reading directly from its registers, then converts it into a mask ;
; value.                                                                      ;
;                                                                             ;
; Input:  Nothing                                                             ;
;         Stack available                                                     ;
;                                                                             ;
; Output: BX = IRQ Mask                                                       ;
;                                                                             ;
; Destroys: BX, DX                                                            ;
;-----------------------------------------------------------------------------;
GetHardwareIrqMask      proc near private
        push    ax
        mov     bl, 04h                 ;Select Logical Device 4 (Ir)
        mov     ax, 0070h               ;Read register CR 70h
        call    IT8661FReadIO           ;AL = Register value
        xor     bx, bx
        bts     bx, ax                  ;BX = IRQ Mask
        pop     ax
        ret
GetHardwareIrqMask      endp


;---------------------------------------;
; SetHardwareConfig                     ;
;---------------------------------------;-------------------------------------;
; This routine sets the current configuration of the peripheral device by     ;
; writing directly to its registers.                                          ;
;                                                                             ;
;     Entry # in       Value Written  Value Written  Value Written  Config    ;
;  DeviceConfigTable     To CR30-0       To CR60        To CR61     Setting   ;
;  -----------------   ------------   ------------   ------------   --------  ;
;          0                 0             XX             XX        Disabled  ;
;          1                 1             03             F8        3F8       ;
;          2                 1             02             F8        2F8       ;
;          3                 1             03             E8        3E8       ;
;          4                 1             02             E8        2E8       ;
;                                                                             ;
; Input:  AL = Entry number in DeviceConfigTable                              ;
;         Stack available                                                     ;
;                                                                             ;
; Output: Nothing                                                             ;
;                                                                             ;
; Destroys: AX                                                                ;
;-----------------------------------------------------------------------------;
SetHardwareConfig       proc near private
        push    bx
        push    ax
        mov     bl, 04h                 ;Select Logical Device 4 (Ir)
        mov     ax, 0030h               ;Disable Ir
        call    IT8661FWriteIO
        mov     ax, 0000h               ;Clear Address
        call    IT8661FWrite6061
        mov     ax, 0070h               ;Clear IRQ
        call    IT8661FWriteIO
        pop     ax
        
        movzx   bx, al
        shl     bx, 1                   ;BX = Index into translation table
        jz      SetHwCfgDone            ;Br if Ir is to be disabled
        
        mov     ax, cs:IT8661SerialConfigTable[bx]      ;AX = value to write to register CR60/61
        mov     bl, 04h                 ;Select Logical Device 4 (Ir)
        call    IT8661FWrite6061        ;Write Ir address to register CR60/61

        mov     bl, 04h                 ;Select Logical Device 4 (Ir)
        mov     ax, 0130h               ;Enable Ir
        call    IT8661FWriteIO
        
SetHwCfgDone:
        pop     bx
        ret
        
SetHardwareConfig       endp


;---------------------------------------;
; SetHardwareIrq                        ;
;---------------------------------------;-------------------------------------;
; This routine sets the current IRQ of the peripheral device by writing       ;
; directly to its registers.                                                  ;
;                                                                             ;
; Input:  DS:SI = Pointer to the node                                         ;
;         Stack available                                                     ;
;                                                                             ;
; Output: Nothing                                                             ;
;                                                                             ;
; Destroys: AX, BX                                                            ;
;-----------------------------------------------------------------------------;
SetHardwareIrq          proc near private
        mov     ax, (DevNodeDataBlock ptr [si]).ComIrq.ides_irq_mask
        bsf     ax, ax
        mov     ah, al
        mov     bl, 04h                 ;Select Logical Device 4 (Ir)
        mov     al, 70h                 ;Select IRQ Register
        call    IT8661FWriteIO          ;Set H/W IRQ
        ret
SetHardwareIrq          endp


;---------------------------------------;
; SetHardwareMode                       ;
;---------------------------------------;-------------------------------------;
; This function sets the parallel port to mode specified in AL                ;
;                                                                             ;
; Input:  AL = Entry number in DeviceConfigTable                              ;
;         Stack available                                                     ;
;                                                                             ;
; Output: None                                                                ;
;                                                                             ;
; Destroys: Nothing                                                           ;
;-----------------------------------------------------------------------------;
SetHardwareMode         proc near private
        pusha
        mov     al, Q_IT8661F_IR_MODE
        call    get_cmos_item           ;AL = 0/1 for HPSIR/ASKIR
        shl     al, 4
        mov     ah, al
;;;     mov     al, Q_IT8661F_Ir_DUPLEX
;;;     call    get_cmos_item           ;AL = 0/1 for Full/Half duplex
;;;     shl     ah, 3
;;;     or      ah, al
        or      ah, 00001000b           ;Set Half Duplex
;;;     and     ah, 11011111b           ;Normal IRQ output 8661F
        mov     bl, 04h                 ;Select Logical Device 4 (Ir)
        mov     al, 0f0h                ;CR F0
        call    IT8661FWriteIO
        popa
        ret
SetHardwareMode         endp


;---------------------------------------;
; ConfigNumberToNodeData                ;
;---------------------------------------;-------------------------------------;
; This routine copies data from the given ConfigTableEntry into the proper    ;
; fields in the node's resource descriptors.                                  ;
;                                                                             ;
; Input:  AL = Entry number in DeviceConfigTable                              ;
;         BX = COM IRQ mask                                                   ;
;         DS:SI = Pointer to buffer containing node structure                 ;
;         Stack available                                                     ;
;                                                                             ;
; Output: Nothing                                                             ;
;                                                                             ;
; Destroys: Nothing                                                           ;
;-----------------------------------------------------------------------------;
ConfigNumberToNodeData  proc near private
        pusha

        mov     (DevNodeDataBlock ptr [si]).ComIrq.ides_irq_mask, bx

        mov     bl, size ConfigTableEntry
        mul     bl                      ;AX = <entry # (AL)> * <entry size>
        mov     bx, offset DeviceConfigTable
        add     bx, ax                  ;BX = proper ConfigTableEntry

; Copy fields from the given ConfigTableEntry into the device node
; before it is returned to the caller.
        mov     ax, (ConfigTableEntry ptr cs:[bx]).PortAddress
        mov     (DevNodeDataBlock ptr [si]).ComPort.pdes_min_base, ax
        mov     (DevNodeDataBlock ptr [si]).ComPort.pdes_max_base, ax
        mov     al, (ConfigTableEntry ptr cs:[bx]).PortSize
        mov     (DevNodeDataBlock ptr [si]).ComPort.pdes_length, al
;;;     mov     ax, (ConfigTableEntry ptr cs:[bx]).IrqMask
;;;     mov     (DevNodeDataBlock ptr [si]).ComIrq.ides_irq_mask, ax

        popa
        ret
ConfigNumberToNodeData  endp


;---------------------------------------;
; NodeDataToConfigNumber                ;
;---------------------------------------;-------------------------------------;
; This routine examines the node data and determines which ConfigTableEntry   ;
; corresponds to the current configuration of the node.                       ;
;                                                                             ;
; Input:  AL = Node number                                                    ;
;         DS:SI = Pointer to the node data                                    ;
;         Stack available                                                     ;
;                                                                             ;
; Output: CF = Clear if a ConfigTableEntry matching the node data was found   ;
;              Set if no ConfigTableEntry matches the node data (node data    ;
;              contains an invalid configuration)                             ;
;         AL = Entry number in DeviceConfigTable                              ;
;                                                                             ;
; Destroys: BX, CX, DX                                                        ;
;-----------------------------------------------------------------------------;
NodeDataToConfigNumber  proc near private
        mov     cx, (offset DeviceConfigTableEnd - offset DeviceConfigTable)/size ConfigTableEntry
        mov     bx, offset DeviceConfigTable
        mov     dx, (DevNodeDataBlock ptr [si]).ComPort.pdes_min_base
        xor     al, al                  ;AL will count entry number

ConfigNumberNext:
        cmp     (ConfigTableEntry ptr cs:[bx]).PortAddress, dx
        ;clc
        je      ConfigNumberFound       ;Br if port found in DeviceConfigTable

        add     bx, size ConfigTableEntry ;Point to next entry
        inc     al                      ;Keep track of which entry we are on
        loop    ConfigNumberNext        ;Try all entries in DeviceConfigTable
        stc                             ;Indicate error, invalid configuration

ConfigNumberFound:
        ret
NodeDataToConfigNumber  endp


;---------------------------------------;
; DummyReturn                           ;
;---------------------------------------;-------------------------------------;
; Input:  Nothing                                                             ;
;                                                                             ;
; Output: Nothing                                                             ;
;                                                                             ;
; Destroys: Nothing                                                           ;
;-----------------------------------------------------------------------------;
DummyReturn     proc near private
        ret
DummyReturn     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 + -