2019-07-21 06:59:23 +00:00
|
|
|
#!/bin/sh
|
7842 - new directory organization
Baremetal is now the default build target and therefore has its sources
at the top-level. Baremetal programs build using the phase-2 Mu toolchain
that requires a Linux kernel. This phase-2 codebase which used to be at
the top-level is now under the linux/ directory. Finally, the phase-2 toolchain,
while self-hosting, has a way to bootstrap from a C implementation, which
is now stored in linux/bootstrap. The bootstrap C implementation uses some
literate programming tools that are now in linux/bootstrap/tools.
So the whole thing has gotten inverted. Each directory should build one
artifact and include the main sources (along with standard library). Tools
used for building it are relegated to sub-directories, even though those
tools are often useful in their own right, and have had lots of interesting
programs written using them.
A couple of things have gotten dropped in this process:
- I had old ways to run on just a Linux kernel, or with a Soso kernel.
No more.
- I had some old tooling for running a single test at the cursor. I haven't
used that lately. Maybe I'll bring it back one day.
The reorg isn't done yet. Still to do:
- redo documentation everywhere. All the README files, all other markdown,
particularly vocabulary.md.
- clean up how-to-run comments at the start of programs everywhere
- rethink what to do with the html/ directory. Do we even want to keep
supporting it?
In spite of these shortcomings, all the scripts at the top-level, linux/
and linux/bootstrap are working. The names of the scripts also feel reasonable.
This is a good milestone to take stock at.
2021-03-04 06:09:50 +00:00
|
|
|
# Translate SubX files to a bootable disk image.
|
|
|
|
#
|
|
|
|
# A couple of gotchas:
|
|
|
|
# * Many phases here have no error-checking. Perhaps I should use a
|
|
|
|
# version of translate_subx_debug for baremetal.
|
|
|
|
# * Don't pass in numbered .subx files without translated .mu files. Our test
|
|
|
|
# harness is in test.mu, and only Mu programs can run tests in baremetal.
|
|
|
|
#
|
|
|
|
# The top level is in general not as rigorous about avoiding dependency cycles
|
|
|
|
# as the lower-level tools in linux/
|
2019-07-21 06:59:23 +00:00
|
|
|
|
2020-04-10 22:28:10 +00:00
|
|
|
set -e
|
2019-07-21 06:59:23 +00:00
|
|
|
|
2021-05-14 18:54:42 +00:00
|
|
|
cat $* |linux/braces > a.braces
|
2019-09-20 17:08:42 +00:00
|
|
|
|
2021-05-14 18:54:42 +00:00
|
|
|
cat a.braces |linux/calls > a.calls
|
2019-09-07 00:45:44 +00:00
|
|
|
|
2021-05-14 18:54:42 +00:00
|
|
|
cat a.calls |linux/sigils > a.sigils
|
2019-08-26 05:15:26 +00:00
|
|
|
|
2021-05-14 18:54:42 +00:00
|
|
|
cat a.sigils |linux/tests > a.tests
|
2019-07-21 06:59:23 +00:00
|
|
|
|
7842 - new directory organization
Baremetal is now the default build target and therefore has its sources
at the top-level. Baremetal programs build using the phase-2 Mu toolchain
that requires a Linux kernel. This phase-2 codebase which used to be at
the top-level is now under the linux/ directory. Finally, the phase-2 toolchain,
while self-hosting, has a way to bootstrap from a C implementation, which
is now stored in linux/bootstrap. The bootstrap C implementation uses some
literate programming tools that are now in linux/bootstrap/tools.
So the whole thing has gotten inverted. Each directory should build one
artifact and include the main sources (along with standard library). Tools
used for building it are relegated to sub-directories, even though those
tools are often useful in their own right, and have had lots of interesting
programs written using them.
A couple of things have gotten dropped in this process:
- I had old ways to run on just a Linux kernel, or with a Soso kernel.
No more.
- I had some old tooling for running a single test at the cursor. I haven't
used that lately. Maybe I'll bring it back one day.
The reorg isn't done yet. Still to do:
- redo documentation everywhere. All the README files, all other markdown,
particularly vocabulary.md.
- clean up how-to-run comments at the start of programs everywhere
- rethink what to do with the html/ directory. Do we even want to keep
supporting it?
In spite of these shortcomings, all the scripts at the top-level, linux/
and linux/bootstrap are working. The names of the scripts also feel reasonable.
This is a good milestone to take stock at.
2021-03-04 06:09:50 +00:00
|
|
|
# no assort since baremetal SubX doesn't have segments yet
|
2019-07-21 06:59:23 +00:00
|
|
|
|
2021-05-14 18:54:42 +00:00
|
|
|
cat a.tests |linux/dquotes > a.dquotes
|
2019-07-21 06:59:23 +00:00
|
|
|
|
2021-05-14 18:54:42 +00:00
|
|
|
cat a.dquotes |linux/pack > a.pack
|
2019-11-18 20:50:01 +00:00
|
|
|
|
2021-05-14 18:54:42 +00:00
|
|
|
cat a.pack |linux/survey_baremetal > labels
|
|
|
|
cat a.pack |linux/labels_baremetal labels > a.survey
|
2019-07-21 06:59:23 +00:00
|
|
|
|
2021-05-14 18:54:42 +00:00
|
|
|
cat a.survey |linux/hex > a.bin
|
2019-07-21 06:59:23 +00:00
|
|
|
|
2021-04-17 03:26:42 +00:00
|
|
|
# Create code.img containing a.bin
|
2021-05-14 19:56:58 +00:00
|
|
|
dd if=/dev/zero of=code.img count=20160 # 20*16*63 512-byte sectors = almost 10MB
|
2021-04-17 03:26:42 +00:00
|
|
|
dd if=a.bin of=code.img conv=notrunc
|
2019-09-05 00:36:12 +00:00
|
|
|
|
2021-07-06 00:53:57 +00:00
|
|
|
if [ `stat --printf="%s" a.bin` -ge 451584 ] # 14 tracks * 63 sectors per track * 512 bytes per sector (keep this sync'd with boot.subx)
|
7842 - new directory organization
Baremetal is now the default build target and therefore has its sources
at the top-level. Baremetal programs build using the phase-2 Mu toolchain
that requires a Linux kernel. This phase-2 codebase which used to be at
the top-level is now under the linux/ directory. Finally, the phase-2 toolchain,
while self-hosting, has a way to bootstrap from a C implementation, which
is now stored in linux/bootstrap. The bootstrap C implementation uses some
literate programming tools that are now in linux/bootstrap/tools.
So the whole thing has gotten inverted. Each directory should build one
artifact and include the main sources (along with standard library). Tools
used for building it are relegated to sub-directories, even though those
tools are often useful in their own right, and have had lots of interesting
programs written using them.
A couple of things have gotten dropped in this process:
- I had old ways to run on just a Linux kernel, or with a Soso kernel.
No more.
- I had some old tooling for running a single test at the cursor. I haven't
used that lately. Maybe I'll bring it back one day.
The reorg isn't done yet. Still to do:
- redo documentation everywhere. All the README files, all other markdown,
particularly vocabulary.md.
- clean up how-to-run comments at the start of programs everywhere
- rethink what to do with the html/ directory. Do we even want to keep
supporting it?
In spite of these shortcomings, all the scripts at the top-level, linux/
and linux/bootstrap are working. The names of the scripts also feel reasonable.
This is a good milestone to take stock at.
2021-03-04 06:09:50 +00:00
|
|
|
then
|
2021-03-15 04:27:39 +00:00
|
|
|
echo "a.bin won't all be loaded on boot"
|
7842 - new directory organization
Baremetal is now the default build target and therefore has its sources
at the top-level. Baremetal programs build using the phase-2 Mu toolchain
that requires a Linux kernel. This phase-2 codebase which used to be at
the top-level is now under the linux/ directory. Finally, the phase-2 toolchain,
while self-hosting, has a way to bootstrap from a C implementation, which
is now stored in linux/bootstrap. The bootstrap C implementation uses some
literate programming tools that are now in linux/bootstrap/tools.
So the whole thing has gotten inverted. Each directory should build one
artifact and include the main sources (along with standard library). Tools
used for building it are relegated to sub-directories, even though those
tools are often useful in their own right, and have had lots of interesting
programs written using them.
A couple of things have gotten dropped in this process:
- I had old ways to run on just a Linux kernel, or with a Soso kernel.
No more.
- I had some old tooling for running a single test at the cursor. I haven't
used that lately. Maybe I'll bring it back one day.
The reorg isn't done yet. Still to do:
- redo documentation everywhere. All the README files, all other markdown,
particularly vocabulary.md.
- clean up how-to-run comments at the start of programs everywhere
- rethink what to do with the html/ directory. Do we even want to keep
supporting it?
In spite of these shortcomings, all the scripts at the top-level, linux/
and linux/bootstrap are working. The names of the scripts also feel reasonable.
This is a good milestone to take stock at.
2021-03-04 06:09:50 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
2021-05-14 19:56:58 +00:00
|
|
|
|
2021-07-22 10:58:54 +00:00
|
|
|
if [ `stat --printf="%s" a.bin` -ge 492544 ] # 15 tracks * 63 sectors per track * 512 bytes per sector
|
|
|
|
then
|
|
|
|
echo "a.bin will overwrite BIOS/Video memory; you'll need to adjust boot.subx to load code to some other non-contiguous area of memory"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2021-05-14 19:56:58 +00:00
|
|
|
# Latter half of disk is for debug info.
|
2021-05-15 04:32:06 +00:00
|
|
|
dd if=labels of=code.img seek=10080 conv=notrunc # keep this sync'd with abort.subx
|
2021-07-29 06:28:29 +00:00
|
|
|
if [ `stat --printf="%s" labels` -ge 1048576 ] # 8 reads * 256 sectors * 512 bytes per sector
|
2021-05-14 19:56:58 +00:00
|
|
|
then
|
2021-05-15 04:29:42 +00:00
|
|
|
echo "labels won't all be loaded on abort"
|
2021-05-14 19:56:58 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
2021-05-15 04:32:06 +00:00
|
|
|
|
2021-07-28 05:37:32 +00:00
|
|
|
if [ `wc -l < labels` -gt 20480 ] # 0x5000 stream capacity in abort.subx
|
2021-05-15 04:32:06 +00:00
|
|
|
then
|
|
|
|
echo "abort will go into infinite regress"
|
|
|
|
exit 1
|
|
|
|
fi
|