kernel, main: add debugger_present variable and skip ints 0, 1, 3, 6

Also adds a CheckDebugger byte to the CONFIG block and
support for reading and writing this setting in the
SYS CONFIG program. Default is 0 (no check assume absent).
This commit is contained in:
C. Masloch 2022-05-21 15:22:48 +02:00 committed by Kenneth J Davis
parent 7ff6c06814
commit 49733547f1
4 changed files with 48 additions and 7 deletions

View File

@ -46,4 +46,8 @@ typedef struct _KernelConfig {
unsigned short Version_Revision;
unsigned short Version_Release;
unsigned char CheckDebugger;
/* 0 = do not check (assume absent),
1 = do check by running breakpoint,
2 = assume present */
} KernelConfig;

View File

@ -76,6 +76,7 @@ Version_Major db 2
Version_Revision dw 41 ; REVISION_SEQ
Version_Release dw 1 ; 0=release build, >0=svn#
CheckDebugger: db 0 ; 0 = no check, 1 = check, 2 = assume present
configend:
kernel_config_size: equ configend - config_signature
; must be below-or-equal the size of struct _KernelConfig
@ -253,6 +254,25 @@ extern _InitKernelConfig
%endif
mov ds, ax ; => init data segment
check_debugger_present:
extern _debugger_present
mov al, 1 ; assume debugger present
cmp byte [di - kernel_config_size + (CheckDebugger - config_signature)], 1
ja .skip_ints_00_06 ; 2 means assume present
jb .absent ; 0 means assume absent
clc ; 1 means check
int3 ; break to debugger
jc .skip_ints_00_06
; The debugger should set CY here to indicate its
; presence. The flag set is checked later to skip
; overwriting the interrupt vectors 00h, 01h, 03h,
; and 06h. This logic is taken from lDOS init.
.absent:
xor ax, ax ; no debugger present
.skip_ints_00_06:
mov byte [_debugger_present], al
jmp _FreeDOSmain
%if XCPU != 86

View File

@ -69,6 +69,9 @@ __segment DosTextSeg = 0;
struct lol FAR *LoL = &DATASTART;
struct _KernelConfig InitKernelConfig = { 0xFF };
UBYTE debugger_present = 0xFF; /* initialised in kernel.asm
do NOT set 0 here or compiler may
move it into bss that we zero out */
VOID ASMCFUNC FreeDOSmain(void)
{
@ -235,10 +238,10 @@ STATIC void setup_int_vectors(void)
} vectors[] =
{
/* all of these are in the DOS DS */
{ 0x0, FP_OFF(int0_handler) }, /* zero divide */
{ 0x1, FP_OFF(empty_handler) }, /* single step */
{ 0x3, FP_OFF(empty_handler) }, /* debug breakpoint */
{ 0x6, FP_OFF(int6_handler) }, /* invalid opcode */
{ 0x80 | 0x0, FP_OFF(int0_handler) }, /* zero divide */
{ 0x80 | 0x1, FP_OFF(empty_handler) }, /* single step */
{ 0x80 | 0x3, FP_OFF(empty_handler) }, /* debug breakpoint */
{ 0x80 | 0x6, FP_OFF(int6_handler) }, /* invalid opcode */
{ 0x19, FP_OFF(int19_handler) }, /* BIOS bootstrap loader, vdisk */
{ 0x20, FP_OFF(int20_handler) },
{ 0x21, FP_OFF(int21_handler) }, /* primary DOS API */
@ -264,7 +267,8 @@ STATIC void setup_int_vectors(void)
setvec(i, empty_handler); /* note: int 31h segment should be DOS DS */
HaltCpuWhileIdle = 0;
for (pvec = vectors; pvec < vectors + (sizeof vectors/sizeof *pvec); pvec++)
setvec(pvec->intno, (intvec)MK_FP(FP_SEG(empty_handler), pvec->handleroff));
if ((pvec->intno & 0x80) == 0 || debugger_present == 0)
setvec(pvec->intno & 0x7F, (intvec)MK_FP(FP_SEG(empty_handler), pvec->handleroff));
pokeb(0, 0x30 * 4, 0xea);
pokel(0, 0x30 * 4 + 1, (ULONG)cpm_entry);

View File

@ -13,7 +13,7 @@
* merged into SYS by tom ehlert *
***************************************************************************/
char VERSION[] = "v1.02";
char VERSION[] = "v1.03";
char PROGRAM[] = "SYS CONFIG";
char KERNEL[] = "KERNEL.SYS";
@ -93,7 +93,8 @@ void showUsage(void)
printf(" Current Options are: DLASORT=0|1, SHOWDRIVEASSIGNMENT=0|1\n"
" SKIPCONFIGSECONDS=#, FORCELBA=0|1\n"
" GLOBALENABLELBASUPPORT=0|1\n"
" BootHarddiskSeconds=0|seconds to wait\n");
" BootHarddiskSeconds=0|seconds to wait\n"
" CheckDebugger=0|1|2\n");
}
/* simply reads in current configuration values, exiting program
@ -215,6 +216,13 @@ void displayConfigSettings(KernelConfig * cfg)
cfg->BootHarddiskSeconds);
}
if (cfg->ConfigSize >= 13)
{
printf
("CheckDebugger=%d : *0=no, 1=check, 2=assume\n",
cfg->CheckDebugger);
}
#if 0 /* we assume that SYS is as current as the kernel */
/* Print value any options added that are unknown as hex dump */
@ -482,6 +490,11 @@ int FDKrnConfigMain(int argc, char **argv)
setSByteOption(&(cfg.BootHarddiskSeconds),
cptr, 0, 127, &updates, "BootHarddiskSeconds");
}
else if (memicmp(argptr, "CheckDebugger", 5) == 0)
{
setByteOption(&(cfg.CheckDebugger),
cptr, 2, &updates, "CheckDebugger");
}
else
{
illegal_arg: