conditionally compile so debug output sent to COM port (2nd computer)

git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1178 6ac86273-5f31-0410-b378-82cca8765d1b
This commit is contained in:
Kenneth J Davis 2006-02-18 15:52:19 +00:00
parent 1420e23819
commit 392fb4148a
4 changed files with 102 additions and 31 deletions

View File

@ -57,6 +57,11 @@ uScanCode db 0 ; Scan code for con: device
global _kbdType global _kbdType
_kbdType db 0 ; 00 for 84key, 10h for 102key _kbdType db 0 ; 00 for 84key, 10h for 102key
%IFDEF DEBUG_PRINT_COMPORT
ASYNC_NEED_INIT db 1
%ENDIF
global ConInit global ConInit
ConInit: ConInit:
xor ax,ax xor ax,ax
@ -243,12 +248,58 @@ _int29_handler:
push di push di
push bp push bp
push bx push bx
%IFDEF DEBUG_PRINT_COMPORT
cmp bx, 0xFD05 ; magic value for COM print routine
je .comprint
%ENDIF
mov ah,0Eh mov ah,0Eh
mov bx,7 mov bx,7
int 10h ; write char al, teletype mode int 10h ; write char al, teletype mode
.int29hndlr_ret:
pop bx pop bx
pop bp pop bp
pop di pop di
pop si pop si
pop ax pop ax
iret iret
%IFDEF DEBUG_PRINT_COMPORT
.comprint:
push dx
mov dx, 1 ; 0=COM1,1=COM2,2=COM3,3=COM4
mov ah, [cs:ASYNC_NEED_INIT]
or ah,ah
jz .skip_init
push ax ; preserve char (AL) to print
; initialize serial port using BIOS to DOS default
; of 2400 bps, 8 data bits, 1 stop bit, and no parity
mov ax, 0x00A3
int 14h ; BIOS initialize serial port
mov ax, 0x011B ; clear the remote screen (ESC[2J)
int 14h ; BIOS write character to serial port
mov ax, 0x015B ; '['
int 14h ; BIOS write character to serial port
mov ax, 0x0132 ; '2'
int 14h ; BIOS write character to serial port
mov ax, 0x014A ; 'J'
int 14h ; BIOS write character to serial port
; mark initialization complete
mov byte [cs:ASYNC_NEED_INIT], 0
pop ax ; restore char to print
.skip_init:
cmp al, 0x0A ; do we need to add a carriage return?
jne .print_it
mov ax, 0x010D ; print as \r\n
int 14h
mov al, 0x0A
.print_it:
mov ah, 0x01
int 14h ; BIOS write character to serial port
pop dx
jmp .int29hndlr_ret
%ENDIF ; DEBUG_PRINT_COMPORT

View File

@ -33,6 +33,11 @@ static BYTE *mainRcsId =
#include "portab.h" #include "portab.h"
#include "globals.h" #include "globals.h"
#ifdef DEBUG
#define DEBUG_TRUENAME
#endif
#include "debug.h"
/* /*
TE-TODO: if called repeatedly by same process, TE-TODO: if called repeatedly by same process,
last allocation must be freed. if handle count < 20, copy back to PSP last allocation must be freed. if handle count < 20, copy back to PSP
@ -89,10 +94,6 @@ long DosMkTmp(BYTE FAR * pathname, UWORD attr)
return rc; return rc;
} }
#ifdef DEBUG
#define DEBUG_TRUENAME
#endif
#define drLetterToNr(dr) ((unsigned char)((dr) - 'A')) #define drLetterToNr(dr) ((unsigned char)((dr) - 'A'))
/* Convert an uppercased drive letter into the drive index */ /* Convert an uppercased drive letter into the drive index */
#define drNrToLetter(dr) ((dr) + 'A') #define drNrToLetter(dr) ((dr) + 'A')
@ -218,12 +219,6 @@ long DosMkTmp(BYTE FAR * pathname, UWORD attr)
*/ */
#ifdef DEBUG_TRUENAME
#define tn_printf(x) printf x
#else
#define tn_printf(x)
#endif
#define PNE_WILDCARD 1 #define PNE_WILDCARD 1
#define PNE_DOT 2 #define PNE_DOT 2
@ -635,7 +630,7 @@ cmdspy report report.out
more report.out more report.out
=== Intspy report file: REPORT.OUT === Intspy report file: REPORT.OUT
1123: IN: C:\INTRSPY\SPY_INT.BAT [FAIL 0001] 1123: IN: C:\INTRSPY\SPY_INT.BAT [FAIL 0001]
1123: OUT:  1123: OUT:
1123: orig buffer: C:\INTRSPY\SPY_INT.BAT 1123: orig buffer: C:\INTRSPY\SPY_INT.BAT
1123: IN: int.??? [FAIL 0001] 1123: IN: int.??? [FAIL 0001]
1123: OUT: C:\INTRSPY 1123: OUT: C:\INTRSPY

View File

@ -93,6 +93,13 @@ void put_console(int c)
#ifdef __WATCOMC__ #ifdef __WATCOMC__
void int29(char c); void int29(char c);
#pragma aux int29 = "int 0x29" parm [al] modify exact [bx]; #pragma aux int29 = "int 0x29" parm [al] modify exact [bx];
#ifdef DEBUG_PRINT_COMPORT
void fastComPrint(char c);
#pragma aux fastComPrint = \
"mov bx, 0xFD05" \
"int 0x29" parm [al] modify exact [bx];
#endif
#endif #endif
void put_console(int c) void put_console(int c)
@ -108,6 +115,9 @@ void put_console(int c)
__int__(0x29); __int__(0x29);
#elif defined(__WATCOMC__) #elif defined(__WATCOMC__)
int29(c); int29(c);
#if defined DEBUG_PRINT_COMPORT
fastComPrint(c);
#endif
#elif defined(I86) #elif defined(I86)
__asm __asm
{ {
@ -141,6 +151,11 @@ STATIC VOID handle_char(COUNT c)
if (charp == 0) if (charp == 0)
put_console(c); put_console(c);
else else
#ifdef DEBUG_PRINT_COMPORT
if (charp == (BYTE FAR *)-1)
fastComPrint(c);
else
#endif
*charp++ = c; *charp++ = c;
} }
@ -168,6 +183,16 @@ VOID VA_CDECL sprintf(char FAR * buff, CONST BYTE FAR * fmt, ...)
handle_char('\0'); handle_char('\0');
} }
#ifdef DEBUG_PRINT_COMPORT
VOID dbgc_printf(CONST BYTE FAR * fmt, ...)
{
va_list arg;
va_start(arg, fmt);
charp = (BYTE FAR *)-1;
do_printf(fmt, arg);
}
#endif
STATIC void do_printf(CONST BYTE FAR * fmt, va_list arg) STATIC void do_printf(CONST BYTE FAR * fmt, va_list arg)
{ {
int base, size; int base, size;
@ -325,7 +350,6 @@ STATIC void do_printf(CONST BYTE FAR * fmt, va_list arg)
} }
va_end(arg); va_end(arg);
} }
#endif #endif
#if !defined(FORSYS) && !defined(_INIT) #if !defined(FORSYS) && !defined(_INIT)

