Added custom log function for CBM machines.

The log function writes directly to the screen. Combined with the usage of PFS this means that the POSIX layer of the C library isn't referenced anymore thus reducing the memory requirements.
This commit is contained in:
Oliver Schmidt 2016-10-15 23:36:53 +02:00
parent d864e73579
commit fb4c42a357
8 changed files with 60 additions and 8 deletions

View File

@ -74,6 +74,12 @@ typedef unsigned short uip_stats_t;
#define LOADER_CONF_ARCH "lib/unload.h" #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 #if MTU_SIZE
#define UIP_CONF_BUFFER_SIZE (UIP_LLH_LEN + MTU_SIZE) #define UIP_CONF_BUFFER_SIZE (UIP_LLH_LEN + MTU_SIZE)
#else /* MTU_SIZE */ #else /* MTU_SIZE */

View File

@ -32,7 +32,6 @@
* *
*/ */
#include <unistd.h>
#include <string.h> #include <string.h>
#include "net/ip/uip.h" #include "net/ip/uip.h"
@ -43,8 +42,8 @@
void void
uip_log(char *message) uip_log(char *message)
{ {
write(STDERR_FILENO, message, strlen(message)); logscr(message, strlen(message));
write(STDERR_FILENO, "\n", 1); logscr("\n", 1);
} }
#endif /* UIP_LOGGING */ #endif /* UIP_LOGGING */
/*-----------------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------------*/
@ -52,9 +51,9 @@ uip_log(char *message)
void void
log_message(const char *part1, const char *part2) log_message(const char *part1, const char *part2)
{ {
write(STDERR_FILENO, part1, strlen(part1)); logscr(part1, strlen(part1));
write(STDERR_FILENO, part2, strlen(part2)); logscr(part2, strlen(part2));
write(STDERR_FILENO, "\n", 1); logscr("\n", 1);
} }
#endif /* LOG_CONF_ENABLED */ #endif /* LOG_CONF_ENABLED */
/*-----------------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------------*/

View File

@ -31,7 +31,7 @@
# Author: Oliver Schmidt <ol.sc@web.de> # Author: Oliver Schmidt <ol.sc@web.de>
# #
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 pfs.S pfs-dir.c pfs-dir-asm.S pfs_remove.S pfs_seek.S pfs_write.S
CONTIKI_CPU = $(CONTIKI)/cpu/6502 CONTIKI_CPU = $(CONTIKI)/cpu/6502

View File

@ -35,6 +35,8 @@
#ifndef CONTIKI_CONF_H_ #ifndef CONTIKI_CONF_H_
#define CONTIKI_CONF_H_ #define CONTIKI_CONF_H_
#define HAVE_LOGSCR
#include "6502def.h" #include "6502def.h"
#if (WITH_PFS && !CFS_IMPL) #if (WITH_PFS && !CFS_IMPL)

View File

@ -0,0 +1,5 @@
; 2016-04-28, Greg King
;
; The C128 function is the same as the C64 function.
.include "../../c64/lib/logscr.S"

View File

@ -31,7 +31,7 @@
# Author: Oliver Schmidt <ol.sc@web.de> # Author: Oliver Schmidt <ol.sc@web.de>
# #
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 pfs.S pfs-dir.c pfs-dir-asm.S pfs_remove.S pfs_seek.S pfs_write.S
CONTIKI_CPU = $(CONTIKI)/cpu/6502 CONTIKI_CPU = $(CONTIKI)/cpu/6502

View File

@ -35,6 +35,8 @@
#ifndef CONTIKI_CONF_H_ #ifndef CONTIKI_CONF_H_
#define CONTIKI_CONF_H_ #define CONTIKI_CONF_H_
#define HAVE_LOGSCR
#include "6502def.h" #include "6502def.h"
#if (WITH_PFS && !CFS_IMPL) #if (WITH_PFS && !CFS_IMPL)

38
platform/c64/lib/logscr.S Normal file
View File

@ -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