📄 ri61flp.asm
字号:
; ;
; 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, 8
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
and al, 0fh ;Keep LPT IRQ info only
xor bx, bx
xor ah, ah
bts bx, ax ;BX = IRQ Mask
GetHardwareIrqMaskDone:
pop ax
ret
GetHardwareIrqMask 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 ax, 0030h ;Disable LPT
mov bl, 03h ;Select Logical Device 3 (LPT)
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
; Activate parallel port
mov ax, 0130h ;Enable LPT
mov bl, 03h ;Select Logical Device 3 (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 al, 70h ;Select IRQ Register
mov bl, 03h ;Select Logical Device 3 (LPT)
call IT8661FWriteIO ;Set H/W IRQ
ret
SetHardwareIrq 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 = IRQ mak ;
; DS:SI = Pointer to buffer containing node structure ;
; Stack available ;
; ;
; Output: Nothing ;
; ;
; Destroys: Nothing ;
;-----------------------------------------------------------------------------;
ConfigNumberToNodeData proc near private
push ax
push bx
; Copy IRQ mask into the device node
mov (DevNodeDataBlock ptr [si]).LptIrq.ides_irq_mask, bx
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 ax, (ConfigTableEntry ptr cs:[bx]).PortAddress
mov (DevNodeDataBlock ptr [si]).LptPort.pdes_min_base, ax
mov (DevNodeDataBlock ptr [si]).LptPort.pdes_max_base, ax
mov al, (ConfigTableEntry ptr cs:[bx]).PortSize
mov (DevNodeDataBlock ptr [si]).LptPort.pdes_length, al
pop bx
pop ax
ret
ConfigNumberToNodeData endp
;---------------------------------------;
; NodeDataToConfigNumber ;
;---------------------------------------;-------------------------------------;
; This routine examines the node data and determines which ConfigTableEntry ;
; corresponds to the current configuration of the node. ;
; ;
; Input: AL = Node number ;
; DS:SI = Pointer to the node data ;
; Stack available ;
; ;
; Output: CF = Clear if a ConfigTableEntry matching the node data was found ;
; Set if no ConfigTableEntry matches the node data (node data ;
; contains an invalid configuration) ;
; AL = Entry number in DeviceConfigTable ;
; ;
; Destroys: BX, CX, DX ;
;-----------------------------------------------------------------------------;
NodeDataToConfigNumber proc near private
mov cx, (offset DeviceConfigTableEnd - offset DeviceConfigTable)/size ConfigTableEntry
mov bx, offset DeviceConfigTable
mov dx, (DevNodeDataBlock ptr [si]).LptPort.pdes_min_base
xor al, al ;AL will count entry number
ConfigNumberNext:
cmp (ConfigTableEntry ptr cs:[bx]).PortAddress, dx
;clc
je ConfigNumberFound ;Br if port found in DeviceConfigTable
add bx, size ConfigTableEntry ;Point to next entry
inc al ;Keep track of which entry we are on
loop ConfigNumberNext ;Try all entries in DeviceConfigTable
stc ;Indicate error, invalid configuration
ConfigNumberFound:
ret
NodeDataToConfigNumber endp
;---------------------------------------;
; DummyReturn ;
;---------------------------------------;-------------------------------------;
; Input: Nothing ;
; ;
; Output: Nothing ;
; ;
; Destroys: Nothing ;
;-----------------------------------------------------------------------------;
DummyReturn proc near private
ret
DummyReturn endp
;*****************************************************************;
;*****************************************************************;
;** **;
;** (C)Copyright 1985-1998, American Megatrends, Inc. **;
;** **;
;** All Rights Reserved. **;
;** **;
;** 6145-F Northbelt Pkwy, Norcross, GA 30071 **;
;** **;
;** Phone (770)-246-8600 **;
;** **;
;*****************************************************************;
;*****************************************************************;
_text ends
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -