     1                                  ;	SCCSID = @(#)srvcall.asm	1.4 85/08/02
     2                                  ;TITLE SRVCALL - Server DOS call
     3                                  ;NAME  SRVCALL
     4                                  ;
     5                                  ; Server DOS call functions
     6                                  ;
     7                                  ;
     8                                  ;   $ServerCall
     9                                  ;
    10                                  ;   Modification history:
    11                                  ;
    12                                  ;	Created: ARR 08 August 1983
    13                                  ;
    14                                  
    15                                  [list -]
    15          ******************       warning: redefining multi-line macro `struc' [-w+pp-macro-redef-multi]
    14                              <4> [list -]
    14                              <3> [list -]
     3                              <2> 
     4                              <2> addsection DOSSTART, align=16 PUBLIC class=DOSSTART
     5                              <2> ; (no prior section) ; DOSSTART		ENDS
     6                              <2> 
     7                              <2> addsection DOSSTARTJUMP, align=1 PUBLIC class=START
     8                              <2> ; (no prior section) ; DOSSTARTJUMP		ENDS
     9                              <2> 
    10                              <2> addsection CONSTANTS, align=2 PUBLIC class=CONST
    11                              <2> ; (no prior section) ; CONSTANTS	ENDS
    12                              <2> 
    13                              <2> addsection DATA, align=2 PUBLIC class=DATA
    14                              <2> ; (no prior section) ; DATA		ENDS
    15                              <2> 
    16                              <2> addsection TABLE, align=2 PUBLIC class=TABLE
    17                              <2> ; (no prior section) ; TABLE		ENDS
    18                              <2> 
    19                              <2> addsection DOSDATATABLE, align=2 PUBLIC class=DOSDATACODE
    20                              <2> ; (no prior section) ; DOSDATATABLE		ENDS
    21                              <2> 
    22                              <2> addsection DOSDATACODE, align=1 PUBLIC class=DOSDATACODE
    23                              <2> ; (no prior section) ; DOSDATACODE		ENDS
    24                              <2> 
    25                              <2> addsection DOSBIODATA, align=2 PUBLIC class=DOSBIODATA
    26                              <2> 
    27                              <2> addsection LAST, align=16 PUBLIC class=LAST
    28                              <2> ; (no prior section) ; LAST		ENDS
    29                              <2> 
    30                              <2> group DOSGROUP DOSSTART DOSSTARTJUMP CONSTANTS DATA TABLE DOSDATATABLE DOSDATACODE DOSBIODATA LAST
     8                              <1> 
     9                              <1> %include "dcodeseg.nas"
     1                              <2> 
     2                              <2> %ifndef DCODESEGNAS
     3                              <2> %assign DCODESEGNAS 1
     4                              <2> 
     5                              <2> section DOSCODETABLE align=2 PUBLIC class=DOSCODE
     6                              <2> ; (no prior section) ; DOSCODETABLE		ENDS
     7                              <2> section DOSCODECODE align=1 PUBLIC class=DOSCODE
     8                              <2> ; (no prior section) ; DOSCODECODE		ENDS
     9                              <2> section DOSBIOCODE align=2 PUBLIC class=DOSCODE
    10                              <2> section BIOCODE	align=2 PUBLIC class=DOSCODE
    11                              <2> 
    12                              <2> %ifnidni DOSENTRYGROUP, DOSCODEGROUP
    13                              <2>  group DOSCODEGROUP DOSCODETABLE DOSCODECODE DOSBIOCODE BIOCODE
    14                              <2> %endif
    15                              <2> 
    16                              <2> %endif
    10                              <1> 
    11                              <1> section LAST
    12                              <1> ; (no prior section) ; LAST		ENDS
    20                                  
    21                                  [list +]
    22                                  section DOSCODECODE
    23                                  [list -]
    23          ******************       warning: out: ... for DOS Version 4.00 ... [-w+user]
    23          ******************       warning: out: BPB.INC... [-w+user]
    23          ******************       warning: out: ... CLONE version build switch on ... [-w+user]
    23          ******************       warning: out: DEVSYM.INC... [-w+user]
    30                                  
    31                                  %ifndef Installed
    32                                   %iassign Installed 0
    33                                  %endif
    34                                  
    35                                  %include "dpl.nas"
     1                              <1> ;	SCCSID = @(#)dpl.asm	1.1 85/04/10
     2                              <1> ;	SCCSID = @(#)dpl.asm	1.1 85/04/10
     3                              <1> DPL	STRUC
     4 00000000 ????                <1> DPL_AX	DW	?	; AX register
     5 00000002 ????                <1> DPL_BX	DW	?	; BX register
     6 00000004 ????                <1> DPL_CX	DW	?	; CX register
     7 00000006 ????                <1> DPL_DX	DW	?	; DX register
     8 00000008 ????                <1> DPL_SI	DW	?	; SI register
     9 0000000A ????                <1> DPL_DI	DW	?	; DI register
    10 0000000C ????                <1> DPL_DS	DW	?	; DS register
    11 0000000E ????                <1> DPL_ES	DW	?	; ES register
    12 00000010 ????                <1> DPL_reserved DW ?	; Reserved
    13 00000012 ????                <1> DPL_UID DW	?	; User (Machine) ID (0 = local macine)
    14 00000014 ????                <1> DPL_PID DW	?	; Process ID (0 = local user PID)
    15                              <1> DPL	ENDS
    36                                  
    37                                  %iassign Installed TRUE
    38                                  
    39                                  	i_need	USER_ID,WORD
    40                                  	i_need	PROC_ID,WORD
    41                                  	i_need	SaveBX,WORD
    42                                  	i_need	SaveDS,WORD
    43                                  	i_need	SWAP_START,BYTE
    44                                  	i_need	SWAP_ALWAYS,BYTE
    45                                  	i_need	SWAP_END,BYTE
    46                                  	I_Need	ThisSFT,DWORD
    47                                  	I_need	fSharing,BYTE
    48                                  	i_need	OpenBuf,128
    49                                  	I_Need	ExtErr,WORD
    50                                  	I_Need	ExtErr_Action,BYTE
    51                                  	I_Need	ExtErrPt,DWORD
    52                                  	I_Need	EXTERR_LOCUS,BYTE	; Extended Error Locus
    53                                  	i_need	JShare,DWORD
    54                                  	i_need	SWAP_AREA_TABLE,BYTE
    55                                  	i_need	SWAP_ALWAYS_AREA,DWORD
    56                                  	i_need	SWAP_ALWAYS_AREA_LEN,WORD
    57                                  	i_need	SWAP_AREA_LEN,WORD
    58                                  
    59                                  BREAK <ServerCall -- Server DOS call>
    60                                  
    61                                  section DOSCODETABLE
    62                                  Public SRVC001S,SRVC001E
    63                                  SRVC001S label byte
    64                                  
    65                                  	align 2, db 0
    66                                  DOSGroup equ DOSGROUP	; NASM port equate
    67                                  Server_Disp equ SERVER_DISP	; NASM port label
    68 00000000 [0500]                  ServerTab	DW	Server_Disp
    69 00000002 [4800]                  SERVERLEAVE	DW	ServerReturn
    70 00000004 00                      	db 0
    71 00000005 0B                      SERVER_DISP	DB	(SERVER_DISP_END-SERVER_DISP-1)/2
    72 00000006 [AD00]                  		DW	OFFSET SRV_CALL		; 0
    73 00000008 [4900]                  		DW	OFFSET COMMIT_ALL	; 1
    74 0000000A [7C00]                  		DW	OFFSET CLOSE_NAME	; 2
    75 0000000C [8700]                  		DW	OFFSET CLOSE_UID	; 3
    76 0000000E [8E00]                  		DW	OFFSET CLOSE_UID_PID	; 4
    77 00000010 [9500]                  		DW	OFFSET GET_LIST		; 5
    78 00000012 [EE00]                  		DW	OFFSET GET_DOS_DATA	; 6
    79 00000014 [0F01]                  		DW	OFFSET SPOOL_OPER	; 7
    80 00000016 [0F01]                  		DW	OFFSET SPOOL_OPER	; 8
    81 00000018 [0F01]                  		DW	OFFSET SPOOL_OPER	; 9
    82                                  D_setExtendedError equ D_SetExtendedError	; NASM port label
    83 0000001A [1D01]                  		DW	OFFSET D_setExtendedError   ; 10
    84                                  SERVER_DISP_END LABEL	BYTE
    85                                  
    86                                  SRVC001E label byte
    87                                  
    88                                  section DOSCODECODE
    89                                  
    90                                   assume nocheck, ss:DOSGROUP
    91                                  
    92                                  ; Inputs:
    93                                  ;	DS:DX -> DPL  (except calls 7,8,9)
    94                                  ; Function:
    95                                  ;	AL=0	Server DOS call
    96                                  ;	AL=1	Commit All files
    97                                  ;	AL=2	Close file by name (SHARING LOADED ONLY) DS:DX in DPL -> name
    98                                  ;	AL=3	Close all files for DPL_UID
    99                                  ;	AL=4	Close all files for DPL_UID/PID_PID
   100                                  ;	AL=5	Get open file list entry
   101                                  ;		    IN: BX File Index
   102                                  ;			CX User Index
   103                                  ;		    OUT:ES:DI -> Name
   104                                  ;			BX = UID
   105                                  ;		    CX = # locked blocks held by this UID
   106                                  ;	AL=6	Get DOS data area
   107                                  ;		    OUT: DS:SI -> Start
   108                                  ;			CX size in bytes of swap if indos
   109                                  ;			DX size in bytes of swap always
   110                                  ;	AL=7	Get truncate flag
   111                                  ;	AL=8	Set truncate flag
   112                                  ;	AL=9	Close all spool files
   113                                  ;	AL=10	SetExtendedError
   114                                  ;	AL=11	DOS4.00 Get DOS data area
   115                                  ;		    DS:SI -> swap table
   116                                  
   117                                  	procedure   D_ServerCall,NEAR
   117          ******************       warning: proc D_ServerCall... [-w+user]
   118                                  ASSUME	DS:NOTHING,ES:NOTHING
   119 00000000 3C07                    	CMP	AL,7
   120 00000002 7219                    	JB	SET_STUFF
   121 00000004 3C09                    	CMP	AL,9
   122 00000006 7627                    	JBE	NO_SET_ID		; No DPL on calls 7,8,9
   123 00000008 3C0B                    	CMP	AL,11				   ;IFS.			;AN000;
   124 0000000A 7511                    	JNZ	SET_STUFF			   ;IFS.			;AN000;
   125 0000000C BF[0000]                	MOV	DI,OFFSET SWAP_AREA_TABLE wrt DOSGROUP ;IFS.			;AN000;
   126 0000000F 16                      	PUSH	SS				   ;IFS.			;AN000;
   127 00000010 07                      	POP	ES				   ;IFS.			;AN000;
   128                                   assume es:DOSGROUP
   129 00000011 E8(0000)                	invoke	GET_USER_STACK			   ;IFS.			;AN000;
   130 00000014 8C440E                  	MOV	[SI + user_DS],ES 		   ;IFS.   ds:si -> swap tab	;AN000;
   131 00000017 897C08                  	MOV	[SI + user_SI],DI 		   ;IFS.			;AN000;
   132 0000001A E9(0000)                	transfer SYS_RET_OK			   ;IFS.			;AN000;
   133                                  SET_STUFF:
   134 0000001D 89D6                    	MOV	SI,DX			; Point to DPL with DS:SI
   135 0000001F 8B5C12                  	MOV	BX,[SI + DPL_UID]
   136 00000022 36891E[0000]            	MOV	[ss:USER_ID],BX		; Set UID
   137 00000027 8B5C14                  	MOV	BX,[SI + DPL_PID]
   138 0000002A 36891E[0000]            	MOV	[ss:PROC_ID],BX		; Set process ID
   139                                  NO_SET_ID:
   140 0000002F 2EFF36[0200]            	PUSH	word [cs:SERVERLEAVE]		; push return address
   141 00000034 2EFF36[0000]            	PUSH	word [cs:ServerTab]		; push table address
   142 00000039 50                      	PUSH	AX
   143 0000003A E8(0000)                	Invoke	TableDispatch
   144                                  errLoc_Unk equ errLOC_Unk	; NASM port equate
   145 0000003D 36C606[0000]01          	MOV	byte [ss:EXTERR_LOCUS],errLoc_Unk ; Extended Error Locus
   146 00000043 B001E9(0000)            	error	error_invalid_function
   147                                  ServerReturn:
   148 00000048 C3                      	return
   149                                  
   150                                  ; Commit - iterate through the open file list and make sure that the
   151                                  ; directory entries are correctly updated.
   152                                  
   153                                  COMMIT_ALL:
   154                                  ASSUME	DS:NOTHING,ES:NOTHING
   155 00000049 31DB                    	XOR	BX,BX			;   for (i=0; ThisSFT=getSFT(i); i++)
   156 0000004B 161F                    	Context DS
   157 0000004D E8(0000)                	EnterCrit   critSFT		; Gonna scan SFT cache, lock it down
   158                                  CommitLoop:
   159 00000050 53                      	SaveReg <BX>
   160 00000051 E8(0000)                	Invoke	SFFromSFN
   161 00000054 7220                    	JC	CommitDone
   162                                  sf_Ref_Count equ sf_ref_count	; NASM port equate
   163 00000056 26833D00                	CMP	word [ES:DI + sf_Ref_Count],0	;	if (ThisSFT->refcount != 0)
   164 0000005A 7416                    	JZ	CommitNext
   165 0000005C 26833DFF                	CMP	word [ES:DI + sf_Ref_Count],sf_busy  ; BUSY SFTs have god knows what
   166 00000060 7410                    	JZ	CommitNext		      ;   in them.
   167                                  ;	TEST	[ES:DI].sf_flags,sf_isnet
   168 00000062 E8(0000)                	invoke	Test_IFS_Remote 	;IFS.					;AN000;
   169 00000065 750B                    	JNZ	CommitNext		;  Skip Network SFTs so the SERVER
   170                                  					;	doesn't deadlock
   171 00000067 893E[0000]              	MOV	WORD PTR [ThisSFT],DI
   172 0000006B 8C06[0200]              	MOV	WORD PTR [ThisSFT+2],ES
   173 0000006F E8(0000)                	Invoke	DOS_Commit		;	    DOSCommit ();
   174                                  CommitNext:
   175 00000072 5B                      	RestoreReg  <BX>
   176 00000073 43                      	INC	BX
   177 00000074 EBDA                    	JMP	CommitLoop
   178                                  CommitDone:
   179 00000076 E8(0000)                	LeaveCrit   critSFT
   180 00000079 5B                      	RestoreReg  <BX>
   181 0000007A EB9E                    	transfer    Sys_Ret_OK
   182                                  
   183                                  CLOSE_NAME:
   184                                  ASSUME	DS:NOTHING,ES:NOTHING
   185                                  
   186                                  %if installed
   187 0000007C 36FF1E[1400]            	Call	far [ss:JShare + 5 * 4]
   188                                  %else
   189                                  	Call	MFTcloN
   190                                  %endif
   191                                  CheckReturns:
   192 00000081 7202                    	JC	func_err
   193 00000083 EBF5                    	transfer SYS_RET_OK
   194                                  func_err:
   195 00000085 EBBE                    	transfer SYS_RET_ERR
   196                                  
   197                                  CLOSE_UID:
   198                                  ASSUME	DS:NOTHING,ES:NOTHING
   199                                  
   200                                  %if installed
   201 00000087 36FF1E[0C00]            	Call	far [ss:JShare + 3 * 4]
   202                                  %else
   203                                  	Call	MFTclU
   204                                  %endif
   205 0000008C EBF3                    	JMP	CheckReturns
   206                                  
   207                                  CLOSE_UID_PID:
   208                                  ASSUME	DS:NOTHING,ES:NOTHING
   209                                  
   210                                  %if installed
   211 0000008E 36FF1E[1000]            	Call	far [ss:JShare + 4 * 4]
   212                                  %else
   213                                  	Call	MFTCloseP
   214                                  %endif
   215 00000093 EBEC                    	JMP	CheckReturns
   216                                  
   217                                  GET_LIST:
   218                                  ASSUME	DS:NOTHING,ES:NOTHING
   219                                  %if installed
   220 00000095 36FF1E[2400]            	Call	far [ss:JShare + 9 * 4]
   221                                  %else
   222                                  	Call	MFT_get
   223                                  %endif
   224 0000009A 72E9                    	JC	func_err
   225 0000009C E8(0000)                	invoke	get_user_stack
   226 0000009F 895C02                  	MOV	[SI + user_BX],BX
   227 000000A2 897C0A                  	MOV	[SI + user_DI],DI
   228 000000A5 8C4410                  	MOV	[SI + user_ES],ES
   229                                  SetCXOK:
   230 000000A8 894C04                  	MOV	[SI + user_CX],CX
   231 000000AB EBD6                    	transfer    SYS_RET_OK
   232                                  
   233                                  SRV_CALL:
   234                                  ASSUME	DS:NOTHING,ES:NOTHING
   235 000000AD 58                      	POP	AX			; get rid of call to $srvcall
   236 000000AE 1E56                    	SaveReg <DS,SI>
   237 000000B0 E8(0000)                	invoke	GET_USER_STACK
   238 000000B3 5F07                    	RestoreReg  <DI,ES>
   239                                   assume es:nothing
   240                                  ;
   241                                  ; DS:SI point to stack
   242                                  ; ES:DI point to DPL
   243                                  ;
   244 000000B5 E8(0000)                	invoke	XCHGP
   245                                  ;
   246                                  ; DS:SI point to DPL
   247                                  ; ES:DI point to stack
   248                                  ;
   249                                  ; We now copy the registers from DPL to save stack
   250                                  ;
   251 000000B8 56                      	SaveReg <SI>
   252 000000B9 B90600                  	MOV	CX,6
   253 000000BC F3A5                    	REP	MOVSW			; Put in AX,BX,CX,DX,SI,DI
   254 000000BE 47                      	INC	DI
   255 000000BF 47                      	INC	DI			; Skip user_BP
   256 000000C0 A5                      	MOVSW				; DS
   257 000000C1 A5                      	MOVSW				; ES
   258 000000C2 5E                      	RestoreReg  <SI>		; DS:SI -> DPL
   259 000000C3 8B04                    	MOV	AX,[SI + DPL_AX]
   260 000000C5 8B5C02                  	MOV	BX,[SI + DPL_BX]
   261 000000C8 8B4C04                  	MOV	CX,[SI + DPL_CX]
   262 000000CB 8B5406                  	MOV	DX,[SI + DPL_DX]
   263 000000CE 8B7C0A                  	MOV	DI,[SI + DPL_DI]
   264 000000D1 8E440E                  	MOV	ES,[SI + DPL_ES]
   265                                   assume es:nothing
   266 000000D4 FF7408                  	PUSH	word [SI + DPL_SI]
   267 000000D7 8E5C0C                  	MOV	DS,[SI + DPL_DS]
   268                                   assume ds:nothing
   269 000000DA 5E                      	POP	SI
   270 000000DB 368C1E[0000]            	MOV	[ss:SaveDS],DS
   271 000000E0 36891E[0000]            	MOV	[ss:SaveBX],BX
   272 000000E5 36C606[0000]FF          	MOV	byte [ss:fSharing],-1		; set no redirect flag
   273 000000EB E9(0000)                	transfer REDISP
   274                                  
   275                                  GET_DOS_DATA:
   276                                  ASSUME	DS:NOTHING,ES:NOTHING
   277 000000EE 36C43E[0000]            	LES	DI,[ss:SWAP_ALWAYS_AREA]	     ;IFS. get beginning addr of swap ;AC000;
   278 000000F3 368B16[0000]            	MOV	DX,[ss:SWAP_ALWAYS_AREA_LEN]    ;IFS. get swap always area len   ;AC000;
   279 000000F8 81E2FF7F                	AND	DX,7FFFH		     ;IFS. clear high bit	      ;AC000;
   280 000000FC 368B0E[0000]            	MOV	CX,[ss:SWAP_AREA_LEN]	     ;IFS. get swap len 	      ;AC000;
   281 00000101 E8(0000)                	invoke	GET_USER_STACK
   282 00000104 8C440E                  	MOV	[SI + user_DS],ES 	     ;	set user regs
   283 00000107 897C08                  	MOV	[SI + user_SI],DI 	     ;
   284 0000010A 895406                  	MOV	[SI + user_DX],DX 	     ;
   285 0000010D EB99                    	JMP	SetCXOK 		     ;				      ;AN000;
   286                                  
   287                                  SPOOL_OPER:
   288                                  ASSUME	DS:NOTHING,ES:NOTHING
   289                                  multNet equ MultNET	; NASM port equate
   290 0000010F 50B82511CD2F5B          	CallInstall NETSpoolOper,multNet,37,AX,BX
   291 00000116 7202                    	JC	func_err2
   292 00000118 EB91                    	transfer SYS_RET_OK
   293                                  func_err2:
   294 0000011A E9(0000)                	transfer SYS_RET_ERR
   295                                  
   296                                  Break	<$SetExtendedError - set extended error for later retrieval>
   297                                  
   298                                  ;
   299                                  ; $SetExtendedError takes extended error information and loads it up for the
   300                                  ; next extended error call.  This is used by interrupt-level proccessors to
   301                                  ; mask their actions.
   302                                  ;
   303                                  ;   Inputs: DS:SI points to DPL which contains all registers
   304                                  ;   Outputs: none
   305                                  ;
   306                                  
   307                                  D_SetExtendedError:
   308                                  	ASSUME	DS:NOTHING,ES:NOTHING
   309                                  dpl_AX equ DPL_AX	; NASM port equate
   310 0000011D 8B04                    	MOV	AX,[SI + dpl_AX]
   311                                  EXTERR equ ExtErr	; NASM port label
   312 0000011F 36A3[0000]              	MOV	[ss:EXTERR],AX
   313                                  dpL_di equ DPL_DI	; NASM port equate
   314 00000123 8B440A                  	MOV	AX,[SI + dpL_di]
   315 00000126 36A3[0000]              	MOV	WORD PTR [ss:ExtErrPt],AX
   316                                  dpL_ES equ DPL_ES	; NASM port equate
   317 0000012A 8B440E                  	MOV	AX,[SI + dpL_ES]
   318 0000012D 36A3[0200]              	MOV	WORD PTR [ss:ExtErrPt+2],AX
   319                                  dpL_BX equ DPL_BX	; NASM port equate
   320 00000131 8B4402                  	MOV	AX,[SI + dpL_BX]
   321                                  EXTERR_ACTION equ ExtErr_Action	; NASM port label
   322 00000134 36A3[0000]              	MOV	WORD PTR [ss:EXTERR_ACTION],AX
   323                                  dpL_CX equ DPL_CX	; NASM port equate
   324 00000138 8B4404                  	MOV	AX,[SI + dpL_CX]
   325 0000013B 368826[0000]            	MOV	[ss:EXTERR_LOCUS],AH
   326 00000140 C3                      	return
   327                                  EndProc D_ServerCall
   327          ******************       warning: ***** Possible stack size error in D_ServerCall ***** [-w+user]
   328                                  
   329                                      END