View File

@ -28,6 +28,7 @@
#include "portab.h" #include "portab.h"
#include "globals.h" #include "globals.h"
#include "debug.h"
#ifdef VERSION_STRINGS #ifdef VERSION_STRINGS
static BYTE *RcsId = static BYTE *RcsId =
@ -157,7 +158,7 @@ STATIC int ChildEnv(seg_t env_seg, seg_t *penv_seg, const char far *path)
seg_t dst_seg = *penv_seg + 1; seg_t dst_seg = *penv_seg + 1;
int i; int i;
printf("ChildEnv. env seg=0x%02x\n", dst_seg); DebugPrintf(("ChildEnv. env seg=0x%02x\n", dst_seg));
if (dst_seg) if (dst_seg)
{ {
const char FAR*p = MK_PTR(const char, dst_seg, 0); const char FAR*p = MK_PTR(const char, dst_seg, 0);
@ -165,27 +166,27 @@ STATIC int ChildEnv(seg_t env_seg, seg_t *penv_seg, const char far *path)
if (*p) if (*p)
while (*p) while (*p)
{ {
printf("["); DebugPrintf(("["));
for (; *p; p++) for (; *p; p++)
if (*p == ' ') printf("<space>"); if (*p == ' ') DebugPrintf(("<space>"));
else printf("%c", *p); else DebugPrintf(("%c", *p));
printf("]\n"); DebugPrintf(("]\n"));
p++; p++;
} }
else else
p++; /* even empty env must have 1 ("") ASCIIZ string */ p++; /* even empty env must have 1 ("") ASCIIZ string */
/* may be followed by empty string (just \0), 16bit count, ASCIIZ argv[0] */ /* may be followed by empty string (just \0), 16bit count, ASCIIZ argv[0] */
printf("End of Env marker = 0x%02x (should be 0)\n", *p); DebugPrintf(("End of Env marker = 0x%02x (should be 0)\n", *p));
printf("argv[0] present = %u\n", *MK_PTR(UWORD, dst_seg, env_sz + 2)); DebugPrintf(("argv[0] present = %u\n", *MK_PTR(UWORD, dst_seg, env_sz + 2)));
p+=3; /* skip 16bit count and point to argv[0] */ p+=3; /* skip 16bit count and point to argv[0] */
if (*p) if (*p)
{ {
for (i = 0; p[i] && (i < 127); i++) for (i = 0; p[i] && (i < 127); i++)
printf("%c", p[i]); DebugPrintf(("%c", p[i]));
printf("\n"); DebugPrintf(("\n"));
} }
else else
printf("No program name (argv[0]) supplied\n"); DebugPrintf(("No program name (argv[0]) supplied\n"));
} }
} }
#endif #endif
@ -337,22 +338,22 @@ static void load_transfer(seg_t ds, exec_blk *ep, int mode)
/* display full command line */ /* display full command line */
if (ctCount > 127) if (ctCount > 127)
{ {
printf("load_transfer. CommantTail=%d count exceeds 127\n", ctCount); DebugPrintf(("load_transfer. CommantTail=%d count exceeds 127\n", ctCount));
ctCount = 127; ctCount = 127;
} }
printf("load_transfer. CommandTail is:\n"); DebugPrintf(("load_transfer. CommandTail is:\n"));
/* use loop in case tail not '\0' terminated */ /* use loop in case tail not '\0' terminated */
if (ctCount) if (ctCount)
{ {
for (i=0; i < ctCount; i++) for (i=0; i < ctCount; i++)
if (ep->exec.cmd_line->ctBuffer[i] == ' ') if (ep->exec.cmd_line->ctBuffer[i] == ' ')
printf("<space>"); DebugPrintf(("<space>"));
else else
printf("%c", ep->exec.cmd_line->ctBuffer[i]); DebugPrintf(("%c", ep->exec.cmd_line->ctBuffer[i]));
printf("\n"); DebugPrintf(("\n"));
} }
else else
printf("<empty>\n"); DebugPrintf(("<empty>\n"));
} }
#endif #endif
@ -494,7 +495,7 @@ COUNT DosComLoader(BYTE FAR * namep, exec_blk * exp, COUNT mode, COUNT fd)
return rc; return rc;
#ifdef DEBUG #ifdef DEBUG
printf("DosComLoader. Loading '%S' at %04x\n", namep, mem); DebugPrintf(("DosComLoader. Loading '%S' at %04x\n", namep, mem));
#endif #endif
++mem; ++mem;
} }
@ -639,7 +640,7 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk * exp, COUNT mode, COUNT fd)
mode &= 0x7f; /* forget about high loading from now on */ mode &= 0x7f; /* forget about high loading from now on */
#ifdef DEBUG #ifdef DEBUG
printf("DosExeLoader. Loading '%S' at %04x\n", namep, mem); DebugPrintf(("DosExeLoader. Loading '%S' at %04x\n", namep, mem));
#endif #endif
/* memory found large enough - continue processing */ /* memory found large enough - continue processing */
} }
@ -817,7 +818,7 @@ void ASMCFUNC P_0(const struct config FAR *Config)
/*exb.exec.fcb_1 = exb.exec.fcb_2 = NULL;*/ /* unimportant */ /*exb.exec.fcb_1 = exb.exec.fcb_2 = NULL;*/ /* unimportant */
#ifdef DEBUG #ifdef DEBUG
printf("Process 0 starting: %s%s\n\n", Shell, tailp + 1); DebugPrintf(("Process 0 starting: %s%s\n\n", Shell, tailp + 1));
#endif #endif
res_DosExec(mode, &exb, Shell); res_DosExec(mode, &exb, Shell);
} }