Skip to content

Commit 31b429c

Browse files
committed
rebase boot
Signed-off-by: Zone.N <zone.niuzh@hotmail.com>
1 parent fe3f88b commit 31b429c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+7101
-213
lines changed

README.md

Lines changed: 45 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[![codecov](https://codecov.io/gh/Simple-XX/SimpleKernel/graph/badge.svg?token=J7NKK3SBNJ)](https://codecov.io/gh/Simple-XX/SimpleKernel)
22
![workflow](https://github.com/Simple-XX/SimpleKernel/actions/workflows/workflow.yml/badge.svg)
33
![commit-activity](https://img.shields.io/github/commit-activity/t/Simple-XX/SimpleKernel)
4-
![last-commit-boot](https://img.shields.io/github/last-commit/Simple-XX/SimpleKernel/boot)
4+
![last-commit-interrupt](https://img.shields.io/github/last-commit/Simple-XX/SimpleKernel/interrupt)
55
![MIT License](https://img.shields.io/github/license/mashape/apistatus.svg)
66
[![LICENSE](https://img.shields.io/badge/license-Anti%20996-blue.svg)](https://github.com/996icu/996.ICU/blob/master/LICENSE)
77
[![996.icu](https://img.shields.io/badge/link-996.icu-red.svg)](https://996.icu)
@@ -10,9 +10,7 @@
1010

1111
# SimpleKernel
1212

13-
**一个现代的多架构内核操作系统,支持 x86_64、RISC-V 和 AArch64 架构**
14-
15-
boot branch
13+
interrupt branch
1614

1715
## 关键词
1816

@@ -65,150 +63,78 @@ make run
6563

6664
本分支是 SimpleKernel 的首个分支。在本分支中,完成了构建系统的基础搭建、基本的文档部署与自动化测试,当然还有最重要的,有基于 u-boot 引导的 x86_64 内核与由 opensbi 启动的 riscv64 内核,可以在 qemu 上运行,并实现了简单的屏幕输出。
6765

68-
||x86_64|riscv64|aarch64|
69-
| :-----------------------: | :-------------------------------: | :---------------------------------------------: | :-------------------: |
70-
|引导|u-boot|u-boot+opensbi|u-boot+atf+optee|
71-
|基本输出|通过 serial 实现|通过 opensbi 提供的 ecall 实现|通过 serial 实现|
72-
|硬件资源探测|由 u-boot 传递|由 u-boot 传递的 dtb|由 u-boot+atf 传递的 dtb|
73-
74-
- 构建系统
75-
76-
参考 [MRNIU/cmake-kernel](https://github.com/MRNIU/cmake-kernel) 的构建系统,详细解释见 [doc/build_system.md](./doc/build_system.md)
77-
78-
- libc 支持
79-
80-
| 函数/变量名 | 用途 | |
81-
| :------------------: | :----------------------------------------------: | :--: |
82-
| `__stack_chk_guard` | 栈保护 | |
83-
| `__stack_chk_fail()` | 栈保护检查失败后调用 | |
84-
| `memcpy()` | 复制内存块 | |
85-
| `memmove()` | 复制内存块,可以处理重叠区域。 | |
86-
| `memset()` | 设置内存块 | |
87-
| `memcmp()` | 比较内存块 | |
88-
| `memchr()` | 在内存块中查找字符 | |
89-
| `strcpy()` | 复制字符串 | |
90-
| `strncpy()` | 复制指定长度的字符串 | |
91-
| `strcat()` | 连接字符串 | |
92-
| `strcmp()` | 比较字符串 | |
93-
| `strncmp()` | 比较指定长度的字符串 | |
94-
| `strlen()` | 获取字符串长度 | |
95-
| `strnlen()` | 获取指定字符串长度 | |
96-
| `strchr()` | 查找字符在字符串中的首次出现 | |
97-
| `strrchr()` | 反向查找字符在字符串中的首次出现 | |
98-
| `strtoull()` | 将字符串按指定进制转换为无符号长长整数 | |
99-
| `strtoul()` | 将字符串按指定进制转换为无符号长整数 | |
100-
| `strtoll()` | 将字符串按指定进制转换为长长整数 | |
101-
| `strtol()` | 将字符串按指定进制转换为长整数 | |
102-
| `atoll()` | 将字符串转换为长长整数 | |
103-
| `atol()` | 将字符串转换为长整数 | |
104-
| `atoi()` | 将字符串转换为整数 | |
105-
| `isalnum()` | 检查字符是否为字母或数字 | |
106-
| `isalpha()` | 检查字符是否为字母 | |
107-
| `isblank()` | 检查字符是否为空白字符(空格或制表符) | |
108-
| `iscntrl()` | 检查字符是否为控制字符 | |
109-
| `isdigit()` | 检查字符是否为十进制数字(0-9) | |
110-
| `isgraph()` | 检查字符是否为可打印字符(不包括空格) | |
111-
| `islower()` | 检查字符是否为小写字母 | |
112-
| `isprint()` | 检查字符是否为可打印字符(包括空格) | |
113-
| `ispunct()` | 检查字符是否为标点符号 | |
114-
| `isspace()` | 检查字符是否为空白字符(空格、制表符、换行符等) | |
115-
| `isupper()` | 检查字符是否为大写字母 | |
116-
| `isxdigit()` | 检查字符是否为十六进制数字(0-9、a-f、A-F) | |
117-
| `tolower()` | 将字符转换为小写 | |
118-
| `toupper()` | 将字符转换为大写 | |
119-
120-
- libc++ 支持
121-
122-
| 函数/变量名 | 用途 | |
123-
| :---------------------: | :----------------------------------: | :--: |
124-
| `__cxa_atexit()` | 注册析构函数 | |
125-
| `__cxa_finalize()` | 调用析构函数 | |
126-
| `__cxa_guard_acquire()` | 静态局部变量初始化锁 | |
127-
| `__cxa_guard_release()` | 静态局部变量初始化完成 | |
128-
| `__cxa_guard_abort()` | 静态局部变量初始化出错 | |
129-
| `__cxa_rethrow()` | 用于简单处理 `throw` | |
130-
| `operator new()` | 运算符重载,空实现,用于全局对象支持 | |
131-
| `operator new[]()` | 运算符重载,空实现,用于全局对象支持 | |
132-
| `operator new()` | 运算符重载,空实现,用于全局对象支持 | |
133-
| `operator new[]()` | 运算符重载,空实现,用于全局对象支持 | |
134-
| `operator delete()` | 运算符重载,空实现,用于全局对象支持 | |
135-
| `operator delete()` | 运算符重载,空实现,用于全局对象支持 | |
136-
| `operator delete[]()` | 运算符重载,空实现,用于全局对象支持 | |
137-
| `operator delete[]()` | 运算符重载,空实现,用于全局对象支持 | |
138-
139-
- 打印函数调用栈
140-
141-
逐层回溯帧指针后与 elf 信息进行对比,实现对函数调用栈的打印
66+
- riscv64
14267

143-
- 基础 c++ 异常 支持
68+
1. 对 CSR 寄存器的抽象
69+
2. 寄存器状态打印
70+
3. 基于 Direct 的中断处理
71+
4. 中断注册函数
72+
5. 时钟中断
14473

145-
通过 throw 抛出异常后停机,没有上下文相关的处理
74+
- aarch64
14675

147-
- klog 内核日志模块
76+
1. 中断注册函数
77+
2. 时钟中断
78+
3. uart 中断
79+
4. gicv3 驱动
14880

149-
基于 ANSI 转义码,在支持 ANSI 转义码的终端中可以显示有颜色的字符串
81+
- X86_64
15082

151-
- 基于 u-boot+opensbi 引导的 riscv64 内核
83+
1. cpu 抽象
84+
2. 8259A pic 控制器抽象
85+
3. 8253/8254 timer 控制器抽象
86+
4. gdt 初始化
87+
5. 中断处理流程
88+
6. 中断注册函数
89+
7. 时钟中断
15290

153-
1. 由 opensbi 进行初始化,直接跳转到内核地址,进入内核逻辑时为 S 态
154-
2. gp 寄存器的初始化
155-
3. 基于 opensbi 的 printf
156-
4. 使用 FIT 打包的内核
91+
- TODO
15792

158-
- 基于 u-boot 引导的 amd64 内核
93+
riscv64 PLIC
15994

160-
1. 由 u-boot 进行初始化,进入内核时为 64 位状态
161-
2. 使用 FIT 打包的内核
95+
x86_64 APIC
16296

163-
- 基于 u-boot+arm-trusted-firmware+optee 的 aarch64 内核
164-
165-
1. 使用 FIT 打包的内核
166-
2. 由 u-boot 进行初始化,进入内核时为 64 位状态
167-
3. 使用 atf 框架
168-
169-
- SMP 支持
170-
171-
多核支持
97+
## 已支持的特性
17298

173-
- spinlock
99+
- [x] [BUILD] 使用 CMake 的构建系统
174100

175-
适用于多核抢占的自旋锁,主要用于 klog 模块
101+
- [x] [BUILD] 使用 gdb remote 调试
176102

177-
- dtb 解析
103+
- [x] [BUILD] 第三方资源集成
178104

179-
- elf 解析
105+
- [x] [COMMON] C++ 全局对象的构造
180106

181-
- ns16550a 串口驱动
107+
- [x] [COMMON] C++ 静态局部对象构造
182108

183-
- pl011 串口驱动
109+
- [x] [COMMON] C 栈保护支持
184110

185-
- 基于 doxygen 的文档生成与自动部署
111+
- [x] [COMMON] printf 支持
186112

187-
github action 会将文档部署到 https://simple-xx.github.io/SimpleKernel/ (仅 main 分支)
113+
- [x] [COMMON] 简单的 C++ 异常支持
188114

189-
- 基于 git submodule 的第三方资源管理
115+
- [x] [COMMON] 带颜色的字符串输出
190116

191-
使用 git submodule 集成第三方资源
117+
- [x] [x86_64] 基于 gnuefi 的 bootloader
192118

193-
- 测试
119+
- [x] [x86_64] 基于 serial 的基本输出
194120

195-
支持 单元测试、集成测试、系统测试,引入 gtest 作为测试框架,同时统计了测试覆盖率
121+
- [x] [x86_64] 物理内存信息探测
196122

197-
- 代码分析
123+
- [x] [x86_64] 显示缓冲区探测
198124

199-
引入 cppcheck、clang-tidy、sanitize 工具提前发现错误
125+
- [x] [x86_64] 调用栈回溯
200126

201-
- 代码格式化
127+
- [x] [riscv64] gp 寄存器的初始化
202128

203-
使用 google 风格
129+
- [x] [riscv64] 基于 opensbi 的基本输出
204130

205-
- docker
131+
- [x] [riscv64] device tree 硬件信息解析
206132

207-
支持使用 docker 构建,详细使用方法见 [doc/docker.md](./doc/docker.md)
133+
- [x] [riscv64] ns16550a 串口驱动
208134

209-
## 已支持的特性
135+
- [x] [riscv64] 调用栈回溯(仅打印地址)
210136

211-
见 新增特性
137+
- [ ] [aarch64] 基于 gnuefi 的 bootloader(调试中)
212138

213139
## 使用的第三方资源
214140

README_ENG.md

Lines changed: 49 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[![codecov](https://codecov.io/gh/Simple-XX/SimpleKernel/graph/badge.svg?token=J7NKK3SBNJ)](https://codecov.io/gh/Simple-XX/SimpleKernel)
22
![workflow](https://github.com/Simple-XX/SimpleKernel/actions/workflows/workflow.yml/badge.svg)
33
![commit-activity](https://img.shields.io/github/commit-activity/t/Simple-XX/SimpleKernel)
4-
![last-commit-boot](https://img.shields.io/github/last-commit/Simple-XX/SimpleKernel/boot)
4+
![last-commit-interrupt](https://img.shields.io/github/last-commit/Simple-XX/SimpleKernel/interrupt)
55
![MIT License](https://img.shields.io/github/license/mashape/apistatus.svg)
66
[![LICENSE](https://img.shields.io/badge/license-Anti%20996-blue.svg)](https://github.com/996icu/996.ICU/blob/master/LICENSE)
77
[![996.icu](https://img.shields.io/badge/link-996.icu-red.svg)](https://996.icu)
@@ -10,7 +10,7 @@
1010

1111
# SimpleKernel
1212

13-
boot branch
13+
interrupt branch
1414

1515
## Key Words
1616

@@ -63,93 +63,80 @@ Pre-configured VSCode settings for running and debugging the kernel are provided
6363

6464
This branch is the first branch of SimpleKernel. In this branch, we have completed the foundation of the build system, basic documentation deployment, and automated testing. Most importantly, we have implemented a u-boot based x86_64 kernel and a RISC-V64 kernel started by OpenSBI, both of which can run on QEMU and achieve simple screen output.
6565

66-
- Build system
66+
- riscv64
6767

68-
References the [MRNIU/cmake-kernel](https://github.com/MRNIU/cmake-kernel) build system. For detailed explanation, see [doc/build_system.md](./doc/build_system.md)
68+
1. CSR register abstraction
69+
2. Register status printing
70+
3. Direct-based interrupt handling
71+
4. Interrupt registration functions
72+
5. Timer interrupts
6973

70-
- Stack Trace Printing
74+
- aarch64
7175

72-
Traverse frame pointers and cross-reference with ELF symbol tables to reconstruct function call stacks.
76+
1. Interrupt registration functions
77+
2. Timer interrupts
78+
3. UART interrupts
79+
4. GICv3 driver
7380

74-
- Basic C++ Exception Support
81+
- x86_64
7582

76-
Implements throw to trigger exceptions followed by system termination (no context-aware exception handling).
83+
1. CPU abstraction
84+
2. 8259A PIC controller abstraction
85+
3. 8253/8254 timer controller abstraction
86+
4. GDT initialization
87+
5. Interrupt handling flow
88+
6. Interrupt registration functions
89+
7. Timer interrupts
7790

78-
- klog Kernel Logging Module
91+
- TODO
7992

80-
Supports ANSI escape codes for colored text output in ANSI-compatible terminals.
93+
riscv64 PLIC
8194

82-
- RISC-V64 (U-Boot + OpenSBI)
95+
x86_64 APIC
8396

84-
1. Initialized by OpenSBI; kernel entry in Supervisor (S) mode.
85-
2. GP (Global Pointer) register initialization.
86-
3. printf implementation leveraging OpenSBI.
87-
4. FIT (Flattened Image Tree) image packaging.
88-
89-
- x86_64 (U-Boot)
90-
91-
1. Initialized by U-Boot; kernel enters 64-bit mode directly.
92-
2. FIT image packaging.
93-
94-
- AArch64 (U-Boot + Arm Trusted Firmware + OP-TEE)
95-
96-
1. FIT image packaging.
97-
2. Initialized by U-Boot in 64-bit mode.
98-
3. ATF (Arm Trusted Firmware) framework integration.
99-
100-
- SMP Support
101-
102-
Multi-core CPU coordination and synchronization
103-
104-
- Spinlock
105-
106-
Preemptive multi-core spinlock implementation (primarily for klog synchronization)
107-
108-
- Device Tree Blob (DTB) Parsing
109-
110-
Hardware configuration decoding and interpretation
97+
## Supported Features
11198

112-
- ELF Parsing
99+
- [x] [BUILD] CMake-based build system
113100

114-
Executable and Linkable Format analysis
101+
- [x] [BUILD] GDB remote debugging
115102

116-
- NS16550A UART Driver
103+
- [x] [BUILD] Third-party resource integration
117104

118-
Serial communication driver for x86/RISC-V platforms
105+
- [x] [COMMON] C++ global object construction
119106

120-
- PL011 UART Driver
107+
- [x] [COMMON] C++ static local object construction
121108

122-
Serial communication driver for ARM platforms
109+
- [x] [COMMON] C stack protection support
123110

124-
- Doxygen-based Documentation Generation and Automatic Deployment
111+
- [x] [COMMON] printf support
125112

126-
GitHub Actions automatically deploys documentation to https://simple-xx.github.io/SimpleKernel/ (main branch only)
113+
- [x] [COMMON] Simple C++ exception support
127114

128-
- Third-party Resource Management based on Git Submodules
115+
- [x] [COMMON] Colored string output
129116

130-
Uses git submodule to integrate third-party resources
117+
- [x] [x86_64] gnuefi-based bootloader
131118

132-
- Testing Framework
119+
- [x] [x86_64] Serial-based basic output
133120

134-
Supports unit testing, integration testing, and system testing using gtest framework with test coverage statistics
121+
- [x] [x86_64] Physical memory information detection
135122

136-
- Code Analysis
123+
- [x] [x86_64] Display buffer detection
137124

138-
Integrates cppcheck, clang-tidy, and sanitize tools for early error detection
125+
- [x] [x86_64] Call stack backtrace
139126

140-
- Code Formatting
127+
- [x] [riscv64] GP register initialization
141128

142-
Uses Google style formatting
129+
- [x] [riscv64] OpenSBI-based basic output
143130

144-
- Docker Support
131+
- [x] [riscv64] Device tree hardware information parsing
145132

146-
Supports building with Docker, see [doc/docker.md](./doc/docker.md)
133+
- [x] [riscv64] ns16550a serial driver
147134

148-
## Supported Features
135+
- [x] [riscv64] Call stack backtrace (address printing only)
149136

150-
See New Features
137+
- [ ] [aarch64] gnuefi-based bootloader (debugging)
151138

152-
## Third-party Dependencies
139+
## Used Third-party Resources
153140

154141
[google/googletest](https://github.com/google/googletest.git)
155142

@@ -173,5 +160,6 @@ See New Features
173160

174161
## Development Guide
175162

176-
- **Code Style**: Google Style (enforced via .clang-format)
177-
- **Naming Convention**: [Google Open Source Style Guide](https://google.github.io/styleguide/cppguide.html)
163+
Code Style: Google, specified by .clang-format
164+
165+
Naming Convention: [Google Open Source Project Style Guide](https://google.github.io/styleguide/cppguide.html)

0 commit comments

Comments
 (0)