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

📄 ri61flpe.asm

📁 <BIOS研发技术剖析>书的源代码,包括完整的BIOS汇编语言源程序.
💻 ASM
📖 第 1 页 / 共 4 页
字号:
        call    GetHardwareConfig
        or      al, al
        jnz     @F                     ;BR if enabled
        or      cs:IT8661FParallelPortExt, PTFLAG_INVISIBLE_NODE
@@:
        call    GetHardwareMode         ;CH = 0/1/2/3 for Normal/EPP/ECP/EPP+ECP
        cmp     ch, 2                   ;check for ECP mode
        jb      @F                      ;BR if not in ECP
        mov     dword ptr cs:DevNodeData[3], ID_ECP_PORT
@@:
        popa
        ret
AdjustSetup     endp


;---------------------------------------;
; IsrInstall                            ;
;---------------------------------------;-------------------------------------;
; This routine may hook any interrupt vector.  This hook will be called only  ;
; when the BIOS is running from RAM, so any old vector address may be saved   ;
; in the code segment for chaining.                                           ;
;                                                                             ;
; Input:  Nothing                                                             ;
;         Stack available                                                     ;
;                                                                             ;
; Output: Nothing                                                             ;
;                                                                             ;
; Destroys: Nothing                                                           ;
;-----------------------------------------------------------------------------;
IsrInstall      proc near private
        push    ds
        push    es
        push    ax
        xor     ax, ax
        mov     ds, ax
        mov     es, ax
        lds     ax, ds:[17h * 4]
        mov     cs:OldInt17Vector, ax
        mov     cs:OldInt17Vector + 2, ds
        
        mov     ax, offset int_17_epp
        mov     es:[17h * 4], ax
        mov     ax, 0f000h
        mov     es:[17h * 4] + 2, ax
        pop     ax
        pop     es
        pop     ds
        ret
        
OldInt17Vector  dw      2 dup (0)

IsrInstall      endp


;---------------------------------------;
; InitHotKey                            ;
;---------------------------------------;-------------------------------------;
; This routine can be used to do any peripheral programming after hot key     ;
; setup is run and system does not need to reboot. this routine is called     ;
; from HOT_KEY_ADJUST_SETUP.                                                  ;
;                                                                             ;
; Input:  Pointer to _old_cmos_buffer and _common_cmos_buffer ?.............. ;
;         DS = Segment of _old_cmos_buffer and _common_cmos_buffer            ;
;         Stack available                                                     ;
;                                                                             ;
; Output: Nothing                                                             ;
;                                                                             ;
; Destroys: Nothing                                                           ;
;-----------------------------------------------------------------------------;
InitHotKey      proc near private
        ret
InitHotKey      endp


;---------------------------------------;
; InitBufferPrfOptimal                  ;
;---------------------------------------;-------------------------------------;
; This routine can be used to update _common_cmos_buffer in peripheral setup  ;
; screen when user loads optimal values.  This routine is called from         ;
; CMOS_SETUP.                                                                 ;
;                                                                             ;
; Input:  Pointer to _common_cmos_buffer ?.................                   ;
;         DS = ES = Segment of _common_cmos_buffer                            ;
;         Stack available                                                     ;
;                                                                             ;
; Output: Nothing                                                             ;
;                                                                             ;
; Destroys: Nothing                                                           ;
;-----------------------------------------------------------------------------;
InitBufferPrfOptimal    proc near private
        ret
InitBufferPrfOptimal    endp


;---------------------------------------;
; InitBufferPrfFailSafe                 ;
;---------------------------------------;-------------------------------------;
; This routine can be used to update _common_cmos_buffer in peripheral setup  ;
; screen when user loads fail safe values.  This routine is called from       ;
; CMOS_SETUP.                                                                 ;
;                                                                             ;
; Input:  Pointer to _common_cmos_buffer ?.................                   ;
;         DS = ES = Segment of _common_cmos_buffer                            ;
;         Stack available                                                     ;
;                                                                             ;
; Output: Nothing                                                             ;
;                                                                             ;
; Destroys: Nothing                                                           ;
;-----------------------------------------------------------------------------;
InitBufferPrfFailSafe   proc near private
        ret
