Skip to content
Merged
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
2 changes: 1 addition & 1 deletion LearnixOS
Submodule LearnixOS updated 55 files
+1 −0 .github/FUNDING.yml
+4 −1 Cargo.toml
+0 −6,880 crates/arch/x86/log.rs
+5 −9 crates/arch/x86/src/memory_map.rs
+0 −3 crates/arch/x86/src/pic8259.rs
+2 −34 crates/arch/x86/src/structures/global_descriptor_table.rs
+25 −26 crates/arch/x86/src/structures/interrupt_descriptor_table.rs
+8 −16 crates/arch/x86/src/structures/paging/page_table.rs
+4 −4 crates/arch/x86/src/structures/paging/page_table_entry.rs
+1 −1 crates/arch/x86/src/structures/segments.rs
+1 −1 crates/common/Cargo.toml
+12 −16 crates/common/src/address_types.rs
+1 −1 crates/common/src/constants/values.rs
+3 −5 crates/common/src/enums/buddy.rs
+16 −9 crates/common/src/enums/paging.rs
+12 −4 crates/common/src/error/paging.rs
+4 −0 crates/common/src/late_init.rs
+1 −34 crates/common/src/lib.rs
+0 −13 crates/common/src/macros.rs
+7 −5 crates/common/src/ring_buffer.rs
+1 −1 crates/drivers/ahci/Cargo.toml
+1 −1 crates/drivers/keyboard/Cargo.toml
+6 −6 crates/drivers/keyboard/src/lib.rs
+8 −4 crates/drivers/keyboard/src/ps2_keyboard.rs
+1 −1 crates/drivers/pci/Cargo.toml
+1 −1 crates/drivers/vga-display/Cargo.toml
+10 −0 crates/libk/Cargo.toml
+170 −0 crates/libk/src/alloc.rs
+31 −0 crates/libk/src/fmt.rs
+5 −0 crates/libk/src/lib.rs
+1 −1 crates/memory/buddy/Cargo.toml
+15 −9 crates/memory/buddy/src/lib.rs
+6 −20 crates/memory/buddy/src/meta.rs
+8 −0 crates/memory/bump/Cargo.toml
+74 −0 crates/memory/bump/src/lib.rs
+3 −1 crates/memory/page/Cargo.toml
+116 −0 crates/memory/page/src/arena.rs
+15 −15 crates/memory/page/src/lib.rs
+17 −15 crates/memory/page/src/map.rs
+1 −1 crates/memory/slab/Cargo.toml
+8 −0 crates/sync/Cargo.toml
+5 −0 crates/sync/src/lib.rs
+82 −0 crates/sync/src/mutex.rs
+225 −0 crates/sync/src/rwlock.rs
+17 −0 crates/sync/src/strategy.rs
+137 −0 crates/sync/tests/mutex_test.rs
+91 −0 crates/sync/tests/rwlock_test.rs
+6 −2 kernel/Cargo.toml
+36 −32 kernel/src/interrupt_handlers.rs
+76 −49 kernel/src/main.rs
+2 −3 kernel/src/timer.rs
+1 −1 rust-toolchain.toml
+0 −3 rustfmt.toml
+1 −1 snippets/Cargo.toml
+1 −1 tests/Cargo.toml
17 changes: 15 additions & 2 deletions book.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,31 @@ inlay-hint-config = "inlay_config.json"
after = ["mdbook-rust-analyzer-highlight"]
command = "cargo run --release --manifest-path mdbook-gh-issue-preview/Cargo.toml"

[preprocessor.github-repository-card]
after = ["gh-issue-preview"]
command = "cargo run --release --manifest-path mdbook-repository-card/Cargo.toml"
username = "sagi21805"
repository = "LearnixOS"
patreon_url = "https://patreon.com/LearnixOS?utm_medium=unknown&utm_source=join_link&utm_campaign=creatorshare_creator&utm_content=copyLink"

