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

📄 elimfunc.new

📁 Dos6.0
💻 NEW
📖 第 1 页 / 共 3 页
字号:
;******************************************************************************
E_Weitek        proc    far
;
	push    bx
	cmp     al,0                    ;Q: sense status ?
	jne     SHORT EW_chkON          ;  N: check next function code
	mov     al,[Weitek_State]       ;  Y: return current state
	jmp     EW_OK

;
; Weitek ON function
;   When Weitek state is set to ON, CEMM goes active whenever it is in
;   AUTO mode and the page table mapping is set to point to the Weitek.
;
EW_chkON:
	cmp     al,1                    ;Q: Weitek ON function ?
	jne     SHORT EW_chkOFF         ;    N: check for OFF function
	test    [Weitek_State],fWeitek_Inst ;Y: Q: Weitek installed ?
	jz      SHORT EWerror               ;     N: report error

	call    dword ptr [checkXMMFar] ;Q: Is there an XMM in the system
	jc      short EWok              ; N: OK to take HMA for WEITEK

	test    [GenFlags],fHMA         ;Q: Does CEMM own the HMA?
	jnz     short EWok              ; Y: map WEITEK

	call    dword ptr [XMMAllocHMAFar]
					;Q: Is the HMA available
	jc      short EWerror           ; N: report error

EWok:
	or      [Weitek_State],fWeitek_Map  ;     Y: set Weitek ON
	or      [Auto_State],fAuto_Weitek   ;        and auto mode flag
	;
	; update CEMM's state
	;   if CEMM is inactive, check for AUTO mode.
	;      if AUTO mode, CEMM goes active.
	;
	test    [Current_State],fState_Active   ;Q: CEMM active ?
	jnz     SHORT EW_ONPg                   ; Y: nothing to do here ...

	cmp     [Current_Mode],MODE_AUTO        ;Q: CEMM in AUTO mode ?
	jne     SHORT EW_ONPg                   ; N: CEMM stays inactive

	call    GoVirtual                       ;(sbp)  Y: go to virtual mode &
	jc      short EWerror
	or      [Current_State],fState_Active   ;(sbp)     set active flag
	;
	; now change 1meg wraparound to point to Weitek addresses
	;
EW_ONPg:
	mov     bx,0            ; Weitek mapping ON
	jmp     SHORT EW_UpdPageMap
;
; HMA not available for WEITEK
EWerror:
	mov     ah,2
	stc
	jmp     SHORT EW_error

;
; Weitek OFF function
;   When Weitek state is set to OFF, CEMM active/inactive state is unaffected
;   by Weitek in AUTO mode.  The 1Meg wraparound is placed back into the
;   page tables.
;
EW_chkOFF:
	cmp     al,2                    ;Q: Weitek OFF function ?
	jne     SHORT EW_InvFunc        ;    N: invalid Weitek subfunction
	test    [Weitek_State],fWeitek_Inst ;Y: Q: Weitek installed ?
	jz      short EWerror           ;         N: report error

	call    dword ptr [checkXMMFar] ;Q: Is there an XMM in the system
	jc      short EWOok             ; N: OK to release HMA for WEITEK

	test    [GenFlags],fHMA         ;Q: Does CEMM own the HMA?
	jz      short EWOok             ; N: OK to release HMA for WEITEK

	call    dword ptr [XMMDeallHMAFar]
					;Q: Is the HMA released?
	jc      short EWerror           ; N: report error

EWOok:
	and     [Weitek_State],NOT fWeitek_Map  ; Y: set Weitek OFF
	and     [Auto_State],NOT fAuto_Weitek   ;    and reset auto mode flag
	;
	; update CEMM's state
	;   if CEMM is in AUTO mode, it is active and CEMM may be able
	;    to go inactive now.
	;
	cmp     [Current_Mode],MODE_AUTO        ;Q: CEMM in AUTO mode ?
	jne     SHORT EW_OFFPg                  ;  N: then no CEMM state change
	cmp     [Auto_State],0                  ;  Y: Q: CEMM stays active ?
	jne     SHORT EW_OFFPg                  ;       Y: then leave
	and     [Current_State],NOT fState_Active ;     N: reset active flag &
	pushf                                   ; and return to real mode
	cli                             ;;; protect this sequence
	mov     al,0Fh                  ;;;
	out     84h,al                  ;;; port 84/85 return to real
	mov     al,00h                  ;;;     sequence ...
	out     85h,al                  ;;;
	jmp     $+2                     ;;; clear prefetch/avoid race cond
	popf
	;
	; now enable 1meg wraparound
	;
EW_OFFPg:
	mov     bx,1            ; Weitek mapping OFF
