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

📄 elimfunc.new

📁 Dos6.0
💻 NEW
📖 第 1 页 / 共 3 页
字号:
.386p
page 58,132
;******************************************************************************
	title   ELIMFUNC - CEMM functions module
;******************************************************************************
;
;   (C) Copyright MICROSOFT Corp. 1986-1991
;   (C) Copyright COMPAQ Computer Corp. 1986-1991
;
;       Title:  EMM386.EXE - MICROSOFT Expanded Memory Manager 386 Driver
;
;       Module: ELIMFUNC - entry point for VDM functions
;
;       Version: 2.00
;
;       Date:   May 24,1986
;
;       Author: Steve Preston
;
;******************************************************************************
;
;       Change Log:
;
;       DATE     REVISION       Description
;       -------- --------       --------------------------------------------
;       04/24/86 Original       From EMML LIM driver.
;       06/28/86 0.02           Name change from CEMM386 to CEMM (SBP).
;       07/05/86 0.04           Added segment R_CODE (SBP).
;       07/10/86 0.05           jmp $+2 before "POPF" (SBP).
;       05/12/87 2.00           moved code to R_CODE (SBP).
;       05/21/87 2.00           added debug functions (SBP).
;       05/31/88 ?.??           set active flag AFTER GoVirtual (SBP).
;
;******************************************************************************
;   Functional Description:
;       This module contains the ON/OFF functionality code for activating/
;   deactivating CEMM from DOS.
;
;******************************************************************************
.lfcond
	page
;******************************************************************************
;                       P U B L I C   D E C L A R A T I O N S
;******************************************************************************
;
	public  b2asc10
	public  b2asc10_far
	public  b2ascHEX
	public  b2ascHEX_far
	public  ELIM_Entry
	public  EFunTab
	public  EFUN_CNT

ifdef   QHKN
	public  Debug_PhysIO
	public  E_Debug
endif

	public  E_GetStatus
	public  E_ONOFF
	public  E_Weitek
	public  I_Message_Display
	public  E_XStatus_Display

;
	page
;******************************************************************************
;                       L O C A L   C O N S T A N T S
;******************************************************************************
;
	include vdmseg.inc
	include vdmsel.inc
	include emm386.inc
	include page.inc
	include emmfunct.inc
	include emmdata.inc
	include winemm.inc

;******************************************************************************
;                       E X T E R N A L    R E F E R E N C E S
;******************************************************************************
;
R_CODE  SEGMENT
	EXTRN   ttl_hndls: WORD
	extrn   GoVirtual:near
;;      extrn   check_XMM:far
;       extrn   XMMAllocateHMA:far
;       extrn   XMMDeallocateHMA:far
	extrn   XMMAllocHMAFar:dword
	extrn   XMMDeallHMAFar:dword
	extrn   checkXMMFar:dword
	extrn   Devname:byte
R_CODE  ENDS


LAST    SEGMENT
	extrn   StatusMess:byte
	extrn   LIMVerMess:byte
	extrn   TotalPagesMess:byte
	extrn   AvailPagesMess:byte
	extrn   TotalHanMess:byte
	extrn   AvailHanMess:byte
	extrn   PFBAMess:byte
	extrn   MemSizeMess:byte
	extrn   ISizeMess:byte
	extrn   InitMessage:byte
	extrn   NoEMSmess:byte
	extrn   UMBstatusMess:byte
	extrn   UMBavail:byte
	extrn   UMBlargest:byte
	extrn   UMBstart:byte
	extrn   AvailUMB:near
	extrn   LargestUMB:near
LAST    ENDS


	page
;******************************************************************************
;                       S E G M E N T   D E F I N I T I O N
;******************************************************************************
;
;******************************************************************************
;
;       Code Segment R_CODE
;
;******************************************************************************
;
R_CODE  segment
	assume  CS:R_CODE, DS:R_CODE, ES:R_CODE
