mirror of
https://github.com/phil-opp/blog_os.git
synced 2025-12-16 14:27:49 +00:00
Compare commits
162 Commits
post-12-wi
...
ceb91f955a
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ceb91f955a | ||
|
|
3340babf51 | ||
|
|
37a0ae0097 | ||
|
|
6fc9fbfb7d | ||
|
|
1f097bba71 | ||
|
|
99fbbad9b0 | ||
|
|
94d14d8d62 | ||
|
|
ebfc7c5f7e | ||
|
|
6f0be666f3 | ||
|
|
d9fa84edd6 | ||
|
|
d1bf96108a | ||
|
|
97de98df33 | ||
|
|
9684f75819 | ||
|
|
d6cc562907 | ||
|
|
b44d8ab7fc | ||
|
|
c551fec1ce | ||
|
|
1d0aa17531 | ||
|
|
e4b3ed6d42 | ||
|
|
b1aec7eb66 | ||
|
|
e2a3e76a32 | ||
|
|
16bbb8f972 | ||
|
|
430e2143f8 | ||
|
|
86ffa24e8e | ||
|
|
a6141e8d2e | ||
|
|
df0c0b5783 | ||
|
|
c27eb1da9c | ||
|
|
deb7c82872 | ||
|
|
2a61f88d8a | ||
|
|
a90a8bea67 | ||
|
|
fda382c6bc | ||
|
|
f52872f3b9 | ||
|
|
688a21e4ed | ||
|
|
75354fe142 | ||
|
|
07d6c9c84e | ||
|
|
2265ddecad | ||
|
|
9edc2c59c7 | ||
|
|
3bc023ec2d | ||
|
|
38604da92f | ||
|
|
6e7c2f4344 | ||
|
|
1a53a115da | ||
|
|
c6990cb52d | ||
|
|
3916bebd15 | ||
|
|
ef9bb1a087 | ||
|
|
2bc4490404 | ||
|
|
f45954e7e4 | ||
|
|
7288459bdf | ||
|
|
7959b77ebd | ||
|
|
bebad6d5a9 | ||
|
|
c73b412ec6 | ||
|
|
6c8fea8b00 | ||
|
|
b99c3f6d1d | ||
|
|
66c1792034 | ||
|
|
445833408c | ||
|
|
3280a0afc7 | ||
|
|
6393247a3b | ||
|
|
8622b9c41b | ||
|
|
a387a00c85 | ||
|
|
faa8d15cb7 | ||
|
|
736a4183db | ||
|
|
4c9cd3ae32 | ||
|
|
26f1f5b896 | ||
|
|
c2dd2477ab | ||
|
|
9d16f0a139 | ||
|
|
a671ad3dbc | ||
|
|
cbead25b43 | ||
|
|
1f49e2e9fe | ||
|
|
8708b54756 | ||
|
|
765c7b21e9 | ||
|
|
2c25d55810 | ||
|
|
021762cf30 | ||
|
|
eb2f818194 | ||
|
|
167ef5bb83 | ||
|
|
4f68f9ba93 | ||
|
|
36e4dc22f3 | ||
|
|
ec95ac0e5a | ||
|
|
d8f280315f | ||
|
|
0e365109be | ||
|
|
e39c7d8ad8 | ||
|
|
066c278277 | ||
|
|
bdb6a424a8 | ||
|
|
c8f72adeb3 | ||
|
|
f40717901b | ||
|
|
96844f6519 | ||
|
|
1501669819 | ||
|
|
cc617ec35e | ||
|
|
195f4489e6 | ||
|
|
1b86d7fd62 | ||
|
|
deb0f63dff | ||
|
|
bee9a7f7ea | ||
|
|
fbdcd45d16 | ||
|
|
d658949f5b | ||
|
|
4c07101f8f | ||
|
|
30be97d035 | ||
|
|
63d0d8cc9f | ||
|
|
d12842bcd5 | ||
|
|
0e52ccbebb | ||
|
|
4de18a8a10 | ||
|
|
3fac6af7b0 | ||
|
|
d4e1f47e62 | ||
|
|
ea5aad0e0c | ||
|
|
4e38e7ddf8 | ||
|
|
4215162b62 | ||
|
|
1afa3af79d | ||
|
|
35c642b3c2 | ||
|
|
49dce7ada7 | ||
|
|
3d96415940 | ||
|
|
fd8a2e0182 | ||
|
|
552eb97f75 | ||
|
|
c42cee8d89 | ||
|
|
3bb076a00f | ||
|
|
e5bd06edcc | ||
|
|
eace075f2c | ||
|
|
2d5150f2a3 | ||
|
|
ebb9f0b8a7 | ||
|
|
edd155d570 | ||
|
|
3200b7a68d | ||
|
|
cde3c8f955 | ||
|
|
6ad573bb11 | ||
|
|
c18cd874ca | ||
|
|
f316bd1a08 | ||
|
|
4a4d704384 | ||
|
|
6380e069f7 | ||
|
|
1ddc27ca88 | ||
|
|
71d8a438f7 | ||
|
|
3a77cbe794 | ||
|
|
3fb4695f6c | ||
|
|
635677d07c | ||
|
|
b276ec4765 | ||
|
|
7341cff39d | ||
|
|
406c406d5f | ||
|
|
6f9cfce6f9 | ||
|
|
acf3717551 | ||
|
|
e78d33a5bf | ||
|
|
6292789393 | ||
|
|
651adbc8bd | ||
|
|
4bbaae24a4 | ||
|
|
44d7654ef6 | ||
|
|
f135aefae8 | ||
|
|
ffaac76876 | ||
|
|
5ae9f62f4d | ||
|
|
da0ee38f09 | ||
|
|
263e852dcc | ||
|
|
614e5b0e86 | ||
|
|
9ee42e0f5f | ||
|
|
c4672096d4 | ||
|
|
ffe1b6abd0 | ||
|
|
16ffe80fd5 | ||
|
|
07d8a22a53 | ||
|
|
bf33685d00 | ||
|
|
3ee6badb33 | ||
|
|
9f9ff59489 | ||
|
|
a1c7931a77 | ||
|
|
2c30310281 | ||
|
|
57cd52b7f5 | ||
|
|
a004e7da9c | ||
|
|
b1bf0873ce | ||
|
|
d7e505da9e | ||
|
|
2039cd7a64 | ||
|
|
ebb862de2a | ||
|
|
d588dca953 | ||
|
|
f23269ed93 | ||
|
|
46264d08ca |
@@ -1,3 +1,7 @@
|
|||||||
|
[unstable]
|
||||||
|
build-std = ["core", "compiler_builtins"]
|
||||||
|
build-std-features = ["compiler-builtins-mem"]
|
||||||
|
|
||||||
[build]
|
[build]
|
||||||
target = "x86_64-blog_os.json"
|
target = "x86_64-blog_os.json"
|
||||||
|
|
||||||
96
.github/workflows/build-code.yml
vendored
96
.github/workflows/build-code.yml
vendored
@@ -1,96 +0,0 @@
|
|||||||
name: Build Code
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- '*'
|
|
||||||
- '!staging.tmp'
|
|
||||||
tags:
|
|
||||||
- '*'
|
|
||||||
schedule:
|
|
||||||
- cron: '40 3 * * *' # every day at 3:40
|
|
||||||
pull_request:
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
test:
|
|
||||||
name: "Test"
|
|
||||||
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
platform: [
|
|
||||||
ubuntu-latest,
|
|
||||||
macos-latest,
|
|
||||||
windows-latest
|
|
||||||
]
|
|
||||||
|
|
||||||
runs-on: ${{ matrix.platform }}
|
|
||||||
timeout-minutes: 15
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: "Checkout Repository"
|
|
||||||
uses: actions/checkout@v1
|
|
||||||
|
|
||||||
- name: Install Rustup
|
|
||||||
run: |
|
|
||||||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain nightly
|
|
||||||
echo ::add-path::$HOME/.cargo/bin
|
|
||||||
if: runner.os == 'macOS'
|
|
||||||
|
|
||||||
- name: "Print Rust Version"
|
|
||||||
run: |
|
|
||||||
rustc -Vv
|
|
||||||
cargo -Vv
|
|
||||||
|
|
||||||
- name: "Install Rustup Components"
|
|
||||||
run: rustup component add rust-src llvm-tools-preview
|
|
||||||
- name: "Install cargo-xbuild"
|
|
||||||
run: cargo install cargo-xbuild --debug
|
|
||||||
- name: "Install bootimage"
|
|
||||||
run: cargo install bootimage --debug
|
|
||||||
|
|
||||||
- name: "Run cargo xbuild"
|
|
||||||
run: cargo xbuild
|
|
||||||
- name: "Create Bootimage"
|
|
||||||
run: cargo bootimage
|
|
||||||
|
|
||||||
# install QEMU
|
|
||||||
- name: Install QEMU (Linux)
|
|
||||||
run: sudo apt update && sudo apt install qemu-system-x86
|
|
||||||
if: runner.os == 'Linux'
|
|
||||||
- name: Install QEMU (macOS)
|
|
||||||
run: brew install qemu
|
|
||||||
if: runner.os == 'macOS'
|
|
||||||
env:
|
|
||||||
HOMEBREW_NO_AUTO_UPDATE: 1
|
|
||||||
HOMEBREW_NO_BOTTLE_SOURCE_FALLBACK: 1
|
|
||||||
HOMEBREW_NO_INSTALL_CLEANUP: 1
|
|
||||||
- name: Install Scoop (Windows)
|
|
||||||
run: |
|
|
||||||
Invoke-Expression (New-Object System.Net.WebClient).DownloadString('https://get.scoop.sh')
|
|
||||||
echo ::add-path::$HOME\scoop\shims
|
|
||||||
if: runner.os == 'Windows'
|
|
||||||
shell: pwsh
|
|
||||||
- name: Install QEMU (Windows)
|
|
||||||
run: scoop install qemu
|
|
||||||
if: runner.os == 'Windows'
|
|
||||||
shell: pwsh
|
|
||||||
- name: "Print QEMU Version"
|
|
||||||
run: qemu-system-x86_64 --version
|
|
||||||
|
|
||||||
- name: "Run cargo xtest"
|
|
||||||
run: cargo xtest
|
|
||||||
|
|
||||||
check_formatting:
|
|
||||||
name: "Check Formatting"
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
timeout-minutes: 2
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v1
|
|
||||||
- name: "Use the latest Rust nightly with rustfmt"
|
|
||||||
uses: actions-rs/toolchain@v1
|
|
||||||
with:
|
|
||||||
toolchain: nightly
|
|
||||||
profile: minimal
|
|
||||||
components: rustfmt
|
|
||||||
override: true
|
|
||||||
- run: cargo fmt -- --check
|
|
||||||
130
.github/workflows/code.yml
vendored
Normal file
130
.github/workflows/code.yml
vendored
Normal file
@@ -0,0 +1,130 @@
|
|||||||
|
name: Code
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- '*'
|
||||||
|
- '!staging.tmp'
|
||||||
|
tags:
|
||||||
|
- '*'
|
||||||
|
schedule:
|
||||||
|
- cron: '40 3 * * *' # every day at 3:40
|
||||||
|
pull_request:
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
check:
|
||||||
|
name: Check
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
platform: [
|
||||||
|
ubuntu-latest,
|
||||||
|
macos-latest,
|
||||||
|
windows-latest
|
||||||
|
]
|
||||||
|
runs-on: ${{ matrix.platform }}
|
||||||
|
steps:
|
||||||
|
- name: Checkout Repository
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
- name: Install Rust Toolchain
|
||||||
|
uses: actions-rs/toolchain@v1
|
||||||
|
with:
|
||||||
|
profile: minimal
|
||||||
|
toolchain: nightly
|
||||||
|
- name: Install `rust-src` Rustup Component
|
||||||
|
run: rustup component add rust-src
|
||||||
|
- name: Run `cargo check`
|
||||||
|
uses: actions-rs/cargo@v1
|
||||||
|
with:
|
||||||
|
command: check
|
||||||
|
|
||||||
|
test:
|
||||||
|
name: Test
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
platform: [
|
||||||
|
ubuntu-latest,
|
||||||
|
macos-latest,
|
||||||
|
windows-latest
|
||||||
|
]
|
||||||
|
runs-on: ${{ matrix.platform }}
|
||||||
|
steps:
|
||||||
|
- name: Install Rust Toolchain
|
||||||
|
uses: actions-rs/toolchain@v1
|
||||||
|
with:
|
||||||
|
profile: minimal
|
||||||
|
toolchain: nightly
|
||||||
|
- name: Install bootimage
|
||||||
|
run: cargo install bootimage --debug
|
||||||
|
- name: Checkout Repository
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
- name: Install Rustup Components
|
||||||
|
run: rustup component add rust-src llvm-tools-preview
|
||||||
|
- name: Run `cargo bootimage`
|
||||||
|
uses: actions-rs/cargo@v1
|
||||||
|
with:
|
||||||
|
command: bootimage
|
||||||
|
|
||||||
|
# install QEMU
|
||||||
|
- name: Install QEMU (Linux)
|
||||||
|
run: sudo apt update && sudo apt install qemu-system-x86
|
||||||
|
if: runner.os == 'Linux'
|
||||||
|
- name: Install QEMU (macOS)
|
||||||
|
run: brew install qemu
|
||||||
|
if: runner.os == 'macOS'
|
||||||
|
env:
|
||||||
|
HOMEBREW_NO_AUTO_UPDATE: 1
|
||||||
|
HOMEBREW_NO_BOTTLE_SOURCE_FALLBACK: 1
|
||||||
|
HOMEBREW_NO_INSTALL_CLEANUP: 1
|
||||||
|
- name: Install QEMU (Windows)
|
||||||
|
run: |
|
||||||
|
choco install qemu --version 2021.5.5
|
||||||
|
echo "$Env:Programfiles\qemu" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
|
||||||
|
if: runner.os == 'Windows'
|
||||||
|
shell: pwsh
|
||||||
|
- name: "Print QEMU Version"
|
||||||
|
run: qemu-system-x86_64 --version
|
||||||
|
|
||||||
|
- name: Run `cargo test`
|
||||||
|
uses: actions-rs/cargo@v1
|
||||||
|
with:
|
||||||
|
command: test
|
||||||
|
|
||||||
|
check_formatting:
|
||||||
|
name: Check Formatting
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout Repository
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
- name: Install Rust Toolchain
|
||||||
|
uses: actions-rs/toolchain@v1
|
||||||
|
with:
|
||||||
|
profile: minimal
|
||||||
|
toolchain: nightly
|
||||||
|
components: rustfmt
|
||||||
|
override: true
|
||||||
|
- name: Run `cargo fmt`
|
||||||
|
uses: actions-rs/cargo@v1
|
||||||
|
with:
|
||||||
|
command: fmt
|
||||||
|
args: --all -- --check
|
||||||
|
|
||||||
|
clippy:
|
||||||
|
name: Clippy
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout Repository
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
- name: Install Rust Toolchain
|
||||||
|
uses: actions-rs/toolchain@v1
|
||||||
|
with:
|
||||||
|
profile: minimal
|
||||||
|
toolchain: nightly
|
||||||
|
components: clippy, rust-src
|
||||||
|
override: true
|
||||||
|
- name: Run `cargo clippy`
|
||||||
|
uses: actions-rs/cargo@v1
|
||||||
|
with:
|
||||||
|
command: clippy
|
||||||
132
Cargo.lock
generated
132
Cargo.lock
generated
@@ -1,25 +1,24 @@
|
|||||||
# This file is automatically @generated by Cargo.
|
# This file is automatically @generated by Cargo.
|
||||||
# It is not intended for manual editing.
|
# It is not intended for manual editing.
|
||||||
[[package]]
|
version = 4
|
||||||
name = "array-init"
|
|
||||||
version = "0.0.4"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "23589ecb866b460d3a0f1278834750268c607e8e28a1b982c907219f3178cd72"
|
|
||||||
dependencies = [
|
|
||||||
"nodrop",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bit_field"
|
name = "bit_field"
|
||||||
version = "0.9.0"
|
version = "0.10.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ed8765909f9009617974ab6b7d332625b320b33c326b1e9321382ef1999b5d56"
|
checksum = "dc827186963e592360843fb5ba4b973e145841266c1357f7180c43526f2e5b61"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bitflags"
|
name = "bitflags"
|
||||||
version = "1.2.1"
|
version = "1.3.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"
|
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "bitflags"
|
||||||
|
version = "2.9.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "6a65b545ab31d687cff52899d4890855fec459eb6afe0da6417b8a18da87aa29"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "blog_os"
|
name = "blog_os"
|
||||||
@@ -27,65 +26,32 @@ version = "0.1.0"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"bootloader",
|
"bootloader",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"spin",
|
"spin 0.5.2",
|
||||||
"uart_16550",
|
"uart_16550",
|
||||||
"volatile",
|
"volatile 0.2.7",
|
||||||
"x86_64 0.8.1",
|
"x86_64",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bootloader"
|
name = "bootloader"
|
||||||
version = "0.8.3"
|
version = "0.9.32"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d596849a47f28abdea62d7a6a25c4f6e69c3d9b09b0a2877db6e9cda004ca993"
|
checksum = "1ea119c3ed05625c179e09d17d0914570a3753ca09c890a73d98f6b72aea00d2"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "cast"
|
|
||||||
version = "0.2.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "4b9434b9a5aa1450faa3f9cb14ea0e8c53bb5d2b3c1bfd1ab4fc03e9f33fbfb0"
|
|
||||||
dependencies = [
|
|
||||||
"rustc_version",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "lazy_static"
|
name = "lazy_static"
|
||||||
version = "1.4.0"
|
version = "1.5.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
|
checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"spin",
|
"spin 0.9.8",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nodrop"
|
name = "rustversion"
|
||||||
version = "0.1.14"
|
version = "1.0.22"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb"
|
checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rustc_version"
|
|
||||||
version = "0.2.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a"
|
|
||||||
dependencies = [
|
|
||||||
"semver",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "semver"
|
|
||||||
version = "0.9.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403"
|
|
||||||
dependencies = [
|
|
||||||
"semver-parser",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "semver-parser"
|
|
||||||
version = "0.7.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "spin"
|
name = "spin"
|
||||||
@@ -94,48 +60,42 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d"
|
checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "uart_16550"
|
name = "spin"
|
||||||
version = "0.2.1"
|
version = "0.9.8"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "803ea8cb602dbb32c1a657a866d2dd79fe7dbeab0fb2ac667cb4dcc7de12a58b"
|
checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67"
|
||||||
dependencies = [
|
|
||||||
"bitflags",
|
|
||||||
"x86_64 0.7.7",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ux"
|
name = "uart_16550"
|
||||||
version = "0.1.3"
|
version = "0.2.19"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "88dfeb711b61ce620c0cb6fd9f8e3e678622f0c971da2a63c4b3e25e88ed012f"
|
checksum = "614ff2a87880d4bd4374722268598a970bbad05ced8bf630439417347254ab2e"
|
||||||
|
dependencies = [
|
||||||
|
"bitflags 1.3.2",
|
||||||
|
"rustversion",
|
||||||
|
"x86_64",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "volatile"
|
name = "volatile"
|
||||||
version = "0.2.6"
|
version = "0.2.7"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "6af0edf5b4faacc31fc51159244d78d65ec580f021afcef7bd53c04aeabc7f29"
|
checksum = "f6b06ad3ed06fef1713569d547cdbdb439eafed76341820fb0e0344f29a41945"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "volatile"
|
||||||
|
version = "0.4.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "442887c63f2c839b346c192d047a7c87e73d0689c9157b00b53dcc27dd5ea793"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "x86_64"
|
name = "x86_64"
|
||||||
version = "0.7.7"
|
version = "0.14.13"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1f27d9168654aee1b0c1b73746caeb4aa33248f8b8c8f6e100e697fcc2a794b2"
|
checksum = "c101112411baafbb4bf8d33e4c4a80ab5b02d74d2612331c61e8192fc9710491"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"array-init",
|
|
||||||
"bit_field",
|
"bit_field",
|
||||||
"bitflags",
|
"bitflags 2.9.2",
|
||||||
"cast",
|
"rustversion",
|
||||||
"ux",
|
"volatile 0.4.6",
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "x86_64"
|
|
||||||
version = "0.8.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "f21672dcbed52bc09eea030d189600c0189c66c97bc5b31779eb780e064a201f"
|
|
||||||
dependencies = [
|
|
||||||
"array-init",
|
|
||||||
"bit_field",
|
|
||||||
"bitflags",
|
|
||||||
"cast",
|
|
||||||
]
|
]
|
||||||
|
|||||||
21
Cargo.toml
21
Cargo.toml
@@ -2,27 +2,36 @@
|
|||||||
name = "blog_os"
|
name = "blog_os"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
authors = ["Philipp Oppermann <dev@phil-opp.com>"]
|
authors = ["Philipp Oppermann <dev@phil-opp.com>"]
|
||||||
edition = "2018"
|
edition = "2024"
|
||||||
|
|
||||||
[[test]]
|
[[test]]
|
||||||
name = "should_panic"
|
name = "should_panic"
|
||||||
harness = false
|
harness = false
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bootloader = "0.8.0"
|
bootloader = "0.9"
|
||||||
volatile = "0.2.6"
|
volatile = "0.2.6"
|
||||||
spin = "0.5.2"
|
spin = "0.5.2"
|
||||||
x86_64 = "0.8.1"
|
x86_64 = "0.14.2"
|
||||||
uart_16550 = "0.2.0"
|
uart_16550 = "0.2.0"
|
||||||
|
|
||||||
[dependencies.lazy_static]
|
[dependencies.lazy_static]
|
||||||
version = "1.0"
|
version = "1.0"
|
||||||
features = ["spin_no_std"]
|
features = ["spin_no_std"]
|
||||||
|
|
||||||
|
[[bin]]
|
||||||
|
name = "blog_os"
|
||||||
|
test = true
|
||||||
|
bench = false
|
||||||
|
|
||||||
|
|
||||||
[package.metadata.bootimage]
|
[package.metadata.bootimage]
|
||||||
test-args = [
|
test-args = [
|
||||||
"-device", "isa-debug-exit,iobase=0xf4,iosize=0x04", "-serial", "stdio",
|
"-device",
|
||||||
"-display", "none"
|
"isa-debug-exit,iobase=0xf4,iosize=0x04",
|
||||||
|
"-serial",
|
||||||
|
"stdio",
|
||||||
|
"-display",
|
||||||
|
"none",
|
||||||
]
|
]
|
||||||
test-success-exit-code = 33 # (0x10 << 1) | 1
|
test-success-exit-code = 33 # (0x10 << 1) | 1
|
||||||
|
|||||||
20
README.md
20
README.md
@@ -1,6 +1,6 @@
|
|||||||
# Blog OS (Testing)
|
# Blog OS (Testing)
|
||||||
|
|
||||||
[](https://github.com/phil-opp/blog_os/actions?query=workflow%3A%22Build+Code%22+branch%3Apost-04)
|
[](https://github.com/phil-opp/blog_os/actions?query=workflow%3A%22Code%22+branch%3Apost-04)
|
||||||
|
|
||||||
This repository contains the source code for the [Testing][post] post of the [Writing an OS in Rust](https://os.phil-opp.com) series.
|
This repository contains the source code for the [Testing][post] post of the [Writing an OS in Rust](https://os.phil-opp.com) series.
|
||||||
|
|
||||||
@@ -10,19 +10,23 @@ This repository contains the source code for the [Testing][post] post of the [Wr
|
|||||||
|
|
||||||
## Building
|
## Building
|
||||||
|
|
||||||
You need a nightly Rust compiler. First you need to install the `cargo-xbuild` and `bootimage` tools:
|
This project requires a nightly version of Rust because it uses some unstable features. At least nightly _2020-07-15_ is required for building. You might need to run `rustup update nightly --force` to update to the latest nightly even if some components such as `rustfmt` are missing it.
|
||||||
|
|
||||||
|
You can build the project by running:
|
||||||
|
|
||||||
```
|
```
|
||||||
cargo install cargo-xbuild bootimage
|
cargo build
|
||||||
```
|
```
|
||||||
|
|
||||||
Then you can build the project by running:
|
To create a bootable disk image from the compiled kernel, you need to install the [`bootimage`] tool:
|
||||||
|
|
||||||
|
[`bootimage`]: https://github.com/rust-osdev/bootimage
|
||||||
|
|
||||||
```
|
```
|
||||||
cargo xbuild
|
cargo install bootimage
|
||||||
```
|
```
|
||||||
|
|
||||||
To create a bootable disk image, run:
|
After installing, you can create the bootable disk image by running:
|
||||||
|
|
||||||
```
|
```
|
||||||
cargo bootimage
|
cargo bootimage
|
||||||
@@ -39,10 +43,10 @@ You can run the disk image in [QEMU] through:
|
|||||||
[QEMU]: https://www.qemu.org/
|
[QEMU]: https://www.qemu.org/
|
||||||
|
|
||||||
```
|
```
|
||||||
cargo xrun
|
cargo run
|
||||||
```
|
```
|
||||||
|
|
||||||
Of course [QEMU] needs to be installed for this.
|
[QEMU] and the [`bootimage`] tool need to be installed for this.
|
||||||
|
|
||||||
You can also write the image to an USB stick for booting it on a real machine. On Linux, the command for this is:
|
You can also write the image to an USB stick for booting it on a real machine. On Linux, the command for this is:
|
||||||
|
|
||||||
|
|||||||
21
src/lib.rs
21
src/lib.rs
@@ -9,10 +9,25 @@ use core::panic::PanicInfo;
|
|||||||
pub mod serial;
|
pub mod serial;
|
||||||
pub mod vga_buffer;
|
pub mod vga_buffer;
|
||||||
|
|
||||||
pub fn test_runner(tests: &[&dyn Fn()]) {
|
pub trait Testable {
|
||||||
|
fn run(&self) -> ();
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<T> Testable for T
|
||||||
|
where
|
||||||
|
T: Fn(),
|
||||||
|
{
|
||||||
|
fn run(&self) {
|
||||||
|
serial_print!("{}...\t", core::any::type_name::<T>());
|
||||||
|
self();
|
||||||
|
serial_println!("[ok]");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn test_runner(tests: &[&dyn Testable]) {
|
||||||
serial_println!("Running {} tests", tests.len());
|
serial_println!("Running {} tests", tests.len());
|
||||||
for test in tests {
|
for test in tests {
|
||||||
test();
|
test.run();
|
||||||
}
|
}
|
||||||
exit_qemu(QemuExitCode::Success);
|
exit_qemu(QemuExitCode::Success);
|
||||||
}
|
}
|
||||||
@@ -42,7 +57,7 @@ pub fn exit_qemu(exit_code: QemuExitCode) {
|
|||||||
|
|
||||||
/// Entry point for `cargo xtest`
|
/// Entry point for `cargo xtest`
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
#[no_mangle]
|
#[unsafe(no_mangle)]
|
||||||
pub extern "C" fn _start() -> ! {
|
pub extern "C" fn _start() -> ! {
|
||||||
test_main();
|
test_main();
|
||||||
loop {}
|
loop {}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
use blog_os::println;
|
use blog_os::println;
|
||||||
use core::panic::PanicInfo;
|
use core::panic::PanicInfo;
|
||||||
|
|
||||||
#[no_mangle]
|
#[unsafe(no_mangle)]
|
||||||
pub extern "C" fn _start() -> ! {
|
pub extern "C" fn _start() -> ! {
|
||||||
println!("Hello World{}", "!");
|
println!("Hello World{}", "!");
|
||||||
|
|
||||||
@@ -30,3 +30,8 @@ fn panic(info: &PanicInfo) -> ! {
|
|||||||
fn panic(info: &PanicInfo) -> ! {
|
fn panic(info: &PanicInfo) -> ! {
|
||||||
blog_os::test_panic_handler(info)
|
blog_os::test_panic_handler(info)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test_case]
|
||||||
|
fn trivial_assertion() {
|
||||||
|
assert_eq!(1, 1);
|
||||||
|
}
|
||||||
|
|||||||
@@ -3,9 +3,6 @@ use lazy_static::lazy_static;
|
|||||||
use spin::Mutex;
|
use spin::Mutex;
|
||||||
use volatile::Volatile;
|
use volatile::Volatile;
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
use crate::{serial_print, serial_println};
|
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
/// A global `Writer` instance that can be used for printing to the VGA text buffer.
|
/// A global `Writer` instance that can be used for printing to the VGA text buffer.
|
||||||
///
|
///
|
||||||
@@ -175,30 +172,22 @@ pub fn _print(args: fmt::Arguments) {
|
|||||||
|
|
||||||
#[test_case]
|
#[test_case]
|
||||||
fn test_println_simple() {
|
fn test_println_simple() {
|
||||||
serial_print!("test_println... ");
|
|
||||||
println!("test_println_simple output");
|
println!("test_println_simple output");
|
||||||
serial_println!("[ok]");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test_case]
|
#[test_case]
|
||||||
fn test_println_many() {
|
fn test_println_many() {
|
||||||
serial_print!("test_println_many... ");
|
|
||||||
for _ in 0..200 {
|
for _ in 0..200 {
|
||||||
println!("test_println_many output");
|
println!("test_println_many output");
|
||||||
}
|
}
|
||||||
serial_println!("[ok]");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test_case]
|
#[test_case]
|
||||||
fn test_println_output() {
|
fn test_println_output() {
|
||||||
serial_print!("test_println_output... ");
|
|
||||||
|
|
||||||
let s = "Some test string that fits on a single line";
|
let s = "Some test string that fits on a single line";
|
||||||
println!("{}", s);
|
println!("{}", s);
|
||||||
for (i, c) in s.chars().enumerate() {
|
for (i, c) in s.chars().enumerate() {
|
||||||
let screen_char = WRITER.lock().buffer.chars[BUFFER_HEIGHT - 2][i].read();
|
let screen_char = WRITER.lock().buffer.chars[BUFFER_HEIGHT - 2][i].read();
|
||||||
assert_eq!(char::from(screen_char.ascii_character), c);
|
assert_eq!(char::from(screen_char.ascii_character), c);
|
||||||
}
|
}
|
||||||
|
|
||||||
serial_println!("[ok]");
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,10 +4,10 @@
|
|||||||
#![test_runner(blog_os::test_runner)]
|
#![test_runner(blog_os::test_runner)]
|
||||||
#![reexport_test_harness_main = "test_main"]
|
#![reexport_test_harness_main = "test_main"]
|
||||||
|
|
||||||
use blog_os::{println, serial_print, serial_println};
|
use blog_os::println;
|
||||||
use core::panic::PanicInfo;
|
use core::panic::PanicInfo;
|
||||||
|
|
||||||
#[no_mangle] // don't mangle the name of this function
|
#[unsafe(no_mangle)] // don't mangle the name of this function
|
||||||
pub extern "C" fn _start() -> ! {
|
pub extern "C" fn _start() -> ! {
|
||||||
test_main();
|
test_main();
|
||||||
|
|
||||||
@@ -21,7 +21,5 @@ fn panic(info: &PanicInfo) -> ! {
|
|||||||
|
|
||||||
#[test_case]
|
#[test_case]
|
||||||
fn test_println() {
|
fn test_println() {
|
||||||
serial_print!("test_println... ");
|
|
||||||
println!("test_println output");
|
println!("test_println output");
|
||||||
serial_println!("[ok]");
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
#![no_std]
|
#![no_std]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
|
|
||||||
use blog_os::{exit_qemu, serial_print, serial_println, QemuExitCode};
|
use blog_os::{QemuExitCode, exit_qemu, serial_print, serial_println};
|
||||||
use core::panic::PanicInfo;
|
use core::panic::PanicInfo;
|
||||||
|
|
||||||
#[no_mangle]
|
#[unsafe(no_mangle)]
|
||||||
pub extern "C" fn _start() -> ! {
|
pub extern "C" fn _start() -> ! {
|
||||||
should_fail();
|
should_fail();
|
||||||
serial_println!("[test did not panic]");
|
serial_println!("[test did not panic]");
|
||||||
@@ -13,7 +13,7 @@ pub extern "C" fn _start() -> ! {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn should_fail() {
|
fn should_fail() {
|
||||||
serial_print!("should_fail... ");
|
serial_print!("should_panic::should_fail...\t");
|
||||||
assert_eq!(0, 1);
|
assert_eq!(0, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,15 +1,16 @@
|
|||||||
{
|
{
|
||||||
"llvm-target": "x86_64-unknown-none",
|
"llvm-target": "x86_64-unknown-none",
|
||||||
"data-layout": "e-m:e-i64:64-f80:128-n8:16:32:64-S128",
|
"data-layout": "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128",
|
||||||
"arch": "x86_64",
|
"arch": "x86_64",
|
||||||
"target-endian": "little",
|
"target-endian": "little",
|
||||||
"target-pointer-width": "64",
|
"target-pointer-width": "64",
|
||||||
"target-c-int-width": "32",
|
"target-c-int-width": 32,
|
||||||
"os": "none",
|
"os": "none",
|
||||||
"executables": true,
|
"executables": true,
|
||||||
"linker-flavor": "ld.lld",
|
"linker-flavor": "ld.lld",
|
||||||
"linker": "rust-lld",
|
"linker": "rust-lld",
|
||||||
"panic-strategy": "abort",
|
"panic-strategy": "abort",
|
||||||
"disable-redzone": true,
|
"disable-redzone": true,
|
||||||
"features": "-mmx,-sse,+soft-float"
|
"features": "-mmx,-sse,+soft-float",
|
||||||
|
"rustc-abi": "x86-softfloat"
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user