From 01396b3a8787d3b6e694675d3f28ddbc90f6b832 Mon Sep 17 00:00:00 2001 From: Austin Clements Date: Sun, 20 Sep 2009 23:07:59 -0400 Subject: [PATCH 1/8] xv6 runs the console on the serial port, not the parallel port --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 1e73ee1..2e1b927 100644 --- a/Makefile +++ b/Makefile @@ -143,7 +143,7 @@ GDBPORT = $(shell expr `id -u` % 5000 + 25000) QEMUOPTS = -smp 2 -hdb fs.img xv6.img qemu: fs.img xv6.img - qemu -parallel mon:stdio $(QEMUOPTS) + qemu -serial mon:stdio $(QEMUOPTS) qemutty: fs.img xv6.img qemu -nographic $(QEMUOPTS) @@ -153,7 +153,7 @@ qemutty: fs.img xv6.img qemu-gdb: fs.img xv6.img .gdbinit @echo "*** Now run 'gdb'." 1>&2 - qemu -parallel mon:stdio $(QEMUOPTS) -s -S -p $(GDBPORT) + qemu -serial mon:stdio $(QEMUOPTS) -s -S -p $(GDBPORT) # CUT HERE # prepare dist for students From 67f7909fe113d1e91cbafeaf3377da813cdcd382 Mon Sep 17 00:00:00 2001 From: Austin Clements Date: Sun, 20 Sep 2009 23:08:36 -0400 Subject: [PATCH 2/8] Use the symbol file --- .gdbinit.tmpl | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.gdbinit.tmpl b/.gdbinit.tmpl index 4c4e734..f71681a 100644 --- a/.gdbinit.tmpl +++ b/.gdbinit.tmpl @@ -1,9 +1,5 @@ set $lastcs = -1 -# This fails on Darwin because the default gdb has no ELF support -# echo + symbol-file obj/kern/kernel\n -# symbol-file obj/kern/kernel - define hook-stop # There doesn't seem to be a good way to detect if we're in 16- or # 32-bit mode, but in 32-bit mode we always run with CS == 8 in the @@ -26,3 +22,6 @@ end echo + target remote localhost:1234\n target remote localhost:1234 + +echo + symbol-file kernel\n +symbol-file kernel From 3adc415471c8b53ef024cde0846c206372cbf04e Mon Sep 17 00:00:00 2001 From: Austin Clements Date: Sun, 20 Sep 2009 23:09:59 -0400 Subject: [PATCH 3/8] Hack to make newlines on the serial port work --- console.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/console.c b/console.c index 0613a47..f7a6590 100644 --- a/console.c +++ b/console.c @@ -205,6 +205,9 @@ consoleintr(int (*getc)(void)) break; default: if(c != 0 && input.e-input.r < INPUT_BUF){ + // The serial port produces 0x13, not 0x10 + if(c == '\r') + c = '\n'; input.buf[input.e++ % INPUT_BUF] = c; consputc(c); if(c == '\n' || c == C('D') || input.e == input.r+INPUT_BUF){ From bab819ed8d77abe65ea16945f42e76b3d4d1ff8b Mon Sep 17 00:00:00 2001 From: Austin Clements Date: Wed, 30 Sep 2009 22:09:48 -0400 Subject: [PATCH 4/8] Be consistent with JOS make targets --- Makefile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 2e1b927..07463d9 100644 --- a/Makefile +++ b/Makefile @@ -145,7 +145,7 @@ QEMUOPTS = -smp 2 -hdb fs.img xv6.img qemu: fs.img xv6.img qemu -serial mon:stdio $(QEMUOPTS) -qemutty: fs.img xv6.img +qemu-nox: fs.img xv6.img qemu -nographic $(QEMUOPTS) .gdbinit: .gdbinit.tmpl @@ -155,6 +155,10 @@ qemu-gdb: fs.img xv6.img .gdbinit @echo "*** Now run 'gdb'." 1>&2 qemu -serial mon:stdio $(QEMUOPTS) -s -S -p $(GDBPORT) +qemu-gdb-nox: fs.img xv6.img .gdbinit + @echo "*** Now run 'gdb'." 1>&2 + qemu -nographic $(QEMUOPTS) -s -S -p $(GDBPORT) + # CUT HERE # prepare dist for students # after running make dist, probably want to From 29d8c2eebbce0274a50558bffc94099083a2cb16 Mon Sep 17 00:00:00 2001 From: Austin Clements Date: Wed, 30 Sep 2009 22:32:50 -0400 Subject: [PATCH 5/8] Handle backspace on serial input and output better. Better solutions are welcome. --- console.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/console.c b/console.c index f7a6590..16d0e7a 100644 --- a/console.c +++ b/console.c @@ -163,7 +163,12 @@ consputc(int c) ; } - uartputc(c); + if (c == BACKSPACE) { + uartputc('\b'); + uartputc(' '); + uartputc('\b'); + } else + uartputc(c); cgaputc(c); } @@ -198,6 +203,7 @@ consoleintr(int (*getc)(void)) } break; case C('H'): // Backspace + case '\x7f': if(input.e != input.w){ input.e--; consputc(BACKSPACE); From 77a9aa55cd0c18ef33ebfa484b534511af4af53d Mon Sep 17 00:00:00 2001 From: Austin Clements Date: Mon, 5 Oct 2009 13:20:23 -0400 Subject: [PATCH 6/8] Record debug info for assmebly code --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 07463d9..24ba05e 100644 --- a/Makefile +++ b/Makefile @@ -39,7 +39,7 @@ OBJCOPY = $(TOOLPREFIX)objcopy OBJDUMP = $(TOOLPREFIX)objdump CFLAGS = -fno-pic -static -fno-builtin -fno-strict-aliasing -O2 -Wall -MD -ggdb -m32 CFLAGS += $(shell $(CC) -fno-stack-protector -E -x c /dev/null >/dev/null 2>&1 && echo -fno-stack-protector) -ASFLAGS = -m32 +ASFLAGS = -m32 -gdwarf-2 # FreeBSD ld wants ``elf_i386_fbsd'' LDFLAGS += -m $(shell $(LD) -V | grep elf_i386 2>/dev/null) From 6639ce56d986cdae197e4f013dde536178ad23f8 Mon Sep 17 00:00:00 2001 From: Austin Clements Date: Wed, 7 Oct 2009 12:05:56 -0400 Subject: [PATCH 7/8] Provide memcpy for compatibility with older versions of gcc --- defs.h | 1 + string.c | 6 ++++++ user.h | 1 + 3 files changed, 8 insertions(+) diff --git a/defs.h b/defs.h index bcfab55..525c05b 100644 --- a/defs.h +++ b/defs.h @@ -124,6 +124,7 @@ void popcli(); // string.c int memcmp(const void*, const void*, uint); void* memmove(void*, const void*, uint); +void* memcpy(void*, const void*, uint); void* memset(void*, int, uint); char* safestrcpy(char*, const char*, int); int strlen(const char*); diff --git a/string.c b/string.c index cb890ee..b356895 100644 --- a/string.c +++ b/string.c @@ -44,6 +44,12 @@ memmove(void *dst, const void *src, uint n) return dst; } +void* +memcpy(void *dst, const void *src, uint n) +{ + return memmove(dst, src, n); +} + int strncmp(const char *p, const char *q, uint n) { diff --git a/user.h b/user.h index 8280b2e..18faadb 100644 --- a/user.h +++ b/user.h @@ -26,6 +26,7 @@ int sleep(int); int stat(char*, struct stat*); char* strcpy(char*, char*); void *memmove(void*, void*, int); +void *memcpy(void*, void*, int); char* strchr(const char*, char c); int strcmp(const char*, const char*); void printf(int, char*, ...); From 2c536bff67ed209b1c5aa3d40e40731813bfcd9a Mon Sep 17 00:00:00 2001 From: Austin Clements Date: Wed, 7 Oct 2009 13:06:55 -0400 Subject: [PATCH 8/8] Remove memcpy prototypes at Russ' request to prevent code from calling memcpy directly. --- defs.h | 1 - string.c | 1 + user.h | 1 - 3 files changed, 1 insertion(+), 2 deletions(-) diff --git a/defs.h b/defs.h index 525c05b..bcfab55 100644 --- a/defs.h +++ b/defs.h @@ -124,7 +124,6 @@ void popcli(); // string.c int memcmp(const void*, const void*, uint); void* memmove(void*, const void*, uint); -void* memcpy(void*, const void*, uint); void* memset(void*, int, uint); char* safestrcpy(char*, const char*, int); int strlen(const char*); diff --git a/string.c b/string.c index b356895..a557dc5 100644 --- a/string.c +++ b/string.c @@ -44,6 +44,7 @@ memmove(void *dst, const void *src, uint n) return dst; } +// memcpy exists to placate GCC. Use memmove. void* memcpy(void *dst, const void *src, uint n) { diff --git a/user.h b/user.h index 18faadb..8280b2e 100644 --- a/user.h +++ b/user.h @@ -26,7 +26,6 @@ int sleep(int); int stat(char*, struct stat*); char* strcpy(char*, char*); void *memmove(void*, void*, int); -void *memcpy(void*, void*, int); char* strchr(const char*, char c); int strcmp(const char*, const char*); void printf(int, char*, ...);