Skip to content

Commit

Permalink
Merge branch 'master' of git+ssh://amsterdam.csail.mit.edu/home/am0/6…
Browse files Browse the repository at this point in the history
….828/xv6
  • Loading branch information
Frans Kaashoek committed Oct 7, 2009
2 parents ab777a9 + 2c536bf commit aaf63e6
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 9 deletions.
7 changes: 3 additions & 4 deletions .gdbinit.tmpl
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -26,3 +22,6 @@ end

echo + target remote localhost:1234\n
target remote localhost:1234

echo + symbol-file kernel\n
symbol-file kernel
12 changes: 8 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -143,17 +143,21 @@ 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-nox: fs.img xv6.img
qemu -nographic $(QEMUOPTS)

.gdbinit: .gdbinit.tmpl
sed "s/localhost:1234/localhost:$(GDBPORT)/" < $^ > $@

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)

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
Expand Down
11 changes: 10 additions & 1 deletion console.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,12 @@ consputc(int c)
;
}

uartputc(c);
if (c == BACKSPACE) {
uartputc('\b');
uartputc(' ');
uartputc('\b');
} else
uartputc(c);
cgaputc(c);
}

Expand Down Expand Up @@ -198,13 +203,17 @@ consoleintr(int (*getc)(void))
}
break;
case C('H'): // Backspace
case '\x7f':
if(input.e != input.w){
input.e--;
consputc(BACKSPACE);
}
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){
Expand Down
7 changes: 7 additions & 0 deletions string.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ 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)
{
return memmove(dst, src, n);
}

int
strncmp(const char *p, const char *q, uint n)
{
Expand Down

0 comments on commit aaf63e6

Please sign in to comment.