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

📄 ri61flpe.asm

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


;---------------------------------------;
; GetHardwareMode                       ;
;---------------------------------------;-------------------------------------;
; This routine determines the current MODE configuration of the peripheral    ;
; device by reading directly from its registers, then converts it into a mask ;
; value.                                                                      ;
;                                                                             ;
; Input:  Nothing                                                             ;
;         Stack available                                                     ;
;                                                                             ;
; Output: CH = LPT Mode                                                       ;
;                                                                             ;
; Destroys: CH                                                                ;
;-----------------------------------------------------------------------------;
GetHardwareMode         proc near private
        push    ax
        push    bx
        mov     bl, 03h                 ;Select Logical Device 3 (LPT)
        mov     al, 0f0h                ;Read LPT mode register
        call    IT8661FReadIO           ;AL = Register value
        and     al, 00000011b
        mov     ch, al
        pop     bx
        pop     ax
        ret
GetHardwareMode         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             78        378       ;
;          2                 1             02             78        278       ;
;          3                 1             03             BC        3BC       ;
;                                                                             ;
; Input:  AL = Entry number in DeviceConfigTable                              ;
;         Stack available                                                     ;
;                                                                             ;
; Output: Nothing                                                             ;
;                                                                             ;
; Destroys: AX, BX                                                            ;
;-----------------------------------------------------------------------------;
SetHardwareConfig       proc near private
        push    ax
        mov     bl, 03h                 ;Select Logical Device 3 (LPT)
        mov     ax, 0030h               ;Disable LPT
        call    IT8661FWriteIO
        mov     ax, 0000h               ;Clear Address
        call    IT8661FWrite6061
        mov     ax, 0070h               ;Clear IRQ
        call    IT8661FWriteIO
        mov     ax, 0074h               ;Clear DMA
        call    IT8661FWriteIO
        pop     ax
        
        movzx   bx, al
        shl     bx, 1                   ;BX = Index into translation table
        jz      SetHwCfgDone            ;Br if LPT is to be disabled
        
        mov     ax, cs:ParallelConfigTable[bx]  ;AX = value to write to register CR60/61
        mov     bl, 03h                 ;Select Logical Device 3 (LPT)
        call    IT8661FWrite6061        ;Write LPT address to register CR60/61
        
        mov     ax, 0130h               ;Enable LPT
        call    IT8661FWriteIO
        
SetHwCfgDone:
        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]).LptIrq.ides_irq_mask
        bsf     bx, ax
        jnz     @F
        xor     bl, bl                  ;No IRQ
@@:
        mov     al, bl                  ;AL = LPT IRQ channel to route
        call    get_lpt_irq_info        ;CF = 0/1 for IO/System IRQ routing
        jnc     IOsetsIRQ               ;BR if IRQ is routed by I/O chipset
        call    set_Lpt_irq             ;IRQ set by system chipset
        ret

IOsetsIRQ:
        mov     ah, bl
        mov     bl, 03h                 ;Select Logical Device 3 (LPT)
        mov     al, 70h                 ;Select IRQ Register
        call    IT8661FWriteIO          ;Set H/W IRQ
        ret
SetHardwareIrq          endp


;---------------------------------------;
; SetHardwareDMA                        ;
;---------------------------------------;-------------------------------------;
; This routine sets the current DMA of the peripheral device by writing       ;
; directly to its registers.                                                  ;
;                                                                             ;
; Input:  DS:SI = Pointer to the node                                         ;
;         Stack available                                                     ;
;                                                                             ;
; Output: Nothing                                                             ;
;                                                                             ;
; Destroys: AX, BX                                                            ;
;-----------------------------------------------------------------------------;
SetHardwareDMA          proc near private
        movzx   bx, (DevNodeDataBlock ptr [si]).LptDMA.ddes_dma_mask
        bsf     ax, bx
        jnz     @F                      ;BR if no DMA mask set
        mov     al, 4                   ;No DMA mask, set AL = 4 for No DMA
@@:                                     ;AL = 0/1/2/3/4 for DMA0/DMA1/DMA2/DMA3/None
        call    set_lpt_dma_select      ;configure the LPT DMA range in chipset
        call    get_lpt_ecp_dma_info    ;CF = 0/1 for IO/Sytem DMA Routing
        jnc     SetIT8661FDma           ;BR if DMA is routed by I/O Chipset
        call    set_lpt_ecp_dma_channel ;DMA routing by system chipset
        ret

