summaryrefslogtreecommitdiff
path: root/kernel/run
diff options
context:
space:
mode:
authorDennis Kobert <dennis@kobert.dev>2019-11-04 03:25:16 +0100
committerDennis Kobert <dennis@kobert.dev>2019-11-04 03:25:16 +0100
commit403c53fd6c7059c159db1604eb178251239fc4bf (patch)
tree99cbba45f546ea23ad8b66274fd9a122ba9f3a8c /kernel/run
parentb47731c6fd99d80b1023d906dd4b3bb377e49438 (diff)
Implement serial connection and basic testing
Diffstat (limited to 'kernel/run')
-rwxr-xr-xkernel/run39
1 files changed, 29 insertions, 10 deletions
diff --git a/kernel/run b/kernel/run
index d8aa011..c18450b 100755
--- a/kernel/run
+++ b/kernel/run
@@ -16,6 +16,7 @@ function define_vars() {
target_name="$target-$name"
target_path="target/"
rust_target_path="$target_path/$target_name/$build_mode/"
+ kernel_libary="$rust_target_path/libkernel.a"
iso_path="$target_path/iso/"
obj_path="$iso_path/obj/"
src_path="src/"
@@ -42,11 +43,12 @@ print_help() {
}
get_rust_bin() {
- if $test_mode; then
- echo "$rust_target_path/$(ls -t1 $rust_target_path | grep -P '^kernel-[a-fA-F0-9]+$' | head -n1)"
- else
- echo "$rust_target_path/libkernel.a"
- fi
+ #if $test_mode; then
+ # echo "$rust_target_path/$(ls -t1 $rust_target_path | grep -P '^kernel-[a-fA-F0-9]+$' | head -n1)"
+ #else
+ # echo "$rust_target_path/libkernel.a"
+ #fi
+ echo "$kernel_libary"
}
prepare_iso() {
@@ -64,16 +66,20 @@ prepare_iso() {
build_iso() {
ld -n -o "$iso_path/isofiles/boot/kernel.bin" -gc-sections -T "$link_script" "$obj_path"/*.o "$(get_rust_bin)"
- grub-mkrescue -d /usr/lib/grub/i386-pc -o "$iso_path/$name.iso" "$iso_path/isofiles"
+ grub-mkrescue -d /usr/lib/grub/i386-pc -o "$iso_path/$name.iso" "$iso_path/isofiles" &> /dev/null
+ echo "$kernel_libary"
}
build() {
if test ! -d "$iso_path/isofiles"; then
prepare_iso
fi
- if $test_mode; then
- RUSTFLAGS="-Clink-arg=-r -Clink-dead-code" cargo xtest --no-run
- else
+ #if $test_mode; then
+ # RUSTFLAGS="-Clink-arg=-r -Clink-dead-code" cargo xtest --no-run
+ #else
+ # cargo xbuild
+ #fi
+ if ! $test_mode; then
cargo xbuild
fi
build_iso
@@ -82,7 +88,18 @@ build() {
run() {
case "$target" in
"x86_64")
- qemu-system-x86_64 -cdrom "$iso_path/$name.iso";;
+ qemu="qemu-system-x86_64 -cdrom $iso_path/$name.iso"
+ if $test_mode; then
+ qemu="$qemu -device isa-debug-exit,iobase=0xf4,iosize=0x04 -serial stdio -display none"
+ fi
+ $qemu
+ case "$?" in
+ 33) exit 0;;
+ 35) exit 1;;
+ *)
+ echo "qemu exited unexpectedly $?";
+ exit 1;;
+ esac;;
*)
echo "error: no laucher defined for target '$target'";;
esac
@@ -98,6 +115,8 @@ for arg in "$@"; do
target="$(echo $arg | sed "s/^-target=//")"; define_vars;;
-test)
test_mode=true; define_vars;;
+ /*kernel-*)
+ kernel_libary=$arg;;
"run") action=run;;
"build") action=build;;
"test") action=test;;