Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/clippy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ on:
push:
branches:
- stage9
- main
pull_request:
branches:
- stage9
- main

jobs:
build:
Expand All @@ -18,7 +20,7 @@ jobs:
os: [ubuntu-latest]

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v5
with:
submodules: true
- name: Check Cargo availability
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ on:
push:
branches:
- stage9
- main
pull_request:
branches:
- stage9
- main

jobs:
build:
Expand All @@ -18,7 +20,7 @@ jobs:
os: [ubuntu-latest]

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v5
with:
submodules: true
- name: Check Cargo availability
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/run.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ name: Build
on:
push:
branches:
- stage9
- main
pull_request:
branches:
- stage9
- main
schedule:
- cron: '0 0 * * 6'

Expand Down Expand Up @@ -36,7 +36,7 @@ jobs:
choco install qemu
echo "$Env:Programfiles\qemu" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
shell: pwsh
- uses: actions/checkout@v4
- uses: actions/checkout@v5
with:
submodules: true
lfs: true
Expand Down
18 changes: 18 additions & 0 deletions CITATION.cff
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
cff-version: 1.2.0
message: "If you use this software, please cite it as below."
authors:
- family-names: "Lankes"
given-names: "Stefan"
orcid: "https://orcid.org/0000-0003-4718-2238"
- family-names: "Klimt"
given-names: "Jonathan"
orcid: "https://orcid.org/0000-0002-5980-2214"
- family-names: "Kröning"
given-names: "Martin"
orcid: "https://orcid.org/0009-0005-0622-4229"

title: "eduOS-rs - A teaching operating system written in Rust"
version: 0.1.0
doi: 10.5281/zenodo.14675628
date-released: 2025-01-16
url: "https://github.com/RWTH-OS/eduOS-rs"
19 changes: 9 additions & 10 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ default = ["qemu-exit"]
vga = []

[dependencies]
bitflags = "2.7"
bitflags = "2.10"
spinning_top = "0.3"
lock_api = "0"
qemu-exit = { version = "3.0", optional = true }
Expand All @@ -30,7 +30,7 @@ num = { version = "0.4", default-features = false }
num-derive = "0.4"

[target.'cfg(target_arch = "x86_64")'.dependencies.bootloader]
version = "0.9.29"
version = "0.9.33"
default-features = false
features = ["recursive_page_table"]

