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

📄 genercfg.a86

📁 一个dos操作系统DRDOS的源码
💻 A86
📖 第 1 页 / 共 5 页
字号:
;    File              : $GENERCFG.A86$
;
;    Description       :
;
;    Original Author   : DIGITAL RESEARCH
;
;    Last Edited By    : $CALDERA$
;
;-----------------------------------------------------------------------;
;    Copyright Work of Caldera, Inc. All Rights Reserved.
;      
;    THIS WORK IS A COPYRIGHT WORK AND CONTAINS CONFIDENTIAL,
;    PROPRIETARY AND TRADE SECRET INFORMATION OF CALDERA, INC.
;    ACCESS TO THIS WORK IS RESTRICTED TO (I) CALDERA, INC. EMPLOYEES
;    WHO HAVE A NEED TO KNOW TO PERFORM TASKS WITHIN THE SCOPE OF
;    THEIR ASSIGNMENTS AND (II) ENTITIES OTHER THAN CALDERA, INC. WHO
;    HAVE ACCEPTED THE CALDERA OPENDOS SOURCE LICENSE OR OTHER CALDERA LICENSE
;    AGREEMENTS. EXCEPT UNDER THE EXPRESS TERMS OF THE CALDERA LICENSE
;    AGREEMENT NO PART OF THIS WORK MAY BE USED, PRACTICED, PERFORMED,
;    COPIED, DISTRIBUTED, REVISED, MODIFIED, TRANSLATED, ABRIDGED,
;    CONDENSED, EXPANDED, COLLECTED, COMPILED, LINKED, RECAST,
;    TRANSFORMED OR ADAPTED WITHOUT THE PRIOR WRITTEN CONSENT OF
;    CALDERA, INC. ANY USE OR EXPLOITATION OF THIS WORK WITHOUT
;    AUTHORIZATION COULD SUBJECT THE PERPETRATOR TO CRIMINAL AND
;    CIVIL LIABILITY.
;-----------------------------------------------------------------------;
;
;    *** Current Edit History ***
;    *** End of Current Edit History ***
;
;    $Log$
;
;    GENERCFG.A86 1.51 93/12/02 00:15:06
;    When auto-sizing DEVICEHIGH requirements use EXE header info if present
;    GENERCFG.A86 1.49 93/11/29 14:10:29
;    Add NUMLOCK=ON/OFF support
;    GENERCFG.A86 1.48 93/11/28 15:32:22
;    Support HIBUFFERS in UMB's
;    GENERCFG.A86 1.47 93/11/22 15:45:11
;    Ignore [COMMON] statements
;    GENERCFG.A86 1.46 93/11/18 16:20:16
;    Add primitive multi-master checking
;    GENERCFG.A86 1.45 93/11/17 20:07:17
;    change history defaults
;    GENERCFG.A86 1.44 93/11/16 14:10:21
;    F5 has precedence over ?
;    GENERCFG.A86 1.42 93/11/08 17:37:06
;    Move INSTALLHIGH to before INSTALL, so it's now recognised
;    GENERCFG.A86 1.41 93/11/04 16:28:08
;    Cosmetic change - the preload name field now strips off "C:\" properly
;    GENERCFG.A86 1.40 93/11/03 22:52:14
;    Replace chardev test with one for zero units
;    GENERCFG.A86 1.39 93/11/03 18:21:16
;    disable CHARDEV test until it gets fixed
;    GENERCFG.A86 1.38 93/11/03 17:11:05
;    Preloaded compression drivers maybe loaded from C: when booting
;    from a diskette.    
;    GENERCFG.A86 1.37 93/10/29 19:42:51
;    DOS=UMB turns HIDOS on
;    GENERCFG.A86 1.36 93/09/28 19:54:52
;    Support "DEVICE?=" syntax, and "SWITCHES=/N"
;    GENERCFG.A86 1.35 93/09/02 22:35:16 
;    Add header to system allocations
;    GENERCFG.A86 1.32 93/08/02 14:46:21
;    hide preload drives from func_device
;    support INSTALLHIGH
;    GENERCFG.A86 1.30 93/07/29 14:47:15
;    Change SETVER method
;    GENERCFG.A86 1.28 93/07/20 22:32:07
;    default upper memory link = FFFF
;    ENDLOG


	include config.equ
	include	i:msdos.equ
	include i:char.def
	include	i:reqhdr.equ
	include	i:driver.equ
	include	i:fdos.equ
	include	i:f52data.def		; Function 52 DOS Data Area
	include	i:doshndl.def		; DOS Handle Structure Definition
	include i:country.def

TRUE	   	equ	0FFFFh		; value of TRUE
FALSE	   	equ	0		; value of FALSE

F5KEY		equ	3F00h		; keys returned by BIOS
F8KEY		equ	4200h		;  in boot_options

CGROUP		group	INITCODE, INITDATA, INITENV

INITCODE	CSEG	PARA 'INITCODE'

	extrn	whitespace:near
	extrn	build_cmd_tail:near
	extrn	device_init:near
	extrn	init_static_request:near
	extrn	block_device:near
	extrn	device_insert:near
if not ADDDRV
	extrn	nls_hook:near
	extrn	nls_unhook:near
endif

CONFIG_ERRLVL	equ	400h		; special 'CONFIG' error level

; config_process returns CF set if an error occurred during command file
; processing for ADDDRV.EXE

	Public config_process
config_process:		; Process CONFIG.SYS

	mov	save_sp,sp		; save SP for unstructured GOSUB's

if ADDDRV
	mov	error_flag,0
else
	mov	ax,offset envstart	; env buffer is para aligned
	mov	cl,4
	shr	ax,cl			; convert offset to paras
	mov	cx,ds
	add	ax,cx			; segment of env variables
	les	bx,drdos_ptr
	mov	es:DRDOS_ENVSEG[bx],ax	; tell COMMAND.COM where we are
	push ds ! pop es
endif

	mov	ah,MS_DRV_GET		; check whether we are loading from
	int	DOS_INT			;   drive C:
	cmp	al,2
	 je	preload_security
	push	ds
	mov	ah,32h			; get DOS parameter block
	mov	dl,3			; ensure drive C: is valid (no critical
	int	DOS_INT			;  errors)
	pop	ds
	cmp	al,0ffh			; skip if the drive is not valid
	 je	preload_stacker
	mov	alt_drive,1		; drive C: should be used also
	jmp	preload_stacker

preload_security:
	call	preload_device		; preload the SECURITY device driver

preload_stacker:
	mov	preload_file,offset stacker_file+2
	call	preload_device		; preload STACKER from default drive
	 jnc	preload_done

	mov	preload_file,offset dblspace_file+2
	call	preload_device		; STACKER failed, try DBLSPACE from default
	 jnc	preload_done

	cmp	alt_drive,0		; STACKER and DBLSPACE failed on A:,
	 je	preload_done		;   should we look on drive C:?

	mov	preload_file,offset stacker_file
	call	preload_device		; preload STACKER from drive C:
	 jnc	preload_done

	mov	preload_file,offset dblspace_file
	call	preload_device		; STACKER failed, try DBLSPACE from C:

preload_done:
	mov	ax,(MS_X_OPEN*256)+80h	; Open the configuration file
	mov	dx,offset cfg_file	; Try Opening the file DCONFIG.SYS
	int	DOS_INT			; if this fails then open CONFIG.SYS
	 jnc	cfg_20			; Found DCONFIG.SYS

if ADDDRV
	mov	si,dx
	mov	dx,offset err_no_command_file
	xor	al,al
	call	config_error
	jmps	cfg_exit
else
	mov	si,offset cfg_file+1
	mov	di,offset cfg_file
	call	copy_asciiz		; make DCONFIG.SYS = CONFIG.SYS
	
	mov	ax,(MS_X_OPEN*256)+80h	; Open the configuration file
	int	DOS_INT			; CONFIG.SYS
	 jc	cfg_exit		; Return on error without complaint
endif

cfg_20:
	mov	bx,ax			; get the CONFIG handle
	mov	ah,MS_X_CLOSE		; Close the CONFIG file
	int	DOS_INT

cfg_nextline:				; Read the next command line
	call	readline		; If Carry then Terminal Error
	 jc	cfg_exit		;  so Exit
	mov	ax,boot_options
cfg_continue:
	push	ax			; save query options
	call	scan			; Now Scan the command List 
	pop	ax			; recover query options
	 jc	cfg_error		; for a matching command name
	call	cfg_query		; prompt to see if we want it
	 jc	cfg_nextline
	call	CFG_FUNC[di]		; Execute the request command
	jmps	cfg_nextline		; and loop till the end of the file

cfg_error:
	mov	dx,offset bad_command	; Display a Bad command error msg
	mov	al,CR			; and the CR terminated string
	call	config_error		; then continue processing
	jmps	cfg_nextline		; Carry Returned On Error

cfg_exit:
	mov	sp,save_sp		; get back the real stack
	call	preload_complete	; move transcient code to final position
if ADDDRV
	cmp	error_flag,1		;Set CF if error flag is zero
	cmc				;Set CF if error flag is 1
endif
	ret


cfg_query:
; On Entry:
;	AX = boot_options key
;	SI -> command tail
;	DI -> CFG_
; On Exit:
;	CY set if we should skip command
;	SI/DI preserved
;
	push	si
	push	di
	test	CFG_FLAGS[di],CF_NOF	; are Function Keys allowed ?
;	clc				; if not process the command
	 jz $+5 ! jmp cfg_query90
	cmp	ax,F5KEY		; F5 bypasses CONFIG processing
	stc				;  so bypass this line
	 je	cfg_query90
	test	CFG_FLAGS[di],CF_QUERY	; specific QUERY request ?
	 jnz	cfg_query10
	cmp	ax,F8KEY		; should we prompt for everything ?
	clc				; if not process the command
	 jne	cfg_query90
cfg_query10:
	push	si
	mov	si,CFG_NAME[di]		; DS:SI -> command name we matched
cfg_query20:
	lodsb				; get character
	test	al,al			; zero terminated
	 jz	cfg_query30
	xchg	ax,dx			; DL= character
	mov	ah,MS_C_WRITE
	int	DOS_INT			; output the character
	jmps	cfg_query20		; "DEVICE"
cfg_query30:
	mov	dl,'='
	mov	ah,MS_C_WRITE
	int	DOS_INT			; "DEVICE="
	pop	si			; rest of command line
cfg_query40:
	lodsb
	cmp	al,CR			; is it the end of the line ?
	 je	cfg_query50		;  no, do another character
	xchg	ax,dx			; DL= character
	mov	ah,MS_C_WRITE
	int	DOS_INT			; output the character
	jmps	cfg_query40		; "DEVICE=FILENAME.SYS"
cfg_query50:
	mov	ah,MS_C_WRITESTR	; Output msg of form " (Y/N) ? "
	mov	dx,offset confirm_msg1
	int	DOS_INT			; do " ("
	mov	ah,MS_C_WRITE
	mov	dl,yes_char
	int	DOS_INT			; do "Y"
	mov	dl,'/'
	int	DOS_INT			; do "/"
	mov	dl,no_char
	int	DOS_INT			; do "N"
	mov	ah,MS_C_WRITESTR
	mov	dx,offset confirm_msg2
	int	DOS_INT			; do ") ? "
cfg_query60:
	call	wait_for_key		; wait until a key is pressed
	mov	al,default_query_char	; if we timeout default
	 jc	cfg_query70
	mov	ah,MS_C_RAWIN
	int	DOS_INT			; read a char
	test	al,al			; is it a function key ?
	 jnz	cfg_query70
	mov	ah,MS_C_RAWIN
	int	DOS_INT			; throw away function keys
    jmps    cfg_query60  
cfg_query70:
	push	ax			; save response
	mov	ah,MS_C_WRITE
	mov	dl,al
	int	DOS_INT			; echo the char
	mov	ah,MS_C_WRITESTR
	mov	dx,offset confirm_msg3	; "DEVICE=FILENAME.SYS (Y/N) ?"
	int	DOS_INT			; now do CR/LF to tidy up
	pop	ax
	call	toupper			; make response upper case
	cmp	al,yes_char		; is it yes ?
	 je	cfg_query90
	stc				; return CY set, skip this line
cfg_query90:
	pop	di
	pop	si
	ret


call_preload_entry:		; call the preload device driver back door
	push	ds		; all DBLSPACE calls destroy DS register
	callf	preload_entry
	pop	ds
	ret

preload_complete:		; CONFIG processing complete
	push	ds
	push	es
	mov	ax,4a11h		; DBLSPACE presence check
	xor	bx,bx
	int	2fh
	or	ax,ax
	 jnz	reloc_end
	test	dx,8000h		; is relocation already complete (may
	 jz	reloc_end		;   be done by HIDEVICE statement)
	mov	bx,0ffffh		; query the size of the transcient
	mov	ax,4a11h		;   portion
	int	2fh

	mov	cx,mem_current		; pull transcient portion down to low
	mov	es,cx			;   memory
	inc	cx
	mov	es:DMD_ID,'D'		; control block type is 'D' (device
	mov	es:DMD_PSP,cx		;   driver), owner is self
	mov	es:DMD_LEN,ax
	inc	ax			; control block overhead
	add	mem_current,ax
	mov	di,8			; copy the name to the control block
	mov	si,preload_file		; device filename
preload_complete10:
	lodsb				; get a character
	cmp	al,'\'			; have we found the '\' yet ?
	 jne	preload_complete10	; no, go swallow another character
	movsw ! movsw ! movsw ! movsw	; copy the 8 bytes
	mov	ax,es
	inc	ax			; segment address of free memory
	mov	es,ax
	mov	bx,0fffeh		; move transcient portion down
	mov	ax,4a11h
	int	2fh
reloc_end:
	pop	es
	pop	ds
	ret

PreloadFixup:
;------------
; On Entry:
;	None
; On Exit:
;	None
;	All regs preserved
;
	push	es
	push	bx
	push	ax
	mov	al,preload_drv		; get number of preload drives
	les	bx,func52_ptr
	sub	es:F52_PHYDRV[bx],al
	sub	es:F52_LASTDRV[bx],al
	pop	ax
	pop	bx
	pop	es
	ret

PreloadCleanup:
;--------------	
; On Entry:
;	None
; On Exit:
;	None
;
; inform DBLSPACE about each device driver
	push	ds
	push	es
	xor	ax,ax
	xchg	al,preload_drv		; get number of preload drives
	les	bx,func52_ptr
	add	es:F52_PHYDRV[bx],al
	add	es:F52_LASTDRV[bx],al
	mov	ax,4a11h		; DBLSPACE installation check
	xor	bx,bx
	int	2fh
	or	ax,ax
	 jnz	broadcast_exit
	test	dx,8000h		; initialisation complete?
	 jz	broadcast_exit
	mov	preload_drv,ch		; save # preload drives
	mov	dx,mem_max		; top of available memory
	mov	cx,mem_current		; base of available memory
	sub	dx,cx
	mov	ah,55h			; version number
	mov	al,dev_count		; number of new units installed
    mov bx,02h          
	callf	preload_entry
broadcast_exit:
	pop	es
	pop	ds
	ret

preload_device:			; preload disk compression driver before
				;   processing (D)CONFIG.SYS file
	mov	dx,preload_file
	mov	cx,mem_current		; next available segment address
	mov	es,cx
	inc	cx
	mov	es:DMD_ID,'D'		; control block type is 'D' (device
	mov	es:DMD_PSP,cx		;   driver), owner is self
	mov	di,8			; copy the name to the control block
	mov	si,dx			; device filename
preload_device10:
	lodsb				; get a character
	cmp	al,'\'			; have we found the '\' yet ?
	 jne	preload_device10	; no, go swallow another character
	movsw ! movsw ! movsw ! movsw	; copy the 8 bytes
	mov	ax,es
	inc	ax			; segment address of free memory
	mov	dev_load_seg,ax		; destination segment for EXEC call
	mov	dev_reloc_seg,ax	; relocation factor for .EXE drivers
	push	ax
	push ds ! pop es
	mov	bx,offset dev_epb	; ES:BX control structure
	mov	ax,(MS_X_EXEC * 256)+3
	int	DOS_INT
	pop	es			; ES:0 -> preload driver
	 jnc	load_ok
load_bad:
	jmp	preload_exit
load_ok:
	cmp	es:WORD PTR .12h,2e2ch	; preload device signature
	 jne	load_bad
	mov	preload_seg,es		; back door entry to preload driver
	cmp	es:word ptr .82h,6	; is it the old DBLSPACE driver ?
	 jne	load_new_dblspace
	mov	preload_ver,6		; yes, give it the old version
load_new_dblspace:
	mov	rel_unit,0		; reset driver relative unit no.
	mov	bx,offset request_hdr	; DS:BX static INIT request header
	mov	ax,mem_max		; highest segment available to the
	mov	ds:RH0_RESIDENT,0	;   driver
	mov	ds:RH0_RESIDENT+2,ax
	mov	ax,cs
	mov	es,ax
	push	ds
	call	init_static_request	; initialise remaining fields
    mov ax,cs:preload_ver   
	callf	preload_entry
	pop	ds
	 jc	preload_exit		; INIT function fails if CARRY set
	or	ax,ax			;   or AX != 0
	 jnz	preload_exit
;;	mov	ax,ds:RH0_RESIDENT	; end of resident portion (offset)
;;	add	ax,15			; convert offset to paragraph size
;;	mov	cl,4
;;	shr	ax,cl
;;	add	ax,ds:RH0_RESIDENT+2	; end of resident portion (segment)
;JS we should check that the source and destination do not overlap here!

	mov	bx,04h			; find the size of the transient code
	call	call_preload_entry
	sub	mem_max,ax		; move the top of available memory down

	mov	es,mem_max		; ES destination for relocatable code
	dec	mem_max			; last free segment address
	mov	bx,06h			; call driver to relocate code etc.
	call	call_preload_entry
    inc ax          
	mov	mem_current,ax		; update base of free TPA

	mov	es,preload_seg
	xor	di,di			; ES:DI -> preload driver
	mov	bx,offset request_hdr
	mov	al,ds:RH0_NUNITS
	test	al,al
	 jz	preload_char_dev
	add	preload_drv,al		; remember how many preloaded drives
	call	block_device		; setup the DPBs and other block structures

preload_char_dev:
	mov	cx,mem_current
	mov	ax,preload_seg
	sub	cx,ax			; CX = length of preload driver
	dec	ax
	mov	es,ax			; ES:0 -> "DMD" for preload driver
	mov	es:DMD_LEN,cx

⌨️ 快捷键说明

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