;
;       ELIM functions table    - far calls
;
EFunTab label   dword
	dw      offset  E_GetStatus
	dw      seg     R_CODE

	dw      offset  E_ONOFF
	dw      seg     R_CODE

	dw      offset  E_Weitek
	dw      seg     R_CODE

ifdef   QHKN
	dw      offset  E_Debug
	dw      seg     R_CODE
endif

EFUN_CNT        equ     ($-EFunTab)/4

	page
;******************************************************************************
;       ELIM_Entry - entry point for general ELIM functions
;
;       THIS IS A FAR CALL ROUTINE
;
;       ENTRY:  REAL or VIRTUAL mode only
;               AH = 0  => get current status of VDM/EMM386
;               AH = 1  => ON/OFF/AUTO
;               AH = 2  => Weitek functions
;               AH = 3  => DEBUG entry
;               AH = 4  => Message Display
;               AH = 5  => Status Display
;
;       EXIT: EMM386 is activated/deactivated if possible
;             NC => no errors.
;             CY => ERROR occured.
;                       AH = error number
;                       AH= 01 =>invalid function.
;
;       USED: none
;
;******************************************************************************
ELIM_Entry      proc    far
;

	push    ebx
	push    ds
;
	mov     bx,seg R_CODE
	mov     ds,bx
	assume  ds:R_CODE
;
	cmp     ah,EFUN_CNT     ;Q: valid function #
	jae     SHORT EE_inv_func ;  N: return error
	xor     bx,bx           ;  Y: exec function
	mov     bl,ah           ; bx = function #
	shl     bx,2            ; dword index
	call    CS:EFunTab[bx]  ; call the function
;
EE_exit:
	pop     ds
	pop     ebx
	ret
;
EE_inv_func:
	mov     ah,01
	stc
	jmp     short EE_exit
;
ELIM_Entry      endp

;******************************************************************************
;       E_GetStatus - get ELIM/VDM status
;
;       ENTRY:  AH = 0
;               DS = R_CODE
;
;       EXIT:   AH = 0 => ELIM ON
;                  = 1 => ELIM OFF
;                  = 2 => ELIM in AUTO mode (ON)
;                  = 3 => ELIM in AUTO mode (OFF)
;
;       USED: none
;
;******************************************************************************
E_GetStatus     proc    far
;
	xor     ah,ah                   ; assume ON
	test    [Current_State],fState_Active
					;Q: CEMM currently ON?
	jnz     SHORT EGS_chkAUTO       ;  Y: chk for AUTO mode
	mov     ah,1                    ;  N: set to OFF
EGS_chkAUTO:
	cmp     [Current_Mode],MODE_AUTO        ;Q: Auto Mode?
	jne     SHORT EGS_exit                  ;  N: leave
	add     ah,2                            ;  Y: map to 2,3
EGS_exit:
	ret
;
E_GetStatus     endp

;******************************************************************************
;       E_ONOFF  - general ON/OFF code for ELIM
;
;       ENTRY:  AH = 1
;                AL = 0 => ON
;                AL = 1 => OFF
;                AL = 2 => AUTO
;               DS = R_CODE
;
;       EXIT:   Virtual mode and ELIM ON
;               OR Real mode and ELIM OFF
;
;       USED: none
;
;******************************************************************************
E_ONOFF proc    far
;
	cmp     al,0                    ;Q: -> CEMM ON ?
	jne     SHORT EOO_chkOFF        ;  N: check for OFF/AUTO

	mov     [Current_Mode],MODE_ON  ; set mode to ON
	mov     [Devname],'E'           ; set to allow presense detect
	jmp     SHORT EOO_ON            ;     go to ON state

EOO_chkOFF:
	cmp     al,1                    ;Q: -> CEMM OFF ?
	jne     SHORT EOO_chkAUTO       ;  N: check for AUTO
	CMP     [handle_count], 1       ; Q:  entries in handle dir <= 1?
	JA      EOO_inv                 ; N: refuse the request
	cmp     [UsedVCPIPages],0       ;Q: Any VCPI pages allocated
	jnz     EOO_inv                 ; Y: continue
