     1                                  ;	SCCSID = @(#)crit.asm	1.1 85/04/10
     2                                  ;TITLE CRIT - Critical Section Routines
     3                                  ;NAME  CRIT
     4                                  ;
     5                                  ; Critical Section Routines
     6                                  ;
     7                                  ;   Critical section handlers
     8                                  ;
     9                                  ;   Modification history:
    10                                  ;
    11                                  ;       Created: ARR 30 March 1983
    12                                  ;
    13                                  
    14                                  [list -]
    14          ******************       warning: redefining multi-line macro `struc' [-w+pp-macro-redef-multi]
    14                              <1> [list -]
    19                                  %include "dosseg.nas"
     1                              <1> ;	SCCSID = @(#)dosseg.asm	1.1 85/04/10
     2                              <1> ;	SCCSID = @(#)dosseg.asm	1.1 85/04/10
     3                              <1> ;
     4                              <1> ; segment ordering for MSDOS
     5                              <1> ;
     6                              <1> 
     7                              <1> %include "ddataseg.nas"
     1                              <2> 
     2                              <2> %include "lmacros3.mac"
     1                              <3> [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                                  
    24                                  global ECritDisk
    25                                  global ECritMem
    26                                  global ECritSFT
    27                                  global LCritDisk
    28                                  global LCritMem
    29                                  global LCritSFT
    30                                  
    31                                  ECritDisk:
    32                                  ECritMem:
    33                                  ECritSFT:
    34 00000000 53                      	push bx
    35 00000001 BB[0100]                	mov bx, patch_dosdata_EcritDisk
    36 00000004 EB10                    	jmp transfer_doscode_to_dosdata
    37                                  
    38                                  LCritDisk:
    39                                  LCritMem:
    40                                  LCritSFT:
    41 00000006 53                      	push bx
    42 00000007 BB[0900]                	mov bx, patch_dosdata_LcritDisk
    43 0000000A EB0A                    	jmp transfer_doscode_to_dosdata
    44                                  
    45                                  global ECritDevice
    46                                  global LCritDevice
    47                                  
    48                                  ECritDevice:
    49 0000000C 53                      	push bx
    50 0000000D BB[1100]                	mov bx, patch_dosdata_EcritDevice
    51 00000010 EB04                    	jmp transfer_doscode_to_dosdata
    52                                  
    53                                  LCritDevice:
    54 00000012 53                      	push bx
    55 00000013 BB[1900]                	mov bx, patch_dosdata_LcritDevice
    56                                  
    57                                  global transfer_doscode_to_dosdata
    58                                  
    59                                  transfer_doscode_to_dosdata:
    60                                   assume ds:nothing, es:nothing, ss:nothing
    61                                  	lframe 0
    62                                  	lpar word, in_ip_out_cs
    63                                  	lpar word, in_bx_out_ip
    64                                  	lpar word, in_ax_out_dosdata_retf
    65 00000016 50                      	 push ax			; ?in_ax = ax
    66 00000017 E81500                  	call doscode_getdosdata
    67                                  	lpar dword, transferto
    68 0000001A 50                      	 push ax			; ?transferto + 2 = DOSDATA
    69 0000001B 53                      	 push bx			; ?transferto = entrypoint
    70 0000001C 5589E5                  	lenter
    71 0000001F 8CCB                    	mov bx, cs
    72 00000021 875E0A                  	xchg bx, [bp + ?in_ip_out_cs]	; ?out_cs = cs
    73 00000024 875E08                  	xchg bx, [bp + ?in_bx_out_ip]	; ?out_ip = ip
    74                                  					; bx = ?in_bx
    75 00000027 B8[0000]                	mov ax, dosdata_retf
    76 0000002A 874606                  	xchg ax, [bp + ?in_ax_out_dosdata_retf]
    77                                  					; ?out_dosdata_retf = dosdata_retf
    78                                  					; ax = ?in_ax
    79 0000002D 5D                      	lleave , optimiserestoresp
    80 0000002E CB                      	retf				; branch to ?transferto,
    81                                  					; ?out_dosdata_retf and ?out_csip on stack
    82                                  
    83                                  global doscode_getdosdata
    84                                  doscode_getdosdata:
    85                                   assume ds:nothing
    86 0000002F 1E                      	push ds
    87 00000030 B80000                  	mov ax, 0
    88 00000033 8ED8                    	mov ds, ax			; ds => IVT
    89                                   assume ds:IVT
    90 00000035 A1C600                  	mov ax, [31h * 4 + 2]		; ds => DOSDATA
    91 00000038 1F                      	pop ds
    92                                   assume ds:nothing
    93 00000039 C3                      	retn
    94                                  
    95                                  
    96                                  section DOSDATACODE	; in DOSDATA
    97                                  
    98                                  dosdata_retf:
    99 00000000 CB                      	retf
   100                                  
   101                                  [list -]
   101          ******************       warning: out: ... for DOS Version 4.00 ... [-w+user]
   101          ******************       warning: out: BPB.INC... [-w+user]
   101          ******************       warning: out: ... CLONE version build switch on ... [-w+user]
   107                                  
   108                                  	I_need  User_In_AX,WORD
   109                                  	i_need  CurrentPDB,WORD
   110                                  %if debug
   111                                  	I_need  BugLev,WORD
   112                                  	I_need  BugTyp,WORD
   113                                  %include "bugtyp.nas"
   114                                  %endif
   115                                  
   116                                  Break   <Critical section handlers>
   117                                  
   118                                  ;
   119                                  ;   Each handler must leave everything untouched; including flags!
   120                                  ;
   121                                  ;   Sleaze for time savings:  first instruction is a return.  This is patched
   122                                  ;   by the sharer to be a PUSH AX to complete the correct routines.
   123                                  ;
   124                                  
   125                                  global patch_dosdata_EcritDisk
   126                                  patch_dosdata_EcritDisk:
   127 00000001 C3                      	RETn
   128                                  ;       PUSH    AX
   129                                  	fmt     TypSect,LevReq,<"PDB $x entering $x">,<CurrentPDB,sect>
   130 00000002 B80180                  	MOV     AX,8000h+critDisk
   131                                  int_ibm equ int_IBM	; NASM port equate
   132 00000005 CD2A                    	INT     int_ibm
   133 00000007 58                      	POP     AX
   134 00000008 C3                      	retn
   135                                  
   136                                  global patch_dosdata_LcritDisk
   137                                  patch_dosdata_LcritDisk:
   138 00000009 C3                      	RETn
   139                                  ;       PUSH    AX
   140                                  	fmt     TypSect,LevReq,<"PDB $x entering $x">,<CurrentPDB,sect>
   141 0000000A B80181                  	MOV     AX,8100h+critDisk
   142 0000000D CD2A                    	INT     int_ibm
   143 0000000F 58                      	POP     AX
   144 00000010 C3                      	retn
   145                                  
   146                                  global patch_dosdata_EcritDevice
   147                                  patch_dosdata_EcritDevice:
   148 00000011 C3                      	RETn
   149                                  ;       PUSH    AX
   150                                  	fmt     TypSect,LevReq,<"PDB $x entering $x">,<CurrentPDB,sect>
   151 00000012 B80280                  	MOV     AX,8000h+critDevice
   152 00000015 CD2A                    	INT     int_ibm
   153 00000017 58                      	POP     AX
   154 00000018 C3                      	retn
   155                                  
   156                                  global patch_dosdata_LcritDevice
   157                                  patch_dosdata_LcritDevice:
   158 00000019 C3                      	RETn
   159                                  ;       PUSH    AX
   160 0000001A B80281                  	MOV     AX,8100h+critDevice
   161 0000001D CD2A                    	INT     int_ibm
   162 0000001F 58                      	POP     AX
   163 00000020 C3                      	retn
   164                                  
   165                                      END
