+++ /dev/null
-*.asm
-*.d
-*.sym
-_*
-kernel
-user1
-userfs
-usertests
-xv6.img
-vectors.S
-bochsout.txt
-bootblock
-bootother
-bootother.out
-parport.out
-fmt
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/bootblock/bootblock ${CMAKE_CURRENT_BINARY_DIR}/kernel/kernel
)
+# Copy the run script
+configure_file(${CMAKE_SOURCE_DIR}/scripts/xv6-qemu ${CMAKE_CURRENT_BINARY_DIR}/xv6-qemu COPYONLY)
+configure_file(${CMAKE_SOURCE_DIR}/scripts/gdbinit ${CMAKE_CURRENT_BINARY_DIR}/.gdbinit COPYONLY)
+
+# Copy the gdb script
+
add_custom_target(
image ALL
DEPENDS buildkern buildboot xv6.img makeuserfs
--- /dev/null
+set $lastcs = -1
+
+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
+ # kernel and CS == 35 in user space
+ if $cs == 8 || $cs == 35
+ if $lastcs != 8 && $lastcs != 35
+ set architecture i386
+ end
+ x/i $pc
+ else
+ if $lastcs == -1 || $lastcs == 8 || $lastcs == 35
+ set architecture i8086
+ end
+ # Translate the segment:offset into a physical address
+ printf "[%4x:%4x] ", $cs, $eip
+ x/i $cs*16+$eip
+ end
+ set $lastcs = $cs
+end
+
+echo + target remote localhost:26000\n
+target remote localhost:26000
+
+echo + symbol-file kernel/kernel\n
+symbol-file kernel/kernel
--- /dev/null
+#!/bin/bash
+
+CPUS="1"
+MEMORY="512"
+GDB=""
+GRAPHIC="-nographic"
+VERBOSE=false
+
+function print_help() {
+ print "usage $0 [-c|--num-cpus=NUM_CPUS] [-g|--gdb] [-x|-x-server] [-v|--verbose] [-m|--memory=PHYS_MEMORY]"
+ print " -h -\? --help -- Display this message"
+ print " -c --num-cpus -- The number of CPUS to give to xv6, default is ${CPUS}"
+ print " -g --gdb -- Enable gdb connections"
+ print " -x --x-server -- Turn on the x server display"
+ print " -v --verbose -- More verbose printing from this script"
+ print " -m --memory -- Set the amount of memory to give to xv6 (default is ${MEMORY})"
+}
+
+OPTIONS="h?c:gxvm"
+LONGOPTS="help,num-cpus:,gdb,x-server,verbose,memory"
+
+! PARSED=$(getopt --options=${OPTIONS} --longoptions=${LONGOPTS} --name "$0" -- "$@")
+
+if [[ ${PIPESTATUS[0]} -ne 0 ]]; then
+ print_help
+ exit 1
+fi
+
+eval set -- "${PARSED}"
+
+
+
+while true; do
+ case "$1" in
+ -h|-\?|--help)
+ print_help
+ exit 0
+ ;;
+ -v|--verbose)
+ VERBOSE=true
+ ;;
+ -c|--num-cpus)
+ CPUS="$2"
+ shift 2
+ ;;
+ -g|--gdb)
+ GDB="-S -gdb tcp::26000"
+ shift
+ ;;
+ --)
+ shift
+ break
+ ;;
+ *)
+ echo "Unrecognized option $1"
+ print_help
+ exit 1
+ ;;
+ esac
+done
+
+
+
+SCRIPT="qemu-system-i386 ${GRAPHIC} -drive file=user/fs.img,index=1,media=disk,format=raw -drive file=xv6.img,index=0,media=disk,format=raw -smp ${CPUS} -m ${MEMORY} ${GDB}"
+
+#if [[ ${VERBOSE} ]]; then
+ echo "COMMAND: ${SCRIPT}"
+#fi
+
+${SCRIPT}
+
project(user ASM)
+include(Sources.cmake)
+
include_directories(include)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -static -fno-builtin -nostdinc -nostartfiles -nodefaultlibs -fno-pic -m32")
# Need to create disassembly
# Need to create symbol files
-set(ulib_SOURCES
- asm/usys.S
-
- src/ulib.c
- src/umalloc.c
- src/printf.c
- )
-
-# Start with just init...
-set(user_SOURCES
- src/init.c
- src/sh.c
- src/ls.c
- )
-
set_property(GLOBAL PROPERTY user_programs)
add_library(ulib OBJECT