copy over debug print to COM ports from UNSTABLE branch
This commit is contained in:
parent
795c1df742
commit
7a73120228
@ -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
|
||||
@ -245,12 +250,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
|
||||
|
36
kernel/prf.c
36
kernel/prf.c
@ -100,6 +100,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)
|
||||
@ -115,6 +122,9 @@ void put_console(int c)
|
||||
__int__(0x29);
|
||||
#elif defined(__WATCOMC__)
|
||||
int29(c);
|
||||
#if defined DEBUG_PRINT_COMPORT
|
||||
fastComPrint(c);
|
||||
#endif
|
||||
#elif defined(__GNUC__)
|
||||
asm volatile("int $0x29" : : "a"(c) : "bx");
|
||||
#elif defined(I86)
|
||||
@ -157,6 +167,11 @@ STATIC VOID handle_char(COUNT c)
|
||||
if (charp == 0)
|
||||
put_console(c);
|
||||
else
|
||||
#ifdef DEBUG_PRINT_COMPORT
|
||||
if (charp == (BYTE SSFAR *)-1)
|
||||
fastComPrint(c);
|
||||
else
|
||||
#endif
|
||||
*charp++ = c;
|
||||
}
|
||||
|
||||
@ -237,13 +252,24 @@ int VA_CDECL sprintf(char * buff, CONST char * fmt, ...)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef DEBUG_PRINT_COMPORT
|
||||
int dbgc_printf(CONST char * fmt, ...)
|
||||
{
|
||||
va_list arg;
|
||||
|
||||
va_start(arg, fmt);
|
||||
charp = (BYTE SSFAR *)-1;
|
||||
do_printf(fmt, arg);
|
||||
handle_char('\0');
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
STATIC void do_printf(CONST BYTE * fmt, va_list arg)
|
||||
{
|
||||
int base;
|
||||
BYTE s[11];
|
||||
BYTE FAR * p;
|
||||
int size;
|
||||
unsigned char flags;
|
||||
int base, size;
|
||||
BYTE s[13]; /* long enough for a 32-bit octal number string with sign */
|
||||
BYTE flags, FAR *p;
|
||||
|
||||
for (;*fmt != '\0'; fmt++)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user