;
;  Update page table mapping of 1meg linear wraparound area
;       Entry: BX = 0 => Weitek mapping ON
;                 = 1 => 1 meg wraparound (Weitek OFF)
;
EW_UpdPageMap:
	test    [Current_State],fState_Active   ;Q: CEMM active?
	jz      SHORT EW_InactMap               ;  N: change mapping
	pushf                                   ;  Y: prot mode call to chg it
	cli                             ;;; protect this sequence
	Call_CEMM_PMF   CEMM_84_Weitek
	popf
	jmp     SHORT EW_OK

EW_InactMap:                    ; CEMM inactive, update Weitek mapping
EW_OK:
	clc
EW_exit:
	pop     bx
	ret

EW_InvFunc:
	mov     ah,1
	stc
	jmp     SHORT EW_error
EW_error:               ; error exit
	stc
	jmp     EW_exit
;
E_Weitek        endp

;LEO ;******************************************************************************
;LEO ; WeitekPageMap - change tables to include/exclude Weitek in page tables
;LEO ;
;LEO ;  NOTE: THIS IS A FAR ROUTINE
;LEO ;
;LEO ;   ENTRY: PROTECTED or REAL mode ONLY
;LEO ;          ES -> page tables
;LEO ;          BX = 0 => Weitek mapping ON
;LEO ;             = 1 => Weitek mapping OFF (1meg wraparound)
;LEO ;   EXIT: same as entry
;LEO ;   USED: none
;LEO ;******************************************************************************
;LEO WeitekPageMap      proc    far
;LEO    pushad
;LEO    cld
;LEO    cmp     bx,0                    ;Q: weitek map on function ?
;LEO    jne     SHORT WPM_chkoff        ;  N: check for off function
;LEO    ;                               ;  Y: change page tables
;LEO    ;  For Weitek 1167 mapping addresses,
;LEO    ; change page table entries for (00100000h,0010EFFFh) ->
;LEO    ;                               (C0000000h,C000EFFFh)
;LEO    ;
;LEO    mov     eax,0C0000000h  ; start with physical addr = C0000000h
;LEO    jmp     SHORT WPM_set_PT        ; set page tables
;LEO
;LEO WPM_chkoff:
;LEO    cmp     bx,1                    ;Q: weitek map off function ?
;LEO    jne     SHORT WPM_exit          ;  N: leave
;LEO    xor     eax,eax                 ;  Y: 1meg wraparound
;LEO
;LEO    ;
;LEO    ; set 60k worth of entries in page tables for 1meg linear
;LEO    ; entry: EAX = begin physical addr
;LEO    ;
;LEO WPM_set_PT:
;LEO    mov     di,100h*4       ; ES:DI -> PTE for 1Meg linear
;LEO    or      al,P_AVAIL              ; make pages available to all
;LEO    mov     cx,0Fh                  ; set 60k worth of entries
;LEO WPM_set_entry:
;LEO    stosd                           ; store EAX to ES:[DI]
;LEO                                    ; ES:[DI] pts to next page table entry
;LEO    add     eax,1000h               ; EAX = next physical page (with attrs)
;LEO    loop    WPM_set_entry           ;Q: done with page table entries ?
;LEO                                    ;  N: loop again
;LEO                                    ;  Y: all done
;LEO WPM_exit:
;LEO    mov     eax,cr3         ; clear the TLB !!!
;LEO    mov     cr3,eax
;LEO    popad
;LEO    ret
;LEO WeitekPageMap      endp

ifdef   QHKN

	page
;******************************************************************************
;       Debug Functions table
;******************************************************************************
;
DebugTab        label   word
	dw      offset  DebugR_GetPTE
	dw      offset  DebugR_PhysIO
DEBTAB_CNT      equ     ($-DebugTab)/2

;******************************************************************************
;       E_Debug  - Debug functions entry point
;
;       ENTRY:  REAL or VIRTUAL mode
;               AH = 3
;                AL = 0 => Get physical address
;                AL = 1 => Get physical DMA contents
;               DS = R_CODE
;
;       EXIT:   Same processor mode as entry
;               CLC => no errors
;               STC => error
;
;       USED: BX
;
;******************************************************************************
E_Debug proc    far
;
	cmp     al,DEBTAB_CNT   ;Q: valid function #
	jae     SHORT ED_inv_func ;  N: return error
	xor     bx,bx           ;  Y: exec function
	mov     bl,al           ; bx = function #
	shl     bx,1            ; word index
	call    CS:DebugTab[bx] ; call the function
;
ED_exit:
	ret
ED_inv_func:
	stc
	ret
;
E_Debug endp
;
	page
;******************************************************************************
;       DebugR_GetPTE  - Returns the Page Table Entry for a Linear Address
;
;       ENTRY:  REAL or VIRTUAL mode
;               AH = 3
;               AL = 0 => Get page table entry
;               ECX = linear address
;               DX = 0  => don't map linear address first (for >1meg addrs)
;               DX = 1  => map linear address first
;               DS = R_CODE
;
;       EXIT:   Same processor mode as entry
;               STC => error
;               CLC => no errors and
;                       ECX = page table entry
;
;       USED: none
;
;******************************************************************************
DebugR_GetPTE   proc    near
	test    [Current_State], fState_Active  ;Q: in Real mode now ?
	jnz     SHORT DRGP_VM                   ;  N: go to Virtual Mode hndlng
						;  Y: ok ..
	push    eax
	push    di
	push    es
	mov     ebx,[PageD_Addr]        ; EBX = 32 bit addr of page dir
	shr     ebx,4                   ; BX = seg addr of page dir
	mov     es,bx                   ; ES -> page dir
	mov     eax,ecx                 ; EAX = linear addr
	PDOff   ax                      ; EAX = page dir offset
	mov     di,ax                   ; DI = page dir offset for this addr
	mov     ebx,ES:[di]             ; EBX = PTE for page table
	test    bx,P_PRES               ;Q: is this page table present ?
	jz      SHORT DRGP_RM_error     ;  N: report error
	and     bx,(P_SIZE-1)           ;  Y: remove status bits
	shr     ebx,4                   ; BX = seg addr of page table
	mov     es,bx                   ; ES -> page table
	mov     eax,ecx                 ; EAX = linear addr
	PTOff   ax                      ; EAX = page table offset
	mov     di,ax                   ; DI = page table offset for this addr
	mov     ecx,ES:[di]             ; ECX = PTE for page table
	clc                     ; no errors

DRGP_RM_exit:
	pop     es
	pop     di
	pop     eax
	ret
DRGP_RM_error:
	stc
	jmp     DRGP_RM_exit
;
; In virtual mode now.  We need to go to protected mode to be sure we can
; access the page tables.
DRGP_VM:
	push    bx
	mov     bl,al                   ; BL = Diag function # for GetPTE
	Call_CEMM_PMF   CEMM_84_Diag    ; exec diag function
	pop     bx
	ret
DebugR_GetPTE   endp

	page
;******************************************************************************
;       DebugR_PhysIO - do physical I/O (at ring 0 PM privilege level)
;
;       ENTRY:  REAL or VIRTUAL mode
;               AH = 3
;               AL = 1 => Do Physical I/O
;                   DX = I/O address
;                   ECX/CX/CL = for OUTs, the value to output
;                   SI = 0 for input
;                      = 1 for output
;                   DI = 0 for byte I/O
;                      = 1 for word I/O
;                      = 2 for dword I/O
;               DS = R_CODE
;
;       EXIT:   Same processor mode as entry
;               STC => error
;               CLC => no errors and
;                   ECX/CX/CL = value input
;
;       USED: none
;
;******************************************************************************
DebugR_PhysIO   proc    near
	test    [Current_State], fState_Active  ;Q: in Real mode now ?
	jnz     SHORT DRPIO_VM                  ;  N: go to Virtual Mode hndlng
	call    FAR PTR Debug_PhysIO            ;  Y: do I/O in real mode
	ret                                     ;     and return
;
; here if virtual mode  => call CEMM Protected Mode Function
;
DRPIO_VM:
	push    bx
	mov     bl,al                   ; BL = Diag function # for PhysIO
	Call_CEMM_PMF   CEMM_84_Diag    ; exec diag function
	pop     bx
	ret
DebugR_PhysIO   endp

	page
;******************************************************************************
;       Debug_PhysIO - do physical I/O
;
;       ENTRY:  REAL MODE or Ring 0 PROT MODE
;                   DX = I/O address
;                   ECX/CX/CL = for OUTs, the value to output
;                   SI =  0 for input
;                      <> 0 for output
;                   DI = 0 for byte I/O
;                      = 1 for word I/O
;                      = 2 for dword I/O
;               DS = R_CODE
;
;       EXIT:   Same processor mode as entry
;                   ECX/CX/CL = value input
;               CLC => no error
;               STC => invalid input
;
;       USED: none
;
;******************************************************************************
Debug_PhysIO    proc    far
	push    eax
	or      si,si           ;Q: Input ?
	jnz     SHORT DPIO_Out  ;  N: do output
				;  Y: do input
	cmp     di,0            ;Q: byte input ?
	jne     SHORT DPIO_InW  ;  N: chk for word

⌨️ 快捷键说明

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