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

📄 ri61flp.asm

📁 <BIOS研发技术剖析>书的源代码,包括完整的BIOS汇编语言源程序.
💻 ASM
📖 第 1 页 / 共 3 页
字号:
        page    ,132                    
        title.  IT8661F Parallel Port Runtime Functions
;*****************************************************************;
;*****************************************************************;
;**                                                             **;
;**      (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/RI61FLP.ASM 1   98/06/04 12:00a $
;
; $Revision: 1 $
;
; $Date: 98/06/04 12:00a $
;*****************************************************************;
;*****************************************************************;
; Revision History
; ----------------
; $Log: /BIOS/PORTING/IO.112/IT8661F/RI61FLP.ASM $
; 
; 1     98/06/04 12:00a Chung
; Initial release.
; 
;*****************************************************************;
;---------------------------------------;
        include devnode.equ
        include io.equ
;---------------------------------------;
        public  IT8661FParallelPort
;---------------------------------------;
        extrn   IT8661FCommonRegisterInit:near
        extrn   IT8661FReadIO           :near
        extrn   IT8661FWriteIO          :near
        extrn   IT8661FRead6061         :near
        extrn   IT8661FWrite6061        :near

        extrn   get_cmos_item           :near
        extrn   set_cmos_item_checksum  :near

        extrn   get_lpt_irq_info        :near
        extrn   set_Lpt_irq             :near

        extrn   Q_IT8661F_LPT_PORT      :abs
        extrn   Q_IT8661F_LPT_IRQ       :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


ParallelConfigTable:
        dw      0000h,  0378h,  0278h,  03BCh


;---------------------------------------;
; Peripheral Table Structure            ;
;---------------------------------------;-------------------------------------;
; This table should be the only public label defined in this file.  It        ;
; contains pointers to the peripheral module's data and functions.            ;
;-----------------------------------------------------------------------------;
IT8661FParallelPort     label word

        dw 0                            ;Flags
        dw DevNodeData                  ;Pointer to device node data

        dw GetNodeStatic                ;Pointer to GetNodeStatic routine
        dw GetNodeDynamic               ;Pointer to GetNodeDynamic routine
        dw SetNodeStatic                ;Pointer to SetNodeStatic routine
        dw SetNodeDynamic               ;Pointer to SetNodeDynamic routine

        dw RegisterInit                 ;Pointer to RegisterInit routine
        dw GetAutoStatus                ;Pointer to GetAutoStatus routine
        dw IdeSetMode                   ;Pointer to IdeSetMode routine
        dw AdjustSetup                  ;Pointer to AdjustSetup routine
        dw IsrInstall                   ;Pointer to IsrInstall routine

        dw InitHotKey                   ;Pointer to InitHotKey routine
        dw InitBufferPrfOptimal         ;Pointer to InitBufferPrfOptimal routine
        dw InitBufferPrfFailSafe        ;Pointer to InitBufferPrfFailSafe routine

        dw DummyReturn                  ;Pointer to FloppySetDensity routine


;---------------------------------------;
; Device Node Data                      ;
;---------------------------------------;-------------------------------------;
; This block of data forms the device node that describes the configuration   ;
; options available to this peripheral device.                                ;
;-----------------------------------------------------------------------------;
DevNodeData     label byte
;         Size     Node Number  Device ID       Base Type       Sub Type        IF Type         Attributes
;         -----    -----------  --------------  --------------  --------------  --------------  ----------------------------------------------
sd_node < NODELEN, 0,           ID_LPT_PORT,    BT_COMMUN,      ST_PARALLEL,    IF_STD_PARALLEL,SDN_ATTR_DYNAMIC_CFG >
        port_descriptor  < PORT_DESC_TAG, PD_FLAG_DECODE_16, 378h, 378h, 8, 4 >  ;Port 378 - 37B
        irq_descriptor   < IRQ_DESC_TAG,   0000000010000000b >  ;IRQ 7
        END_OF_ALLOCATED_RESOURCES
        DEPENDENT_FUNCTION_START
          port_descriptor < PORT_DESC_TAG, PD_FLAG_DECODE_16, 378h, 378h, 8, 4 > ;Port 378 - 37B
          irq_descriptor  < IRQ_DESC_TAG,   0000000010100000b >  ;IRQ 7, 5
        DEPENDENT_FUNCTION_START
          port_descriptor < PORT_DESC_TAG, PD_FLAG_DECODE_16, 278h, 278h, 8, 4 > ;Port 278 - 27B
          irq_descriptor  < IRQ_DESC_TAG,   0000000010100000b >  ;IRQ 7, 5
        DEPENDENT_FUNCTION_START
          port_descriptor < PORT_DESC_TAG, PD_FLAG_DECODE_16, 3BCh, 3BCh, 4, 4 > ;Port 3BC - 3BF
          irq_descriptor  < IRQ_DESC_TAG,   0000000010100000b >  ;IRQ 7, 5
        END_OF_ALTERNATE_RESOURCES
        END_OF_COMPATIBLE_DEV_IDS
NODELEN = DevNodeDataEnd - DevNodeData
DevNodeDataEnd  label byte

; Format of Device Node Data
;-------------------------------------------------
DevNodeDataBlock        struc
        NodeData        sd_node <>
        LptPort         port_descriptor <>
        LptIrq          irq_descriptor <>
DevNodeDataBlock        ends

; Format of ConfigTableEntry
;-------------------------------------------------
ConfigTableEntry        struc
        PortAddress     dw ?
        PortSize        db ?
ConfigTableEntry        ends


;---------------------------------------;
; DeviceConfigTable                     ;
;---------------------------------------;-------------------------------------;
; This table contains one entry for each possible device configuration        ;
; setting.  This table is only used by routines in this file.  This table is  ;
; used in two ways:                                                           ;
;                                                                             ;
; 1. During GetNode calls the device's configuration is read from CMOS or     ;
;    hardware and the device node data must be updated with proper values.    ;
;    Because of this each entry should contain enough information to fill in  ;
;    any fields in the device node that depend on the hardware's current      ;
;    settings.                                                                ;
;                                                                             ;
; 2. During SetNode calls the caller passes in a device node structure and    ;
;    requests that the device's configuration be updated in CMOS or directly  ;
;    in hardware.  In this case the variable fields in the device node data   ;
;    will be compared with each entry in the table.  If a match is found      ;
;    the value to write to CMOS (or hardware register) should be able to be   ;
;    derived from the entry number in the table.  For this reason, it is      ;
;    advantageous to put the table in the same order as CMOS setup values.    ;
;-----------------------------------------------------------------------------;
DeviceConfigTable:

;                    PortAddress  PortSize  IrqMask
;                    -----------  --------  -------
  ConfigTableEntry <    0000h,       00h >  ;Disabled
  ConfigTableEntry <    0378h,       08h >  ;Port 378-37B
  ConfigTableEntry <    0278h,       08h >  ;Port 278-27B
  ConfigTableEntry <    03BCh,       04h >  ;Port 3BC-3BF 

DeviceConfigTableEnd:

        
;---------------------------------------;
; GetNodeStatic                         ;
;---------------------------------------;-------------------------------------;
; This function gets a device's configuration from CMOS.  The caller has      ;
; already copied the device node data into the caller's buffer (at DS:SI).    ;
; This function should read the node's configuration from CMOS 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                                                           ;
;-----------------------------------------------------------------------------;
GetNodeStatic   proc near private
        pusha
        
; Get LPT IRQ
        mov     al, Q_IT8661F_LPT_IRQ
        call    get_cmos_item           ;AL = 0/1 for IRQ5/IRQ7
        mov     bx, 0020h               ;Assume IRQ5
        jz      @F
        mov     bl, 80h                 ;IRQ7
        
@@:                                     ;BX = LPT IRQ mask
; 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

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

RtnStaticInfoToNode:                    ;AL = Entry # in DeviceConfigTable
                                        ;BX = LPT IRQ 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    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

RtnDynamicInfoToNode:                   ;AL = Entry # in DeviceConfigTable
                                        ;BX = LPT IRQ mask
        call    ConfigNumberToNodeData  ;Move proper values into node data
        popa
        clc
        ret
GetNodeDynamic  endp


;---------------------------------------;
; SetNodeStatic                         ;
;---------------------------------------;-------------------------------------;

⌨️ 快捷键说明

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