-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpintos-setup.sh
executable file
·110 lines (90 loc) · 3.65 KB
/
pintos-setup.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#!/bin/bash
function msg() {
echo -ne '\033[01;33m'
echo "$1"
echo -ne '\033[00m'
}
function die() {
echo -ne '\033[01;31m'
echo "$1"
echo -ne '\033[00m'
exit 1
}
# Some quick checks before we get started with side effects
if [ -z "$1" ]; then
die "usage: ./setup.sh ABSOLUTE_PATH_TO_PINTOS_DIRECTORY"
fi
if [ ! -d "$1" ]; then
die "argument '$1' is not a directory"
fi
# Process threads-vs-userprog argument
USERPROG=0
VM=0
FILESYS=0
ARG2=$2
if [ -z "$2" ]; then
ARG2=threads
fi
if [ "$ARG2" = "threads" -o "$ARG2" = "k" ]; then
msg "Setting up a kernel-space pintos build"
elif [ "$ARG2" = "userprog" -o "$ARG2" = "u" ]; then
msg "Setting up a user-space pintos build"
USERPROG=1
elif [ "$ARG2" = "vm" -o "$ARG2" = "v" ]; then
msg "Setting up a user-space pintos build with vm enabled"
USERPROG=1
VM=1
elif [ "$ARG2" = "filesys" -o "$ARG2" = "f" ]; then
msg "Setting up a user-space pintos build with filesys enabled"
USERPROG=1
FILESYS=1
else
die "Argument 2 must be either 'threads' or 'userprog' or 'vm' or 'filesys'"
fi
# Get started with side effects.
./prepare-workspace.sh || die "couldn't prepare workspace"
# Build iterative deepening wrapper.
cd id || die "couldn't cd into id"
make || die "couldn't build id program"
# Put config.landslide into place.
cd ../pebsim || die "couldn't cd into pebsim"
CONFIG=config.landslide.pintos
CONFIG_EXTRA=config-extra.landslide.pintos
SYMLINK=config.landslide
[ -f $CONFIG ] || die "couldn't find appropriate config: $CONFIG"
rm -f "$SYMLINK" || die "couldn't clear symlink $SYMLINK"
ln -s "$CONFIG" "$SYMLINK" || die "couldn't create config symlink"
rm -f bochsrc.txt || die "couldn't clear symlink bochsrc.txt"
ln -s bochsrc-pintos.txt bochsrc.txt || die "couldn't create bochsrc symlink"
rm -f "$CONFIG_EXTRA" || die "couldn't clear $CONFIG_EXTRA"
echo "#!/bin/bash" >> "$CONFIG_EXTRA" || die "write error"
echo "# Auto generated by $0. Do not edit." >> "$CONFIG_EXTRA" || die "write error"
echo "# Made on `date` for group '$1'." >> "$CONFIG_EXTRA" || die "write error"
echo "PINTOS_USERPROG=$USERPROG" >> "$CONFIG_EXTRA" || die "write error"
# Import and build student pintos.
cd pintos || die "couldn't cd into pintos directory"
PINTOSDIR="$PWD"
msg "Importing your Pintos into '$PINTOSDIR' - look there if something goes wrong..."
./import-pintos.sh "$1" "$USERPROG" "$VM" "$FILESYS" || die "could not import your pintos"
./build.sh "$USERPROG" "$VM" "$FILESYS" || die "import pintos was successful, but build failed (from '$PWD')"
cd ../../pebsim/ || die "couldn't cd into pebsim"
# Fix size of console lock in config, which varies across ze studence.
CONSOLE_LOCK_NUMS=`objdump -t kernel | sort | grep -A1 '\<console_lock\>' | cut -d' ' -f1`
CONSOLE_LOCK_BASE=`echo $CONSOLE_LOCK_NUMS | cut -d' ' -f1`
CONSOLE_LOCK_END=`echo $CONSOLE_LOCK_NUMS | cut -d' ' -f2`
CONSOLE_LOCK_SIZE=$((0x$CONSOLE_LOCK_END - 0x$CONSOLE_LOCK_BASE))
msg "This kernel's locks are $CONSOLE_LOCK_SIZE bytes."
echo "CONSOLE_LOCK_SIZE=$CONSOLE_LOCK_SIZE" >> "$CONFIG_EXTRA" || die "write error"
# Make sure landslide compiles before approving use of ID wrapper program.
msg "Setting up Landslide..."
export LANDSLIDE_CONFIG=config.landslide
./build.sh || die "Failed to compile landslide. Please send a tarball of this directory to Ben for assistance."
echo -ne '\033[01;33m'
echo "Note: Your Pintos was imported into '$PINTOSDIR'. If you wish to make changes to it, recommend editing it in '$1' then running this script again."
echo -ne '\033[01;32m'
echo "Setup successful. Can now run ./landslide."
echo -ne '\033[00m'
rm -f current-pintos-group.txt
echo "$1" >> current-pintos-group.txt
rm -f current-architecture.txt
echo "pintos" > current-architecture.txt