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.

This commit is contained in:
Kenneth J Davis 2025-03-28 10:22:13 -04:00
parent 192cccc68f
commit 634257b913
No known key found for this signature in database
GPG Key ID: 59D5F216C38F11FD
7 changed files with 35 additions and 53 deletions

View File

@ -6,8 +6,10 @@ if NOT "%1" == "/?" goto start
echo ":-----------------------------------------------------------------------" echo ":-----------------------------------------------------------------------"
echo ":- Syntax: BUILD [-r] [fat32|fat16] [msc|wc|tc|tcpp|bc] [86|186|386] " echo ":- Syntax: BUILD [-r] [fat32|fat16] [msc|wc|tc|tcpp|bc] [86|186|386] "
echo ":- [debug] [lfnapi] [/L #] [/D value] [list] [upx] [win] " echo ":- [debug] [lfnapi] [/L #] [/D value] [list] [upx] [win] "
echo ":- [com] [com# #] "
echo ":- option case is significant !! " echo ":- option case is significant !! "
echo ":- Note: Open Watcom (wc) is the preferred compiler " echo ":- Note: Open Watcom (wc) is the preferred compiler "
echo ":- com does debug output on COM2, whereas com# 0 for COM1 ... "
echo ":-----------------------------------------------------------------------" echo ":-----------------------------------------------------------------------"
goto end goto end
@ -56,6 +58,14 @@ if "%1" == "lfnapi" set ALLCFLAGS=%ALLCFLAGS% -DWITHLFNAPI
if "%1" == "win" set ALLCFLAGS=%ALLCFLAGS% -DWIN31SUPPORT if "%1" == "win" set ALLCFLAGS=%ALLCFLAGS% -DWIN31SUPPORT
if "%1" == "win" set NASMFLAGS=%NASMFLAGS% -DWIN31SUPPORT if "%1" == "win" set NASMFLAGS=%NASMFLAGS% -DWIN31SUPPORT
if "%1" == "com" set ALLCFLAGS=%ALLCFLAGS% -DDEBUG_PRINT_COMPORT
if "%1" == "com" set NASMFLAGS=%ALLCFLAGS% -DDEBUG_PRINT_COMPORT
REM specify comport, default is COM2, 0=COM1, 1=COM2, 2=COM3
if "%1" == "com#" set ALLCFLAGS=%ALLCFLAGS% -DDEBUG_PRINT_COMPORT %2
if "%1" == "com#" set NASMFLAGS=%ALLCFLAGS% -DDEBUG_PRINT_COMPORT %2
if "%1" == "com#" shift
if "%1" == "com#" goto nextOption
if "%1" == "list" set NASMFLAGS=%NASMFLAGS% -l$*.lst if "%1" == "list" set NASMFLAGS=%NASMFLAGS% -l$*.lst
if "%1" == "/L" goto setLoadSeg if "%1" == "/L" goto setLoadSeg

View File

@ -31,10 +31,6 @@
#include "init-mod.h" #include "init-mod.h"
#include "dyndata.h" #include "dyndata.h"
#ifdef VERSION_STRINGS
static BYTE *RcsId =
"$Id: config.c 1705 2012-02-07 08:10:33Z perditionc $";
#endif
#ifdef DEBUG #ifdef DEBUG
#define DebugPrintf(x) printf x #define DebugPrintf(x) printf x
@ -342,15 +338,9 @@ void PreConfig(void)
{ {
/* Initialize the base memory pointers */ /* Initialize the base memory pointers */
#ifdef DEBUG DebugPrintf(("SDA located at 0x%p\n", internal_data));
{
printf("SDA located at 0x%p\n", internal_data);
}
#endif
/* Begin by initializing our system buffers */ /* Begin by initializing our system buffers */
#ifdef DEBUG /* DebugPrintf(("Preliminary %d buffers allocated at 0x%p\n", Config.cfgBuffers, buffers));*/
/* printf("Preliminary %d buffers allocated at 0x%p\n", Config.cfgBuffers, buffers);*/
#endif
LoL->sfthead = MK_FP(FP_SEG(LoL), 0xcc); /* &(LoL->firstsftt) */ LoL->sfthead = MK_FP(FP_SEG(LoL), 0xcc); /* &(LoL->firstsftt) */
/* LoL->FCBp = (sfttbl FAR *)&FcbSft; */ /* LoL->FCBp = (sfttbl FAR *)&FcbSft; */
@ -362,18 +352,14 @@ void PreConfig(void)
LoL->CDSp = KernelAlloc(sizeof(struct cds) * LoL->lastdrive, 'L', 0); LoL->CDSp = KernelAlloc(sizeof(struct cds) * LoL->lastdrive, 'L', 0);
#ifdef DEBUG /* DebugPrintf((" FCB table 0x%p\n",LoL->FCBp));*/
/* printf(" FCB table 0x%p\n",LoL->FCBp);*/ DebugPrintf((" sft table 0x%p\n", LoL->sfthead));
printf(" sft table 0x%p\n", LoL->sfthead); DebugPrintf((" CDS table 0x%p\n", LoL->CDSp));
printf(" CDS table 0x%p\n", LoL->CDSp); DebugPrintf((" DPB table 0x%p\n", LoL->DPBp));
printf(" DPB table 0x%p\n", LoL->DPBp);
#endif
/* Done. Now initialize the MCB structure */ /* Done. Now initialize the MCB structure */
/* This next line is 8086 and 80x86 real mode specific */ /* This next line is 8086 and 80x86 real mode specific */
#ifdef DEBUG DebugPrintf(("Preliminary allocation completed: top at %p\n", lpTop));
printf("Preliminary allocation completed: top at %p\n", lpTop);
#endif
} }
/* Do second pass initialization: near allocation and MCBs */ /* Do second pass initialization: near allocation and MCBs */
@ -443,9 +429,7 @@ void PostConfig(void)
/* Begin by initializing our system buffers */ /* Begin by initializing our system buffers */
/* dma_scratch = (BYTE FAR *) KernelAllocDma(BUFFERSIZE); */ /* dma_scratch = (BYTE FAR *) KernelAllocDma(BUFFERSIZE); */
#ifdef DEBUG /* DebugPrintf(("DMA scratchpad allocated at 0x%p\n", dma_scratch)); */
/* printf("DMA scratchpad allocated at 0x%p\n", dma_scratch); */
#endif
config_init_buffers(Config.cfgBuffers); config_init_buffers(Config.cfgBuffers);
@ -462,12 +446,11 @@ void PostConfig(void)
LoL->CDSp = KernelAlloc(sizeof(struct cds) * LoL->lastdrive, 'L', Config.cfgLastdriveHigh); LoL->CDSp = KernelAlloc(sizeof(struct cds) * LoL->lastdrive, 'L', Config.cfgLastdriveHigh);
#ifdef DEBUG /* DebugPrintf((" FCB table 0x%p\n",LoL->FCBp));*/
/* printf(" FCB table 0x%p\n",LoL->FCBp);*/ DebugPrintf((" sft table 0x%p\n", LoL->sfthead->sftt_next));
printf(" sft table 0x%p\n", LoL->sfthead->sftt_next); DebugPrintf((" CDS table 0x%p\n", LoL->CDSp));
printf(" CDS table 0x%p\n", LoL->CDSp); DebugPrintf((" DPB table 0x%p\n", LoL->DPBp));
printf(" DPB table 0x%p\n", LoL->DPBp);
#endif
if (Config.cfgStacks) if (Config.cfgStacks)
{ {
VOID FAR *stackBase = VOID FAR *stackBase =
@ -1845,9 +1828,7 @@ STATIC BOOL LoadDevice(BYTE * pLine, char FAR *top, COUNT mode)
/* The device driver is paragraph aligned. */ /* The device driver is paragraph aligned. */
eb.load.reloc = eb.load.load_seg = base; eb.load.reloc = eb.load.load_seg = base;
#ifdef DEBUG DebugPrintf(("Loading device driver %s at segment %04x\n", szBuf, base));
printf("Loading device driver %s at segment %04x\n", szBuf, base);
#endif
if ((result = init_DosExec(3, &eb, szBuf)) != SUCCESS) if ((result = init_DosExec(3, &eb, szBuf)) != SUCCESS)
{ {

View File

@ -34,6 +34,7 @@ static BYTE *dosfnsRcsId =
#endif #endif
#include "globals.h" #include "globals.h"
#include "debug.h"
/* /// Added for SHARE. - Ron Cemer */ /* /// Added for SHARE. - Ron Cemer */

View File

@ -27,24 +27,20 @@
/****************************************************************/ /****************************************************************/
#include "portab.h" #include "portab.h"
#ifdef VERSION_STRINGS
static BYTE *errorRcsId =
"$Id: error.c 709 2003-09-24 19:34:11Z bartoldeman $";
#endif
#include "globals.h" #include "globals.h"
#include "debug.h"
#ifdef DEBUG #ifdef DEBUG
/* error registers */ /* error registers */
VOID dump(void) VOID dump(void)
{ {
printf("Register Dump [AH = %02x CS:IP = %04x:%04x FLAGS = %04x]\n", DebugPrintf(("Register Dump [AH = %02x CS:IP = %04x:%04x FLAGS = %04x]\n",
error_regs.AH, error_regs.CS, error_regs.IP, error_regs.FLAGS); error_regs.AH, error_regs.CS, error_regs.IP, error_regs.FLAGS));
printf("AX:%04x BX:%04x CX:%04x DX:%04x\n", DebugPrintf(("AX:%04x BX:%04x CX:%04x DX:%04x\n",
error_regs.AX, error_regs.BX, error_regs.CX, error_regs.DX); error_regs.AX, error_regs.BX, error_regs.CX, error_regs.DX));
printf("SI:%04x DI:%04x DS:%04x ES:%04x\n", DebugPrintf(("SI:%04x DI:%04x DS:%04x ES:%04x\n",
error_regs.SI, error_regs.DI, error_regs.DS, error_regs.ES); error_regs.SI, error_regs.DI, error_regs.DS, error_regs.ES));
} }
#endif #endif

View File

@ -29,10 +29,8 @@
#include "portab.h" #include "portab.h"
#include "globals.h" #include "globals.h"
#include "debug.h"
#ifdef VERSION_STRINGS
BYTE *RcsId = "$Id: fatfs.c 1632 2011-06-13 16:29:14Z bartoldeman $";
#endif
/* */ /* */
/* function prototypes */ /* function prototypes */

View File

@ -442,7 +442,7 @@ dispatch:
if (bDumpRegs) if (bDumpRegs)
{ {
fmemcpy(&error_regs, user_r, sizeof(iregs)); fmemcpy(&error_regs, user_r, sizeof(iregs));
printf("System call (21h): %02x\n", user_r->AX); DebugPrintf(("System call (21h): %02x\n", user_r->AX));
dump_regs = TRUE; dump_regs = TRUE;
dump(); dump();
} }

View File

@ -32,10 +32,6 @@
#include "dyndata.h" #include "dyndata.h"
#include "debug.h" #include "debug.h"
#ifdef VERSION_STRINGS
static BYTE *mainRcsId =
"$Id: main.c 1699 2012-01-16 20:45:44Z perditionc $";
#endif
static char copyright[] = static char copyright[] =
"(C) Copyright 1995-2023 Pasquale J. Villani and The FreeDOS Project.\n" "(C) Copyright 1995-2023 Pasquale J. Villani and The FreeDOS Project.\n"