ifdef QEMS
	MOV     AX, [free_pages]        ; Get original free 4K pages    ;@PIW
	CMP     AX, [free_4k_pages]     ; Q: Is any page (de)allocated? ;@PIW
	jne     EOO_inv                 ; Y:
endif
	cmp     cs:[UMBHMA],TRUE        ;Q: Are UMBs defined?
	je      EOO_inv                 ; Y: don't turn off
	mov     [Current_Mode],MODE_OFF ; N: set mode to OFF
	mov     [Devname],'$'           ;set to prevent presense detect
	jmp     SHORT EOO_OFF

EOO_chkAUTO:
	cmp     al,2                            ;Q: -> CEMM AUTO ?
	jne     SHORT EOO_inv                   ; N: invalid function call
	mov     [Current_Mode],MODE_AUTO        ; Y: set mode to AUTO

	or      [Auto_State],fAuto_Users        ; assume users: active

	cmp     [handle_count],1                ;Q: EMS users active?
	jne     short EOOcont                   ; Y: continue
	cmp     cs:[UMBHMA],TRUE                ;Q: Is virtual HMA/UMB provided?
	je      short EOOcont                   ; Y: continue
	cmp     [UsedVCPIPages],0               ;Q: Any VCPI pages allocated
	jnz     EOOcont                         ; Y: continue   
ifdef QEMS
	mov     ax,[free_pages]                 ; Get original free 4K pages
	cmp     ax,[free_4k_pages]              ;Q: Is any page allocated?
	jne     short EOOcont                   ; Y: continue
endif
	and     [Auto_State],not fAuto_Users    ; N: CEMM may be turned inactive

EOOcont:
	mov     [Devname],'E'           ;set to allow presense detect
	cmp     [Auto_State],0          ;Q: turn on for AUTO mode ?
	je      SHORT EOO_OFF           ;  N: go to OFF state
					;  Y: go to ON state

	;
	; go to Virtual Mode operation and activate CEMM
	;
EOO_ON:
	test    [Current_State],fState_Active   ;Q: currently active ?
	jnz     SHORT EOO_OK                    ;  Y: just leave
	call    GoVirtual                       ;  N: go to virtual mode & (sbp)
	jc      short EOOerror
	or      [Current_State],fState_Active   ;     set active flag      (sbp)
	jmp     short EOO_OK
	;
	; go to Real Mode operation and deactivate CEMM
	;
EOOerror:
	and     [Current_State],not fState_Active; make inactive
	mov     [Current_Mode],MODE_OFF          ; set mode to OFF
	mov     [Devname],'$'                    ; set to prevent presense detect

EOO_OFF:
	test    [Current_State],fState_Active   ;Q: currently inactive ?
	jz      SHORT EOO_OK                    ;  Y: just leave
	and     [Current_State],NOT fState_Active ;N: reset active flag &
	push    ax                              ; and return to real mode
	pushf
	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
	pop     ax
	cmp     [Current_Mode],MODE_OFF
	jne     short EOO_OK
;
;   leave with no errors
;
EOO_OK:
	clc
EOO_exit:
	ret
;
;  invalid ON/OFF/AUTO function call
;
EOO_inv:
	stc
	ret
;
E_ONOFF endp

;******************************************************************************
;       E_Weitek  - Weitek support functions
;
;       ENTRY:  AH = 2
;                AL = 0 => sense current Weitek state
;                AL = 1 => turn Weitek ON
;                AL = 2 => turn Weitek OFF
;               DS = R_CODE
;
;       EXIT:   STC and AH = 1 for invalid subfunction (AL)
;               for AL = 0 (sense Weitek state)
;                   AL -> bit 0 = Weitek installed flag
;                         bit 1 = Weitek mapped flag
;               for AL = 1 or 2
;                   STC and AH = 2 => Weitek not installed
;                       CEMM ON or OFF depending on current
;                       CEMM mode (ON/OFF/AUTO).
;
;       USED: none
;

⌨️ 快捷键说明

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