Expand Down
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ eduOS-rs is derived from following tutorials and software distributions:
2. Erik Kidd's [toyos-rs][kidd], which is an extension of Philipp Opermann's kernel.
3. The original version of [eduOS][stlankes], which was the old teaching kernel written in C.
4. eduOS-rs' uses a memory allocator, which is derived from the [buddy_system_allocator][buddy].
5. The first version of paging is derived from a version, which was developed by [Colin Finck's][colin].
5. The first version of paging is derived from a version, which was developed by [Colin Finck][colin].

[opp]: http://blog.phil-opp.com/
[kidd]: http://www.randomhacks.net/bare-metal-rust/
[stlankes]: http://rwth-os.github.io/eduOS/
[rust-barebones-kernel]: https://github.com/thepowersgang/rust-barebones-kernel
[acsos]: http://www.os.rwth-aachen.de/
[acsos]: https://www.acs.eonerc.rwth-aachen.de/cms/e-on-erc-acs/studium/lehrveranstaltungen/~xwyom/grundgebiete-der-informatik-4-betriebs/?lidx=1
[colin]: https://github.com/ColinFinck
[buddy]: https://github.com/rcore-os/buddy_system_allocator

Expand Down Expand Up @@ -61,7 +61,7 @@ $ apt-get install -y git qemu-system-x86 build-essential
This project uses Rustup to set its Rust toolchain.
Follow the instructions to [install Rust using Rustup](https://www.rust-lang.org/tools/install).

In addition, the tool https://github.com/rust-osdev/bootimage[bootimage] is required, which creates a bootable diskimage.
In addition, the tool [bootimage](https://github.com/rust-osdev/bootimage) is required, which creates a bootable diskimage.
Please install the tool with following command.

```sh
Expand Down Expand Up @@ -120,17 +120,17 @@ Currently, following stages of development are available:

Introduce a virtual file system with an in-memory file system as example file system.

9. stage9 - Run Linux application as common process

Start a simple Linux application (_HelloWorld_) on top of eduOS-rs. The application is a _position-independent executable_ (PIE) and use [musl-libc](http://www.musl-libc.org) as standard C library. The FPU support is disabled.

## Useful Links

1. [http://www.gnu.org/software/grub/manual/multiboot/](http://www.gnu.org/software/grub/manual/multiboot/)
2. [http://www.osdever.net/tutorials/view/brans-kernel-development-tutorial](http://www.osdever.net/tutorials/view/brans-kernel-development-tutorial)
3. [http://www.jamesmolloy.co.uk/tutorial_html/index.html](http://www.jamesmolloy.co.uk/tutorial_html/index.html)
4. [http://techblog.lankes.org/tutorials/](http://techblog.lankes.org/tutorials/)
5. [http://www.os.rwth-aachen.de](http://www.os.rwth-aachen.de)
6. [http://www.noteblok.net/2014/06/14/bachelor](http://www.noteblok.net/2014/06/14/bachelor)
7. [https://sourceware.org/newlib/](https://sourceware.org/newlib/)
8. [http://rwth-os.github.io/eduOS/](http://rwth-os.github.io/eduOS/)
9. [https://intermezzos.github.io](https://intermezzos.github.io)
3. [https://www.acs.eonerc.rwth-aachen.de/cms/e-on-erc-acs/studium/lehrveranstaltungen/~xwyom/grundgebiete-der-informatik-4-betriebs/?lidx=1](https://www.acs.eonerc.rwth-aachen.de/cms/e-on-erc-acs/studium/lehrveranstaltungen/~xwyom/grundgebiete-der-informatik-4-betriebs/?lidx=1)
4. [http://rwth-os.github.io/eduOS/](http://rwth-os.github.io/eduOS/)
5. [https://intermezzos.github.io](https://intermezzos.github.io)

## License

Expand Down
5 changes: 2 additions & 3 deletions src/fs/initrd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ use crate::synch::spinlock::*;
use alloc::sync::Arc;
use alloc::vec::Vec;
use core::ops::{Deref, DerefMut};
use core::slice;
use spinning_top::RwSpinlock;

#[derive(Debug)]
Expand All @@ -19,10 +18,10 @@ pub(crate) struct RomHandle {
}

impl RomHandle {
pub fn new(addr: *const u8, len: usize) -> Self {
pub fn new(slice: &'static [u8]) -> Self {
RomHandle {
pos: Spinlock::new(0),
data: Arc::new(RwSpinlock::new(unsafe { slice::from_raw_parts(addr, len) })),
data: Arc::new(RwSpinlock::new(slice)),
}
}

Expand Down
25 changes: 10 additions & 15 deletions src/fs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ use crate::scheduler::{insert_io_interface, remove_io_interface};
use alloc::string::{String, ToString};
use alloc::sync::Arc;
use alloc::vec::Vec;
use core::convert::TryInto;
use core::include_bytes;

static DEMO: &[u8] = include_bytes!("../../demo/hello");
Expand All @@ -37,7 +36,7 @@ trait VfsNode: core::fmt::Debug + core::marker::Send + core::marker::Sync {

/// VfsNodeFile represents a file node of the virtual file system.
trait VfsNodeFile: VfsNode + core::fmt::Debug + core::marker::Send + core::marker::Sync {
/// Create a file handle to the current file
/// Create an IO interface to the current file
fn get_handle(&self, _opt: OpenOption) -> Result<Arc<dyn IoInterface>>;
}

Expand All @@ -57,7 +56,7 @@ trait VfsNodeDirectory: VfsNode + core::fmt::Debug + core::marker::Send + core::
) -> Result<Arc<dyn IoInterface>>;

/// Mound memory region as file
fn traverse_mount(&mut self, _components: &mut Vec<&str>, addr: u64, len: u64) -> Result<()>;
fn traverse_mount(&mut self, _components: &mut Vec<&str>, slice: &'static [u8]) -> Result<()>;
}

/// The trait `Vfs` specifies all operation on the virtual file systems.
Expand All @@ -73,7 +72,7 @@ trait Vfs: core::fmt::Debug + core::marker::Send + core::marker::Sync {
fn open(&mut self, path: &str, flags: OpenOption) -> Result<Arc<dyn IoInterface>>;

/// Mound memory region as file
fn mount(&mut self, path: &String, addr: u64, len: u64) -> Result<()>;
fn mount(&mut self, path: &String, slice: &'static [u8]) -> Result<()>;
}

/// Entrypoint of the file system
Expand Down Expand Up @@ -105,9 +104,9 @@ pub fn open(name: &str, flags: OpenOption) -> io::Result<FileDescriptor> {
}
}

/// A symbolic link `path2` is created to `path1`
pub fn mount(path: &String, addr: u64, len: u64) -> Result<()> {
unsafe { VFS_ROOT.as_mut().unwrap().mount(path, addr, len) }
/// Mount slice to to `path`
pub fn mount(path: &String, slice: &'static [u8]) -> Result<()> {
unsafe { VFS_ROOT.as_mut().unwrap().mount(path, slice) }
}

/// Help function to check if the argument is an abolute path
Expand Down Expand Up @@ -181,18 +180,14 @@ pub(crate) fn init() {
if DEMO.len() > 0 {
info!(
"Found mountable file at 0x{:x} (len 0x{:x})",
&DEMO as *const _ as u64,
DEMO.as_ptr() as u64,
DEMO.len()
);
root.mount(
&String::from("/bin/demo"),
DEMO.as_ptr() as u64,
DEMO.len().try_into().unwrap(),
)
.expect("Unable to mount file");
root.mount(&String::from("/bin/demo"), &DEMO)
.expect("Unable to mount file");
}

//root.lsdir().unwrap();
root.lsdir().unwrap();
//info!("root {:?}", root);
unsafe {
VFS_ROOT = Some(root);
Expand Down
16 changes: 7 additions & 9 deletions src/fs/vfs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,20 +127,20 @@ impl VfsNodeDirectory for VfsDirectory {
}
}

fn traverse_mount(&mut self, components: &mut Vec<&str>, addr: u64, len: u64) -> Result<()> {
fn traverse_mount(&mut self, components: &mut Vec<&str>, slice: &'static [u8]) -> Result<()> {
if let Some(component) = components.pop() {
let node_name = String::from(component);

if components.is_empty() == true {
// Create file on demand
let file = Box::new(VfsFile::new_from_rom(addr, len));
let file = Box::new(VfsFile::new_from_rom(slice));
self.children.insert(node_name, file);

Ok(())
} else {
// traverse to the directories to the endpoint
if let Some(directory) = self.get_mut::<VfsDirectory>(&node_name) {
directory.traverse_mount(components, addr, len)
directory.traverse_mount(components, slice)
} else {
Err(Error::InvalidArgument)
}
Expand Down Expand Up @@ -171,9 +171,9 @@ impl VfsFile {
}
}

pub fn new_from_rom(addr: u64, len: u64) -> Self {
pub fn new_from_rom(slice: &'static [u8]) -> Self {
VfsFile {
data: DataHandle::ROM(RomHandle::new(addr as *const u8, len as usize)),
data: DataHandle::ROM(RomHandle::new(slice)),
}
}
}
Expand Down Expand Up @@ -286,16 +286,14 @@ impl Vfs for Fs {
}

/// Mound memory region as file
fn mount(&mut self, path: &String, addr: u64, len: u64) -> Result<()> {
fn mount(&mut self, path: &String, slice: &'static [u8]) -> Result<()> {
if check_path(path) {
let mut components: Vec<&str> = path.split("/").collect();

components.reverse();
components.pop();

self.handle
.lock()
.traverse_mount(&mut components, addr, len)
self.handle.lock().traverse_mount(&mut components, slice)
} else {
Err(Error::InvalidFsPath)
}
Expand Down
4 changes: 2 additions & 2 deletions test.ps1
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Invoke-Command -Script { cargo run } -ErrorAction SilentlyContinue
IF( $LASTEXITCODE -EQ 5 ) {
Write-Output "eduOS-rs runs succesfully within Qemu"
Write-Output "eduOS-rs runs successfully within Qemu"
Exit 0
} else {
Write-Output echo "eduOS-rs isn't able to run within Qemu"
Write-Output "eduOS-rs isn't able to run within Qemu"
Exit 1
}
Loading