SetIT8661FDma:
        mov     ah, al
        mov     bl, 03h                 ;Select Logical Device 3 (LPT)
        mov     al, 074h                ;Select DMA Register
        call    IT8661FWriteIO          ;Set H/W DMA
        ret
SetHardwareDMA          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 = LPT IRQ mask                                                   ;
;         CH = LPT mode                                                       ;
;         CL = DMA mask                                                       ;
;                                                                             ;
;         DS:SI = Pointer to buffer containing node structure                 ;
;         Stack available                                                     ;
;                                                                             ;
; Output: Nothing                                                             ;
;                                                                             ;
; Destroys: Nothing                                                           ;
;-----------------------------------------------------------------------------;
ECP_FLAGS       equ     DD_FLAG_WIDTH_8 + DD_FLAG_COUNT_BYTE + DD_FLAG_SPEED_COMP

ConfigNumberToNodeData  proc near private
        pusha

; Copy IRQ mask into the device node
        mov     (DevNodeDataBlock ptr [si]).LptIrq.ides_irq_mask, bx
; Copy DMA mask into the device node
        mov     (DevNodeDataBlock ptr [si]).LptDMA.ddes_dma_mask, cl

; Point DI to first dependent node
        mov     di, si
        add     di, (size DevNodeDataBlock) + 3 ;Point to start of dependent nodes

        cmp     ch, 02h
        jb      NotECPMode
        pusha
        mov     cx, 3
FixerECPLoop:
; Set ECP address
        mov     ax, (LptDependentNode ptr [di]).LptPort.pdes_min_base
        add     ax, 400h                ;AX = ECP address
        mov     (LptDependentNode ptr [di]).EcpPort.pdes_min_base, ax
        mov     (LptDependentNode ptr [di]).EcpPort.pdes_max_base, ax
        mov     (LptDependentNode ptr [di]).EcpPort.pdes_alignment, 4
        mov     (LptDependentNode ptr [di]).EcpPort.pdes_length, 3
; Set ECP DMA Mask
        mov     al, byte ptr cs:LptDmaBitMask
        mov     (LptDependentNode ptr [di]).LptDMA.ddes_dma_mask, al
        add     di, (size LptDependentNode) + 1
        loop    FixerECPLoop
        popa
NotECPMode:

        mov     dl, al                  ;DL = entry number
        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     al, (ConfigTableEntry ptr cs:[bx]).PortSize
        mov     (DevNodeDataBlock ptr [si]).LptPort.pdes_length, al
        mov     ax, (ConfigTableEntry ptr cs:[bx]).PortAddress
        mov     (DevNodeDataBlock ptr [si]).LptPort.pdes_min_base, ax
        mov     (DevNodeDataBlock ptr [si]).LptPort.pdes_max_base, ax
        or      ax, ax
        jz      NodeUpdateDone          ;Br if disabled

        add     ax, 400h                ;AX = ECP address

; Update node according to port mode
        dec     ch                      ;CH=-1/0/1/2 for Normal/EPP/ECP/EPP+ECP
        js      ModeSPP                 ;Br if port set to Normal
        jz      Adjust_Node

; Set ECP mode node information
        mov     (DevNodeDataBlock ptr [si]).EcpPort.pdes_min_base, ax
        mov     (DevNodeDataBlock ptr [si]).EcpPort.pdes_max_base, ax
        mov     (DevNodeDataBlock ptr [si]).EcpPort.pdes_alignment, 4
        mov     (DevNodeDataBlock ptr [si]).EcpPort.pdes_length, 3
        mov     (DevNodeDataBlock ptr [si]).LptDMA.ddes_dma_flags, ECP_FLAGS
        mov     (DevNodeDataBlock ptr [si]).NodeData.sdn_if_type, IF_ECP
;;;     jmp     short Adjust_node

ModeSPP:
;谀哪哪哪哪哪目
;矹ames 031996媚哪哪哪哪哪哪哪哪哪哪哪哪;
;滥哪哪哪哪哪馁
; Please clear DMA resource to all dependent function nodes if not ECP
; And set all dependent functions' length to 4/8 for non-EPP/EPP
;哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪

⌨️ 快捷键说明

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