From: David Devecsery Date: Thu, 14 May 2020 14:48:58 +0000 (-0400) Subject: Added run scripts. Life is better now X-Git-Url: https://git.devinivas.org/?a=commitdiff_plain;h=886b76dbba3b9f8dc8c98cdb4bd35d7a8241507c;p=cs3210-lab1.git Added run scripts. Life is better now --- diff --git a/.cvsignore b/.cvsignore deleted file mode 100644 index 081a43c..0000000 --- a/.cvsignore +++ /dev/null @@ -1,16 +0,0 @@ -*.asm -*.d -*.sym -_* -kernel -user1 -userfs -usertests -xv6.img -vectors.S -bochsout.txt -bootblock -bootother -bootother.out -parport.out -fmt diff --git a/CMakeLists.txt b/CMakeLists.txt index e3d975d..78ac704 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -43,6 +43,12 @@ add_custom_command( 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 diff --git a/scripts/gdbinit b/scripts/gdbinit new file mode 100644 index 0000000..e4029e8 --- /dev/null +++ b/scripts/gdbinit @@ -0,0 +1,27 @@ +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 diff --git a/scripts/xv6-qemu b/scripts/xv6-qemu new file mode 100755 index 0000000..337bd25 --- /dev/null +++ b/scripts/xv6-qemu @@ -0,0 +1,71 @@ +#!/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} + diff --git a/user/CMakeLists.txt b/user/CMakeLists.txt index afee636..8cb606f 100644 --- a/user/CMakeLists.txt +++ b/user/CMakeLists.txt @@ -1,5 +1,7 @@ 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") @@ -15,21 +17,6 @@ set(CMAKE_C_LINK_EXECUTABLE "ld -m elf_i386 -N -e main -Ttext 0 -o