Skip to content

Commit

Permalink
Use 'towbootctl' to create bootable images; Remove GRUB support; Inte…
Browse files Browse the repository at this point in the history
…grate 'run.sh' functionality into 'Makefile.toml'
  • Loading branch information
fruhland committed May 21, 2024
1 parent fb9ff1c commit ab976fe
Show file tree
Hide file tree
Showing 15 changed files with 324 additions and 322 deletions.
40 changes: 28 additions & 12 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,46 @@ jobs:
build:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- name: Install Rust
- uses: actions/checkout@v4

- name: Install packages
uses: amitie10g/install-package@v1.2.3
with:
apt: build-essential nasm wget

- name: Install Rust for x86-64 Linux
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
override: true
target: x86_64-unknown-linux-gnu
components: rust-src
- name: Install Rust for x86_64 UEFI
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
target: x86_64-unknown-uefi
- name: Install Rust for i686 UEFI
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
target: i686-unknown-uefi
- name: Install Rust for x86_64 UEFI
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
target: x86_64-unknown-uefi

- name: Install cargo-make
run: cargo install --no-default-features cargo-make

- uses: awalsh128/cache-apt-pkgs-action@v1
with:
packages: make nasm dosfstools mtools zstd unzip wget
- name: Install towbootctl
run: cargo install --git https://github.com/hhuOS/towboot --features=binary -Z bindeps towbootctl

- name: Build
run: cargo make --no-workspace

- name: Create artifact
run: tar -czvf d3os.tar.gz d3os.img run.sh README.md
run: cargo make --no-workspace image

- name: Upload artifact
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: D3OS
path: d3os.tar.gz
path: d3os.img
8 changes: 2 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,7 @@ Cargo.lock
# End of https://www.toptal.com/developers/gitignore/api/rust,clion+iml,VisualStudioCode

d3os.img
d3os.iso
efi/OVMF.fd
RELEASEX64_OVMF.fd
loader/kernel.elf
loader/initrd.tar
loader/initrd
loader/towboot/towboot-x64.efi
loader/grub/iso/boot/kernel.elf
loader/grub/iso/boot/initrd.tar
loader/initrd
6 changes: 3 additions & 3 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
"label": "qemu-gdb",
"type": "shell",
"isBackground": true,
"command": "${workspaceRoot}/run.sh",
"args": ["--debug", "vscode"],
"command": "cargo",
"args": [ "make", "--no-workspace", "--profile", "development", "debug" ],
"problemMatcher": [
{
"pattern": [
Expand All @@ -47,7 +47,7 @@
"background": {
"activeOnStart": true,
"beginsPattern": ".",
"endsPattern": "Debugging with VSCode...",
"endsPattern": "Ready to debug",
}
}
],
Expand Down
70 changes: 45 additions & 25 deletions Makefile.toml
Original file line number Diff line number Diff line change
@@ -1,56 +1,76 @@
[env]
BOOTLOADER_DIRECTORY = "${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/loader"
INITRD_DIRECTORY = "${BOOTLOADER_DIRECTORY}/initrd"
OVMF_URL = "https://retrage.github.io/edk2-nightly/bin/RELEASEX64_OVMF.fd"
LINKER = "ld"
LINKER_MAC = "x86_64-elf-ld"
PATH = "${PATH}:~/.cargo/bin"

[tasks.default]
alias = "towboot"
alias = "qemu"

# Run tasks

[tasks.debug]
command = "qemu-system-x86_64"
args = [ "-S", "-gdb", "tcp::1234", "-machine", "q35,pcspk-audiodev=audio0", "-m", "128M", "-cpu", "qemu64", "-bios", "RELEASEX64_OVMF.fd", "-boot", "d", "-vga", "std", "-rtc", "base=localtime", "-drive", "driver=raw,node-name=boot,file.driver=file,file.filename=d3os.img", "-audiodev", "id=audio0,driver=pa" ]
dependencies = [ "debug-signal-vscode" ]

[tasks.debug.mac]
args = [ "-S", "-gdb", "tcp::1234", "-machine", "q35,pcspk-audiodev=audio0", "-m", "128M", "-cpu", "qemu64", "-bios", "RELEASEX64_OVMF.fd", "-boot", "d", "-vga", "std", "-rtc", "base=localtime", "-drive", "driver=raw,node-name=boot,file.driver=file,file.filename=d3os.img", "-audiodev", "id=audio0,driver=coreaudio" ]

[tasks.debug-signal-vscode]
command = "echo"
args = [ "Ready to debug" ]
dependencies = [ "image", "ovmf" ]

[tasks.qemu]
command = "qemu-system-x86_64"
args = [ "-machine", "q35,pcspk-audiodev=audio0", "-m", "128M", "-cpu", "qemu64", "-bios", "RELEASEX64_OVMF.fd", "-boot", "d", "-vga", "std", "-rtc", "base=localtime", "-drive", "driver=raw,node-name=boot,file.driver=file,file.filename=d3os.img", "-audiodev", "id=audio0,driver=pa" ]
dependencies = [ "image", "ovmf" ]

[tasks.qemu.mac]
args = [ "-machine", "q35,pcspk-audiodev=audio0", "-m", "128M", "-cpu", "qemu64", "-bios", "RELEASEX64_OVMF.fd", "-boot", "d", "-vga", "std", "-rtc", "base=localtime", "-drive", "driver=raw,node-name=boot,file.driver=file,file.filename=d3os.img", "-audiodev", "id=audio0,driver=coreaudio" ]

[tasks.ovmf]
command = "wget"
args = [ "-N", "${OVMF_URL}" ]

# Build tasks

[tasks.link_members]
[tasks.link-members]
run_task = { name = "link", fork = true }
dependencies = [ "create-initrd-directory" ]

[tasks.create-initrd-directory]
command = "mkdir"
args = [ "-p", "${INITRD_DIRECTORY}" ]

[tasks.towboot]
cwd = "${BOOTLOADER_DIRECTORY}/towboot"
command = "./build.sh"
dependencies = [ "link_members", "initrd" ]

[tasks.grub]
cwd = "${BOOTLOADER_DIRECTORY}/grub"
command = "grub-mkrescue"
args = [ "-o", "${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/d3os.iso", "iso/" ]
dependencies = [ "grub-copy-files" ]

[tasks.grub-copy-files]
cwd = "${BOOTLOADER_DIRECTORY}"
command = "cp"
args = [ "kernel.elf", "initrd.tar", "grub/iso/boot" ]
dependencies = [ "link_members", "initrd" ]

[tasks.initrd]
cwd = "${INITRD_DIRECTORY}"
command = "tar"
args = [ "-cf", "${BOOTLOADER_DIRECTORY}/initrd.tar", "hello", "shell", "uptime", "date" ]
dependencies = [ "link_members" ]
dependencies = [ "link-members" ]

[tasks.image]
cwd = "${BOOTLOADER_DIRECTORY}"
command = "towbootctl"
args = [ "image", "--target", "${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/d3os.img", "--", "-config", "towboot.toml"]
dependencies = [ "link-members", "initrd" ]

# Cleanup tasks

[tasks.clean]
dependencies = [ "clean_workspace", "clean_members" ]
dependencies = [ "clean-workspace", "clean-members" ]

[tasks.clean_workspace]
[tasks.clean-workspace]
command = "rm"
args = [ "-rf",
"${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/d3os.img",
"${BOOTLOADER_DIRECTORY}/kernel.elf",
"${BOOTLOADER_DIRECTORY}/initrd.tar",
"${BOOTLOADER_DIRECTORY}/grub/iso/boot/kernel.elf",
"${BOOTLOADER_DIRECTORY}/grub/iso/boot/initrd.tar" ]
"${INITRD_DIRECTORY}",
"RELEASEX64_OVMF.fd" ]