[output.html]
git-repository-url = "https://github.com/sagi21805/LearnixOS"
default-theme = "navy"
preferred-dark-theme = "navy"
additional-css = ["theme/whichlang.css", "theme/hlrs.css", "theme/gh-issue.css", "theme/tags.css"]
additional-css = [
"theme/whichlang.css",
"theme/hlrs.css",
"theme/gh-issue.css",
"theme/tags.css",
"theme/github-box.css",
]
additional-js = [
"theme/whichlang.js",
"theme/filepath-links.js",
"theme/giscuss.js",
"theme/tags.js",
"theme/highlight.js"
"theme/highlight.js",
"theme/github-card.js",
]
mathjax-support = true

Expand Down
2 changes: 1 addition & 1 deletion mdbook-gh-issue-preview
11 changes: 11 additions & 0 deletions mdbook-repository-card/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[package]
name = "mdbook-repository_card"
version = "0.1.0"
edition = "2024"

[dependencies]
mdbook-preprocessor = "0.5.3"
regex = "1.12.2"
serde = "1.0.228"
serde_json = "1.0.148"
toml = "0.5.11"
4 changes: 4 additions & 0 deletions mdbook-repository-card/rustfmt.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
max_width = 65
comment_width = 65
wrap_comments = true
format_strings = false
175 changes: 175 additions & 0 deletions mdbook-repository-card/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
use std::{io, process};

use mdbook_preprocessor::{
Preprocessor, PreprocessorContext, book::Book, errors::Error,
};
use regex::Regex;
use toml::value::Table;

pub struct GithubRepositoryCard;

