[syslinux:master] sysdump: port memdump to com32 with the intent of enhancing it

syslinux-bot for H. Peter Anvin hpa at zytor.com
Sat Feb 6 17:48:12 PST 2010


Commit-ID:  c823e677c273321821975fa4bd512f7eabf0ce51
Gitweb:     http://syslinux.zytor.com/commit/c823e677c273321821975fa4bd512f7eabf0ce51
Author:     H. Peter Anvin <hpa at zytor.com>
AuthorDate: Sat, 6 Feb 2010 11:24:24 -0800
Committer:  H. Peter Anvin <hpa at zytor.com>
CommitDate: Sat, 6 Feb 2010 11:24:24 -0800

sysdump: port memdump to com32 with the intent of enhancing it

Port memdump to com32, with the intent of modifying and enhancing it.

Signed-off-by: H. Peter Anvin <hpa at zytor.com>


---
 com32/{gdbstub => sysdump}/Makefile   |   15 +++-----
 {memdump => com32/sysdump}/README     |    0
 {memdump => com32/sysdump}/file.h     |    2 +-
 {memdump => com32/sysdump}/main.c     |   62 ++++-----------------------------
 {memdump => com32/sysdump}/serial.c   |    3 +-
 {memdump => com32/sysdump}/srecsend.c |    1 +
 {memdump => com32/sysdump}/srecsend.h |    1 -
 {memdump => com32/sysdump}/ymodem.txt |    0
 {memdump => com32/sysdump}/ymsend.c   |    1 +
 {memdump => com32/sysdump}/ymsend.h   |    1 -
 10 files changed, 17 insertions(+), 69 deletions(-)

diff --git a/com32/gdbstub/Makefile b/com32/sysdump/Makefile
similarity index 78%
copy from com32/gdbstub/Makefile
copy to com32/sysdump/Makefile
index 5513876..a64414a 100644
--- a/com32/gdbstub/Makefile
+++ b/com32/sysdump/Makefile
@@ -1,6 +1,7 @@
 ## -----------------------------------------------------------------------
 ##
 ##   Copyright 2001-2008 H. Peter Anvin - All Rights Reserved
+##   Copyright 2010 Intel Corporation; author: H. Peter Anvin
 ##
 ##   This program is free software; you can redistribute it and/or modify
 ##   it under the terms of the GNU General Public License as published by
@@ -11,28 +12,26 @@
 ## -----------------------------------------------------------------------
 
 ##
-## GDB remote debugging
+## Simple menu system
 ##
 
 topdir = ../..
 include ../MCONFIG
 
-CFLAGS += -fPIE
-
 LIBS	   = ../libutil/libutil_com.a ../lib/libcom32.a $(LIBGCC)
 LNXLIBS	   = ../libutil/libutil_lnx.a
 
-MODULES	  = gdbstub.c32
+MODULES	  = sysdump.c32
 TESTFILES =
 
-OBJS = main.o int.o serial.o gdbstub.o
+OBJS = $(patsubst %.c,%.o,$(wildcard *.c))
 
 all: $(MODULES) $(TESTFILES)
 
-gdbstub.elf : $(OBJS) $(LIBS) $(C_LIBS)
+sysdump.elf : $(OBJS) $(LIBS) $(C_LIBS)
 	$(LD) $(LDFLAGS) -o $@ $^
 
-tidy dist clean:
+tidy dist:
 	rm -f *.o *.lo *.a *.lst *.elf .*.d *.tmp
 
 clean: tidy
@@ -43,7 +42,5 @@ spotless: clean
 	rm -f *~ \#*
 
 install:
-	mkdir -m 755 -p $(INSTALLROOT)$(AUXDIR)
-	install -m 644 $(MODULES) $(INSTALLROOT)$(AUXDIR)
 
 -include .*.d
diff --git a/memdump/README b/com32/sysdump/README
similarity index 100%
copy from memdump/README
copy to com32/sysdump/README
diff --git a/memdump/file.h b/com32/sysdump/file.h
similarity index 95%
copy from memdump/file.h
copy to com32/sysdump/file.h
index 8da6973..72fad3d 100644
--- a/memdump/file.h
+++ b/com32/sysdump/file.h
@@ -1,7 +1,7 @@
 #ifndef FILE_H
 #define FILE_H
 
