Skip to content

Commit ad65326

Browse files
committed
docs: 完善了相关文档
1 parent 1feb618 commit ad65326

File tree

6 files changed

+105
-34
lines changed

6 files changed

+105
-34
lines changed

README.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
---
66

7-
Documentation: [https://prokadoc.pages.dev/](https://prokadoc.pages.dev/)
7+
For more documentation, please visit: [https://prokadoc.pages.dev/](https://prokadoc.pages.dev/).
88

9-
Welcome to Proka Kernel, an operating system kernel developed by young talents at RainSTR Studio.
9+
Welcome to use Proka Kernel, an operating system kernel developed by young talents at RainSTR Studio.
1010
Primarily for learning and practice, our goal is to evolve it into a stable and reliable system.
1111

1212
## Project Highlights
@@ -48,10 +48,10 @@ We recommend `rustup` for Rust management.
4848

4949
```bash
5050
# Install Rust (via rustup)
51-
# curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
52-
# source $HOME/.cargo/env
53-
# rustup default nightly
54-
# rustup target add x86_64-unknown-none
51+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
52+
source $HOME/.cargo/env
53+
rustup default nightly
54+
rustup target add x86_64-unknown-none
5555

5656
# Install core build tools
5757
sudo apt-get update
@@ -72,13 +72,13 @@ From the project root:
7272
```bash
7373
make menuconfig
7474
```
75-
Please follow its instructions to config.
75+
Please follow its instructions to configure the kernel's settings.
7676
7777
2. **Compile Kernel**:
7878
```bash
7979
make
8080
```
81-
The kernel file will be put at `output/kernel`.
81+
The kernel file will be put at `output/kernel` in project root.
8282
8383
3. **Build ISO Image**:
8484
```bash
@@ -100,6 +100,7 @@ Thank you to all contributors!
100100
* **moyan** <me@moyanjdc.top>
101101
* **xiaokuai** <rainyhowcool@outlook.com>
102102
* **TMX** <273761857@qq.com>
103+
* **LKBaka** <linkervb@outlook.com>
103104
104105
### How to Contribute
105106

docs/getting-started/build-and-run.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,22 @@
22

33
## 编译内核
44
```bash
5-
make
5+
# 如果是debug(dev)模式的话,直接写make all即可
6+
make all
7+
8+
# 如果是release(prod)模式的话,需要给PROFILE=release。
9+
PROFILE=release make all
610
```
711

812
## 创建 ISO 镜像
913
```bash
10-
make iso
14+
# 与上同理,debug(dev)模式直接写make iso即可,release(prod)模式需要给PROFILE=release。
15+
# 这里以release模式为例,哪个模式下封装哪个模式的镜像。
16+
PROFILE=release make iso
1117
```
1218

1319
## 在 QEMU 中运行
1420
```bash
21+
# 为了调试,使用此命令时将直接以debug(dev)模式运行。
1522
make run
1623
```

docs/getting-started/setup.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
- **Rust Toolchain**: `nightly` 版本,目标平台 `x86_64-unknown-none`
55
- **GCC**: 用于编译 C 代码。
66
- **Make**: 构建自动化。
7+
- **Anaxa Builder**: 用于解析相关配置,并编译内核。
78

89
## 模拟与镜像工具
910
- **QEMU**: 内核模拟运行。

docs/infrastructure/config-system.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,4 @@ a = "./a"
7575

7676
配置界面使用`make menuconfig`启动,会启动一个TUI界面,用户可以通过键盘输入来配置内核。
7777

78-
配置界面的详细使用方法请参考[]()
78+
配置界面的详细使用方法请参考[Anaxa Builder README](https://github.com/RainSTR-Studio/anaxa-builder/blob/main/README.md)

docs/introduction/conventions.md

Lines changed: 72 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -51,35 +51,37 @@ kernel/src/
5151

5252
### 注释与文档
5353

54+
对于注释,我们建议使用英文编写,以确保项目的国际化,使全世界的开发者都能够理解和维护代码。
55+
5456
**单行注释**
5557
```rust
56-
// 使用简单的注释解释复杂逻辑
57-
let frame = allocator.allocate()?; // 如果分配失败则返回错误
58+
// Use the simple comment to explain the complex logic
59+
let frame = allocator.allocate()?; // If allocation fails, return an error
5860
```
5961

6062
**多行注释**
6163
```rust
6264
/*
63-
* 复杂的算法说明
64-
* 第二行说明
65+
* Complex algorithm description
66+
* Second line description
6567
*/
6668
```
6769

6870
**文档注释**
6971
```rust
70-
/// 分配一个物理帧
72+
/// Allocate a physical frame
7173
///
72-
/// # 参数
73-
/// - `allocator`: 帧分配器实例
74-
/// - `count`: 需要分配的帧数
74+
/// # Arguments
75+
/// - `allocator`: The frame allocator instance
76+
/// - `count`: The number of frames to allocate
7577
///
76-
/// # 返回值
77-
/// 返回分配的帧地址,或错误
78+
/// # Returns
79+
/// Returns the address of the allocated frame, or an error
7880
///
79-
/// # 安全要求
80-
/// 调用者必须确保帧分配器已初始化
81+
/// # Safety Requirements
82+
/// The caller must ensure that the frame allocator is initialized
8183
///
82-
/// # 示例
84+
/// # Examples
8385
/// ```
8486
/// let frame = allocate_frames(&mut allocator, 1)?;
8587
/// ```
@@ -90,7 +92,7 @@ pub fn allocate_frames(allocator: &mut FrameAllocator, count: usize) -> Result<F
9092

9193
**内联汇编注释**
9294
```rust
93-
// SAFETY: 必须确保内存对齐和权限正确
95+
// SAFETY: Must ensure that the page table address is valid and properly aligned
9496
unsafe {
9597
asm!("mov cr3, {}", in(reg) page_table_addr);
9698
}
@@ -109,15 +111,18 @@ unsafe {
109111

110112
**示例**
111113
```rust
112-
/// 设置当前页表
114+
/// Set the current page table
115+
///
116+
/// # Arguments
117+
/// - `page_table_addr`: The address of the page table to set as the current page table
113118
///
114-
/// # 安全要求
115-
/// - `page_table_addr` 必须指向有效的页表
116-
/// - 页表必须正确设置权限位
117-
/// - 调用者必须确保在此函数后不会访问无效内存
119+
/// # Safety Requirements
120+
/// - `page_table_addr` must point to a valid page table
121+
/// - The page table must have the correct permission bits set
122+
/// - The caller must ensure that no invalid memory will be accessed after this function returns
118123
pub unsafe fn set_page_table(page_table_addr: usize) {
119-
// SAFETY: 调用者必须确保 page_table_addr 指向有效的页表结构,
120-
// 并且在切换页表后不会立即访问可能无效的内存地址
124+
// SAFETY: The caller must ensure that `page_table_addr` points to a valid page table structure,
125+
// and that no invalid memory will be accessed after this function returns.
121126
asm!("mov cr3, {}", in(reg) page_table_addr);
122127
}
123128
```
@@ -153,11 +158,56 @@ pub unsafe fn set_page_table(page_table_addr: usize) {
153158
### 测试要求
154159

155160
**单元测试**
156-
- Rust: 使用 `#[test]` 属性
161+
- Rust: 使用 `#[test_case]` 属性,即在测试函数前添加 `#[test_case]` 宏(**不是 `#[test]`!!!**
157162

158163
**测试文件位置**
159164
- Rust 测试与源码在同一文件(使用 `#[cfg(test)]`
160165

166+
**示例**
167+
```rust
168+
// 这里假定你是在proka-kernel(lib/main)下写的代码,即kernel/src/lib.rs已经
169+
// mod了你的module。
170+
//
171+
// 此时你便可以直接使用`#[test_case]`宏来编写测试用例。
172+
173+
// 这里定义一个功能
174+
pub struct MyStruct {
175+
pub field: u32,
176+
}
177+
178+
impl MyStruct {
179+
/// Initilaize a new `MyStruct` with the given field value.
180+
pub fn new(field: u32) -> Self {
181+
Self { field }
182+
}
183+
184+
/// Return the value of the `field` field.
185+
pub fn some_method(&self) -> u32 {
186+
self.field
187+
}
188+
}
189+
190+
// 这里编写测试用例
191+
#[cfg(test)]
192+
mod tests {
193+
use super::*;
194+
195+
/// Test the `new` method.
196+
#[test_case]
197+
fn test_new() {
198+
let my_struct = MyStruct::new(114514);
199+
assert_eq!(my_struct.field, 114514);
200+
}
201+
202+
/// Test the `some_method` method.
203+
#[test_case]
204+
fn test_some_method() {
205+
let my_struct = MyStruct::new(114514);
206+
assert_eq!(my_struct.some_method(), 114514);
207+
}
208+
}
209+
```
210+
161211
---
162212

163213
## 总结

docs/introduction/vision.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,13 @@
1-
# 项目愿景与特性
1+
# 项目愿景与特性
2+
3+
## 项目愿景
4+
5+
对于此项目,我们希望实现一个简单、可靠的操作系统内核,同时提供丰富的功能和特性。
6+
7+
作为一名中国人,我们希望这个项目能够为中国的开源社区做出贡献,同时也能够为中国的信息技术发展做出贡献。
8+
9+
## 项目特性
10+
11+
我们这个项目最先的目标是实现一个简单的操作系统内核,同时提供基本的功能和特性。
12+
13+
将来随着我们技术的不断改善,我们可能会实现自己的文件系统、可执行文件格式、专属于此内核的引导器等,以实现此系统的国产化,推动中国的信息技术发展。

0 commit comments

Comments
 (0)