[tasks.clean_members]
[tasks.clean-members]
run_task = { name = "clean", fork = true }
56 changes: 34 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,42 +1,54 @@
# D3OS
A new research operating system, developed by the [operating systems group](https://www.cs.hhu.de/en/research-groups/operating-systems.html) of the department of computer science at [Heinrich Heine University Düsseldorf](https://www.hhu.de)

## Requirements
<p align="center">
<a href="https://www.uni-duesseldorf.de/home/en/home.html"><img src="media/hhu.svg" width=300></a>
</p>

For building D3OS, a _rust nightly_ toolchain is needed. To install _rust_ use [rustup](https://rustup.rs/).
<p align="center">
<a href="https://github.com/hhu-bsinfo/D3OS/actions/workflows/build.yml"><img src="https://github.com/hhu-bsinfo/D3OS/actions/workflows/build.yml/badge.svg"></a>
<img src="https://img.shields.io/badge/Rust-2021-blue.svg">
<img src="https://img.shields.io/badge/license-GPLv3-orange.svg">
</p>

`rustup toolchain install nightly`
## Requirements

And activate it for the current folder with:
For building D3OS, a _rust nightly_ toolchain is needed. To install _rust_ use [rustup](https://rustup.rs/).

`rustup override set nightly`
```
rustup toolchain install nightly
rustup override set nightly
```

To run the build commands _cargo-make_ is required. Install it with:

`cargo install --no-default-features cargo-make`
```
cargo install --no-default-features cargo-make
```

Further the following packages for Debian/Ubuntu based systems (or their equivalent packages on other distributions) need to be installed:

`apt install build-essential nasm mtools fdisk zstd`

To run the final OS image _QEMU_ is required:

`apt install qemu-system-x86_64`

## Build

For a full build run:
```
apt install build-essential nasm wget qemu-system-x86_64
```

`cargo make --no-workspace`
D3OS depends on the rust-based bootloader [towboot](https://github.com/hhuOS/towboot), which provides the `towbootctl` utility for creating bootable images. Install it with:

This will produce _d3os.img_.
```
rustup target install i686-unknown-uefi x86_64-unknown-uefi
cargo install --git https://github.com/hhuOS/towboot --features=binary -Z bindeps towbootctl
```

## Run
## Build and Run

To run the image, build it first and then use:
To build D3OS and run it in QEMU, just execute:

`./run.sh`
```
cargo make --no-workspace
```

This will execute the operating system with _QEMU_.
To only build the bootable image _d3os.img_, run:

For more information see `run.sh --help`.
```
cargo make --no-workspace image
```
20 changes: 0 additions & 20 deletions loader/grub/iso/boot/grub/grub.cfg

This file was deleted.

4 changes: 2 additions & 2 deletions loader/towboot/towboot.toml → loader/towboot.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ log_level = "info"
[entries]
[entries.d3os]
name = "D3OS"
image = "\\kernel.elf"
modules = [ { image = "\\initrd.tar", argv = "initrd" } ]
image = "kernel.elf"
modules = [ { image = "initrd.tar", argv = "initrd" } ]
30 changes: 0 additions & 30 deletions loader/towboot/build.sh

This file was deleted.

Loading

0 comments on commit ab976fe

Please sign in to comment.