93 lines
No EOL
4.7 KiB
Markdown
93 lines
No EOL
4.7 KiB
Markdown
# lifeblood os
|
|
### extreme warning: this project is in an INCREDIBLY early stage, see **warnings** section
|
|
lifeblood os is the operating system for the lifeblood project
|
|
it currently supports riscv32imac, and has some basic support for ppc32 (albeit it probably won't compile, and
|
|
has no drivers)
|
|
|
|
## warnings
|
|
- as of right now, this project has just gotten to the point where it can run the shell and run programs from it.
|
|
please keep this in mind.
|
|
- the design of the kernel is *very esoteric*, this is mainly due to it being targeted for systems with very limited
|
|
memory, as the lifeblood computer was originally designed around 32K of ram (although we're currently redesigning
|
|
to include more, and the qemu emulator version requires 5MiB to run)
|
|
- tons of stuff is missing, notably if you develop a program, you may run into a relocation issue due to the limitations
|
|
of the lbos relocator.
|
|
- speaking of which, if you do not have experience with low level programming, you may currently find it difficult to
|
|
write programs, however still feel free to explore the code and see what you can do!
|
|
|
|
## building
|
|
install the rust toolchain for riscv32imac-unknown-none-elf, then run the following commands for each thing you want
|
|
to build:
|
|
### kernel
|
|
```shell
|
|
LBOS_ARCH=virt cargo build --release --target riscv32imac-unknown-none-elf --features arch_virt
|
|
```
|
|
### TURNTBL.DDI
|
|
```shell
|
|
cd turntable
|
|
LBOS_ARCH=riscv32 cargo build --release --target riscv32imac-unknown-none-elf --features arch_riscv32
|
|
cd ..
|
|
# the following is required to convert the ELF output to the DDI format that lbos uses
|
|
cd makeddi
|
|
cargo run -- ../turntable/target/riscv32imac-unknown-none-elf/release/turntable ../turntable/target/riscv32imac-unknown-none-elf/release/TURNTBL.DDI
|
|
cd ..
|
|
```
|
|
### EXAMPLE.DDI
|
|
```shell
|
|
cd example
|
|
LBOS_ARCH=riscv32 cargo build --release --target riscv32imac-unknown-none-elf --features arch_riscv32
|
|
cd ..
|
|
# the following is required to convert the ELF output to the DDI format that lbos uses
|
|
cd makeddi
|
|
cargo run -- ../example/target/riscv32imac-unknown-none-elf/release/example ../example/target/riscv32imac-unknown-none-elf/release/EXAMPLE.DDI
|
|
cd ..
|
|
```
|
|
|
|
## getting it running
|
|
you'll need to install qemu with support for riscv32, and make a fat32 filesystem image with the shell "TURNTBL.DDI"
|
|
and optionally the "EXAMPLE.DDI" program.
|
|
**NOTE FOR FAT32 FILESYSTEM:** it is currently required that the sector size is 512 bytes, this is hardcoded; cluster
|
|
size is not hardcoded.
|
|
the best way to do this is to run something like
|
|
```shell
|
|
dd if=/dev/zero of=test.img bs=1M count=256 status=progress
|
|
mkdosfs -F 32 test.img
|
|
sudo losetup -fP test.img
|
|
```
|
|
and then run the `./copy_to_fs.sh` script to copy the built files to the filesystem like so
|
|
```shell
|
|
./copy_to_fs.sh /dev/loop0 # or whatever the loopback device you created is called, see losetup -a
|
|
```
|
|
note that the script will likely need to be run as root because of linux's requirements for fat32 filesystems; and more
|
|
importantly that the script expects the binary files to be in the directories above in the build section.
|
|
after you do this, the filesystem should be ready for the kernel and you should be able to run a variant of the
|
|
following to run the kernel
|
|
```shell
|
|
qemu-system-riscv32 -machine virt -bios none -drive if=none,format=raw,file=/dev/loop0,id=disk1 -device virtio-blk-device,drive=disk1 -serial mon:stdio -m 5M -kernel target/riscv32imac-unknown-none-elf/release/lbos
|
|
```
|
|
(note that this will take over your terminal and steal CTRL+C, so you'll need to kill it by closing the terminal or
|
|
manually killing the process)
|
|
|
|
in the shell you can currently do two things:
|
|
- `ls` will list files in the root directory
|
|
- `<file>` will run the program `<file>` in the root directory, always capitalize your file name!
|
|
|
|
## developing programs
|
|
currently, the best way to program is to use rust and link to the liblbos library included in this repo,
|
|
you should be able to using something like
|
|
```toml
|
|
[dependencies]
|
|
liblbos = { git = "https://forge.voremicrocomputers.com/Vore_Microcomputers/lifeblood_os.git" }
|
|
```
|
|
but i have not tested this yet so please tell me if it doesn't work
|
|
|
|
if you want to develop a program in another language, you'll need to investigate everything in this repo to figure out
|
|
how lbos expects programs to look. (this will be documented eventually)
|
|
|
|
good places to start with either developing in rust, or porting another language are:
|
|
- turntable, the lbos shell which showcases some basic fs operations and task loading
|
|
- example, a simple hello world program that should give you the bare minimum to build and link correctly
|
|
- liblbos, a helper library that defines structs (all should be C repr) as well as helper functions for syscalls and
|
|
kernel IPC
|
|
|
|
feel free to shoot me an email if you have any questions! (nikocs at voremicrocomputers dot com) |