init.asm
来自「Dos6.0」· 汇编 代码 · 共 2,531 行 · 第 1/5 页
ASM
2,531 行
dw offset LAST:Incorrect_DOS ; Incorrect Version of DOS
dw offset LAST:InsfMem ; Insufficient Memory
dw offset LAST:Already_Inst; Already Installed
dw offset LAST:No_PF_Avail ; No Page Frame Space Avail
dw offset LAST:Adj_Size ; Pool Size Adjusted
dw offset LAST:InvPFBA ; Page Frame Base Addr Adjusted
dw offset LAST:InvMRA ; Map Register Adjusted
dw offset LAST:InvParm ; Invalid Parameter msg
dw offset LAST:PFWarning ; Page Frame warning message
dw offset LAST:NoWeitek ; Weitek not installed
dw offset LAST:NoXMM ; XMS manager not installed
dw offset LAST:BadXMM ; Possible bad HIMEM version
dw offset LAST:OF_won_err ; Unable to enable WEITEK
dw OFFSET LAST:PF_not_3_2 ; Use Pn without a page frame
dw offset LAST:OtherEMM ; Other EMM on system already
dw offset LAST:HMAonMsg ; Virtual HMA is invalid
dw offset LAST:UMBmemMsg ; No more UMB/HMA memory
dw offset LAST:UserAbortMsg; User aborted installation
MAX_MSG equ (this byte - msg_tbl)/2 ; # of messages to display
; macro for printing messages located in LAST segment
; ENTRY: DX = offset LAST:message
PRINT_MSG macro
push ds
mov ax,seg LAST
mov ds,ax ; ds = LAST
mov ah,PRINT_STRING
int MS_DOS ; output init message
pop ds
ENDM
page
;******************************************************************************
; Init - Initialization routine for CEMM.
;
; ENTRY: DS:BX pts to INIT request header.
;
; EXIT: AX = INIT status for request header
; if NO errors :
; CEMM initialized.
; if [ON] parameter specified on command line
; exit in Virtual mode and CEMM active.
; else ( [OFF] parameter specified )
; exit in Real mode and CEMM inactive.
; if errors:
; Real Mode
; USED: none
;
;******************************************************************************
Init_CEMM386 proc far
.8086 ; 8086 code only
mov cs:[SYSSS],ss
mov cs:[SYSSP],sp
mov ax,seg L_STACK
mov ss,ax
lea sp,L_STACK:[LastStackTop]
push bx ; BP+10
push dx ; BP+8
push bp ; BP+6
push di ; BP+4
push ds ; BP+2
push es ; BP+0
mov bp,sp
;
; initialize debugger ***** this assumes we are on a 386 *****
;
mov ax,seg _DATA
mov ds,ax
assume ds:_DATA
ifdef BugMode
mov al,0FFh
call InitDeb
endif
ifdef DEBUG
call InitDeb
endif
;
; initialize break address to not install
;
mov bx,[bp+2] ; get entry DS from stack
mov es,bx
assume es:ABS0
mov bx,[bp+10] ; ES:BX pts to req hdr
mov word ptr es:[bx.BRK_OFF],0000 ; set it
mov ax,seg R_CODE ; get brk addr segment
;;;inc ax ; reserve dos link pointer
mov es:[bx.BRK_SEG],ax ; break addr = cs - don't install
mov byte ptr es:[bx.NUM_UNITS],0 ; 0 - don't install
mov ax,seg STACK
mov cs:[EndDriver],ax
;
; verify DOS version
;
call chk_DOS
jnc short IE_proc
jmp ICinvdos
IE_proc:
;
; verify processor type
;
call Is386 ;Q: is this a 386 ?
jnc short IE_state ; Y: check machine state
jmp ICnon386 ; N: no, set error
ifdef 910318
jc short inc_prc ; N: no, set error
; Y: check machine state
endif
IE_state:
;
; verify machine state
;
push es
mov ax,seg R_CODE
mov es,ax
call dword ptr es:[chkMcStateFar]
pop es
;Q: is the machine in real mode
jnc short IE_machine ; Y: check machine type
jmp ICbadstate ; N: no, set error
ifdef 910318
jc short IE_badstate ; N: error
endif
.386P ; atleast a 386 at this point
IE_machine:
mov ax,X_HI_MEM_SEG ; ROM segment
mov es,ax ; into es
assume es:ABS0
mov ax,es:X_MT_AT ; get machine type
mov [ROMID],al ; save machine type
ifdef 910318
jmp short IE_EISACheck
ifdef ROMIDMCA
cmp al,ROMIDISA ;Q: Is this an ISA/EISA class machine?
je short IE_EISACheck ; Y: continue
cmp al,ROMIDPS2 ;Q: Is this a PS2 with 386 proc?
je short IE_EISACheck ; Y: continue
endif
inc_prc:
jmp ICnon386
;;IE_badstate:
;; jmp ICbadstate
.386P ; atleast a 386 at this point
IE_EISACheck:
endif
ifdef MSFLAG
call segfixup ; fix up GS & FS (see segfix.asm)
endif
mov ax,seg _DATA ; setup new segments
mov ds,ax
mov ax,seg R_CODE
mov gs,ax
ASSUME ds:_DATA
ASSUME gs:R_CODE
call EISACheck ; check if this is an EISA machine
call MCACheck ; check if this is an MCA machine
call IsZenith ; check to see if this is a ZENITH
IE_UserAbort:
;
; check if special key-sequence is being pressed - if so, don't load
;
call Check_Install_Abort ;Q: Is user requesting an abort?
jnc short IE_otherEMM ; N: check for another EMM
or gs:[msg_flag],UserAbort_MSG
jmp IE_exit
IE_otherEMM:
;
; Verify CEMM is not installed or another EMM is present
;
call Inst_chk
or ax,ax ;Q: Int 67h vector zero?
jz short IE_chk_pt ; Y: OK
or al,al ;Q: CEMM Already installed?
jnz short IECEMMInstalled ; Y: error, exit
;
; Check if another EMM is already on system.
;
mov ah,40h ; get status function
int 67h
or ax,ax ;Q: Other EMM already installed?
jnz short IE_chk_pt ; N: OK
or gs:[msg_flag],OTHER_EMM_MSG
jmp IE_exit
IECEMMinstalled:
or gs:[msg_flag],INS_ERR_MSG ; y: error
jmp IE_exit ; quit
IE_chk_pt:
call Is386s ;Q: Is it a COMPAQ 386SX based machine?
jne short IE_chk_pt1 ; N: no, continue
or gs:[GenFlags],f386SX ; Y: set flag
IE_chk_pt1:
; Detect if channel 6 of 8237 is connected to a Columbia Data
; Products SCSI drive.
mov ax, 0100h
mov si, 6a6ah
xor di,di
int 11h
cmp di, 6a6ah ; Q: did DI come back with 6a6a
jne IE_no_CDP_SCSI ; N: No CDP SCSI
cmp ah, 33h ; Y: is the version > 33h
ja IE_no_CDP_SCSI ; Y: the drive's softare will use
; VDS
mov gs:[CDPSCSI], 1 ; N: set flag to indicate that a CDP
; SCSI is on channel 6. Setting
; this flag indicates that the
; initial values of base,page and
; count on channel 6 as maintained
; by our data structures will be 0.
IE_no_CDP_SCSI:
; M008 - Start
call IsCompaq ;Q: is it a Compaq 386
jnz IE_Weitek_chk ; N: no, continue
call IsCPQ16 ; Set bit if it is a 386/16
; M008 - end
ifndef MSFLAG
ifdef 900105
call NoResetRoutine ; Y: don't need a reset routine
endif
call IsP8042 ;Q: Is this a password 8042 machine?
jne short IE_Weitek_chk ; N: no, continue
or gs:[GenFlags],fP8042 ; Y: set flag
mov al,26h ; check if A20 is toggled via port 92h
out 70h,al ; byte 26h contains CMOS bit
in al,71h ; get CMOS value
test al,20h ;Q: Port 92h used in A20 toggle?
jz short IE_Weitek_chk ; N: continue
or gs:[GenFlags],fP92 ; Y: set flag
endif
IE_Weitek_chk:
xor eax,eax ; clear high word of AX
int 11h
test eax,fI11h_Weitek_Inst SHL 16 ;Q: Weitek installed ?
jz short IE_Toshiba ; N: check for Toshiba stuff
or gs:[Weitek_State],fWeitek_Inst ; Y: set installed flag
; Do Toshiba specific checks to exclude some upper memory regions
; that are used by their BIOS and power management hardware.
IE_Toshiba:
call SetToshibaOptions
;
; parse command line for
; (1) requested size for expanded memory
; (2) page frame base address
; (3) I/O addresses for board emulations
; (4) Driver exit mode (virtual or real)
;
IE_parse:
mov bx,[bp+2] ; get entry DS from stack
mov es,bx
assume es:ABS0
mov bx,[bp+10] ; ES:BX pts to req hdr
les di,ES:[bx.ARG_PTR] ; ES:DI pts to config.sys command
; line parameters
call GetPathName ; get drivers path and name
call parser ; parse the parameters
mov ah, 2 ; Force VERBOSE mode if user is
int 16h ; holding down the Alt key
test al, 08h ; Int 16h/2 == Get Keyboard Flags
jz short @f ; 08h set if Alt key down
mov [Verbose], TRUE
@@:
test gs:[msg_flag],KILLER_MSG; Q: any killer messages?
JNZ IE_exit ; Y: exit with error
;
; Check for memory above 16 meg on Compaq ISA systems, must buffer DMA
; above 16 meg on these systems
;
call IsCompaq ; Is this a Compaq?
jnz IE_xmm_check
mov ax, 0E801h ; Compaq Get Memory Size Function
int 15h
jc short IE_xmm_check ; If not supported, continue
or dx,dx ;Q: Is there memory configured >16MB?
jz short IE_xmm_check ; N: continue
or gs:[genflags],fabove16M ; Y:Set flag to indicate support>16M
IE_xmm_check:
call $chkCPQxmm ; activate non CPQ XMMs on EISA machines
call XMMcheck
test gs:[msg_flag],KILLER_MSG; Q: any killer messages?
jnz IE_exit ; Y: exit with error
;
; Setup for extended memory allocation
;
IE_alloc:
;
; Estimate amount of memory needed in extended memory!
;
movzx eax,cs:[max_pool_size]
shl eax,10 ; requested EMS pool
mov ebx,eax
shr ebx,10 ; memory needed for PHs
add eax,ebx ; 4K per PH
add eax,7*1024*4 ; space for PTs(4),PFs(2),PD(1)
add eax,[DMABufferSize] ; space for DMA buffer
movzx ebx,[NumOfUMBwindows] ; number of UMBs
shl ebx,12 ; each UMB is 4K
add eax,ebx
cmp cs:[HMAonSet],TRUE ;Q: Virtual HMA required?
jne short IEmemInit ; N: continue
add eax,10000h ; Y: add 64K for a virtual HMA
IEmemInit:
call EstWorkSpace ; EBX = estimated work space (code/data)
add eax,ebx
add eax,10000h ; leave HMA area available
call MemInit ; free memory in system (above 1M)
mov [TopOfPhysicalMemory],eax ; save top of memory
add eax,1000h-1 ; next 4K page
shr eax,12 ; number of PTE's needed
mov [MaxPTEIndex],eax ; save max PTE index
or eax,eax ;Q: Atleast 4K free above 1M?
jnz short IE_got_mem ; Y: continue
or gs:[msg_flag],MEM_ERR_MSG;N: do not load
jmp IE_exit ;
IE_got_mem:
; Now that memory size is know, check that min_pool_size <= max_pool_size <=
; total free memory.
call TotalFreeMem ; make sure max_pool <= free mem size
shr eax, 10 ; in k
and al, 0F0h ; round down to nearest 16k
cmp eax, MAX_SIZE
jbe short cmp_max_to_free
mov ax, MAX_SIZE
cmp_max_to_free:
cmp ax, [max_pool_size]
jae short cmp_min
mov [max_pool_size], ax
cmp [max_pool_set], TRUE ; if max was explictly set, tell user
jne short cmp_min ; we changed it
or gs:[msg_flag], SIZE_ADJ_MSG
cmp_min:
cmp ax, [min_pool_size] ; check that min_pool <= free mem size
jae short in_range
mov [min_pool_size], ax
cmp [min_pool_set], TRUE
jne short in_range
or gs:[msg_flag], SIZE_ADJ_MSG
in_range:
ifdef ROMcomp
IE_ROMcompress:
;
; If necessary, fix all ROM pointers
;
call FixROMptrs
endif
;
; Get DMA buffer and initialize for virtualizing DMA chips
;
IE_DMABuffer:
call DMAInit ; initialize DMA support
test gs:[msg_flag],KILLER_MSG;Q: Enough memory?
jz short IE_InitVDM ; Y: init VDM
jmp IE_exit ; N: do not load
;
; Init VDM - GDT,IDT,TSS,Page Tables, WEITEK
;
IE_InitVDM:
call VDM_Init
test gs:[msg_flag],KILLER_MSG ;Q: any killer messages?
JNZ IE_exit ; Y: exit
;
; Allocate work space and update GDT entries.
;
IE_InitWS:
call WSInit
test gs:[msg_flag],KILLER_MSG ;Q: any killer messages?
JNZ IE_exit ; Y: exit
IE_InitPool:
call GetEMSPool
test gs:[msg_flag],KILLER_MSG ;Q: any killer messages?
JNZ IE_exit ; Y: exit
;
; init EMM data
;
IE_InitEMM:
call EMM_Init
test gs:[msg_flag],KILLER_MSG ;Q: any killer messages?
ifdef BugMode
jz short IE_MoveWS ; N: move work space
else
jz short IE_InitDEB ; N: init debugger
endif
jmp IE_exit ; Y: exit
ifndef BugMode
;
; initailize variables for debugger
;
IE_InitDEB:
ifndef DEBUG
;call InitDeb
endif
endif
;
; Move work space up to extended memory.
;
IE_MoveWS:
call WSMove
test gs:[msg_flag],KILLER_MSG ;Q: any killer messages?
JNZ IE_exit ; Y: exit
IFDEF QHKN
IE_chkbase:
call MoveExtBIOS ; move extended BIOS data area
xor eax,eax ; clear high order word
int 12h ; get base memory size
push ax ; save it
; The end of the driver's resident part is rounded up to
; a 1k boundary.
mov ax,cs:[EndDriver]
add ax,40h - 1
shr eax,6
add ax,DOS3X_ADJ + 64 ; add in dos 3.xx adjustment and 64k
pop dx ; get base memory back
cmp dx,ax ; q: do we have enough?
jae short IE_setbrk ; y: continue
or gs:[msg_flag],MEM_ERR_MSG ; n: set memory error
jmp short IE_exit ; and exit
;
; set driver break addr in Init Request Header
;
IE_setbrk:
mov bx,[bp+2] ; get entry DS from stack
mov es,bx
assume es:ABS0
mov bx,[bp+10] ; ES:BX pts to req hdr
mov ES:[bx.BRK_OFF],10h ; set it
mov ax,cs:[EndDriver] ; get brk addr segment
mov ES:[bx.BRK_SEG],ax ; set it
ENDIF
;
; Allocate all extended memory used
;
xor eax,eax ; normal allocation
call MemExit ; allocate all memory
call dword ptr gs:[checkXMMFar] ; check XMM status
ifdef BugMode
;
; initialize debugger before going to virtual/protected mode
;
mov al,0FFh
call InitDeb
endif
;
; Check exit status of VDM/CEMM
; and set CEMM active/inactive depending on the
; mode (ON/OFF/AUTO) selected by the user.
; In Auto Mode,
; Weitek mapped => always ON.
;
; default to inactive
mov gs:[Auto_State],0 ; default to AUTO & inactive
and gs:[Current_State],NOT fState_Active
; Weitek mapped ?
test gs:[Weitek_State],fWeitek_Map ;Q: Weitek mapping selected?
jz short IE_InitState ; N: AUTO => inactive
or gs:[Auto_State],fAuto_Weitek ; Y: AUTO => active
IE_InitState:
mov al,gs:[Initial_Mode] ; get initial mode
mov gs:[Current_Mode],al ; set it
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?