     1                                  ;    File              : $SUPPORT.A86$
     2                                  ;
     3                                  ;    Description       :
     4                                  ;
     5                                  ;    Original Author   : DIGITAL RESEARCH
     6                                  ;
     7                                  ;    Last Edited By    : $CALDERA$
     8                                  ;
     9                                  ;-----------------------------------------------------------------------;
    10                                  ;    Copyright Work of Caldera, Inc. All Rights Reserved.
    11                                  ;      
    12                                  ;    THIS WORK IS A COPYRIGHT WORK AND CONTAINS CONFIDENTIAL,
    13                                  ;    PROPRIETARY AND TRADE SECRET INFORMATION OF CALDERA, INC.
    14                                  ;    ACCESS TO THIS WORK IS RESTRICTED TO (I) CALDERA, INC. EMPLOYEES
    15                                  ;    WHO HAVE A NEED TO KNOW TO PERFORM TASKS WITHIN THE SCOPE OF
    16                                  ;    THEIR ASSIGNMENTS AND (II) ENTITIES OTHER THAN CALDERA, INC. WHO
    17                                  ;    HAVE ACCEPTED THE CALDERA OPENDOS SOURCE LICENSE OR OTHER CALDERA LICENSE
    18                                  ;    AGREEMENTS. EXCEPT UNDER THE EXPRESS TERMS OF THE CALDERA LICENSE
    19                                  ;    AGREEMENT NO PART OF THIS WORK MAY BE USED, PRACTICED, PERFORMED,
    20                                  ;    COPIED, DISTRIBUTED, REVISED, MODIFIED, TRANSLATED, ABRIDGED,
    21                                  ;    CONDENSED, EXPANDED, COLLECTED, COMPILED, LINKED, RECAST,
    22                                  ;    TRANSFORMED OR ADAPTED WITHOUT THE PRIOR WRITTEN CONSENT OF
    23                                  ;    CALDERA, INC. ANY USE OR EXPLOITATION OF THIS WORK WITHOUT
    24                                  ;    AUTHORIZATION COULD SUBJECT THE PERPETRATOR TO CRIMINAL AND
    25                                  ;    CIVIL LIABILITY.
    26                                  ;-----------------------------------------------------------------------;
    27                                  ;
    28                                  ;    *** Current Edit History ***
    29                                  ;    *** End of Current Edit History ***
    30                                  ;
    31                                  ;    $Log$
    32                                  ;    SUPPORT.A86 1.11 93/11/29 13:39:28
    33                                  ;    Don't rely on DS when return_ called
    34                                  ;    ENDLOG
    35                                  ;
    36                                  ;	The following Support routines are provided for both the 
    37                                  ;	handle and FCB functions which require critical error handler
    38                                  ;	support.
    39                                  ;
    40                                  ; 15 Jun 88 Modify the SYSDAT and SUPERVISOR variables to enable
    41                                  ;           the relocation of the BDOS into high memory
    42                                  ;  5 Jan 89 Only set PCKBD mode if we own the default console
    43                                  ;  9 Mar 89 Support a split PCMODE and SYSDAT Segments
    44                                  ; 22 Sep 89 LDT support routine added
    45                                  ; 29 Jan 90 Int 2A critical section support added to dpbdos_entry
    46                                  ;  7 Mar 90 Convert to register preserved function calls
    47                                  ;  4 May 90 DRDOS int3x handlers removed (they are pointed to IRET
    48                                  ;           in PCMODE_DATA by INIT.PCM)
    49                                  ; 12 Dec 90 keep error server number inverted so local = 0, more compatible
    50                                  
    51                                  ;
    52                                  
    53                                  group PCMDATA PCMODE_DATA FDOS_DSEG
    54                                  group PCMCODE PCM_CODE
    55                                  
    56                                  ASSUME DS:PCMDATA
    57                                  
    58                                  	[list -]
    64                                  
    65                                  section PCM_CODE public align=1 class=CODE
    66                                  	extrn	error_exit:near		; Standard Error Exit Routine
    67                                  	extrn	fcberror_exit:near	; Special FCB function Error Exit
    68                                  	extrn	fdos_entry:near
    69                                  	extrn	get_dseg:near
    70                                  
    71                                  ;
    72                                  ;	STRLEN determines the length of the string passed in DS:SI
    73                                  ;	and returns the byte length in CX.
    74                                  ;
    75                                  	Public	strlen
    76                                  strlen:
    77 00000000 06                      	push 	es
    78 00000001 57                      	push 	di
    79 00000002 1E                      	push 	ds
    80 00000003 07                      	pop 	es
    81 00000004 89F7                    	mov	di,si
    82 00000006 B9FFFF                  	mov	cx,0FFFFh
    83 00000009 28C0                    	sub	al,al
    84 0000000B F2AE                    	repnz	scasb	
    85 0000000D 5F                      	pop 	di
    86 0000000E 07                      	pop 	es
    87 0000000F F7D1                    	not	cx
    88 00000011 49                      	dec	cx
    89 00000012 C3                      	ret
    90                                  
    91                                  ;
    92                                  ;	This routine sets the address to be returned to by the 
    93                                  ;	FDOS when an error has occured and the RETRY request has been
    94                                  ;	made. The set_retry routine should be used as follows:-
    95                                  ;
    96                                  ;	mov	al,Valid Error Responses
    97                                  ;	call	set_retry
    98                                  ;	Init All FDOS Parameters
    99                                  ;	call	fdos_crit
   100                                  ;
   101                                  ; NB. For register model return with AX = dos_AL extended to 16 bit
   102                                  
   103                                  	Public	set_retry_RF
   104                                  set_retry_RF:
   105 00000013 B018                    	mov	al,OK_RF		; Valid to RETRY or FAIL
   106                                  ;	jmp	set_retry		; (the most common case)
   107                                  
   108                                  	Public	set_retry
   109                                  set_retry:
   110 00000015 A2[0000]                	mov	[valid_flg],al		; Save Valid Error Reponses
   111 00000018 8F06[0000]              	pop	word [retry_off]		; Save the Routine Address
   112 0000001C 8926[0000]              	mov	[retry_sp],sp		; and the Stack Pointer
   113 00000020 88E0                    	mov	al,ah			; get function number
   114 00000022 30E4                    	xor	ah,ah			; make it a word
   115 00000024 A3[0000]                	mov	[FD_FUNC],ax		; save it for the FDOS
   116 00000027 1E                      	push	ds
   117 00000028 53                      	push	bx
   118 00000029 C51E[0000]              	lds	bx,[int21regs_ptr]	; point to users registers
   119 0000002D 836716FE                	and	word [reg_FLAGS + bx],~ CARRY_FLAG
   120 00000031 8A07                    	mov	al,[reg_AL + bx]		; clear CY assuming we will succeed
   121 00000033 5B                      	pop	bx			;  and reload AL with entry value
   122 00000034 1F                      	pop	ds
   123 00000035 FF26[0000]              	jmp	near [retry_off]
   124                                  
   125                                  ;
   126                                  ;	The FDOS routine executes the CCP/M FDOS function using the 
   127                                  ;	static FDOS parameter block defined in the Data Segment.
   128                                  ;
   129                                  	Public	fdos_crit
   130                                  fdos_crit:
   131 00000039 E84300                  	call	fdos_nocrit
   132 0000003C 83F8A6                  	cmp	ax,ED_LASTERROR		; Compare against last error code
   133 0000003F 731D                    	 jnb	fdos_error		; if NOT below then is ERROR CODE
   134 00000041 09C0                    	or	ax,ax			; Reset the Carry Flag and Return
   135 00000043 C3                      	ret
   136                                  
   137                                  	Public	fdos_ax_crit
   138                                  fdos_ax_crit:
   139 00000044 E83800                  	call	fdos_nocrit
   140 00000047 83F8A6                  	cmp	ax,ED_LASTERROR		; Compare against last error code
   141 0000004A 7312                    	 jnb	fdos_error		; if NOT below then is ERROR CODE
   142 0000004C 09C0                    	or	ax,ax			; Reset the Carry Flag and Return
   143                                  ;	jmp	return_AX_CLC		; Save the Return Code
   144                                  
   145                                  	Public	return_AX_CLC
   146                                  return_AX_CLC:
   147                                  ;-------------
   148                                  ; On Entry:
   149                                  ;	AX to be returned to caller in AX
   150                                  ; On Exit:
   151                                  ;	ES:DI trashed
   152                                  ;
   153 0000004E 1E                      	push 	ds
   154 0000004F 57                      	push 	di
   155 00000050 36C53E[0000]            	lds	di,[ss:int21regs_ptr]
   156 00000055 8905                    	mov	[reg_AX + di],ax		; return AX to caller
   157 00000057 836516FE                	and	word [reg_FLAGS + di],~ CARRY_FLAG
   158 0000005B 5F                      	pop 	di
   159 0000005C 1F                      	pop 	ds
   160 0000005D C3                      	ret
   161                                  
   162                                  
   163                                  fdos_error:				; Process the Error
   164 0000005E 3B26[0000]              	cmp	sp,[retry_sp]		; Is the user expecting use to 
   165 00000062 7503                    	 jnz	fdos_e10		; return or use the default handler
   166 00000064 E9(0000)                	jmp	error_exit		; If CALLed then return with the error
   167                                  fdos_e10:				; to the calling routine.
   168 00000067 F9                      	stc
   169 00000068 C3                      	ret
   170                                  
   171                                  	Public	fcbfdos_crit
   172                                  fcbfdos_crit:
   173 00000069 E81300                  	call	fdos_nocrit
   174 0000006C 83F8A6                  	cmp	ax,ED_LASTERROR		; Compare against last error code
   175 0000006F 7303                    	 jnb	fcbfdos_error		; if NOT below then is ERROR CODE
   176 00000071 09C0                    	or	ax,ax			; Reset the Carry Flag and Return
   177 00000073 C3                      	ret
   178                                  
   179                                  fcbfdos_error:				; Process the Error
   180 00000074 3B26[0000]              	cmp	sp,[retry_sp]		; Is the user expecting use to 
   181 00000078 7503                    	 jnz	fcbfdos_e10		; return or use the default handler
   182 0000007A E9(0000)                	jmp	fcberror_exit		; If CALLed then return with the error
   183                                  fcbfdos_e10:				; to the calling routine.
   184 0000007D F9                      	stc
   185 0000007E C3                      	ret
   186                                  
   187                                  	Public	fdos_nocrit
   188                                  fdos_nocrit:
   189 0000007F BA[0000]                	mov	dx,offset fdos_data	; point to fdos parameter block
   190 00000082 1E                      	push 	ds
   191 00000083 06                      	push 	es
   192 00000084 56                      	push 	si
   193 00000085 57                      	push 	di
   194 00000086 55                      	push 	bp
   195 00000087 E8(0000)                	call	fdos_entry		; BDOS module entry point
   196 0000008A 09C0                    	or	ax,ax			; Set the Flags
   197 0000008C 5D                      	pop  	bp
   198 0000008D 5F                      	pop  	di
   199 0000008E 5E                      	pop  	si
   200 0000008F 07                      	pop 	es
   201 00000090 1F                      	pop  	ds
   202 00000091 C3                      	ret
   203                                  
   204                                  
   205                                  	Public	reload_ES
   206                                  reload_ES:
   207                                  ; On Entry:
   208                                  ;	None
   209                                  ; On Exit:
   210                                  ;	ES = callers ES
   211                                  ;	All regs preserved
   212                                  ;
   213 00000092 53                      	push	bx
   214 00000093 36C41E[0000]            	les	bx,[ss:int21regs_ptr]
   215 00000098 268E4710                	mov	es,[es:reg_ES + bx]	; reload with callers ES
   216 0000009C 5B                      	pop	bx
   217 0000009D C3                      	ret
   218                                  
   219                                  	
   220                                  	Public	return_BX
   221                                  return_BX:
   222                                  ;---------
   223                                  ; On Entry:
   224                                  ;	BX to be returned to caller in BX
   225                                  ; On Exit:
   226                                  ;	All regs preserved
   227                                  ;
   228 0000009E 1E                      	push 	ds
   229 0000009F 56                      	push 	si
   230 000000A0 36C536[0000]            	lds	si,[ss:int21regs_ptr]
   231 000000A5 895C02                  	mov	[reg_BX + si],bx		; return BX to caller
   232 000000A8 5E                      	pop 	si
   233 000000A9 1F                      	pop 	ds
   234 000000AA C3                      	ret
   235                                  
   236                                  	Public	return_CX
   237                                  return_CX:
   238                                  ;---------
   239                                  ; On Entry:
   240                                  ;	CX to be returned to caller in CX
   241                                  ; On Exit:
   242                                  ;	All regs preserved
   243                                  ;
   244 000000AB 1E                      	push 	ds
   245 000000AC 53                      	push 	bx
   246 000000AD 36C51E[0000]            	lds	bx,[ss:int21regs_ptr]
   247 000000B2 894F04                  	mov	[reg_CX + bx],cx		; return CX to caller
   248 000000B5 5B                      	pop 	bx
   249 000000B6 1F                      	pop 	ds
   250 000000B7 C3                      	ret
   251                                  
   252                                  	Public	return_DX
   253                                  return_DX:
   254                                  ;---------
   255                                  ; On Entry:
   256                                  ;	DX to be returned to caller in DX
   257                                  ; On Exit:
   258                                  ;	All regs preserved
   259                                  ;
   260 000000B8 1E                      	push 	ds
   261 000000B9 53                      	push 	bx
   262 000000BA 36C51E[0000]            	lds	bx,[ss:int21regs_ptr]
   263 000000BF 895706                  	mov	[reg_DX + bx],dx		; return DX to caller
   264 000000C2 5B                      	pop 	bx
   265 000000C3 1F                      	pop 	ds
   266 000000C4 C3                      	ret
   267                                  
   268                                  PCM_CODE	ends
   269                                  
   270                                  section PCMODE_DATA public align=2 class=DATA
   271                                  
   272                                  
   273                                  	extrn	current_psp:word
   274                                  	extrn	DBCS_tbl:word		; double byte character set table
   275                                  	extrn	int21regs_ptr:dword
   276                                  	extrn	retry_off:word
   277                                  	extrn	retry_sp:word
   278                                  	extrn	valid_flg:byte
   279                                  
   280                                  PCMODE_DATA	ends
   281                                  
   282                                  	end
   283                                  
