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

📄 ri61flpe.asm

📁 <BIOS研发技术剖析>书的源代码,包括完整的BIOS汇编语言源程序.
💻 ASM
📖 第 1 页 / 共 4 页
字号:
        
GetAddressFromCmos:
; Get parallel port address
        mov     al, Q_IT8661F_LPT_PORT
        call    get_cmos_item           ;AL = 0/1/2/3/4 for
                                        ;     AUTO/Disabled/378/278/3BC
        dec     al
        jns     GetNodeNotAuto          ;Br if not set to AUTO
        call    GetHardwareConfig       ;Read config directly from hardware
        call    GetHardwareIrqMask      ;BX = IRQ channel (mask)
        call    GetHardwareDMAMask      ;CL = LPT ECP DMA (mask)

GetNodeNotAuto:                         ;AL = Entry # in DeviceConfigTable
        or      al, al
        jnz     RtnStaticInfoToNode     ;BR if enabled
        xor     bx, bx                  ;Force No IRQ if LPT is disabled
        xor     cl, cl                  ;Force No DMA if LPT is disabled

RtnStaticInfoToNode:                    ;AL = Entry # in DeviceConfigTable
                                        ;BX = LPT IRQ mask
                                        ;CH = 0/1/2/3 for Normal/EPP/ECP/EPP+ECP
                                        ;CL = LPT DMA Mask
        call    ConfigNumberToNodeData  ;Move proper values into node data
        popa
        clc
        ret
GetNodeStatic   endp


;---------------------------------------;
; GetNodeDynamic                        ;
;---------------------------------------;-------------------------------------;
; This function gets a device's configuration directly from hardware.  The    ;
; caller has already copied the device node data into the caller's buffer     ;
; (at DS:SI).  This function should read hardware registers and update        ;
; the variable fields in the node's current configuration section.  This      ;
; function is called during POST and runtime.                                 ;
;                                                                             ;
; Input:  AL = Node number                                                    ;
;         DS:SI = Pointer to the node                                         ;
;         Stack available                                                     ;
;                                                                             ;
; Output: CF = Set if error getting node, clear if no error                   ;
;                                                                             ;
; Destroys: Nothing                                                           ;
;-----------------------------------------------------------------------------;
GetNodeDynamic  proc near private
        pusha
        call    GetHardwareMode         ;Read Mode from hardware(CH)
        call    GetHardwareDMAMask      ;CL = LPT ECP DMA (mask)
        call    GetHardwareIrqMask      ;BX = IRQ channel (mask)
        call    GetHardwareConfig       ;AL = Entry # in DeviceConfigTable
        or      al, al
        jnz     RtnDynamicInfoToNode    ;BR if enabled
        xor     bx, bx                  ;Force No IRQ if LPT is disabled
        xor     cl, cl                  ;Force No DMA if LPT is disabled

RtnDynamicInfoToNode:                   ;AL = Entry # in DeviceConfigTable
                                        ;BX = LPT IRQ mask
                                        ;CH = 0/1/2/3 for Normal/EPP/ECP/EPP+ECP
                                        ;CL = LPT ECP DMA Mask
        call    ConfigNumberToNodeData  ;Move proper values into node data
        popa
        clc
        ret
GetNodeDynamic  endp


;---------------------------------------;
; SetNodeStatic                         ;
;---------------------------------------;-------------------------------------;
; This function sets a device's configuration in CMOS.  This function is      ;
; called only during runtime.                                                 ;
;                                                                             ;
; Input:  AL = Node number                                                    ;
;         DS:SI = Pointer to the node                                         ;
;         Stack available                                                     ;
;                                                                             ;
; Output: CF = Set if error setting node, clear if no error                   ;
;                                                                             ;
; Destroys: Nothing                                                           ;
;-----------------------------------------------------------------------------;
SetNodeStatic   proc near private
        pusha

; Set parallel port address
        call    NodeDataToConfigNumber  ;AL = Entry # in DeviceConfigTable
        jc      SetNodeDone             ;Br if invalid config was requested

        mov     ah, al                  ;AH = 0/1/2/3 for Disabled/378/278/3BC
        inc     ah                      ;AH = 1/2/3/4 for Disabled/378/278/3BC
        mov     al, Q_IT8661F_LPT_PORT
        call    set_cmos_item_checksum
        
; Set parallel port IRQ
        xor     ah, ah                  ;Assume IRQ5
        test    (DevNodeDataBlock ptr [si]).LptIrq.ides_irq_mask, 0020h
        jnz     SetDevIrqToCmos
        inc     ah                      ;IRQ7
SetDevIrqToCmos:                        ;AH = 0/1 for IRQ5/IRQ7
        mov     al, Q_IT8661F_LPT_IRQ
        call    set_cmos_item_checksum
        
