- fixed endianess bug in printf
authorJohn Tsiombikas <nuclear@member.fsf.org>
Sun, 31 Jan 2021 19:08:33 +0000 (21:08 +0200)
committerJohn Tsiombikas <nuclear@member.fsf.org>
Sun, 31 Jan 2021 19:08:33 +0000 (21:08 +0200)
- added memdump function
- added script to start a pty connected to the emulator

src/amiga/libc/stdio.c
src/amiga/mem.c
src/debug.c [new file with mode: 0644]
src/debug.h [new file with mode: 0644]
uaeterm [new file with mode: 0755]

index c404a52..9617a0c 100644 (file)
@@ -104,7 +104,7 @@ static int intern_printf(char *buf, size_t sz, const char *fmt, va_list ap)
        int base = 10;
        int alt = 0;
        int fwidth = 0;
-       int padc = ' ';
+       char padc = ' ';
        int sign = 0;
        int left_align = 0;     /* not implemented yet */
        int hex_caps = 0;
@@ -157,7 +157,7 @@ static int intern_printf(char *buf, size_t sz, const char *fmt, va_list ap)
 
                                        slen = strlen(conv_buf);
                                        for(i=slen; i<fwidth; i++) {
-                                               bwrite(BUF(buf), SZ(sz), (char*)&padc, 1);
+                                               bwrite(BUF(buf), SZ(sz), &padc, 1);
                                                cnum++;
                                        }
 
@@ -178,7 +178,7 @@ static int intern_printf(char *buf, size_t sz, const char *fmt, va_list ap)
                                        slen = strlen(str);
 
                                        for(i=slen; i<fwidth; i++) {
-                                               bwrite(BUF(buf), SZ(sz), (char*)&padc, 1);
+                                               bwrite(BUF(buf), SZ(sz), &padc, 1);
                                                cnum++;
                                        }
                                        bwrite(BUF(buf), SZ(sz), str, slen);
index 2b82db3..78db240 100644 (file)
@@ -2,11 +2,17 @@
 #include "serial.h"
 #include "mem.h"
 #include "amigalib.h"
+#include "debug.h"
 
 int init_mem(void)
 {
        struct alib_memnode *mem;
 
+       printf("chip memory top: %lx\n", (unsigned long)execbase->chipmem_top);
+
+       printf("memlist head node:\n");
+       memdump(execbase->memlist.head, sizeof(struct alib_memnode));
+
        printf("Memory ranges:\n");
        mem = execbase->memlist.head;
        while(mem->n_next) {
diff --git a/src/debug.c b/src/debug.c
new file mode 100644 (file)
index 0000000..00482f4
--- /dev/null
@@ -0,0 +1,32 @@
+#include <stdio.h>
+#include <ctype.h>
+#include "debug.h"
+
+void memdump(void *ptr, int len)
+{
+       int i;
+       unsigned char *p = ptr;
+
+       while(len > 0) {
+               printf("%06lx ", (unsigned long)p);
+               for(i=0; i<16; i++) {
+                       if(len - i <= 0) {
+                               printf("   ");
+                       } else {
+                               printf(" %02x", (unsigned int)p[i]);
+                       }
+                       if((i & 7) == 7) putchar(' ');
+               }
+               printf(" |");
+               for(i=0; i<16; i++) {
+                       if(len - i <= 0) {
+                               putchar(' ');
+                       } else {
+                               putchar(isprint(p[i]) ? p[i] : '.');
+                       }
+               }
+               printf("|\n");
+               len -= 16;
+               p += 16;
+       }
+}
diff --git a/src/debug.h b/src/debug.h
new file mode 100644 (file)
index 0000000..51386cd
--- /dev/null
@@ -0,0 +1,6 @@
+#ifndef DEBUG_H_
+#define DEBUG_H_
+
+void memdump(void *ptr, int len);
+
+#endif /* DEBUG_H_ */
diff --git a/uaeterm b/uaeterm
new file mode 100755 (executable)
index 0000000..4ea9e2e
--- /dev/null
+++ b/uaeterm
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+port=`cat fs-uae.conf | grep serial_port | awk '{ print $3; }'`
+if [ -z "$port" ]; then
+       echo "fs-uae.conf doesn't include a serial_port config option"
+       exit 1
+fi
+
+socat pty,raw,echo=0,link=$port -,raw,echo=0