Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added some docs and an example for how to use the APIC #460

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/target/
**/*.rs.bk
.idea
69 changes: 55 additions & 14 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ members = [
"tests/test_kernels/min_stack",
"tests/test_kernels/lower_memory_free",
"tests/test_kernels/write_usable_memory",
"docs/apic_example",
]
exclude = ["examples/basic", "examples/test_framework"]

Expand Down
14 changes: 14 additions & 0 deletions docs/apic_example/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[package]
name = "apic_example"
edition = "2021"
version.workspace = true
license.workspace = true
repository.workspace = true

[dependencies]
bootloader_api = { workspace = true }
x86_64 = "=0.15.1"
lazy_static = "=1.5.0"
spin = "=0.9.8"
acpi = "=4.1.1"
log = "=0.4.19"
30 changes: 30 additions & 0 deletions docs/apic_example/apic.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# How to use the APIC

## src/main.rs

In the example provided we will be using a dynamic memory mapping. This is for exemplification only and can be changed
with your own implementation of the memory mapper.

## src/apic.rs

Here we create an `AcpiHandlerImpl` that implements the `AcpiHandler` trait from the `apic` crate.
We have also added an enum with all the APIC registers from
the [OS Dev Wiki](https://wiki.osdev.org/APIC)
The main functions of the file are:

- Init the Local APIC
- Init the IO APIC
- Map the APIC

## src/frame_allocator.rs

This implements a basic frame allocator based on the [blog post](https://os.phil-opp.com/heap-allocation/)

## src/gdt.rs

Implements a basic Global Descriptor Table based on
the [blog post](https://os.phil-opp.com/double-fault-exceptions/#the-global-descriptor-table/) as well as ensures that
all segment registers are written, including `ss` and `ds`.

## src/idt.rs
Implements a basic Interrupt Descriptor Table based on the [blog post](https://os.phil-opp.com/hardware-interrupts/)
Loading
Loading