static HTML: &str = r##"
<div class="github-repo-box" data-repo="{username}/{repository}">
<div class="repo-header">
<div class="repo-title-group">
<svg aria-hidden="true" height="18" viewBox="0 0 16 16" version="1.1" width="18" class="icon" fill="currentColor">
<path d="M2 2.5A2.5 2.5 0 0 1 4.5 0h8.75a.75.75 0 0 1 .75.75v12.5a.75.75 0 0 1-.75.75h-2.5a.75.75 0 0 1 0-1.5h1.75v-2h-8a1 1 0 0 0-.714 1.7.75.75 0 1 1-1.072 1.05A2.495 2.495 0 0 1 2 11.5Zm10.5-1h-8a1 1 0 0 0-1 1v6.708A2.486 2.486 0 0 1 4.5 9h8ZM5 12.25a.25.25 0 0 1 .25-.25h3.5a.25.25 0 0 1 .25.25v3.25a.25.25 0 0 1-.4.2l-1.45-1.087a.249.249 0 0 0-.3 0L5.4 15.7a.25.25 0 0 1-.4-.2Z"></path>
</svg>
<a class="repo-title-link" href="#" target="_blank" rel="noopener noreferrer">
<span class="repo-title-text">Loading repository...</span>
</a>
</div>
<div class="repo-actions">
{patreon}<a class="github-btn btn-sponsor" href="#" target="_blank" rel="noopener noreferrer">
<svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" class="icon"><path fill="#bf3989" d="m8 14.25.345.666a.75.75 0 0 1-.69 0l-.008-.004-.018-.01a7.152 7.152 0 0 1-.31-.17 22.055 22.055 0 0 1-3.434-2.414C2.045 10.731 0 8.35 0 5.5 0 2.836 2.086 1 4.25 1 5.797 1 7.153 1.802 8 3.02 8.847 1.802 10.203 1 11.75 1 13.914 1 16 2.836 16 5.5c0 2.85-2.045 5.231-3.885 6.818a22.066 22.066 0 0 1-3.744 2.584l-.018.01-.006.003h-.002Z"></path></svg>
Sponsor
</a>
<a class="github-btn btn-star" href="#" target="_blank" rel="noopener noreferrer">
<svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" class="icon"><path fill="#e3b341" d="M8 .25a.75.75 0 0 1 .673.418l1.882 3.815 4.21.612a.75.75 0 0 1 .416 1.279l-3.046 2.97.719 4.192a.751.751 0 0 1-1.088.791L8 12.347l-3.766 1.98a.75.75 0 0 1-1.088-.79l.72-4.194L.818 6.374a.75.75 0 0 1 .416-1.28l4.21-.611L7.327.668A.75.75 0 0 1 8 .25Z"></path></svg>
Star
</a>
<a class="github-btn btn-comment" href="#" onclick="window.scrollTo({top: document.body.scrollHeight, behavior: 'smooth'}); return false;">
<svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" class="icon" fill="currentColor">
<path fill-rule="evenodd" d="M1.75 1h12.5c.966 0 1.75.784 1.75 1.75v9.5A1.75 1.75 0 0 1 14.25 14H8.06l-2.573 2.573A1.458 1.458 0 0 1 3 15.543V14H1.75A1.75 1.75 0 0 1 0 12.25v-9.5C0 1.784.784 1 1.75 1Z M3.5 4.25h9v1.1h-9Z M3.5 6.95h9v1.1h-9Z M3.5 9.65h6v1.1h-6Z"></path>
</svg>
Comment
</a>
</div>
</div>
<div class="repo-body">
<p class="repo-description">Connecting to GitHub API...</p>
</div>
<div class="repo-footer">
<span class="stat-item repo-language" style="display: none;">
<span class="language-color"></span>
<span class="repo-language-text">Language</span>
</span>
<a class="stat-item link-stars" href="#" target="_blank" rel="noopener noreferrer">
<svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" class="icon"><path fill="currentColor" d="M8 .25a.75.75 0 0 1 .673.418l1.882 3.815 4.21.612a.75.75 0 0 1 .416 1.279l-3.046 2.97.719 4.192a.751.751 0 0 1-1.088.791L8 12.347l-3.766 1.98a.75.75 0 0 1-1.088-.79l.72-4.194L.818 6.374a.75.75 0 0 1 .416-1.28l4.21-.611L7.327.668A.75.75 0 0 1 8 .25Z"></path></svg>
<span class="repo-stars-count">0</span>
</a>
<a class="stat-item link-forks" href="#" target="_blank" rel="noopener noreferrer">
<svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" class="icon"><path fill="currentColor" d="M5 5.372v.878c0 .414.336.75.75.75h4.5a.75.75 0 0 0 .75-.75v-.878a2.25 2.25 0 1 1 1.5 0v.878a2.25 2.25 0 0 1-2.25 2.25h-1.5v2.128a2.251 2.251 0 1 1-1.5 0V8.5h-1.5A2.25 2.25 0 0 1 3.5 6.25v-.878a2.25 2.25 0 1 1 1.5 0ZM5 3.25a.75.75 0 1 0-1.5 0 .75.75 0 0 0 1.5 0Zm6.75.75a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5Zm-3 8.75a.75.75 0 1 0-1.5 0 .75.75 0 0 0 1.5 0Z"></path></svg>
<span class="repo-forks-count">0</span>
</a>
<a class="stat-item link-commits" href="#" target="_blank" rel="noopener noreferrer">
<svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" class="icon"><path fill="currentColor" d="M11.93 8.5a4.002 4.002 0 0 1-7.86 0H.75a.75.75 0 0 1 0-1.5h3.32a4.002 4.002 0 0 1 7.86 0h3.32a.75.75 0 0 1 0 1.5h-3.32Zm-1.43-.5a2.5 2.5 0 1 0-5 0 2.5 2.5 0 0 0 5 0Z"></path></svg>
<span class="repo-commits-count">0</span>
</a>
<a class="stat-item link-issues" href="#" target="_blank" rel="noopener noreferrer">
<svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" class="icon"><path fill="currentColor" d="M8 9.5a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3Z"></path><path fill="currentColor" d="M8 0a8 8 0 1 1 0 16A8 8 0 0 1 8 0ZM1.5 8a6.5 6.5 0 1 0 13 0 6.5 6.5 0 0 0-13 0Z"></path></svg>
<span class="repo-issues-count">0</span>
</a>
</div>
</div>
"##;

static PATREON: &str = r##"
<a class="github-btn btn-patreon" href="{patreon_url}" target="_blank" rel="noopener noreferrer">
<svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" class="icon">
<circle cx="9.5" cy="6.2" r="5.2" fill="#FF424D"></circle>
<rect x="1.3" y="0.6" width="2.4" height="14.8" fill="#052D49"></rect>
</svg>
Patreon
</a>
"##;

impl Preprocessor for GithubRepositoryCard {
fn name(&self) -> &str {
"github-repository-card"
}

fn run(
&self,
ctx: &PreprocessorContext,
mut book: Book,
) -> Result<Book, Error> {
let conf_raw = ctx.config.get::<Table>(&format!(
"preprocessor.{}",
self.name()
))?;

let mut username = "";
let mut repository = "";
let mut patreon_url = "";

if let Some(conf) = &conf_raw {
username = conf
.get("username")
.and_then(|v| v.as_str())
.unwrap_or_default();
repository = conf
.get("repository")
.and_then(|v| v.as_str())
.unwrap_or_default();
patreon_url = conf
.get("patreon_url")
.and_then(|v| v.as_str())
.unwrap_or_default();
}

if username.is_empty() || repository.is_empty() {
eprintln!(
"[ERROR]: Configuration for username or repository is missing. Please specify both in the preprocessor configuration under `username` and `repository`."
);
return Ok(book);
}

let patreon = if !patreon_url.is_empty() {
PATREON.replace("{patreon_url}", &patreon_url)
} else {
eprintln!("[INFO]: Patreon url was not specified.");
String::from("")
};

let re = Regex::new(r"#!\[repository_card\]").unwrap();

let html = HTML
.replace("{username}", username)
.replace("{repository}", repository)
.replace("{patreon}", &patreon);

book.for_each_mut(|item| {
if let mdbook_preprocessor::book::BookItem::Chapter(
chapter,
) = item
{
chapter.content = re
.replace_all(
&chapter.content,
|_caps: &regex::Captures| {
format!("{}", html)
},
)
.to_string();
}
});

Ok(book)
}
}

fn main() {
let preprocessor = GithubRepositoryCard;

if std::env::args().len() > 1 {
if std::env::args().nth(1).unwrap() == "supports" {
process::exit(0);
}
}

if let Err(e) = handle_preprocessing(&preprocessor) {
eprintln!("{}", e);
process::exit(1);
}
}

fn handle_preprocessing(
pre: &impl Preprocessor,
) -> Result<(), mdbook_preprocessor::errors::Error> {
let (ctx, book) =
mdbook_preprocessor::parse_input(io::stdin())?;
let processed_book = pre.run(&ctx, book)?;
serde_json::to_writer(io::stdout(), &processed_book)?;
Ok(())
}
2 changes: 1 addition & 1 deletion mdbook-rust-analyzer-highlight
4 changes: 4 additions & 0 deletions src/Help.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Huge thanks for being here!

---

#![repository_card]

Taking the time to read through this project means the world to me. I hope you learned something valuable!

I work on this project in most of my free time!
Expand Down
2 changes: 2 additions & 0 deletions src/Introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ _"If you can't explain it simply, you don't understand it well enough." - Albert

---

#![repository_card]

Imagine you need to write some code to read from a file. You write a single, elegant line of Python
<code class="language-hlrs" style="filter: brightness(0.9); padding: 2px 3px; border-radius: 3px; display: inline-block;">
<span class="hlrs-keyword">with</span> <span class="hlrs-function">open</span>(<span class="hlrs-litstr">"my_file.txt"</span>) <span class="hlrs-keyword">as</span> <span class="hlrs-variable">f</span>:
Expand Down
4 changes: 4 additions & 0 deletions src/Roadmap.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Roadmap

---

#![repository_card]

This document specifies the planned topics and features that will be developed in the LearnixOS and covered by this book.

Each topic has a corresponding issue both in the book and in the OS repository. The status of each topic can be tracked using the links provided in the tables below.
Expand Down
2 changes: 2 additions & 0 deletions src/ch01-00-getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ _"the journey of a thousand miles begins with one step." - lao tzu_

---

#![repository_card]

Let's start our Operating System journey! There is a lot to learn, but every journey has to start somewhere :)

In this chapter we discuss:
Expand Down
2 changes: 2 additions & 0 deletions src/ch01-01-making-stand-alone-binary.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ _"Machines take me by surprise with great frequency." - Alan Turing_

---

#![repository_card]

The first step in making our operating system is making a program that can be compiled, and executed, without any dependency.
This is not a straightforward task, because every program that we use in our daily life uses at least one, very important dependency: `The Standard Library`.
Sometimes, this library is provided by the operating system itself, for example, libc for the Linux kernel, or the WinAPI for the Windows operating system, and most of the time it is wrapped around by our programming languages.
Expand Down
2 changes: 2 additions & 0 deletions src/ch01-02-booting-our-binary.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ _"There is no elevator to success - you have to take the stairs." - Zig Ziglar_

---

#![repository_card]

In the previous section, we created a standalone binary, which is not linked to any standard library. But if you looked closely, and inspected the binary, you would see that we used a build target that is called `x86_64-unknown-none`, which is a generic target that doesn't specify any operating system or vendor, but it still specifies the architecture as `x86_64`, which is the architecture of most modern computers.

## Understanding Rust Targets
Expand Down
2 changes: 2 additions & 0 deletions src/ch01-03-debugging-methods.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ _"If debugging is the process of removing bugs, then programming must be the pro

---

#![repository_card]

Debugging is a crucial part of a good operating system, and especially at the start of its development. We still don't have good debugging methods like printing, so we need to use other methods.

By far the most annoying bug is the triple fault, which will be explained extensively in the [Interrupts](ch05-00-interrupts-and-exceptions.md) Chapter. In short, this is an error that is not recoverable, and the CPU will reset itself, and it looks like this:
Expand Down
2 changes: 2 additions & 0 deletions src/ch02-00-a-minimal-bootloader.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ _"From a small spark may burst a mighty flame." - Dante Alighieri_

---

#![repository_card]

Writing a bootloader is not an easy task, and it can include a lot of [things](http://wiki.osdev.org/Rolling_Your_Own_Bootloader#A_list_of_things_you_might_want_to_do).
In this chapter we will write the minimal needed bootloader to load our kernel, and obtain information that is necessary for it.

Expand Down
2 changes: 2 additions & 0 deletions src/ch02-01-legacy-legacy-legacy.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ _"Compatibility means deliberately repeating other people's mistakes." - David W

---

#![repository_card]

When writing our bootloader, and especially in the first stages, we encounter a lot of legacy that needs to be handled.
This legacy may come in multiple shapes, like bios interrupts, magic numbers and things that need to be initialized. Most of this work will be covered in this chapter.

Expand Down
2 changes: 2 additions & 0 deletions src/ch02-02-entering-protected-mode.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ _"With great power comes great responsibility." - Voltaire / Spider-Man_

---

#![repository_card]

As you may recall from previous chapters, our BIOS only loads the first sector to RAM, which leaves about just shy of 512 bytes[^1].
After we read from disk, it will enable us to write much more code, because we will not be limited to 512 bytes.
But just before we do that, we don't want to limit ourselves to only 16bit instructions.
Expand Down
Loading
Loading