InitBufferPrfFailSafe   endp


;---------------------------------------;
; GetHardwareConfig                     ;
;---------------------------------------;-------------------------------------;
; This routine determines the current configuration of the peripheral device  ;
; by reading directly from its registers.  The value returned is an entry     ;
; number in the DeviceConfigTable.                                            ;
;                                                                             ;
;   Value Read     Value Read       Entry # in       Config                   ;
;   From CR30    From CR60/CR61  DeviceConfigTable   Setting                  ;
;  ------------   ------------   -----------------   --------                 ;
;       0            XX / XX             0           Disabled                 ;
;       1            03 / 78             1           378                      ;
;       1            02 / 78             2           278                      ;
;       1            03 / BC             3           3BC                      ;
;                                                                             ;
; Input:  Nothing                                                             ;
;         Stack available                                                     ;
;                                                                             ;
; Output: AL = Entry number in DeviceConfigTable that represents the current  ;
;              configuration of the peripheral device.                        ;
;                                                                             ;
; Destroys: Nothing                                                           ;
;-----------------------------------------------------------------------------;
GetHardwareConfig       proc near private
        push    bx
        mov     al, 30h                 ;Read register CR30
        mov     bl, 03h                 ;Select Logical Device 3 (LPT)
        call    IT8661FReadIO           ;AL = Register value
        or      al, al
        jz      GetCfgDone              ;LPT disabled, done return 0
        
        mov     bl, 03h                 ;Select Logical Device 3 (LPT)
        call    IT8661FRead6061         ;AX = LPT base address
        xor     bx, bx

MatchingConfigEntry:
        cmp     ax, cs:ParallelConfigTable[bx]  ;AX = LPT base address
                                        ;BX = Index into config table
        je      ConfigTableEntryFound
        add     bx, 2                   ;Next config entry index
        cmp     bx, 6
        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
        call    get_lpt_irq_info        ;CF = 0/1 for IO/System IRQ routing
                                        ;BX = IRQ channel (mask)
                                        ;DX = IRQ available (not used here)
        jc      GetHardwareIrqMaskDone  ;BR if system chipset routes IRQ
        
        mov     al, 70h                 ;Read register CR 70h
        mov     bl, 03h                 ;Select Logical Device 3 (LPT)
        call    IT8661FReadIO           ;AL = Register value
        xor     bx, bx
        xor     ah, ah
        bts     bx, ax                  ;BX = IRQ Mask

GetHardwareIrqMaskDone:
        pop     ax
        ret
GetHardwareIrqMask      endp


;---------------------------------------;
; GetHardwareDMAMask                    ;
;---------------------------------------;-------------------------------------;
; This routine determines the current DMA configuration of the peripheral     ;
; device by reading directly from its registers, then converts it into a mask ;
; value.                                                                      ;
;                                                                             ;
; Input:  Nothing                                                             ;
;         Stack available                                                     ;
;                                                                             ;
; Output: CL = DMA Mask                                                       ;
;                                                                             ;
; Destroys: CL, DL                                                            ;
;-----------------------------------------------------------------------------;
GetHardwareDMAMask              proc near private
        push    ax
        push    bx
        call    get_lpt_ecp_dma_info    ;CF = 0/1 for IO/System DMA routing
                                        ;CL = LPT ECP DMA (mask)
                                        ;DL = LPT ECP DMA available (not used here)
        jc      GetHardwareDmaMaskDone  ;BR if system chipset routes DMA

        xor     cl, cl                  ;Clear DMA mask in not ECP mode
        mov     bl, 03h                 ;Select Logical Device 3 (LPT)
        mov     al, 0f0h                ;Read IR mode register
        call    IT8661FReadIO           ;AL = Register value
        test    al, 00000010b
        jz      GetHardwareDmaMaskDone  ;BR if not in ECP mode

        mov     bl, 03h                 ;Select Logical Device 3 (LPT)
        mov     al, 74h                 ;Read register CR 74h
        call    IT8661FReadIO           ;AL = Register value
        xor     ah, ah
        xor     cl, cl
        bts     cx, ax                  ;CL DMA Mask

GetHardwareDmaMaskDone:
        pop     bx
        pop     ax

⌨️ 快捷键说明

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