]> Devi Nivas Git - cs3210-lab1.git/commitdiff
Added run scripts. Life is better now
authorDavid Devecsery <ddevec@gatech.edu>
Thu, 14 May 2020 14:48:58 +0000 (10:48 -0400)
committerDavid Devecsery <ddevec@gatech.edu>
Thu, 14 May 2020 14:48:58 +0000 (10:48 -0400)
.cvsignore [deleted file]
CMakeLists.txt
scripts/gdbinit [new file with mode: 0644]
scripts/xv6-qemu [new file with mode: 0755]
user/CMakeLists.txt

diff --git a/.cvsignore b/.cvsignore
deleted file mode 100644 (file)
index 081a43c..0000000
+++ /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
index e3d975dbccd04b7348dd222e04282c2b1837c7bf..78ac7047101dd2067a2e4b431fc80c9e296233e9 100644 (file)
@@ -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 (file)
index 0000000..e4029e8
--- /dev/null
@@ -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 (executable)
index 0000000..337bd25
--- /dev/null
@@ -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}
+
index afee6365b98a568e8ae375d386b68b980559321b..8cb606f88ae1b3aa98273f283cd3d03516bb6fe5 100644 (file)
@@ -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 <OBJECTS> -o <TA
 # 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