-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathriscvctl
executable file
·71 lines (65 loc) · 2.18 KB
/
riscvctl
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
#!/bin/sh
usage()
{
echo "$(basename $0): [kern|world|bbl|qemu|spike] <args>" >&2
exit 1
}
set -e
cd ~/src/freebsd-dev/dev/riscv
case "$1" in
kern|kernel)
shift
if [ $# -ne 1 -o "$1" != "-a" ]; then
flags=-DKERNFAST
fi
nice -n 20 make $flags -j$(sysctl -n hw.ncpu) buildkernel KERNCONF=GENERIC -s \
TARGET_ARCH=riscv64 CROSS_TOOLCHAIN=riscv64-gcc
destdir=${HOME}/src/riscv/world
make installkernel KERNCONF=GENERIC TARGET_ARCH=riscv64 DESTDIR=$destdir -s -DNO_ROOT
;;
world)
shift
destdir=${HOME}/src/riscv/world
if [ $# -ne 1 -o "$1" != "-a" ]; then
flags=-DNO_CLEAN
fi
opts="WITHOUT_DTRACE_TESTS= WITHOUT_OFED="
nice -n 20 make $flags -j$(sysctl -n hw.ncpu) -s buildworld \
$opts WITHOUT_FORMAT_EXTENSIONS= \
TARGET_ARCH=riscv64 CROSS_TOOLCHAIN=riscv64-gcc
make TARGET_ARCH=riscv64 $opts -DNO_ROOT DESTDIR=$destdir installworld
make TARGET_ARCH=riscv64 $opts -DNO_ROOT DESTDIR=$destdir distribution
cd $destdir
echo 'hostname=qemu' >> etc/rc.conf
echo '/dev/vtbd0 / ufs rw 1 1' > etc/fstab
echo './etc/fstab type=file uname=root gname=wheel mode=0644' >> METALOG
echo './etc/rc.conf type=file uname=root gname=wheel mode=0644' >> METALOG
makefs -D -f 1000000 -o version=2 -s 8g ${HOME}/src/riscv/riscv.img METALOG
;;
bbl)
cd ~/src/riscv/riscv-pk
rm -rf build
mkdir build
cd build
CFLAGS=-nostdlib ../configure --enable-logo --prefix=${HOME}/src/riscv --host=riscv64-unknown-freebsd13.0 \
--with-arch=rv64imafdc --with-payload=${HOME}/src/riscv/world/boot/kernel/kernel
gmake -j $(sysctl -n hw.ncpu) bbl
;;
qemu)
shift
if [ $# -eq 2 -a "$1" = "-i" ]; then
img=$2
else
img=${HOME}/src/riscv/riscv.img
fi
sudo qemu-system-riscv64 -machine virt -m 2048M -kernel ${HOME}/src/riscv/riscv-pk/build/bbl -nographic \
-drive file=${img},format=raw,id=hd0 -device virtio-blk-device,drive=hd0 \
-netdev tap,ifname=tap0,script=no,id=net0 -device virtio-net-device,netdev=net0 -smp 4
;;
spike)
sudo spike -m2048 -p2 ${HOME}/src/riscv/riscv-pk/build/bbl
;;
*)
usage
;;
esac