Skip to content

Commit 634257b

Browse files
committed
add convenience switch to redirect debug output to COM port when building, update some debug prints to use our debug interface so print to COM port when enabled.
1 parent 192cccc commit 634257b

File tree

7 files changed

+35
-53
lines changed

7 files changed

+35
-53
lines changed

build.bat

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@ if NOT "%1" == "/?" goto start
66
echo ":-----------------------------------------------------------------------"
77
echo ":- Syntax: BUILD [-r] [fat32|fat16] [msc|wc|tc|tcpp|bc] [86|186|386] "
88
echo ":- [debug] [lfnapi] [/L #] [/D value] [list] [upx] [win] "
9+
echo ":- [com] [com# #] "
910
echo ":- option case is significant !! "
1011
echo ":- Note: Open Watcom (wc) is the preferred compiler "
12+
echo ":- com does debug output on COM2, whereas com# 0 for COM1 ... "
1113
echo ":-----------------------------------------------------------------------"
1214
goto end
1315

@@ -56,6 +58,14 @@ if "%1" == "lfnapi" set ALLCFLAGS=%ALLCFLAGS% -DWITHLFNAPI
5658
if "%1" == "win" set ALLCFLAGS=%ALLCFLAGS% -DWIN31SUPPORT
5759
if "%1" == "win" set NASMFLAGS=%NASMFLAGS% -DWIN31SUPPORT
5860

61+
if "%1" == "com" set ALLCFLAGS=%ALLCFLAGS% -DDEBUG_PRINT_COMPORT
62+
if "%1" == "com" set NASMFLAGS=%ALLCFLAGS% -DDEBUG_PRINT_COMPORT
63+
REM specify comport, default is COM2, 0=COM1, 1=COM2, 2=COM3
64+
if "%1" == "com#" set ALLCFLAGS=%ALLCFLAGS% -DDEBUG_PRINT_COMPORT %2
65+
if "%1" == "com#" set NASMFLAGS=%ALLCFLAGS% -DDEBUG_PRINT_COMPORT %2
66+
if "%1" == "com#" shift
67+
if "%1" == "com#" goto nextOption
68+
5969
if "%1" == "list" set NASMFLAGS=%NASMFLAGS% -l$*.lst
6070

6171
if "%1" == "/L" goto setLoadSeg

kernel/config.c

Lines changed: 14 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,6 @@
3131
#include "init-mod.h"
3232
#include "dyndata.h"
3333

34-
#ifdef VERSION_STRINGS
35-
static BYTE *RcsId =
36-
"$Id: config.c 1705 2012-02-07 08:10:33Z perditionc $";
37-
#endif
3834

3935
#ifdef DEBUG
4036
#define DebugPrintf(x) printf x
@@ -342,15 +338,9 @@ void PreConfig(void)
342338
{
343339
/* Initialize the base memory pointers */
344340

345-
#ifdef DEBUG
346-
{
347-
printf("SDA located at 0x%p\n", internal_data);
348-
}
349-
#endif
341+
DebugPrintf(("SDA located at 0x%p\n", internal_data));
350342
/* Begin by initializing our system buffers */
351-
#ifdef DEBUG
352-
/* printf("Preliminary %d buffers allocated at 0x%p\n", Config.cfgBuffers, buffers);*/
353-
#endif
343+
/* DebugPrintf(("Preliminary %d buffers allocated at 0x%p\n", Config.cfgBuffers, buffers));*/
354344

355345
LoL->sfthead = MK_FP(FP_SEG(LoL), 0xcc); /* &(LoL->firstsftt) */
356346
/* LoL->FCBp = (sfttbl FAR *)&FcbSft; */
@@ -362,18 +352,14 @@ void PreConfig(void)
362352

363353
LoL->CDSp = KernelAlloc(sizeof(struct cds) * LoL->lastdrive, 'L', 0);
364354

365-
#ifdef DEBUG
366-
/* printf(" FCB table 0x%p\n",LoL->FCBp);*/
367-
printf(" sft table 0x%p\n", LoL->sfthead);
368-
printf(" CDS table 0x%p\n", LoL->CDSp);
369-
printf(" DPB table 0x%p\n", LoL->DPBp);
370-
#endif
355+
/* DebugPrintf((" FCB table 0x%p\n",LoL->FCBp));*/
356+
DebugPrintf((" sft table 0x%p\n", LoL->sfthead));
357+
DebugPrintf((" CDS table 0x%p\n", LoL->CDSp));
358+
DebugPrintf((" DPB table 0x%p\n", LoL->DPBp));
371359

372360
/* Done. Now initialize the MCB structure */
373361
/* This next line is 8086 and 80x86 real mode specific */
374-
#ifdef DEBUG
375-
printf("Preliminary allocation completed: top at %p\n", lpTop);
376-
#endif
362+
DebugPrintf(("Preliminary allocation completed: top at %p\n", lpTop));
377363
}
378364

379365
/* Do second pass initialization: near allocation and MCBs */
@@ -443,9 +429,7 @@ void PostConfig(void)
443429

444430
/* Begin by initializing our system buffers */
445431
/* dma_scratch = (BYTE FAR *) KernelAllocDma(BUFFERSIZE); */
446-
#ifdef DEBUG
447-
/* printf("DMA scratchpad allocated at 0x%p\n", dma_scratch); */
448-
#endif
432+
/* DebugPrintf(("DMA scratchpad allocated at 0x%p\n", dma_scratch)); */
449433

450434
config_init_buffers(Config.cfgBuffers);
451435

@@ -462,12 +446,11 @@ void PostConfig(void)
462446

463447
LoL->CDSp = KernelAlloc(sizeof(struct cds) * LoL->lastdrive, 'L', Config.cfgLastdriveHigh);
464448

465-
#ifdef DEBUG
466-
/* printf(" FCB table 0x%p\n",LoL->FCBp);*/
467-
printf(" sft table 0x%p\n", LoL->sfthead->sftt_next);
468-
printf(" CDS table 0x%p\n", LoL->CDSp);
469-
printf(" DPB table 0x%p\n", LoL->DPBp);
470-
#endif
449+
/* DebugPrintf((" FCB table 0x%p\n",LoL->FCBp));*/
450+
DebugPrintf((" sft table 0x%p\n", LoL->sfthead->sftt_next));
451+
DebugPrintf((" CDS table 0x%p\n", LoL->CDSp));
452+
DebugPrintf((" DPB table 0x%p\n", LoL->DPBp));
453+
471454
if (Config.cfgStacks)
472455
{
473456
VOID FAR *stackBase =
@@ -1845,9 +1828,7 @@ STATIC BOOL LoadDevice(BYTE * pLine, char FAR *top, COUNT mode)
18451828
/* The device driver is paragraph aligned. */
18461829
eb.load.reloc = eb.load.load_seg = base;
18471830

1848-
#ifdef DEBUG
1849-
printf("Loading device driver %s at segment %04x\n", szBuf, base);
1850-
#endif
1831+
DebugPrintf(("Loading device driver %s at segment %04x\n", szBuf, base));
18511832

18521833
if ((result = init_DosExec(3, &eb, szBuf)) != SUCCESS)
18531834
{

kernel/dosfns.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ static BYTE *dosfnsRcsId =
3434
#endif
3535

3636
#include "globals.h"
37+
#include "debug.h"
3738

3839
/* /// Added for SHARE. - Ron Cemer */
3940

kernel/error.c

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,24 +27,20 @@
2727
/****************************************************************/
2828

2929
#include "portab.h"
30-
31-
#ifdef VERSION_STRINGS
32-
static BYTE *errorRcsId =
33-
"$Id: error.c 709 2003-09-24 19:34:11Z bartoldeman $";
34-
#endif
35-
3630
#include "globals.h"
31+
#include "debug.h"
32+
3733

3834
#ifdef DEBUG
3935
/* error registers */
4036
VOID dump(void)
4137
{
42-
printf("Register Dump [AH = %02x CS:IP = %04x:%04x FLAGS = %04x]\n",
43-
error_regs.AH, error_regs.CS, error_regs.IP, error_regs.FLAGS);
44-
printf("AX:%04x BX:%04x CX:%04x DX:%04x\n",
45-
error_regs.AX, error_regs.BX, error_regs.CX, error_regs.DX);
46-
printf("SI:%04x DI:%04x DS:%04x ES:%04x\n",
47-
error_regs.SI, error_regs.DI, error_regs.DS, error_regs.ES);
38+
DebugPrintf(("Register Dump [AH = %02x CS:IP = %04x:%04x FLAGS = %04x]\n",
39+
error_regs.AH, error_regs.CS, error_regs.IP, error_regs.FLAGS));
40+
DebugPrintf(("AX:%04x BX:%04x CX:%04x DX:%04x\n",
41+
error_regs.AX, error_regs.BX, error_regs.CX, error_regs.DX));
42+
DebugPrintf(("SI:%04x DI:%04x DS:%04x ES:%04x\n",
43+
error_regs.SI, error_regs.DI, error_regs.DS, error_regs.ES));
4844
}
4945
#endif
5046

kernel/fatfs.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,8 @@
2929

3030
#include "portab.h"
3131
#include "globals.h"
32+
#include "debug.h"
3233

33-
#ifdef VERSION_STRINGS
34-
BYTE *RcsId = "$Id: fatfs.c 1632 2011-06-13 16:29:14Z bartoldeman $";
35-
#endif
3634

3735
/* */
3836
/* function prototypes */

kernel/inthndlr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ VOID ASMCFUNC int21_service(iregs FAR * r)
442442
if (bDumpRegs)
443443
{
444444
fmemcpy(&error_regs, user_r, sizeof(iregs));
445-
printf("System call (21h): %02x\n", user_r->AX);
445+
DebugPrintf(("System call (21h): %02x\n", user_r->AX));
446446
dump_regs = TRUE;
447447
dump();
448448
}

kernel/main.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,6 @@
3232
#include "dyndata.h"
3333
#include "debug.h"
3434

35-
#ifdef VERSION_STRINGS
36-
static BYTE *mainRcsId =
37-
"$Id: main.c 1699 2012-01-16 20:45:44Z perditionc $";
38-
#endif
3935

4036
static char copyright[] =
4137
"(C) Copyright 1995-2023 Pasquale J. Villani and The FreeDOS Project.\n"

0 commit comments

Comments
 (0)