Skip to content

Commit d4a4e0d

Browse files
committed
M1: qemu x86 bootloader
1 parent a787814 commit d4a4e0d

16 files changed

Lines changed: 386 additions & 179 deletions

File tree

.github/workflows/ci.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: CI # 工作流名称
2+
3+
# push到main或者有PR时触发
4+
on:
5+
push:
6+
branches: [ main ]
7+
pull_request:
8+
9+
jobs:
10+
build-and-boot:
11+
runs-on: ubuntu-22.04 # 在Ubuntu 22.04环境下运行
12+
steps:
13+
# 签出到运行环境
14+
- name: Checkout
15+
uses: actions/checkout@v4
16+
17+
# xorriso-制作ISO镜像; make, nasm, gcc-构建LimineOS;
18+
# qemu-system-x86-运行LimineOS
19+
- name: Install deps
20+
run: |
21+
sudo apt-get update
22+
sudo apt-get install -y qemu-system-x86 xorriso make nasm gcc
23+
24+
- name: Setup Rust (nightly) (actions-rs)
25+
uses: actions-rs/toolchain@v1
26+
with:
27+
toolchain: nightly
28+
components: rust-src, llvm-tools-preview
29+
profile: minimal
30+
31+
- name: Build kernel & ISO
32+
run: |
33+
bash scripts/make_iso.sh
34+
35+
- name: Boot in QEMU (headless) and check log
36+
run: |
37+
set -e
38+
timeout 20s bash -c 'qemu-system-x86_64 -machine q35 -m 256M -serial stdio -display none -cdrom build/rint-m1.iso -no-reboot | tee qemu.log || true'
39+
grep -q "RINT KERNEL: init OK" qemu.log

Cargo.lock

Lines changed: 48 additions & 109 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
[workspace]
22
members = [
33
"kernel",
4-
"crates/hal",
5-
"crates/scheduler",
6-
"crates/metrics",
7-
"crates/sched-sim",
8-
"arch-x86_64",
9-
"arch-riscv64",
4+
# "crates/hal",
5+
# "crates/scheduler",
6+
# "crates/metrics",
7+
# "crates/sched-sim",
8+
# "arch-x86_64",
9+
# "arch-riscv64",
1010
]
1111
resolver = "2"

LICENCE

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Apache License
2+
Version 2.0, January 2004
3+
http://www.apache.org/licenses/
4+
5+
Copyright (c) 2026, mackz-maxw
6+
7+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
8+
9+
[...snip...]
10+
END OF TERMS AND CONDITIONS

README.md

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<details>
1515
<summary>
1616

17-
### M0 - 含创建基本仓库结构与能在本机/WSL 运行的 sched-sim 原型文件
17+
### M0 - 创建基本仓库结构
1818
</summary>
1919

2020
一:需要的工具
@@ -90,15 +90,47 @@
9090
9191
</details>
9292
93+
9394
<details>
9495
<summary>
9596
96-
### M1 - (工作中
97+
### M1 - 引导程序(bootloader
9798
</summary>
98-
</details>
9999
100+
目标:x86_64 • 引导:Limine • 许可证:Apache-2.0 • 开发环境:WSL2 Ubuntu 22
101+
102+
可用功能
103+
- 通过引导入口 `_start` 和临时栈实现最小的 long-mode 内核入口
104+
- 在 COM1 上的串口日志(在 QEMU 中使用 `-serial stdio` 可以看到日志)
105+
- Panic 处理器和基本的引导横幅
106+
- Limine ISO 构建脚本和 QEMU 启动脚本
107+
- CI 会构建 ISO 并验证启动日志包含 `RINT KERNEL: init OK`
108+
109+
先决条件(WSL2 Ubuntu 22)
110+
```bash
111+
sudo apt-get update
112+
sudo apt-get install -y build-essential qemu-system-x86 xorriso make nasm gcc
113+
```
114+
下载配置的nightly工具链 `rustup toolchain install`
115+
116+
本地构建与运行
117+
```bash
118+
bash scripts/make_iso.sh
119+
bash scripts/qemu.sh
120+
```
121+
122+
预期输出:
123+
```
124+
==============================
125+
RINT Rust Microkernel (M1)
126+
Arch: x86_64 | Boot: Limine | License: Apache-2.0
127+
==============================
128+
RINT KERNEL: init OK
129+
```
100130
</details>
101131

132+
133+
102134
<details>
103135
<summary>
104136

kernel/.cargo/config.toml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
[build]
2-
target = "x86_64-unknown-none"
2+
target = "x86_64-rint.json"
33

4-
[target.x86_64-unknown-none]
5-
linker = "ld.lld"
6-
rustflags = ["-C", "link-arg=-nostartfiles"]
4+
[target."x86_64-rint.json"]
5+
rustflags = [
6+
"-Clink-arg=-Tkernel/ld/link.ld",
7+
]
8+
9+
[unstable]
10+
build-std = ["core", "compiler_builtins", "alloc"]
11+
build-std-features = ["compiler-builtins-mem"]

kernel/Cargo.toml

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,28 @@
11
[package]
2-
name = "kernel"
2+
name = "rint-kernel"
33
version = "0.1.0"
44
edition = "2024"
5+
license = "Apache-2.0"
6+
authors = ["mackz-maxw <github.com/mackz-maxw>"]
57

68
[dependencies]
9+
x86_64 = "0.14"
10+
spin = "0.9"
11+
uart_16550 = "0.2"
12+
volatile = "0.5"
13+
14+
[profile.dev]
15+
panic = "abort"
16+
lto = false
17+
opt-level = 0
18+
codegen-units = 16
19+
20+
[profile.release]
21+
panic = "abort"
22+
lto = "thin"
23+
opt-level = "z"
24+
codegen-units = 1
25+
26+
[lib]
27+
name = "rint_kernel"
28+
crate-type = ["staticlib"]

0 commit comments

Comments
 (0)