-#include "mystuff.h"
+#include <stddef.h>
 
 struct serial_if {
     int port;
diff --git a/memdump/main.c b/com32/sysdump/main.c
similarity index 64%
copy from memdump/main.c
copy to com32/sysdump/main.c
index 068f657..5aba85e 100644
--- a/memdump/main.c
+++ b/com32/sysdump/main.c
@@ -14,70 +14,24 @@
 #include <string.h>
 #include <stdlib.h>
 #include <stdbool.h>
-#include "mystuff.h"
+#include <inttypes.h>
+#include <dprintf.h>
 #include "ymsend.h"
 #include "srecsend.h"
-#include "io.h"
 
 const char *program = "memdump";
 
 void __attribute__ ((noreturn)) die(const char *msg)
 {
-    puts(program);
-    puts(": ");
-    puts(msg);
-    putchar('\n');
+    printf("%s: %s\n", program, msg);
     exit(1);
 }
 
-#ifdef DEBUG
-# define dprintf printf
-#else
-# define dprintf(...) ((void)0)
-#endif
-
-static inline __attribute__ ((const))
-uint16_t ds(void)
-{
-    uint16_t v;
-asm("movw %%ds,%0":"=rm"(v));
-    return v;
-}
-
-#define GDT_ENTRY(flags,base,limit)		\
-	(((uint64_t)(base & 0xff000000) << 32) |	\
-	 ((uint64_t)flags << 40) |			\
-	 ((uint64_t)(limit & 0x00ff0000) << 32) |	\
-	 ((uint64_t)(base & 0x00ffff00) << 16) |	\
-	 ((uint64_t)(limit & 0x0000ffff)))
-
 static void get_bytes(void *buf, size_t len, struct file_info *finfo,
 		      size_t pos)
 {
-    size_t end;
-    static uint64_t gdt[6];
-    size_t bufl;
-
     pos += (size_t) finfo->pvt;	/* Add base */
-    end = pos + len;
-
-    if (end <= 0x100000) {
-	/* Can stay in real mode */
-	asm volatile ("movw %3,%%fs ; "
-		      "fs; rep; movsl ; "
-		      "movw %2,%%cx ; "
-		      "rep; movsb"::"D" (buf), "c"(len >> 2),
-		      "r"((uint16_t) (len & 3)), "rm"((uint16_t) (pos >> 4)),
-		      "S"(pos & 15)
-		      :"memory");
-    } else {
-	bufl = (ds() << 4) + (size_t) buf;
-	gdt[2] = GDT_ENTRY(0x0093, pos, 0xffff);
-	gdt[3] = GDT_ENTRY(0x0093, bufl, 0xffff);
-	asm volatile ("pushal ; int $0x15 ; popal"::"a" (0x8700),
-		      "c"((len + 1) >> 1), "S"(&gdt)
-		      :"memory");
-    }
+    memcpy(buf, (void *)pos, len);
 }
 
 int main(int argc, char *argv[])
@@ -120,7 +74,7 @@ int main(int argc, char *argv[])
     prefix = argv[2];
 
     if (!srec) {
-	puts("Printing prefix...\n");
+	puts("Printing prefix...");
 	sif.write(&sif, ymodem_banner, sizeof ymodem_banner - 1);
     }
 
@@ -138,9 +92,7 @@ int main(int argc, char *argv[])
 	finfo.size = len;
 	finfo.pvt = (void *)start;
 
-	puts("Sending ");
-	puts(filename);
-	puts("...\n");
+	printf("Sending %s...\n", filename);
 
 	if (srec)
 	    send_srec(&sif, &finfo, get_bytes);
@@ -149,7 +101,7 @@ int main(int argc, char *argv[])
     }
 
     if (!srec) {
-	puts("Sending closing signature...\n");
+	puts("Sending closing signature...");
 	end_ymodem(&sif);
     }
 
diff --git a/memdump/serial.c b/com32/sysdump/serial.c
similarity index 97%
copy from memdump/serial.c
copy to com32/sysdump/serial.c
index 1c613d1..75bbd48 100644
--- a/memdump/serial.c
+++ b/com32/sysdump/serial.c
@@ -1,9 +1,8 @@
 #include <stdbool.h>
 #include <stdio.h>
+#include <sys/io.h>
 
-#include "mystuff.h"
 #include "file.h"
-#include "io.h"
 
 enum {
     THR = 0,
diff --git a/memdump/srecsend.c b/com32/sysdump/srecsend.c
similarity index 98%
copy from memdump/srecsend.c
copy to com32/sysdump/srecsend.c
index 78f32ed..5ca92c6 100644
--- a/memdump/srecsend.c
+++ b/com32/sysdump/srecsend.c
@@ -4,6 +4,7 @@
 
 #include <string.h>
 #include <stdio.h>
+#include <inttypes.h>
 #include "srecsend.h"
 
 static void make_srec(struct serial_if *sif, char type, size_t addr,
diff --git a/memdump/srecsend.h b/com32/sysdump/srecsend.h
similarity index 90%
copy from memdump/srecsend.h
copy to com32/sysdump/srecsend.h
index f2b0822..667be20 100644
--- a/memdump/srecsend.h
+++ b/com32/sysdump/srecsend.h
@@ -1,7 +1,6 @@
 #ifndef SRECSEND_H
 #define SRECSEND_H
 
-#include "mystuff.h"
 #include "file.h"
 
 void send_srec(struct serial_if *, struct file_info *,
diff --git a/memdump/ymodem.txt b/com32/sysdump/ymodem.txt
similarity index 100%
copy from memdump/ymodem.txt
copy to com32/sysdump/ymodem.txt
diff --git a/memdump/ymsend.c b/com32/sysdump/ymsend.c
similarity index 99%
copy from memdump/ymsend.c
copy to com32/sysdump/ymsend.c
index 9d89294..332b2b2 100644
--- a/memdump/ymsend.c
+++ b/com32/sysdump/ymsend.c
@@ -4,6 +4,7 @@
 
 #include <string.h>
 #include <stdio.h>
+#include <inttypes.h>
 #include "ymsend.h"
 
 enum {
diff --git a/memdump/ymsend.h b/com32/sysdump/ymsend.h
similarity index 91%
copy from memdump/ymsend.h
copy to com32/sysdump/ymsend.h
index b0d7438..ac6bef6 100644
--- a/memdump/ymsend.h
+++ b/com32/sysdump/ymsend.h
@@ -1,7 +1,6 @@
 #ifndef YMSEND_H
 #define YMSEND_H
 
-#include "mystuff.h"
 #include "file.h"
 
 void send_ymodem(struct serial_if *, struct file_info *,



More information about the Syslinux-commits mailing list