📄 vmm.inc
字号:
;******************************************************************************
;
; (C) Copyright MICROSOFT Corp., 1988-1990
;
; Title: VMM.INC - Include file for Virtual Machine Manager
;
; Version: 1.00
;
; Date: 05-May-1988
;
; Author: RAL
;
;------------------------------------------------------------------------------
;
; Change log:
;
; DATE REV DESCRIPTION
; ----------- --- -----------------------------------------------------------
; 05-May-1988 RAL Original
;
;==============================================================================
; NON Windows/386 Virtual Device sources can include this file to get some
; useful equates by declaring the symbol "Not_VxD" If this symbol is defined,
; then everything that has to do with the specifics of the 32 bit environment
; for virtual devices is removed. Useful equates include: device ID's, pushad
; structure, BeginDoc/EndDoc/BeginMsg/EndMsg equates, page table equates, etc.
False EQU 0
True EQU NOT False
;
; These null macros are recognized by a utility program that produces
; documentation files.
;
BeginDoc EQU <>
EndDoc EQU <>
BeginMsg EQU <>
EndMsg EQU <>
BeginDoc
;******************************************************************************
;
; EQUATES FOR REQUIRED DEVICES
;
; Device ID formulation note:
;
; Device ID's are a combination of OEM # and device # in the form:
;
; xOOOOOOOOOODDDDD
;
; The high bit of the device ID is reserved for future use. The next
; 10 bits are the OEM # which is assigned by Microsoft. The last 5 bits
; are the device #. This allows each OEM to create 32 unique devices.
; If an OEM is creating a replacement for a standard device, then it
; should re-use the standard ID listed below. Microsoft reserves the
; first 16 OEM #'s (0 thru 0Fh)
;
;==============================================================================
Undefined_Device_ID EQU 00000h
VMM_Device_ID EQU 00001h ; Used for dynalink table
Debug_Device_ID EQU 00002h
VPICD_Device_ID EQU 00003h
VDMAD_Device_ID EQU 00004h
VTD_Device_ID EQU 00005h
V86MMGR_Device_ID EQU 00006h
PageSwap_Device_ID EQU 00007h
Parity_Device_ID EQU 00008h
Reboot_Device_ID EQU 00009h
VDD_Device_ID EQU 0000Ah
VSD_Device_ID EQU 0000Bh
VMD_Device_ID EQU 0000Ch
VKD_Device_ID EQU 0000Dh
VCD_Device_ID EQU 0000Eh
VPD_Device_ID EQU 0000Fh
VHD_Device_ID EQU 00010h
VMCPD_Device_ID EQU 00011h
EBIOS_Device_ID EQU 00012h
BIOSXlat_Device_ID EQU 00013h
VNETBIOS_Device_ID EQU 00014h
DOSMGR_Device_ID EQU 00015h
WINLOAD_Device_ID EQU 00016h
SHELL_Device_ID EQU 00017h
VMPoll_Device_ID EQU 00018h
VPROD_Device_ID EQU 00019h
DOSNET_Device_ID EQU 0001Ah
VFD_Device_ID EQU 0001Bh
VDD2_Device_ID EQU 0001Ch ; Secondary display adapter
WINDEBUG_Device_ID EQU 0001Dh
TSRLoad_Device_ID EQU 0001Eh ; TSR instance utility ID
;
; Initialization order equates. Devices are initialized in order from
; LOWEST to HIGHEST. If 2 or more devices have the same initialization
; order value, then they are initialized in order of occurance, so a
; specific order is not guaranteed. Holes have been left to allow maximum
; flexibility in ordering devices.
;
VMM_Init_Order EQU 000000000h
Debug_Init_Order EQU 004000000h
VPROD_Init_Order EQU 008000000h
VPICD_Init_Order EQU 00C000000h
VTD_Init_Order EQU 014000000h
PageSwap_Init_Order EQU 01C000000h
Parity_Init_Order EQU 020000000h
Reboot_Init_Order EQU 024000000h
EBIOS_Init_Order EQU 026000000h
VDD_Init_Order EQU 028000000h
VSD_Init_Order EQU 02C000000h
VCD_Init_Order EQU 030000000h
VMD_Init_Order EQU 034000000h
VKD_Init_Order EQU 038000000h
VPD_Init_Order EQU 03C000000h
VHD_Init_Order EQU 040000000h
VFD_Init_Order EQU 044000000h
VMCPD_Init_Order EQU 048000000h
BIOSXlat_Init_Order EQU 050000000h
VNETBIOS_Init_Order EQU 054000000h
DOSMGR_Init_Order EQU 058000000h
DOSNET_Init_Order EQU 05C000000h
WINLOAD_Init_Order EQU 060000000h
VMPoll_Init_Order EQU 064000000h
Undefined_Init_Order EQU 080000000h
WINDEBUG_Init_Order EQU 081000000h
VDMAD_Init_Order EQU 090000000h
V86MMGR_Init_Order EQU 0A0000000h
SHELL_Init_Order EQU 0B0000000h
EndDoc
;******************************************************************************
;
; Macro to cause a delay in between I/O accesses to the same device.
;
;------------------------------------------------------------------------------
IO_Delay macro
jmp $+2
ENDM
Pushad_Struc STRUC
Pushad_EDI dd ? ; Client's EDI
Pushad_ESI dd ? ; Client's ESI
Pushad_EBP dd ? ; Client's EBP
Pushad_ESP dd ? ; ESP at pushall
Pushad_EBX dd ? ; Client's EBX
Pushad_EDX dd ? ; Client's EDX
Pushad_ECX dd ? ; Client's ECX
Pushad_EAX dd ? ; Client's EAX
Pushad_Struc ENDS
IFNDEF Not_VxD
??_CUR_CODE_SEG = 0
??_CODE = 1
??_ICODE = 2
??_LCODE = 3
??_RCODE = 4
?_CODE equ <(??_CUR_CODE_SEG MOD 8) - ??_CODE>
?_ICODE equ <(??_CUR_CODE_SEG MOD 8) - ??_ICODE>
?_LCODE equ <(??_CUR_CODE_SEG MOD 8) - ??_LCODE>
?_RCODE equ <(??_CUR_CODE_SEG MOD 8) - ??_RCODE>
;
; SEGMENT definitions and order
;
;* 32 Bit locked code
_LTEXT SEGMENT DWORD USE32 PUBLIC 'CODE'
_LTEXT ENDS
;* 32 Bit code
_TEXT SEGMENT DWORD USE32 PUBLIC 'PCODE'
_TEXT ENDS
;* 32 Bit initialization code
_ITEXT SEGMENT DWORD USE32 PUBLIC 'ICODE'
_ITEXT ENDS
;* Contains 32 Bit locked data
_LDATA SEGMENT DWORD PUBLIC 'CODE'
_LDATA ENDS
;* Contains 32 Bit data
_DATA SEGMENT DWORD PUBLIC 'PCODE'
_DATA ENDS
;* Contains 32 Bit initialization data
_IDATA SEGMENT DWORD PUBLIC 'ICODE'
_IDATA ENDS
;* Real Mode initialization code/data for devices
_RCODE SEGMENT WORD USE16 PUBLIC 'RCODE'
_RCODE ENDS
_LGROUP GROUP _LTEXT, _LDATA
_PGROUP GROUP _TEXT, _DATA
_IGROUP GROUP _ITEXT, _IDATA
ASSUME CS:FLAT, DS:FLAT, ES:FLAT, SS:FLAT
OFFSET32 EQU <OFFSET FLAT:>
BeginDoc
;==============================================================================
; The following macros are used in defining the routines
; in a VxD which are going to be registered with VMM as callable entry
; points. Once registered, the entry points can be called by any other
; devices via the "VxDCall" macro, defined below. In the comments below,
; replace "VxD" with the appropriate device name.
;
;*******
; In the VxD.INC file, put the following lines, replacing <function_name>
; with an appropriate name describing the function of the routine.
;
; Begin_Service_Table VxD[,<segname>]
; VxD_Service <function_name>[,<local segname>]
; VxD_Service <function_name>[,<local segname>]
; . . .
; VxD_Service <function_name>[,<local segname>]
; End_Service_Table VxD[,<segname>]
;
; Note that <segname> is an optional argument and, if specified, the
; table is put in the segment defined by the macro "yyy_Data_Seg",
; where yyy=segname. Otherwise the segment is defined by the
; "VxD_Data_Seg" macro, defined below.
; Note that <local segname> is an optional argument and, if specified,
; the procedure's segment is defined by the macro "zzz_Code_Seg",
; where zzz=segname. Otherwise the segment is defined by the
; "VxD_Code_Seg" macro, defined below.
;
;*******
; One VxD module should have the following in order to define the entry points:
;Create_VxD_Service_Table = 1 ; Only in module where table is
; INCLUDE VxD.INC ; Include the table definition
;
;*******
; All modules that want to call the services defined in the table should include
; VxD.INC, but not define the label "Create_VxD_Service_Table". This
; will define the service names to be used with the VxDCall macro.
;
EndDoc
Begin_Service_Table MACRO Device_Name, Def_Segment
IFB <Def_Segment>
BST2 Device_Name, VxD
ELSE
BST2 Device_Name, Def_Segment
ENDIF
ENDM
BST2 MACRO Device_Name, Def_Segment
Num_&Device_Name&_Services = 0
IFDEF Create_&Device_Name&_Service_Table
Def_Segment&_LOCKED_DATA_SEG
Device_Name&_Service_Table LABEL DWORD
Device_Name&_Service MACRO Procedure, Local_Seg
PUBLIC $&&Procedure
IF1
$&&Procedure LABEL DWORD
ENDIF
IFDIFI <Local_Seg>, <LOCAL>
IFNB <Local_Seg>
Local_Seg&&_SEG
ELSE
Def_Segment&_CODE_SEG
ENDIF
EXTRN @&&Procedure:NEAR
IFNB <Local_Seg>
Local_Seg&&_ENDS
ELSE
Def_Segment&_CODE_ENDS
ENDIF
ENDIF
dd OFFSET32 @&&Procedure
Procedure = (Device_Name&_Device_ID SHL 16) + Num_&Device_Name&_Services
Num_&Device_Name&_Services = Num_&Device_Name&_Services + 1
ENDM
ELSE
Device_Name&_Service MACRO Procedure
Procedure = (Device_Name&_Device_ID SHL 16) + Num_&Device_Name&_Services
Num_&Device_Name&_Services = Num_&Device_Name&_Services + 1
ENDM
ENDIF
ENDM
;------------------------------------------------------------------------------
End_Service_Table MACRO Device_Name, Def_Segment
PURGE Device_Name&_Service
IFDEF Create_&Device_Name&_Service_Table
IFB <Def_Segment>
VxD_LOCKED_DATA_ENDS
ELSE
Def_Segment&_LOCKED_DATA_ENDS
ENDIF
ENDIF
ENDM
;******************************************************************************
;
; Dword_Align -- Aligns code to dword boundry by inserting nops
;
;------------------------------------------------------------------------------
Dword_Align MACRO Seg_Name
LOCAL segn
IFNB <Seg_Name>
segn equ Seg_Name
ELSE
IFE ?_CODE
segn equ <_TEXT>
ELSE
IFE ?_ICODE
segn equ <_ITEXT>
ELSE
IFE ?_LCODE
segn equ <_LTEXT>
ELSE
.err Dword_Align not supported
ENDIF
ENDIF
ENDIF
ENDIF
IF (($-OFFSET segn:0) MOD 4)
db 4 - (($-OFFSET segn:0) MOD 4) DUP (90h)
ENDIF
ENDM
BeginDoc
;******************************************************************************
;
; Fatal_Error
;
; DESCRIPTION:
; This macro is used to crash Windows/386 when an unrecoverable error
; is detected. If Msg_Ptr is ommitted then no error message will be
; displayed, otherwise Msg_Ptr is the address
; when the
;
; PARAMETERS:
; Msg_Ptr (OPTIONAL) - Points to an ASCIIZ string to display.
;
; EXIT:
; To DOS (hopefully). This macro never returns.
;
;==============================================================================
EndDoc
Fatal_Error MACRO Msg_Ptr, Exit_Flags
pushad
IFB <Msg_Ptr>
xor esi, esi
ELSE
mov esi, Msg_Ptr
IFB <Exit_Flags>
xor eax, eax
ELSE
mov eax, Exit_Flags
ENDIF
ENDIF
VMMcall Fatal_Error_Handler
ENDM
EF_Hang_On_Exit EQU 1h
;******************************************************************************
;==============================================================================
;------------------------------------------------------------------------------
BeginDoc
;******************************************************************************
; The following are control block offsets of items that can be of interest
; to VxDs.
;*******
; VM status indicates globally interesting VM states
CB_VM_Status EQU DWORD PTR 00h
VMStat_Exclusive EQU 000000000000000000001b ; VM is exclusive mode
VMStat_Exclusive_Bit EQU 0
VMStat_Background EQU 000000000000000000010b ; VM runs in background
VMStat_Background_Bit EQU 1
VMStat_Creating EQU 000000000000000000100b ; In process of creating
VMStat_Creating_Bit EQU 2
VMStat_Suspended EQU 000000000000000001000b ; VM not scheduled
VMStat_Suspended_Bit EQU 3
VMStat_Not_Executeable EQU 000000000000000010000b ; VM partially destroyed
VMStat_Not_Executeable_Bit EQU 4
VMStat_PM_Exec EQU 000000000000000100000b ; Currently in PM app
VMStat_PM_Exec_Bit EQU 5
VMStat_PM_App EQU 000000000000001000000b ; PM app present in VM
VMStat_PM_App_Bit EQU 6
VMStat_PM_Use32 EQU 000000000000010000000b ; PM app is 32-bit
VMStat_PM_Use32_Bit EQU 7
VMStat_VxD_Exec EQU 000000000000100000000b ; Call from VxD
VMStat_VxD_Exec_Bit EQU 8
VMStat_High_Pri_Back EQU 000000000001000000000b ; High pri background
VMStat_High_Pri_Back_Bit EQU 9
VMStat_Blocked EQU 000000000010000000000b ; Blocked on semaphore
VMStat_Blocked_Bit EQU 0Ah
VMStat_Awakening EQU 000000000100000000000b ; Woke up after blocked
VMStat_Awakening_Bit EQU 0Bh
VMStat_PageableV86 EQU 000000001000000000000b ; part of V86 is pageable (PM app)
VMStat_PageableV86Bit EQU 0Ch
VMStat_V86IntsLocked EQU 000000010000000000000b ; Rest of V86 is locked
VMStat_V86IntsLockedBit EQU 0Dh ; regardless of pager type
VMStat_TS_Sched EQU 000000100000000000000b ; Scheduled by time-slicer
VMStat_TS_Sched_Bit EQU 0Eh
VMStat_Idle EQU 000001000000000000000b ; VM has released time
VMStat_Idle_Bit EQU 0Fh ; slice
VMStat_Use32_Mask EQU VMStat_PM_Use32 OR VMStat_VxD_Exec
;*******
; Add this value to a V86 linear address to get address of VM's memory in
; the VMM linear address space
CB_High_Linear EQU DWORD PTR 04h
;*******
CB_Client_Pointer EQU DWORD PTR 08h
CB_VMID EQU DWORD PTR 0Ch
;
; Equates for protected mode application control blocks
;
PMCB_Flags EQU DWORD PTR 00h
PMCB_Parent EQU DWORD PTR 04h
EndDoc
;******************************************************************************
; V M M S E R V I C E S
;******************************************************************************
Begin_Service_Table VMM, VMM
VMM_Service Get_VMM_Version, LOCAL ; MUST REMAIN SERVICE 0!
VMM_Service Get_Cur_VM_Handle
VMM_Service Test_Cur_VM_Handle
VMM_Service Get_Sys_VM_Handle
VMM_Service Test_Sys_VM_Handle
VMM_Service Validate_VM_Handle
VMM_Service Get_VMM_Reenter_Count, LOCAL
VMM_Service Begin_Reentrant_Execution, LOCAL
VMM_Service End_Reentrant_Execution, LOCAL
VMM_Service Install_V86_Break_Point
VMM_Service Remove_V86_Break_Point
VMM_Service Allocate_V86_Call_Back
VMM_Service Allocate_PM_Call_Back
VMM_Service Call_When_VM_Returns
VMM_Service Schedule_Global_Event
VMM_Service Schedule_VM_Event
VMM_Service Call_Global_Event
VMM_Service Call_VM_Event
VMM_Service Cancel_Global_Event
VMM_Service Cancel_VM_Event
VMM_Service Call_Priority_VM_Event
VMM_Service Cancel_Priority_VM_Event
VMM_Service Get_NMI_Handler_Addr, LOCAL
VMM_Service Set_NMI_Handler_Addr, LOCAL
VMM_Service Hook_NMI_Event
VMM_Service Call_When_VM_Ints_Enabled
VMM_Service Enable_VM_Ints
VMM_Service Disable_VM_Ints
VMM_Service Map_Flat
VMM_Service Map_Lin_To_VM_Addr
;
; Scheduler services
;
VMM_Service Adjust_Exec_Priority
VMM_Service Begin_Critical_Section
VMM_Service End_Critical_Section
VMM_Service End_Crit_And_Suspend
VMM_Service Claim_Critical_Section
VMM_Service Release_Critical_Section
VMM_Service Call_When_Not_Critical
VMM_Service Create_Semaphore
VMM_Service Destroy_Semaphore
VMM_Service Wait_Semaphore
VMM_Service Signal_Semaphore
VMM_Service Get_Crit_Section_Status
VMM_Service Call_When_Task_Switched
VMM_Service Suspend_VM
VMM_Service Resume_VM
VMM_Service No_Fail_Resume_VM
VMM_Service Nuke_VM
VMM_Service Crash_Cur_VM
VMM_Service Get_Execution_Focus
VMM_Service Set_Execution_Focus
VMM_Service Get_Time_Slice_Priority
VMM_Service Set_Time_Slice_Priority
VMM_Service Get_Time_Slice_Granularity
VMM_Service Set_Time_Slice_Granularity
VMM_Service Get_Time_Slice_Info
VMM_Service Adjust_Execution_Time
VMM_Service Release_Time_Slice
VMM_Service Wake_Up_VM
VMM_Service Call_When_Idle
VMM_Service Get_Next_VM_Handle
;
; Time-out and system timer services
;
VMM_Service Set_Global_Time_Out
VMM_Service Set_VM_Time_Out
VMM_Service Cancel_Time_Out
VMM_Service Get_System_Time
VMM_Service Get_VM_Exec_Time
VMM_Service Hook_V86_Int_Chain
VMM_Service Get_V86_Int_Vector
VMM_Service Set_V86_Int_Vector
VMM_Service Get_PM_Int_Vector
VMM_Service Set_PM_Int_Vector
VMM_Service Simulate_Int
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -