📄 cstart.asm
字号:
; File : $Workfile: CSTART.ASM$
;
; 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$
; CSTART.ASM 1.2 97/03/21 15:01:01
; Added /n option to disable critical error handler
; CSTART.ASM 1.38 94/12/21 10:45:05
; Reduced Heap size to 860h just to be sure.
; CSTART.ASM 1.34 94/03/29 16:10:05
; _docmd_int2f returns 1 or 0 depending on whether or not the command
; is accepted.
; CSTART.ASM 1.31 93/11/18 18:50:18
; Fix HMA registration problem
; CSTART.ASM 1.30 93/11/09 00:00:14
; Shorten _ge_config_env
; CSTART.ASM 1.28 93/11/05 00:54:25
; move HMA registration code to where it's actually executed
; CSTART.ASM 1.27 93/11/04 23:39:11
; Fix problem with resident data relocation code
; CSTART.ASM 1.26 93/11/04 20:06:09
; int2E_far_entry now does CLI and STI the correct way round when loading
; SS and SP.
; CSTART.ASM 1.25 93/10/24 13:13:34
; Added strategy 'best fit upper mem'' & link upper mem'
; put_resident_high()
; CSTART.ASM 1.24 93/09/10 15:56:46
; CLS checks for ANSI using Int 2F/1A00
; CSTART.ASM 1.23 93/08/26 09:40:50
; Now use PSP for stack during func 4b exec. There's some debug
; code in case things screw up.
; CSTART.ASM 1.21 93/08/03 10:04:18
; Stopped using memory above A000 for transient portion because the
; stack was disappearing when MEMMAX -V executed.
; CSTART.ASM 1.20 93/07/05 08:35:00
; Now switch to a stack located at the top of conventional memory before
; calling INT 21 ah=4B.
; CSTART.ASM 1.19 93/05/24 11:38:22
; alloc_com_memory now allocates copy buffer by allocating largest possible
; block then shrinking it to the correct size. This prevents the buffer
; being located in upper memory after a HILOAD.
; CSTART.ASM 1.16 93/02/24 17:42:01
; int10_cls() no longer checks position of INT 29 vector.
; CSTART.ASM 1.12 92/11/17 14:26:40
; Change to set_reload_file to allow switches on COMSPEC line.
; CSTART.ASM 1.10 92/09/17 11:31:43
; INT 2e DS=SI=0 now works when we are relocated.
; CSTART.ASM 1.9 92/09/11 10:45:36
; our_cmd_int2f altered so we can support multi-line macros in DOSKEY.
; CSTART.ASM 1.8 92/08/06 09:55:22
; Correctly support INT 2F AH=AEh for EDOS. See _cmd_line_int2f.
; Int 2E DS=SI=0 causes batch processing to halt.
; CSTART.ASM 1.7 92/07/20 17:13:44
; Added the following maintanence source code changes:
; 29 Apr 92 Now sets Novell error mode to 00 on entry, and restores
; ; original mode on exit.
; 18 May 92 Added routine get_original_envsize, to use as default if
; ; /E option not used
; ENDLOG
page 62,132
title COMMAND.COM Startup Routines and Resident Section
;
; 7 Nov 87 Force the initial PATH specification to the root of the
; boot drive. Also add a new variable TEMPDRV which is
; Concurrents Temporary Drive.
;
; 10 Dec 87 If DRNET has been loaded then add the DRNET=x.x string to
; the initial environment.
; 25 Feb 88 Run the 2nd Phase RSP's before spawning the remaining TMPs
; 1 Mar 88 Initialize the AUTOLOGON and NODE variables for diskless
; workstation support. Support the NODE environment variable
; 21 Mar 88 Allow for all registers to be corrupted on return from the
; DOS EXEC function call.
; 5 Apr 88 Correctly handle incorrect command line length passed by
; FrameWork Install Program
; 13 Apr 88 Move Memory allocation code to DOSIF and initialise the
; default console in PD for SunRiver.
; 10 May 88 Clean-Up the segment grouping and force the CGROUP to be
; linked after the data for everything but the TMP. Add the
; INT10_CLS function for DOSPLUS
; 12 May 88 Cater for DesqView passing an environment segment of 0000
; 13 May 88 Alter FCB build to giver F & RED when /FRED typed in For FS.COM
; 19 May 88 Prevent CODE being moved to high memory if loaded as an .EXE
; or no initial environment is supplied
; 20 May 88 Move reload messages into the MESSAGE.C file.
; 24 May 88 Use the internal Critical Error handler and check for ABORT
; codes while in the Command Processor Code.
; 6 Jun 88 Move Command ReadLine down to resident code - so SK+ can
; overwrite the hi-mem portion.
; 16 Jun 88 VC_DATA now returns the Physical Console Number as well.
; 21 Jun 88 Add FARPTR routine which determines the correct segment to
; return to PRINTF based on the offset of a message.
; 22 Jun 88 remove environment & PSP setup & RSP spawning code
; for banked RSP support. Kludgey CDOS_EXEC code for banking
; 29 Jun 88 Modify MASTER_ENV so it can be called from C and change the
; exec code to use the internal FCB parsing.
; 30 Jun 88 Set the default PRINTER and AUX using the information in the
; INT17 and INT14 mapping arrays.
; 20 Jul 88 Increase HEAP Size to 0A00h for the TMP
; 9 Aug 88 Terminate the command line after a CR or LF for
; BitStream Fontware.
; 31 Aug 88 Make the READLINE function call from high memory so PolyTron
; PolyWindows can be invoked from the command line.
; 22 Sep 88 Always use INT_BREAK routine for Control Break Handling
; 03 Oct 88 Invalidate the Old Environment for Novell under CDOS.
; 09 Nov 88 Select the correct DR-DOS history Buffer.
; 15 Nov 88 Re-initilaise Interrupt handlers after an EXEC for Novell
; 21 Nov 88 Install Command Processor Backdoor but just terminate caller
; 13 Dec 88 Generate the FCBs for a DOS exec internally for compatibility
; with Novell Netware.
; 15 Dec 88 Force the default INT 22, 23, 24 and 2E handlers to be set
; relative to the PSP. Update PSP copies of interrupt 22, 23, 24
; if this is the root DOS process.
; 25 Jan 89 If new DRDOS internal data layout get the PD a new way
; 27 Feb 89 fix MAKE_FCB, use SI from F_PARSE if possible
; 15 Apr 89 INT2E handler
; 17 Apr 89 int10_cls: don't return to 25 lines if in 43 or 50 line mode
; 31 May 89 DRDOS get PD using new f4458 backdoor
; 6 Jun 89 int2e: amend our copy of command, not users command
; 19 Jun 89 Remove "Alternative" methods of getting PD address
; 14 Jul 89 SideKick Plus checksum only done if STDERR is to CON
; (so when LAPLINK does CTTY COM1 it goes quicker)
; 6 Sep 89 Call INT21/5D09,5D08 in readline
; 30 Oct 89 Throw away startup code (put it in STACK segment)
; 13 Nov 89 Relocate DRDOS resident code over command line/fcbs in PSP
; 30 Jan 90 in_exec is now incremented and decremented to allow
; novell menu program to exit successfully.
; 30 Jan 90 Added batch_seg_ptr before first occurance of string
; 'A:\COMMAND.COM' (reload_file). Novell uses it during
; remote boot.
; 31 Jan 90 restore_term_addr puts back old Int22/23/24 ready for
; an EXIT command (DESQview bug)
; If no environment make reload_file in root of default drive
; 7 Feb 90 Turn off HILOAD on DRDOS
; Add d2cgroupptr support routine (see COM.C)
; 27 Mar 90 turn history buffers to command when in readline, so COPY CON
; etc will use application buffers
; 30 Mar 90 Stop cleanly when we can't reload transient portion rather
; than overwriting other peoples memory and crashing
; 4 Apr 90 dbcs_init moved from DOSIF, use system table,
; throw away init code
; 12 Apr 90 changed for no inherited environment
; 18 Apr 90 add JW's changes to int10_cls to support JW's new VGA card
; 9 May 90 Int2E doesn't trash Int24, returns with CY clear
; 17 May 90 CLI/STI round stack swap in INT2E exit routine.
; 5 Jun 90 Int21/4458 checks CY before fetching PD, so if running on DOS
; we carry on into the C code which gives version error
; 12 Jun 90 master_env now leaves MS_M_STARTEGY alone, because Novell
; gets confused if it ends up high
; 3/Jul/90 DLS data into R_TEXT for Watcom C v7.0 (again - I originally
; did this on 20/Apr/90, but someone screwed up with the
; archive version managment).
; 2-Aug-90 RG-00- define LOGIN procedures for Stellar security
; 1-Sep-90 _msgfarptr added for DLS
; 13-Sep-90 COMSPEC=A:\COMMAND.COM even when CDOS.COM
; 21-Sep-90 Increase TMP heap size so we can save initial state for
; subsequent login's.
; 26-Sep-90 We now switch to our own psp during an INT 2Eh.
; This fixes bug experienced with NOVELL MENU.EXE on top of
; DR DOS 5.0.
; 11-Oct-90 CDOSTMP exec stashes unlinked MD in PSP for TSR auto-load
; 03-Dec-90 Stop corruption of DMD chain when allocating high memory for
; transient portion of command processor
; 11 dec 90 CDOS.COM switches to TMP history buffer
; 13 dec 90 save ES around TMP P_EXEC (DRNET sometimes trashes it)
; 17 dec 90 exec of CMD call io_pckbd with cl=40h (must be 24 line)
; 26/Feb/91 Increased _rld_msgs maximum text size from 100 to 120.
; 11/Mar/91 Added show_help function. COMMAND.COM is now really
; an EXE file with the help messages tagged onto the end.
; 25/Apr/91 Most of the resident code/data is now relocatable to high
; memory. Some Novell critical data is left in low memory.
; 15/May/91 Added dummy code to force at least one relocation item in
; .exe header so loader doesn't think file is EXEPACKed.
; 12/Jun/91 Added dummy code to allow Software Carousel to run.
; See int22_entry.
; 19 jun 91 disable control break until handler initialised
; 24/Jun/91 Changed memory allocation procedure on return from func 4B to
; allow Novell Remote Boot to work.
; 2 jul 91 our_cmd_int2f only has single parameter
; 26 jul 91 Novell dummy pipe filenames zero terminated
; 29 jul 91 A 1K far buffer is now allocated by alloc_com_memory. It is
; used by type, batch_read, and printf.
; 5 Aug 91 Call Get Extended Error (int 21 ah=59) after exec.
; 14 Aug 91 Put pointers to _batch, _batchflg, and _echoflg in low memory
; stub. This is primarily for Software Carousel.
; 4 Dec 91 Fixed problem with full environment trashing next DMD.
; 29 Apr 92 Rearranged DGROUP so that constant code and data appear after
; the stack - So that Multitasker need not save it.
; 10 Jun 92 show_help function now copes with doubled % characters.
;
;------------------------------------------------------------------------------
.xlist
include msdos.equ
include mserror.equ
include char.def
.list
; This is the offset in segment FFFF to which we will relocate.
; It is set to E0 to allow for a PCNFS bug
HISEG_OFF equ 0E0h
FALSE equ 0h
TRUE equ not FALSE
ThreeCOM equ TRUE
Copy_Buffer_Size equ 0C80h ; 50k of buffer space in paras
; matches MAX_COPYBUF in COMCPY.C
RLSTACK_SIZE equ 256+256 ; Reserve for ReadLine stack
; We need 260 bytes for possible
; buffer, plus a little stack
; If the stack overflows it isn't
; a disaster - we will just re-load
; COMMAND.COM
ifdef CDOSTMP
C_HEAP_SIZE equ 1200h ; C routine Heap Size - TMP has
else ; extra to save ENV in
;C_HEAP_SIZE equ 0800h ; C routine Heap Size
;endif ; (observed sizes 500h-600h - IJ)
C_HEAP_SIZE equ 0860h ; C routine Heap Size
; For safety increased that value as UNC filenames require 128 byte buffers
; allocated dynamically on tha stack. With respect to the observed sizes
; above it might be dangerous to leave that value at 0800h. I would have
; increased the value to 0A00 but then it does no longer fit into HMA. (JBM)
endif
ifdef DOSPLUS
include f52data.def
else
.xlist
include system.def
include pd.def
.list
XIOS_HISTBUF equ 44 ; Get the History Buffer Address
XIOS_PCKBD equ 32 ; Set keyboard/screen modes
NETMOD_BIT equ 040h ; Network Module in MODULE_MAP
; Concurrent DOS System Data Page Format
XIOS_ENTRY equ ds:dword ptr 0028h ; XIOS function Entry
CCPMSEG equ es:word ptr 0040h ; OS Starting Paragraph
MODULE_MAP equ es:byte ptr 0046h ; Concurrent Module Map
NVCNS equ es:byte ptr 0047h ; Number of Virtual Consoles
MFL equ es:word ptr 005Ah ; Memory Free List
RLR equ es:word ptr 0068h ; Ready List Root
VERSION equ es:word ptr 0078h ; OS Version String Offset
MWDR equ es:word ptr 0098h ; Memory Window Decriptor
BOOTDRV equ es:byte ptr 009Dh ; System Boot Drive
ENVSIZE equ es:word ptr 00B8h ; Environment Size Bytes
DRNET_NODE equ es:byte ptr 00BAh ; DR-NET Node Number
DRNET_FLAG equ es:byte ptr 00BB ; DR-NET Flags
V386_PTR equ es:word ptr 00C8h ; 386 Data pointer
CCBLIST equ es:word ptr 0C3Eh ; XIOS CCB$LIST
INT17_PTR equ es:word ptr 0C46h ; XIOS INT 17 Mapping Array
INT14_PTR equ es:word ptr 0C48h ; XIOS INT 14 Mapping Array
CCB_OWNER equ es:word ptr 0 ; CCB Owning Process
CCB_PCNS equ es:byte ptr 10 ; CCB Physical Console Number
CCB_VCNS equ es:byte ptr 11 ; CCB Virtual Console Number
MF_CODE equ 0004h ; MD flag bit
endif
;
; Standard definitions for PSP variable
;
PSP_TERM_IP equ es:word ptr 000Ah
PSP_PARENT equ es:word ptr 0016h
PSP_ENVIRON equ es:word ptr 002ch
ifndef DOSPLUS
; The following Macro takes one parameter which is the Concurrent DOS
; function number.
bdos MACRO func
ifnb <func>
mov cl,func
endif
int 224
ENDM
.xlist
include ccpm.equ
.list
endif
swap MACRO reg1, reg2
push reg1
push reg2
pop reg1
pop reg2
ENDM
page
ifdef CDOSTMP
;
; For the Concurrent DOS TMP the CGROUP segments are defined
; first so that the CGROUP appears first in the .EXE file and
; can be converted to a .COM by "RELOC" or "EXE2BIN". This .COM
; file is then converted to a .CMD by the COM2CMD utility which
; uses the data embeded at the start of the code to generate the
; right groups.
;
HGROUP GROUP HEADER
HEADER SEGMENT para public 'HEADER'
HEADER ENDS
DGROUP GROUP RSP_SEG,PD_SEG,UDA_SEG,NULL,EXEC_CODE,_DATA,DATA,CONST,FIXED,_BSS,HEAP,c_common,STACK,DYNAMIC
RSP_SEG SEGMENT para public 'CDOS_DATA'
RSP_SEG ENDS
PD_SEG SEGMENT para public 'CDOS_DATA'
PD_SEG ENDS
UDA_SEG SEGMENT para public 'CDOS_DATA'
UDA_SEG ENDS
NULL SEGMENT para public 'BEGDATA'
NULL ENDS
EXEC_CODE SEGMENT byte public 'DATA'
EXEC_CODE ENDS
_DATA SEGMENT byte public 'DATA'
_DATA ENDS
DATA SEGMENT byte public 'DATA'
DATA ENDS
CONST SEGMENT byte public 'CONST'
CONST ENDS
FIXED SEGMENT para public 'FDATA'
FIXED ENDS
_BSS SEGMENT word public 'BSS'
_BSS ENDS
HEAP SEGMENT word public 'BSS'
HEAP ENDS
c_common SEGMENT byte public 'BSS'
c_common ENDS
STACK SEGMENT para public 'BSS'
STACK ENDS
DYNAMIC SEGMENT para public 'DDATA'
DYNAMIC ENDS
endif
ifndef CDOSTMP
; The following declarations declare the presence and order of
; various data segments within the DATA Group of the command
; processor.
;
DGROUP GROUP R_TEXT, ED_TEXT, NULL, _DATA, DATA, CONST, FIXED, _BSS, HEAP, c_common, STACK, DYNAMIC
R_TEXT SEGMENT para public 'CDOS_DATA'
R_TEXT ENDS
NULL SEGMENT byte public 'BEGDATA'
NULL ENDS
_DATA SEGMENT byte public 'DATA'
_DATA ENDS
DATA SEGMENT byte public 'DATA'
DATA ENDS
CONST SEGMENT byte public 'CONST'
CONST ENDS
FIXED SEGMENT byte public 'FDATA'
FIXED ENDS
_BSS SEGMENT byte public 'BSS'
_BSS ENDS
HEAP SEGMENT byte public 'BSS'
HEAP ENDS
c_common SEGMENT byte public 'BSS'
c_common ENDS
STACK SEGMENT word public 'STACK'
STACK ENDS
ED_TEXT SEGMENT para public 'CDATA'
Public ed_text_start
ed_text_start label byte
ED_TEXT ENDS
DYNAMIC SEGMENT para public 'DDATA'
DYNAMIC ENDS
endif
CGROUP GROUP _TEXT, _MSG, _TEXTEND
_TEXT SEGMENT para public 'CODE'
ifdef DLS
extrn _my_dls_init:far
endif
_TEXT ENDS
_MSG SEGMENT byte public 'CODE'
_MSG ENDS
_TEXTEND SEGMENT para public 'CODE'
_TEXTEND ENDS
CEND GROUP ETEXT, ETEXTEND
ETEXT SEGMENT para public 'XEND'
ETEXT ENDS
ETEXTEND SEGMENT para public 'XEND'
ETEXTEND ENDS
codeOFFSET equ offset CGROUP:
dataOFFSET equ offset DGROUP:
endOFFSET equ offset CEND:
code_length equ codeOFFSET rlstack ; Total Code Length
real_code equ code_length - RLSTACK_SIZE
static_length equ dataOFFSET FIXED ; Static Data Length
dynamic_length equ dataOFFSET ed_text_start
total_length equ dataOFFSET DYNAMIC ; Total Data Length
cgroup_length equ codeOFFSET _TEXTEND
cend_length equ endOFFSET ETEXTEND
; help_length is an APPROXIMATE value, but it must be LARGER than the correct
; length of the help segment.
ifdef DLS
help_length equ 0A000h
else
help_length equ 05000h
endif
page
public __acrtused ; trick to force in startup
__acrtused = 9876h ; funny value not easily matched in SYMDEB
ifdef CDOSTMP
HEADER SEGMENT public 'HEADER'
dw 0EDCh ; Header Signature
dw offset HGROUP:CGROUP ; Code Group
dw real_code ; Real Code Size
dw offset HGROUP:DGROUP
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -