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

📄 ri61flpe.asm

📁 <BIOS研发技术剖析>书的源代码,包括完整的BIOS汇编语言源程序.
💻 ASM
📖 第 1 页 / 共 4 页
字号:
        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/RI61FLPE.ASM 1  98/06/04 12:00a $
;
; $Revision: 1 $
;
; $Date: 98/06/04 12:00a $
;*****************************************************************;
;*****************************************************************;
; Revision History
; ----------------
; $Log: /BIOS/PORTING/IO.112/IT8661F/RI61FLPE.ASM $
; 
; 1     98/06/04 12:00a Chung
; Initial release.
; 
;*****************************************************************;
;---------------------------------------;
        include devnode.equ
        include io.equ
;---------------------------------------;
        public  IT8661FParallelPortExt
;---------------------------------------;
        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   get_Lpt_ecp_dma_info    :near
        extrn   set_lpt_ecp_dma_channel :near

        extrn   Q_IT8661F_LPT_PORT      :abs
        extrn   Q_IT8661F_LPT_MODE      :abs
        extrn   Q_IT8661F_LPT_IRQ       :abs
        extrn   Q_IT8661F_LPT_ECP_DMA   :abs

        extrn   RtDummyRet              :near
        extrn   set_lpt_decode_select(RtDummyRet):near
        extrn   set_lpt_dma_select(RtDummyRet):near
;---------------------------------------;

;---------------------------------------;
;       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

LptDmaBitMask:
        db      00001011b               ;DMA 3,1,0


;---------------------------------------;
; 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.            ;
;-----------------------------------------------------------------------------;
IT8661FParallelPortExt  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, 0378h, 0378h, 04h, 08h >
        port_descriptor <PORT_DESC_TAG, PD_FLAG_DECODE_16, 0000h, 0000h, 00h, 00h >
        irq_descriptor  <IRQ_DESC_TAG,  0000000010000000b >  ;IRQ 7
        dma_descriptor  <DMA_DESC_TAG,  00000000b, DD_FLAG_WIDTH_8 + DD_FLAG_MASTER + DD_FLAG_COUNT_BYTE + DD_FLAG_SPEED_COMP>
        END_OF_ALLOCATED_RESOURCES
        DEPENDENT_FUNCTION_START
          port_descriptor <PORT_DESC_TAG, PD_FLAG_DECODE_16, 0378h, 0378h, 04h, 08h >
          port_descriptor <PORT_DESC_TAG, PD_FLAG_DECODE_16, 0000h, 0000h, 00h, 00h >
          irq_descriptor  <IRQ_DESC_TAG,  0000000010100000b >  ;IRQ 7,5
          dma_descriptor  <DMA_DESC_TAG,  00000000b, DD_FLAG_WIDTH_8 + DD_FLAG_MASTER + DD_FLAG_COUNT_BYTE + DD_FLAG_SPEED_COMP>
        DEPENDENT_FUNCTION_START
          port_descriptor < PORT_DESC_TAG, PD_FLAG_DECODE_16, 0278h, 0278h, 04h, 08h >
          port_descriptor < PORT_DESC_TAG, PD_FLAG_DECODE_16, 0000h, 0000h, 00h, 00h >
          irq_descriptor  < IRQ_DESC_TAG,  0000000010100000b >  ;IRQ 7,5
          dma_descriptor  < DMA_DESC_TAG,  00000000b, DD_FLAG_WIDTH_8 + DD_FLAG_MASTER + DD_FLAG_COUNT_BYTE + DD_FLAG_SPEED_COMP >
        DEPENDENT_FUNCTION_START
          port_descriptor < PORT_DESC_TAG, PD_FLAG_DECODE_16, 03bch, 03bch, 04h, 04h >
          port_descriptor < PORT_DESC_TAG, PD_FLAG_DECODE_16, 0000h, 0000h, 00h, 00h >
          irq_descriptor  < IRQ_DESC_TAG,  0000000010100000b >  ;IRQ 7,5
          dma_descriptor  < DMA_DESC_TAG,  00000000b, DD_FLAG_WIDTH_8 + DD_FLAG_MASTER + DD_FLAG_COUNT_BYTE + DD_FLAG_SPEED_COMP >
        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 <>
        EcpPort         port_descriptor <>
        LptIrq          irq_descriptor <>
        LptDMA          dma_descriptor <>
DevNodeDataBlock        ends

LptDependentNode        struc
        LptPort         port_descriptor <>
        EcpPort         port_descriptor <>
        LptIrq          irq_descriptor <>
        LptDma          dma_descriptor <>
LptDependentNode        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      GetEcpDmaFromCmos
        mov     bl, 80h                 ;IRQ7
        
GetEcpDmaFromCmos:                      ;BX = LPT IRQ mask
; Get LPT DMA
        xor     cl, cl                  ;CL = 0 if not in ECP mode
        mov     al, Q_IT8661F_LPT_MODE
        call    get_cmos_item           ;AL=0/1/2/3 for Normal/EPP/ECP/EPP+ECP
        mov     ch, al                  ;CH=0/1/2/3 for Normal/EPP/ECP/EPP+ECP
        cmp     ch, 2
        jb      GetAddressFromCmos      ;BR if not in ECP mode
        
        mov     al, Q_IT8661F_LPT_ECP_DMA
        call    get_cmos_item           ;AL = 0/1/2/3 for DMA0/DMA1/DMA2/DMA3
        xor     ah, ah
        xor     dx, dx
        bts     dx, ax
        mov     cl, dl                  ;CL = LPT ECP DMA mask

⌨️ 快捷键说明

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