Skip to content

Commit 4d30943

Browse files
committed
rename byte [SDA + 25Ch] from _tsr to _term_type, fix int 24h rc
This fixes int 24h abort to set the return code to 200h. The ErrorMode misuse is apparently necessary, but was not sufficient to set the return code.
1 parent 4fea8ad commit 4d30943

File tree

6 files changed

+26
-19
lines changed

6 files changed

+26
-19
lines changed

kernel/entry.asm

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ segment HMA_TEXT
4141
extern _user_r
4242
extern _ErrorMode
4343
extern _InDOS
44+
extern _term_type
4445
%IFDEF WIN31SUPPORT
4546
extern _winInstanced
4647
%ENDIF ; WIN31SUPPORT
@@ -264,11 +265,11 @@ reloc_call_int21_handler:
264265
; NB: At this point, SS != DS and won't be set that way
265266
; until later when which stack to run on is determined.
266267
;
267-
int21_reentry:
268-
Protect386Registers
269268
mov dx,[cs:_DGROUP_]
270269
mov ds,dx
271-
270+
mov byte [_term_type], 0 ; reset termination type
271+
int21_reentry: ; entered here from int 24h abort, ds = dx => DGROUP
272+
Protect386Registers
272273
cmp ah,33h
273274
je int21_user
274275
cmp ah,50h
@@ -760,4 +761,6 @@ CritErrAbort:
760761
mov ax,4C00h
761762
mov [bp+reg_ax],ax
762763
sti
764+
mov byte [_term_type], 2 ; set int 24h abort error
765+
mov dx, ds
763766
jmp int21_reentry ; restart the system call

kernel/globals.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ extern BYTE
307307
ASM internal_data[], /* sda areas */
308308
ASM swap_always[], /* " " */
309309
ASM swap_indos[], /* " " */
310-
ASM tsr, /* true if program is TSR */
310+
ASM term_type, /* 0 normal, 1 ^C, 2 int 24h, 3 TSR */
311311
ASM break_flg, /* true if break was detected */
312312
ASM break_ena; /* break enabled flag */
313313
extern void FAR * ASM dta; /* Disk transfer area (kludge) */

kernel/inthndlr.c

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -811,7 +811,7 @@ VOID ASMCFUNC int21_service(iregs FAR * r)
811811
case 0x31:
812812
DosMemChange(cu_psp, lr.DX < 6 ? 6 : lr.DX, 0);
813813
return_code = lr.AL | 0x300;
814-
tsr = TRUE;
814+
term_type = 3; /* ecm: TSR terminate */
815815
return_user();
816816
break;
817817

@@ -1104,18 +1104,11 @@ VOID ASMCFUNC int21_service(iregs FAR * r)
11041104

11051105
/* End Program */
11061106
case 0x4c:
1107-
tsr = FALSE;
1108-
rc = 0;
1109-
if (ErrorMode)
1110-
{
1111-
ErrorMode = FALSE;
1112-
rc = 0x200;
1113-
}
1114-
else if (break_flg)
1115-
{
1107+
if (break_flg) {
11161108
break_flg = FALSE;
1117-
rc = 0x100;
1109+
term_type = 1;
11181110
}
1111+
rc = term_type << 8;
11191112
return_code = lr.AL | rc;
11201113
if (DosMemCheck() != SUCCESS)
11211114
panic("MCB chain corrupted");
@@ -1784,7 +1777,7 @@ VOID INRPT FAR int23_handler(int es, int ds, int di, int si, int bp,
17841777
int sp, int bx, int dx, int cx, int ax,
17851778
int ip, int cs, int flags)
17861779
{
1787-
tsr = FALSE;
1780+
term_type = 1;
17881781
return_mode = 1;
17891782
return_code = -1;
17901783
mod_sto(CTL_C);

kernel/kernel.asm

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -838,8 +838,12 @@ _Server_Call db 0 ;252 - Server call Func 5D sub 0
838838
; Pad to 05CCh
839839
times (25ch - ($ - _internal_data)) db 0
840840

841-
global _tsr ; used by break and critical error
842-
_tsr db 0 ;25C - handlers during termination
841+
global _term_type ; used by break and critical error
842+
_term_type db 0 ;25C - handlers during termination
843+
; ecm: 00h = normal terminate,
844+
; 01h = control-c terminate,
845+
; 02h = critical error abort,
846+
; 03h = TSR terminate
843847
db 0 ;25D - padding
844848
global term_psp
845849
term_psp dw 0 ;25E - 0??

kernel/procsupt.asm

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
extern _user_r
3535

3636
extern _break_flg ; break detected flag
37+
extern _term_type
3738
extern _int21_handler ; far call system services
3839

3940
%include "stacks.inc"
@@ -257,6 +258,12 @@ _spawn_int23:
257258
push ds ;; we need DGROUP
258259
mov ds, [cs:_DGROUP_]
259260
inc byte [_break_flg]
261+
mov byte [_term_type], 1
262+
; ecm: This is overwritten in the int 21h handler,
263+
; but is passed from the int 23h caller to the
264+
; terminate code in MS-DOS by writing this.
265+
; For us, break_flg is used in function 4Ch to
266+
; re-set term_type to 1 later.
260267
pop ds
261268

262269
xor ah, ah ;; clear ah --> perform DOS-00 --> terminate

kernel/task.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,7 @@ VOID return_user(void)
593593
/* might be a good idea to do that after closing
594594
but doesn't help NET either TE */
595595

596-
if (!tsr && p->ps_parent != cu_psp)
596+
if (term_type != 3 && p->ps_parent != cu_psp)
597597
{
598598
network_redirector(REM_CLOSEALL);
599599
for (i = 0; i < p->ps_maxfiles; i++)

0 commit comments

Comments
 (0)