diff --git a/cpu/6502/6502def.h b/cpu/6502/6502def.h index 2da81b02e..c0f5c999a 100644 --- a/cpu/6502/6502def.h +++ b/cpu/6502/6502def.h @@ -74,6 +74,12 @@ typedef unsigned short uip_stats_t; #define LOADER_CONF_ARCH "lib/unload.h" +#ifdef HAVE_LOGSCR +void logscr(const void *msg, unsigned len); +#else +#define logscr(msg, len) write(STDERR_FILENO, msg, len) +#endif + #if MTU_SIZE #define UIP_CONF_BUFFER_SIZE (UIP_LLH_LEN + MTU_SIZE) #else /* MTU_SIZE */ diff --git a/cpu/6502/lib/log.c b/cpu/6502/lib/log.c index 93ed0eeda..a259c06d6 100644 --- a/cpu/6502/lib/log.c +++ b/cpu/6502/lib/log.c @@ -32,7 +32,6 @@ * */ -#include #include #include "net/ip/uip.h" @@ -43,8 +42,8 @@ void uip_log(char *message) { - write(STDERR_FILENO, message, strlen(message)); - write(STDERR_FILENO, "\n", 1); + logscr(message, strlen(message)); + logscr("\n", 1); } #endif /* UIP_LOGGING */ /*-----------------------------------------------------------------------------------*/ @@ -52,9 +51,9 @@ uip_log(char *message) void log_message(const char *part1, const char *part2) { - write(STDERR_FILENO, part1, strlen(part1)); - write(STDERR_FILENO, part2, strlen(part2)); - write(STDERR_FILENO, "\n", 1); + logscr(part1, strlen(part1)); + logscr(part2, strlen(part2)); + logscr("\n", 1); } #endif /* LOG_CONF_ENABLED */ /*-----------------------------------------------------------------------------------*/ diff --git a/platform/c128/Makefile.c128 b/platform/c128/Makefile.c128 index dab80b1dc..c1adbaf08 100644 --- a/platform/c128/Makefile.c128 +++ b/platform/c128/Makefile.c128 @@ -31,7 +31,7 @@ # Author: Oliver Schmidt # -CONTIKI_TARGET_SOURCEFILES += exec.c lseek.c \ +CONTIKI_TARGET_SOURCEFILES += exec.c logscr.S lseek.c \ pfs.S pfs-dir.c pfs-dir-asm.S pfs_remove.S pfs_seek.S pfs_write.S CONTIKI_CPU = $(CONTIKI)/cpu/6502 diff --git a/platform/c128/contiki-conf.h b/platform/c128/contiki-conf.h index 0e72f20c4..9ee7cc2b7 100644 --- a/platform/c128/contiki-conf.h +++ b/platform/c128/contiki-conf.h @@ -35,6 +35,8 @@ #ifndef CONTIKI_CONF_H_ #define CONTIKI_CONF_H_ +#define HAVE_LOGSCR + #include "6502def.h" #if (WITH_PFS && !CFS_IMPL) diff --git a/platform/c128/lib/logscr.S b/platform/c128/lib/logscr.S new file mode 100644 index 000000000..e87e2aa17 --- /dev/null +++ b/platform/c128/lib/logscr.S @@ -0,0 +1,5 @@ +; 2016-04-28, Greg King +; +; The C128 function is the same as the C64 function. + + .include "../../c64/lib/logscr.S" diff --git a/platform/c64/Makefile.c64 b/platform/c64/Makefile.c64 index 96b54c287..7fcb4d19f 100644 --- a/platform/c64/Makefile.c64 +++ b/platform/c64/Makefile.c64 @@ -31,7 +31,7 @@ # Author: Oliver Schmidt # -CONTIKI_TARGET_SOURCEFILES += exec.c lseek.c \ +CONTIKI_TARGET_SOURCEFILES += exec.c logscr.S lseek.c \ pfs.S pfs-dir.c pfs-dir-asm.S pfs_remove.S pfs_seek.S pfs_write.S CONTIKI_CPU = $(CONTIKI)/cpu/6502 diff --git a/platform/c64/contiki-conf.h b/platform/c64/contiki-conf.h index 102d01a77..21ea459bd 100644 --- a/platform/c64/contiki-conf.h +++ b/platform/c64/contiki-conf.h @@ -35,6 +35,8 @@ #ifndef CONTIKI_CONF_H_ #define CONTIKI_CONF_H_ +#define HAVE_LOGSCR + #include "6502def.h" #if (WITH_PFS && !CFS_IMPL) diff --git a/platform/c64/lib/logscr.S b/platform/c64/lib/logscr.S new file mode 100644 index 000000000..e9f297be7 --- /dev/null +++ b/platform/c64/lib/logscr.S @@ -0,0 +1,38 @@ +; 2002-11-16, Ullrich von Bassewitz +; 2016-04-28, Greg King +; +; void logscr(const void *msg, unsigned len); + + .export _logscr + + .import BSOUT + .import popax + .importzp ptr1, ptr2 + +;-------------------------------------------------------------------------- + +.proc _logscr + eor #$FF + sta ptr2 + txa + eor #$FF + sta ptr2+1 ; remember -count-1 + + jsr popax ; get buf + sta ptr1 + stx ptr1+1 + +L1: inc ptr2 ; count the char that will be printed + bne L2 + inc ptr2+1 + beq L9 +L2: ldy #$00 + lda (ptr1),y + jsr BSOUT + inc ptr1 + bne L1 + inc ptr1+1 + bne L1 ; branch always + +L9: rts +.endproc