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
_kbdType db 0 ; 00 for 84key, 10h for 102key
%IFDEF DEBUG_PRINT_COMPORT
ASYNC_NEED_INIT db 1
%ENDIF
global ConInit
ConInit:
xor ax,ax
@ -243,12 +248,58 @@ _int29_handler:
push di
push bp
push bx
%IFDEF DEBUG_PRINT_COMPORT
cmp bx, 0xFD05 ; magic value for COM print routine
je .comprint
%ENDIF
mov ah,0Eh
mov bx,7
int 10h ; write char al, teletype mode
.int29hndlr_ret:
pop bx
pop bp
pop di
pop si
pop ax
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 "globals.h"
#ifdef DEBUG
#define DEBUG_TRUENAME
#endif
#include "debug.h"
/*
TE-TODO: if called repeatedly by same process,
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;
}
#ifdef DEBUG
#define DEBUG_TRUENAME
#endif
#define drLetterToNr(dr) ((unsigned char)((dr) - 'A'))
/* Convert an uppercased drive letter into the drive index */
#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_DOT 2
@ -635,7 +630,7 @@ cmdspy report report.out
more report.out
=== Intspy report file: REPORT.OUT
1123: IN: C:\INTRSPY\SPY_INT.BAT [FAIL 0001]
1123: OUT: 
1123: OUT:
1123: orig buffer: C:\INTRSPY\SPY_INT.BAT
1123: IN: int.??? [FAIL 0001]
1123: OUT: C:\INTRSPY

View File

@ -93,6 +93,13 @@ void put_console(int c)
#ifdef __WATCOMC__
void int29(char c);
#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
void put_console(int c)
@ -108,6 +115,9 @@ void put_console(int c)
__int__(0x29);
#elif defined(__WATCOMC__)
int29(c);
#if defined DEBUG_PRINT_COMPORT
fastComPrint(c);
#endif
#elif defined(I86)
__asm
{
@ -141,6 +151,11 @@ STATIC VOID handle_char(COUNT c)
if (charp == 0)
put_console(c);
else
#ifdef DEBUG_PRINT_COMPORT
if (charp == (BYTE FAR *)-1)
fastComPrint(c);
else
#endif
*charp++ = c;
}
@ -168,6 +183,16 @@ VOID VA_CDECL sprintf(char FAR * buff, CONST BYTE FAR * fmt, ...)
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)
{
int base, size;
@ -325,7 +350,6 @@ STATIC void do_printf(CONST BYTE FAR * fmt, va_list arg)
}
va_end(arg);
}
#endif
#if !defined(FORSYS) && !defined(_INIT)

View File

@ -28,6 +28,7 @@
#include "portab.h"
#include "globals.h"
#include "debug.h"
#ifdef VERSION_STRINGS
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;
int i;
printf("ChildEnv. env seg=0x%02x\n", dst_seg);
DebugPrintf(("ChildEnv. env seg=0x%02x\n", dst_seg));
if (dst_seg)
{
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)
while (*p)
{
printf("[");
DebugPrintf(("["));
for (; *p; p++)
if (*p == ' ') printf("<space>");
else printf("%c", *p);
printf("]\n");
if (*p == ' ') DebugPrintf(("<space>"));
else DebugPrintf(("%c", *p));
DebugPrintf(("]\n"));
p++;
}
else
p++; /* even empty env must have 1 ("") ASCIIZ string */
/* 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);
printf("argv[0] present = %u\n", *MK_PTR(UWORD, dst_seg, env_sz + 2));
DebugPrintf(("End of Env marker = 0x%02x (should be 0)\n", *p));
DebugPrintf(("argv[0] present = %u\n", *MK_PTR(UWORD, dst_seg, env_sz + 2)));
p+=3; /* skip 16bit count and point to argv[0] */
if (*p)
{
for (i = 0; p[i] && (i < 127); i++)
printf("%c", p[i]);
printf("\n");
DebugPrintf(("%c", p[i]));
DebugPrintf(("\n"));
}
else
printf("No program name (argv[0]) supplied\n");
DebugPrintf(("No program name (argv[0]) supplied\n"));
}
}
#endif
@ -337,22 +338,22 @@ static void load_transfer(seg_t ds, exec_blk *ep, int mode)
/* display full command line */
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;
}
printf("load_transfer. CommandTail is:\n");
DebugPrintf(("load_transfer. CommandTail is:\n"));
/* use loop in case tail not '\0' terminated */
if (ctCount)
{
for (i=0; i < ctCount; i++)
if (ep->exec.cmd_line->ctBuffer[i] == ' ')
printf("<space>");
DebugPrintf(("<space>"));
else
printf("%c", ep->exec.cmd_line->ctBuffer[i]);
printf("\n");
DebugPrintf(("%c", ep->exec.cmd_line->ctBuffer[i]));
DebugPrintf(("\n"));
}
else
printf("<empty>\n");
DebugPrintf(("<empty>\n"));
}
#endif
@ -494,7 +495,7 @@ COUNT DosComLoader(BYTE FAR * namep, exec_blk * exp, COUNT mode, COUNT fd)
return rc;
#ifdef DEBUG
printf("DosComLoader. Loading '%S' at %04x\n", namep, mem);
DebugPrintf(("DosComLoader. Loading '%S' at %04x\n", namep, mem));
#endif
++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 */
#ifdef DEBUG
printf("DosExeLoader. Loading '%S' at %04x\n", namep, mem);
DebugPrintf(("DosExeLoader. Loading '%S' at %04x\n", namep, mem));
#endif
/* 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 */
#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
res_DosExec(mode, &exb, Shell);
}