summaryrefslogtreecommitdiff
path: root/run.sh
diff options
context:
space:
mode:
authorAlejandro Sior <aho@sior.be>2022-06-18 10:39:10 +0200
committerAlejandro Sior <aho@sior.be>2022-06-18 10:39:10 +0200
commitbd98b26786d21ffddb017ffe35ecaa4a9fd0aa4a (patch)
tree1b78a43385bf0751abab8dd2423905696fd5baab /run.sh
parent3aefeeb723b8822916fb39b7c32551c35c06e32f (diff)
boot: arbitrary location of stage 1 and identity map more memoryHEADmaster
Diffstat (limited to 'run.sh')
-rwxr-xr-xrun.sh18
1 files changed, 18 insertions, 0 deletions
diff --git a/run.sh b/run.sh
index 6b28de9..346267c 100755
--- a/run.sh
+++ b/run.sh
@@ -1,5 +1,14 @@
#!/bin/sh -e
+print_u32() {
+ printf "\\$(printf %o $(($1&0xFF)))\\$(printf %o $((($1 >> 8)&0xFF)))\\$(printf %o $((($1 >> 16)&0xFF)))\\$(printf %o $((($1 >> 24)&0xFF)))"
+}
+
+
+write_u32() {
+ print_u32 $1 | dd if=/dev/stdin of=$3 conv=notrunc bs=1 seek=$2 status=none
+}
+
# :Tell hare to use our custom runtime
# and linker scripts (this feature is so simple and neat :))
export HAREPATH=.
@@ -19,4 +28,13 @@ objcopy \
--binary-architecture=i386:x86-64 \
boot boot.bin
+size=$(stat -c %s boot.bin)
+sectors=$((size/512 + 1))
+write_u32 1 $((446 + 8)) boot.bin
+write_u32 $sectors $((446 + 12)) boot.bin
+
+[ -f boot.img ] && rm boot.img
+../gptman/gptman convert boot.bin boot.img
+chmod +rw boot.img
+
bochs