SetEcpDmaToCmos:
; Set parallel port ECP DMA
        movzx   bx, (DevNodeDataBlock ptr [si]).LptDMA.ddes_dma_mask
        bsf     ax, bx
        jz      @F
        mov     ah, al                  ;AH = 0/1/2/3 for DMA0/DMA1/DMA2/DMA3
        mov     al, Q_IT8661F_LPT_ECP_DMA
        call    set_cmos_item_checksum
@@:
        clc

SetNodeDone:
        popa
        ret
SetNodeStatic   endp


;---------------------------------------;
; SetNodeDynamic                        ;
;---------------------------------------;-------------------------------------;
; This function sets a device's configuration directly into hardware.  This   ;
; function is called during POST and runtime.                                 ;
;                                                                             ;
; Input:  AL = Node number                                                    ;
;         DS:SI = Pointer to the node                                         ;
;         Stack available                                                     ;
;                                                                             ;
; Output: CF = Set if error setting node, clear if no error                   ;
;                                                                             ;
; Destroys: Nothing                                                           ;
;-----------------------------------------------------------------------------;
SetNodeDynamic  proc near private
        pusha
        call    NodeDataToConfigNumber  ;AL = Entry # in DeviceConfigTable
        jc      SetNodeDone             ;Br if invalid config was requested
                                        ;AL = 0/1/2/3 for Disabled/378/278/3BC
        call    set_lpt_decode_select   ;configure the LPT I/O range in chipset
        call    SetHardwareConfig       ;Configure device to requested setting
        or      al, al
        jz      SetNodeDoneX

        mov     al, Q_IT8661F_LPT_MODE
        call    get_cmos_item           ;AL=0/1/2/3 for Normal/EPP/ECP/EPP+ECP
        call    IT8661FSetPPMode

        call    SetHardwareIrq          ;Configure device IRQ
        call    SetHardwareDma          ;Configure device DMA

SetNodeDoneX:
        clc
        
SetNodeDone:
        popa
        ret
SetNodeDynamic  endp


;---------------------------------------;
; RegisterInit                          ;
;---------------------------------------;-------------------------------------;
; This function initializes the peripheral chip's registers to power on       ;
; defaults and prepares the chip for configuration.  The device should be     ;
; disabled so it is not detected as an off board device.                      ;
;                                                                             ;
; Input:  Nothing                                                             ;
;         Stack available                                                     ;
;                                                                             ;
; Output: Nothing                                                             ;
;                                                                             ;
; Destroys: Nothing                                                           ;
;-----------------------------------------------------------------------------;
RegisterInit    proc near private
        call    IT8661FCommonRegisterInit
        ret
RegisterInit    endp


;---------------------------------------;
; GetAutoStatus                         ;
;---------------------------------------;-------------------------------------;
; This function reports if a peripheral chip device is set to auto or manual  ;
; in CMOS.                                                                    ;
;                                                                             ;
; Input:  AL = Node number                                                    ;
;         Stack available                                                     ;
;                                                                             ;
; Output: AL = 0 If device is set to AUTO mode in CMOS                        ;
;              1 If device is set to MANUAL mode in CMOS                      ;
;                                                                             ;
; Destroys: Nothing                                                           ;
;-----------------------------------------------------------------------------;
GetAutoStatus   proc near private
        mov     al, Q_IT8661F_LPT_PORT
        call    get_cmos_item           ;AL = 0/1/2/3/4 for
                                        ;     AUTO/Disabled/378/278/3BC
        jz      GetAutoDone             ;Br if set to auto
        mov     al, 1                   ;Return manual value
GetAutoDone:
        ret
GetAutoStatus   endp


;---------------------------------------;
; IdeSetMode                            ;
;---------------------------------------;-------------------------------------;
; This routine should set the mode/DMA timing of an IDE peripheral device.    ;
;                                                                             ;
; Input:  PIO mode / DMA timing                                               ;
;         Stack available                                                     ;
;                                                                             ;
; Output:                                                                     ;
;                                                                             ;
; Destroys: Nothing                                                           ;
;-----------------------------------------------------------------------------;
IdeSetMode      proc near private
        ret
IdeSetMode      endp


;---------------------------------------;
; AdjustSetup                           ;
;---------------------------------------;-------------------------------------;
; This routine programs any peripheral chip specific parameters which need to ;
; be programmed after SETUP e.g. Serial Port FIFO enable, Parallel Port       ;
; Direction, etc.  Please note that before setup, these parameters should be  ;
; set to disabled (normal) setting.  This routine is called from ADJUST_SETUP ;
; hook in PC1.ASM file.                                                       ;
;                                                                             ;
; Input:  Nothing                                                             ;
;         Stack available                                                     ;
;                                                                             ;
; Output: Nothing                                                             ;
;                                                                             ;
; Destroys: Nothing                                                           ;
;-----------------------------------------------------------------------------;
AdjustSetup     proc near private
        pusha
        and     cs:IT8661FParallelPortExt, not PTFLAG_INVISIBLE_NODE

⌨️ 快捷键说明

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