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

New intr #189

Merged
merged 213 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
213 commits
Select commit Hold shift + click to select a range
e62993b
update README
MRNIU May 30, 2024
d436c2d
Merge branch 'boot' into new_intr
MRNIU May 30, 2024
30d798e
Merge branch 'boot' into new_intr
MRNIU May 30, 2024
5c463a3
feat(riscv64): add reg oprs
MRNIU May 30, 2024
e43b497
feat(riscv64): add reg oprs
MRNIU May 30, 2024
107da45
merge boot
MRNIU May 30, 2024
afb0a9b
merge boot
MRNIU May 30, 2024
a491a98
wocao
MRNIU May 30, 2024
e190516
wocao
MRNIU May 30, 2024
fd3b651
wocao
MRNIU May 30, 2024
eafa43b
wocao
MRNIU May 30, 2024
78fd015
wocao
MRNIU May 30, 2024
c273040
wocao
MRNIU May 30, 2024
912ea99
fix typo
MRNIU May 30, 2024
bb50602
feat(intr): clint timer inited
MRNIU May 30, 2024
50df01e
feat(intr): timer intr done
MRNIU May 30, 2024
0a812ab
feat(intr): more support for intr base
MRNIU May 31, 2024
68e8a39
pref(intr)
MRNIU May 31, 2024
ff4ccda
fix(context): update Save/LoadAllRegs macro
MRNIU May 31, 2024
1f860bb
feat(cpu): add DisableSupervisorTimer
MRNIU May 31, 2024
c4a941c
fix(context): update Save/LoadAllRegs macro
MRNIU May 31, 2024
5cad8bc
bug: endless loop when timer intr
MRNIU May 31, 2024
7095148
style
MRNIU May 31, 2024
513213f
merge boot
MRNIU May 31, 2024
94837c6
feat(cpu): ostream
MRNIU May 31, 2024
4df49c5
merge boot
MRNIU May 31, 2024
980f99b
style
MRNIU May 31, 2024
25e87db
style
MRNIU May 31, 2024
0d908b4
update
MRNIU May 31, 2024
b42a73c
feat(cpu): update riscv64 sie sip status define
MRNIU Jun 2, 2024
946ce32
fix(cpu): riscv64 xtvec typo
MRNIU Jun 2, 2024
817867b
fix(cpu): riscv64 xtvec typo
MRNIU Jun 2, 2024
8f04e06
comment(cpu): add riscv-privileged url
MRNIU Jun 2, 2024
ca4741f
fix(cpu): riscv64 xtvec typo
MRNIU Jun 2, 2024
e29925f
feat(intr): riscv64 ebreak exception
MRNIU Jun 3, 2024
c85645a
fix(cpu): update callee registers
MRNIU Jun 3, 2024
f9a1fa5
fix(boot): update riscv64 gp init code accroed to riscv_abi doc
MRNIU Jun 3, 2024
733ef06
tmp
MRNIU Jun 3, 2024
6ce29ac
pref(libcxx): update cpp ctor and dtor
MRNIU Jun 3, 2024
1e64993
comment: update
MRNIU Jun 3, 2024
8e9959b
pref(intr): remove asm interrupt entry
MRNIU Jun 3, 2024
aab1104
feat(cpu): update with template
MRNIU Jun 3, 2024
090f9ee
feat(cpu): update with template
MRNIU Jun 3, 2024
0590084
feat(cpu): update with template
MRNIU Jun 3, 2024
13d2304
feat(cpu): update with template
MRNIU Jun 3, 2024
7b4a6be
feat(cpu): update with template
MRNIU Jun 3, 2024
41d7a33
feat(cpu): update with template
MRNIU Jun 3, 2024
3e66fec
feat(cpu): sscratch
MRNIU Jun 3, 2024
4ce0430
feat(cpu): sepc
MRNIU Jun 3, 2024
78efef4
feat(cpu): sepc
MRNIU Jun 3, 2024
823f3f8
fix(cpu): update with if constexpr std::is_same
MRNIU Jun 3, 2024
71bbeb6
feat(cpu): sstatus
MRNIU Jun 3, 2024
66f68f3
feat(cpu): stvec
MRNIU Jun 3, 2024
38e56ca
feat(cpu): sideleg, sedeleg, but Illegal Instruction
MRNIU Jun 3, 2024
f548d36
feat(cpu): sip sie
MRNIU Jun 3, 2024
2842f74
feat(cpu): satp stval
MRNIU Jun 4, 2024
2031278
style
MRNIU Jun 4, 2024
9454fa4
feat(cpu): stvec
MRNIU Jun 4, 2024
b6292d1
pref(main): add include
MRNIU Jun 3, 2024
f863630
feat(libcxx): new overload for iostream
MRNIU Jun 4, 2024
a8415b4
bug(intr): cannot ebreak
MRNIU Jun 4, 2024
a90c0d5
bug(intr): cannot ebreak
MRNIU Jun 4, 2024
83c79e1
pref(cpu): crs order
MRNIU Jun 4, 2024
20a8f6e
pref(cpu): crs order
MRNIU Jun 4, 2024
2c25b81
pref(cpu): use namespace
MRNIU Jun 4, 2024
4b2f5fd
pref(cpu): use namespace
MRNIU Jun 4, 2024
5d3566d
pref(intr): use alignas
MRNIU Jun 4, 2024
553a792
fix(cpu): add volatile for asm
MRNIU Jun 4, 2024
496a1cc
pref(intr): use alignas
MRNIU Jun 4, 2024
45956d7
fix(intr): ebreak
MRNIU Jun 4, 2024
bebc494
pref(cpu): use __asm__
MRNIU Jun 4, 2024
a1595a6
bug(intr): timer
MRNIU Jun 4, 2024
0678b8f
fix(intr): timer intr done
MRNIU Jun 4, 2024
0a81630
feat(cpu): add time cycle instret stimecmp
MRNIU Jun 4, 2024
319f6fe
typo
MRNIU Jun 4, 2024
0838ea9
typo
MRNIU Jun 4, 2024
fb6f568
doc(README): update
MRNIU Jun 4, 2024
07c5cfa
Merge branch 'boot' into new_intr
MRNIU Jun 5, 2024
e5b18bd
Merge branch 'boot' into new_intr
MRNIU Jun 5, 2024
075f125
refactor(cpu): move to arch/include
MRNIU Jun 5, 2024
a3ffa47
Merge branch 'boot' into new_intr
MRNIU Jun 8, 2024
f7222b9
Merge branch 'boot' into new_intr
MRNIU Jun 13, 2024
75d20aa
typo
MRNIU Jun 13, 2024
1be6e83
Merge branch 'boot' into new_intr
MRNIU Jun 13, 2024
6e68638
Merge branch 'boot' into new_intr
MRNIU Jun 13, 2024
44dad02
feat(arch): riscv get cpu frequency use libfdt
MRNIU Jun 13, 2024
6df27ce
fix(intr): riscv64 intr done
MRNIU Jun 13, 2024
bb0cb25
feat(intr): use Singleton
MRNIU Jun 13, 2024
6ef6cdc
Merge branch 'boot' into new_intr
MRNIU Jun 13, 2024
daa43d5
Merge branch 'boot' into new_intr
MRNIU Jun 13, 2024
6510ddf
style
MRNIU Jun 13, 2024
d76bb49
rename
MRNIU Jun 13, 2024
eef107e
Merge branch 'boot' into new_intr
MRNIU Jun 13, 2024
7e17fbb
Merge branch 'boot' into new_intr
MRNIU Jun 14, 2024
8c69876
Merge branch 'boot' into new_intr
MRNIU Jun 14, 2024
61fda11
style
MRNIU Jun 14, 2024
db578ab
feat(intr): working on x86_64 interrupt
MRNIU Jun 14, 2024
fe2a100
comment(cpu): add x86_64 cpu doc info
MRNIU Jun 14, 2024
94d36d4
comment(cpu): add x86_64 cpu doc info
MRNIU Jun 14, 2024
1168677
Merge branch 'boot' into new_intr
MRNIU Jun 14, 2024
9b9085c
pref(libc/libcxx): remove printf
MRNIU Jun 14, 2024
4e07be5
refactor(cpu): update riscv64 cpu.hpp
MRNIU Jun 14, 2024
a11ab20
refactor(cpu): update x86_64 cpu.hpp
MRNIU Jun 14, 2024
845cdbe
style
MRNIU Jun 14, 2024
a57868a
refactor(cpu): update x86_64 cpu.hpp
MRNIU Jun 14, 2024
b711e1b
fix(cpu): x86_64 read rbp
MRNIU Jun 14, 2024
2f033f6
feat(arch): add x86_64 reg info
MRNIU Jun 15, 2024
0baad8b
Merge branch 'boot' into new_intr
MRNIU Jun 16, 2024
a13dc4b
feat(intr): update aarch64 interrupt framework
MRNIU Jun 16, 2024
bd06bcf
Merge branch 'boot' into new_intr
MRNIU Jun 17, 2024
37c88a4
test(ut): update riscv64_cpu_test
MRNIU Jun 17, 2024
664647f
test(ut): update riscv64_cpu_test
MRNIU Jun 17, 2024
65ab8b5
test(ut): update riscv64_cpu_test
MRNIU Jun 17, 2024
6daf613
test(ut): update riscv64_cpu_test
MRNIU Jun 17, 2024
82f9251
test(ut): update riscv64_cpu_test
MRNIU Jun 17, 2024
b231da2
test(ut): update riscv64_cpu_test
MRNIU Jun 17, 2024
156fa92
test(ut): update x86_64_cpu_test efer
MRNIU Jun 17, 2024
ce491e0
test(ut): update x86_64_cpu_test rflags
MRNIU Jun 17, 2024
1867f4a
test(ut): update x86_64_cpu_test cr
MRNIU Jun 17, 2024
62815fb
test(ut): update kernel_fdt_test GetTimebaseFrequencyTest
MRNIU Jun 17, 2024
602e92f
feat(cpu): add asm
MRNIU Jun 17, 2024
9bc202e
feat(cpu): remove unused
MRNIU Jun 17, 2024
4032c9a
pref(cpu): update x86_64 ReadWrite
MRNIU Jun 18, 2024
7dda9eb
pref(cpu): update riscv64 cpu
MRNIU Jun 18, 2024
9042097
pref(cpu): update x86_64 cpu
MRNIU Jun 18, 2024
c72fe3e
pref(cpu): update x86_64 cpu
MRNIU Jun 18, 2024
220f7c7
pref(cpu): update x86_64 cpu rflags
MRNIU Jun 18, 2024
80ddf5c
pref(cpu): update x86_64 cpu gdtr ldtr idtr
MRNIU Jun 18, 2024
fbbd14f
pref(cpu): update x86_64 cpu tr
MRNIU Jun 18, 2024
dc16e54
pref(cpu): update x86_64 cpu cr0
MRNIU Jun 18, 2024
de54b05
pref(cpu): update x86_64 cpu
MRNIU Jun 18, 2024
8689d42
pref(cpu): update x86_64 cpu gdtr
MRNIU Jun 18, 2024
8ac5c92
Merge branch 'boot' into new_intr
MRNIU Jun 18, 2024
742cc68
feat(cpu): cout x86_64 regs
MRNIU Jun 18, 2024
2a87f94
feat(cpu): cout x86_64 regs
MRNIU Jun 18, 2024
6b293d1
feat(cpu): cout x86_64 gdtr
MRNIU Jun 18, 2024
df7fb67
feat(cpu): update riscv64 regs
MRNIU Jun 18, 2024
b9bae03
Merge branch 'boot' into new_intr
MRNIU Jun 18, 2024
4886a53
rename
MRNIU Jun 18, 2024
bdc3dc1
rename
MRNIU Jun 18, 2024
4e55092
feat(cpu): read/write efer
MRNIU Jun 19, 2024
8e4bd70
style
MRNIU Jun 19, 2024
36af502
feat(cpu): idtr
MRNIU Jun 19, 2024
53e5d75
feat(cpu): idtr
MRNIU Jun 19, 2024
08d5755
feat(cpu): idtr
MRNIU Jun 19, 2024
2c21eb9
feat(cpu): idtr
MRNIU Jun 19, 2024
0c60adf
feat(cpu): idtr
MRNIU Jun 19, 2024
1635cec
feat(intr): update
MRNIU Jun 19, 2024
793f202
feat(intr): set idtr
MRNIU Jun 20, 2024
41f2fbb
feat(cpu): add gdtr
MRNIU Jun 20, 2024
6e9f2b1
style
MRNIU Jun 20, 2024
b6a3348
feat(cpu): add x86_64 segment register
MRNIU Jun 20, 2024
4494af0
working on x86_64 intr
MRNIU Jun 24, 2024
ab67b83
cpu: fix warning
MRNIU Jun 28, 2024
a101a0d
cpu: add SegmentDescriptor ctor
MRNIU Jun 28, 2024
2b843f2
feat(cpu): update SegmentDescriptor
MRNIU Jul 1, 2024
0b07be6
feat(cpu): segment_register read/write
MRNIU Jul 1, 2024
75bd602
feat(cpu): segment_register ostream
MRNIU Jul 1, 2024
89a242e
feat(cpu): set segment_descriptors
MRNIU Jul 2, 2024
1ef02e4
feat(arch, cpu): gdtr done
MRNIU Jul 2, 2024
c7a83d5
pref(arch): update gdt setup
MRNIU Jul 2, 2024
91713ce
comment: update
MRNIU Jul 2, 2024
94c8ff1
comment: update
MRNIU Jul 2, 2024
c356f2e
Merge branch 'boot' into new_intr
MRNIU Jul 2, 2024
50d8d11
doc(README): update
MRNIU Jul 2, 2024
d7ba847
feat(cpu): add SystemSegmentAndGateDescriptorTypes
MRNIU Jul 2, 2024
314d4cc
fix(interrupt): idtr limit
MRNIU Jul 2, 2024
a4dde40
feat(cpu): add idtr
MRNIU Jul 2, 2024
4a5cf08
feat(intr): going on
MRNIU Jul 2, 2024
404b9d9
feat(intr): handle int 0 and int 1
MRNIU Jul 2, 2024
7436d79
feat(intr): add isr
MRNIU Jul 2, 2024
fee94b9
feat(intr): add isr
MRNIU Jul 2, 2024
9adba91
feat(intr): rename
MRNIU Jul 2, 2024
c75504f
feat(intr): add irq
MRNIU Jul 2, 2024
228bead
feat(cpu): add ostream for ErrorCode
MRNIU Jul 3, 2024
4655636
feat(intr): add ErrorCode support
MRNIU Jul 3, 2024
1f358a9
feat(intr): rename
MRNIU Jul 4, 2024
9b081d7
feat(intr): no errorcode interrupt done
MRNIU Jul 4, 2024
e220fb1
todo(intr): interrupt wth error code
MRNIU Jul 4, 2024
d1c6f32
todo(intr): interrupt wth error code
MRNIU Jul 4, 2024
0e25e71
feat(intr): working on irq
MRNIU Jul 5, 2024
ca2f788
feat(cpu): add selctor index
MRNIU Jul 5, 2024
d8202a2
feat(intr): timer intr worked
MRNIU Jul 6, 2024
f7c3082
feat(intr, cpu): timer done
MRNIU Jul 6, 2024
156f0aa
comment: update
MRNIU Jul 6, 2024
4b9154c
comment: update
MRNIU Jul 6, 2024
d7ae1ff
comment: update
MRNIU Jul 6, 2024
9f05fab
comment: update
MRNIU Jul 6, 2024
67d637f
doc: update README
MRNIU Jul 6, 2024
6c8cd5a
doc: update README
MRNIU Jul 6, 2024
d6c0323
Merge branch 'boot' into new_intr
MRNIU Jul 8, 2024
8e070a8
bug: found bug
MRNIU Jul 8, 2024
2e2eaad
Merge branch 'boot' into new_intr
MRNIU Jul 8, 2024
28278ea
Merge branch 'boot' into new_intr
MRNIU Jul 31, 2024
8049686
Merge branch 'boot' into new_intr
MRNIU Jul 31, 2024
9339f98
feat: add Debug log
MRNIU Jul 31, 2024
871b7e4
feat: add Debug log
MRNIU Jul 31, 2024
00986dc
fix: update change cs
MRNIU Aug 1, 2024
214e080
Merge branch 'boot' into new_intr
MRNIU Aug 1, 2024
251eec7
Merge branch 'boot' into new_intr
MRNIU Aug 1, 2024
27585ac
Merge branch 'boot' into new_intr
MRNIU Aug 1, 2024
b89f2ae
Merge branch 'boot' into new_intr
MRNIU Aug 5, 2024
f423d9f
Merge branch 'boot' into new_intr
MRNIU Aug 7, 2024
68929d2
Merge branch 'boot' into new_intr
MRNIU Aug 7, 2024
6449c2c
Merge branch 'boot' into new_intr
MRNIU Aug 7, 2024
211f34f
refactor: rename std::ostream with sk_std::
MRNIU Aug 7, 2024
a54448c
Merge branch 'boot' into new_intr
MRNIU Aug 26, 2024
bb19532
style: update log level
MRNIU Aug 27, 2024
545f2ce
Merge branch 'boot' into new_intr
MRNIU Aug 30, 2024
c264454
Merge branch 'boot' into new_intr
MRNIU Aug 30, 2024
1a2bda2
Merge branch 'boot' into new_intr
MRNIU Aug 30, 2024
e275766
fix: overflow
MRNIU Sep 11, 2024
5503b97
fix: overflow
MRNIU Sep 11, 2024
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
137 changes: 50 additions & 87 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[![codecov](https://codecov.io/gh/Simple-XX/SimpleKernel/graph/badge.svg?token=J7NKK3SBNJ)](https://codecov.io/gh/Simple-XX/SimpleKernel)
![workflow](https://github.com/Simple-XX/SimpleKernel/actions/workflows/workflow.yml/badge.svg)
![commit-activity](https://img.shields.io/github/commit-activity/t/Simple-XX/SimpleKernel)
![last-commit-boot](https://img.shields.io/github/last-commit/Simple-XX/SimpleKernel/boot)
![last-commit-boot](https://img.shields.io/github/last-commit/Simple-XX/SimpleKernel/intr)
![MIT License](https://img.shields.io/github/license/mashape/apistatus.svg)
[![LICENSE](https://img.shields.io/badge/license-Anti%20996-blue.svg)](https://github.com/996icu/996.ICU/blob/master/LICENSE)
[![996.icu](https://img.shields.io/badge/link-996.icu-red.svg)](https://996.icu)
Expand All @@ -10,7 +10,7 @@

# SimpleKernel

boot branch
intr branch

## 关键词

Expand Down Expand Up @@ -77,7 +77,6 @@ boot branch
# 开始执行
c
```


## 执行流

Expand Down Expand Up @@ -112,81 +111,29 @@ boot branch

## 新增特性

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

||x86_64|riscv64|aarch64|
| :-----------------------: | :-------------------------------: | :---------------------------------------------: | :-------------------: |
|引导|UEFI|opensbi|UEFI(未完成)|
|基本输出|通过 serial 实现|通过 opensbi 提供的 ecall 实现|TODO|
|硬件资源探测|由 UEFI 传递|dtb 解析|TODO|

- 构建系统

参考 [MRNIU/cmake-kernel](https://github.com/MRNIU/cmake-kernel) 的构建系统,详细解释见 [doc/build_system.md](./doc/build_system.md)

- libc 支持

| 函数/变量名 | 用途 | |
| :------------------: | :------------------------------: | :--: |
| `__stack_chk_guard` | 栈保护 | |
| `__stack_chk_fail()` | 栈保护检查失败后调用 | |
| `memcpy()` | 复制内存块 | |
| `memmove()` | 复制内存块,可以处理重叠区域。 | |
| `memset()` | 设置内存块 | |
| `memcmp()` | 比较内存块 | |
| `memchr()` | 在内存块中查找字符 | |
| `strcpy()` | 复制字符串 | |
| `strncpy()` | 复制指定长度的字符串 | |
| `strcat()` | 连接字符串 | |
| `strcmp()` | 比较字符串 | |
| `strncmp()` | 比较指定长度的字符串 | |
| `strlen()` | 获取字符串长度 | |
| `strnlen()` | 获取指定字符串长度 | |
| `strchr()` | 查找字符在字符串中的首次出现 | |
| `strrchr()` | 反向查找字符在字符串中的首次出现 | |

- libc++ 支持

| 函数/变量名 | 用途 | |
| :---------------------: | :----------------------------------: | :--: |
| `__cxa_atexit()` | 注册析构函数 | |
| `__cxa_finalize()` | 调用析构函数 | |
| `__cxa_guard_acquire()` | 静态局部变量初始化锁 | |
| `__cxa_guard_release()` | 静态局部变量初始化完成 | |
| `__cxa_guard_abort()` | 静态局部变量初始化出错 | |
| `__cxa_rethrow()` | 用于简单处理 `throw` | |
| `operator new()` | 运算符重载,空实现,用于全局对象支持 | |
| `operator new[]()` | 运算符重载,空实现,用于全局对象支持 | |
| `operator new()` | 运算符重载,空实现,用于全局对象支持 | |
| `operator new[]()` | 运算符重载,空实现,用于全局对象支持 | |
| `operator delete()` | 运算符重载,空实现,用于全局对象支持 | |
| `operator delete()` | 运算符重载,空实现,用于全局对象支持 | |
| `operator delete[]()` | 运算符重载,空实现,用于全局对象支持 | |
| `operator delete[]()` | 运算符重载,空实现,用于全局对象支持 | |

- 打印函数调用栈

逐层回溯帧指针后与 elf 信息进行对比,实现对函数调用栈的打印

- 基础 c++ 异常 支持

通过 throw 抛出异常后停机,没有上下文相关的处理
- riscv64

- 带颜色的输出
1. 对 CSR 寄存器的抽象
2. 寄存器状态打印
3. 基于 Direct 的中断处理
4. 中断注册函数
5. 时钟中断

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

- 基于 gnu-efi 引导的 x86_64 内核

编译后生成 boot.efi 与 kernel.elf,进入 uefi 环境后首先执行 boot.efi,初始化完成后跳转到 kernel.elf 执行
1. cpu 抽象
2. 8259A pic 控制器抽象
3. 8253/8254 timer 控制器抽象
4. gdt 初始化
5. 中断处理流程
6. 中断注册函数
7. 时钟中断

- TODO

- 基于 opensbi 引导的 riscv64 内核
riscv64 PLIC

1. 由 opensbi 进行初始化,直接跳转到内核地址,进入内核逻辑时为 S 态
2. gp 寄存器的初始化
3. 使用 libfdt(dtc 的一部分) 对 opensbi 传递的 dtb 信息进行解析
4. ns16550a 串口驱动
5. 基于 opensbi 的 printf
x86_64 APIC

- 全局对象

Expand All @@ -198,33 +145,49 @@ boot branch
| `static Singleton<BasicInfo> kBasicInfo` | src/kernel/include/basic_info.hpp | 内核基本信息 |
| `static cpu::Serial kSerial(cpu::kCom1)` | src/kernel/arch/x86_64/arch_main.cpp | X86_64 下的串口 |

- 基于 doxygen 的文档生成与自动部署


## 已支持特性

github action 会将文档部署到 https://simple-xx.github.io/SimpleKernel/ (仅 main 分支)
- [x] [BUILD] 使用 CMake 的构建系统

- 基于 git submodule 的第三方资源管理
- [x] [BUILD] 使用 gdb remote 调试

使用 git submodule 集成第三方资源
- [x] [BUILD] 第三方资源集成

- 测试
- [x] [COMMON] C++ 全局对象的构造

支持 单元测试、集成测试、系统测试,引入 gtest 作为测试框架,同时统计了测试覆盖率
- [x] [COMMON] C++ 静态局部对象构造

- 代码分析
- [x] [COMMON] C 栈保护支持

引入 cppcheck、clang-tidy、sanitize 工具提前发现错误
- [x] [COMMON] printf 支持

- 代码格式化
- [x] [COMMON] 简单的 C++ 异常支持

使用 google 风格
- [x] [COMMON] 带颜色的字符串输出

- docker
- [x] [x86_64] 基于 gnuefi 的 bootloader

支持使用 docker 构建,详细使用方法见 [doc/docker.md](./doc/docker.md)
- [x] [x86_64] 基于 serial 的基本输出

## 已支持特性
- [x] [x86_64] 物理内存信息探测

- [x] [x86_64] 显示缓冲区探测

- [x] [x86_64] 调用栈回溯

- [x] [riscv64] gp 寄存器的初始化

- [x] [riscv64] 基于 opensbi 的基本输出

- [x] [riscv64] device tree 硬件信息解析

- [x] [riscv64] ns16550a 串口驱动

- [x] [riscv64] 调用栈回溯(仅打印地址)

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

## 使用的第三方资源

Expand Down
3 changes: 2 additions & 1 deletion src/kernel/arch/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ target_include_directories(arch INTERFACE

target_sources(arch INTERFACE
$<$<STREQUAL:${CMAKE_SYSTEM_PROCESSOR},riscv64>:
${CMAKE_CURRENT_SOURCE_DIR}/${CMAKE_SYSTEM_PROCESSOR}/macro.S
${CMAKE_CURRENT_SOURCE_DIR}/${CMAKE_SYSTEM_PROCESSOR}/boot.S
>
${CMAKE_CURRENT_SOURCE_DIR}/${CMAKE_SYSTEM_PROCESSOR}/macro.S
${CMAKE_CURRENT_SOURCE_DIR}/${CMAKE_SYSTEM_PROCESSOR}/arch_main.cpp
${CMAKE_CURRENT_SOURCE_DIR}/${CMAKE_SYSTEM_PROCESSOR}/backtrace.cpp
${CMAKE_CURRENT_SOURCE_DIR}/${CMAKE_SYSTEM_PROCESSOR}/interrupt.cpp
)
37 changes: 37 additions & 0 deletions src/kernel/arch/aarch64/interrupt.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/**
* @file interrupt.cpp
* @brief 中断初始化
* @author Zone.N ([email protected])
* @version 1.0
* @date 2023-07-15
* @copyright MIT LICENSE
* https://github.com/Simple-XX/SimpleKernel
* @par change log:
* <table>
* <tr><th>Date<th>Author<th>Description
* <tr><td>2023-07-15<td>Zone.N ([email protected])<td>创建文件
* </table>
*/

#include "interrupt.h"

#include "kernel_log.hpp"
#include "sk_cstdio"

Interrupt::Interrupt() { klog::Info("Interrupt init.\n"); }

void Interrupt::Do(uint64_t cause, uint8_t *context) {
(void)cause;
(void)context;
}

void Interrupt::RegisterInterruptFunc(uint64_t cause, InterruptFunc func) {
(void)cause;
(void)func;
}

uint32_t InterruptInit(uint32_t, uint8_t *) {
klog::Info("Hello InterruptInit\n");

return 0;
}
61 changes: 61 additions & 0 deletions src/kernel/arch/aarch64/interrupt.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@

/**
* @file interrupt.h
* @brief interrupt 头文件
* @author Zone.N ([email protected])
* @version 1.0
* @date 2023-07-15
* @copyright MIT LICENSE
* https://github.com/Simple-XX/SimpleKernel
* @par change log:
* <table>
* <tr><th>Date<th>Author<th>Description
* <tr><td>2023-07-15<td>Zone.N ([email protected])<td>创建文件
* </table>
*/

#ifndef SIMPLEKERNEL_SRC_KERNEL_ARCH_AARCH64_INCLUDE_INTERRUPT_H_
#define SIMPLEKERNEL_SRC_KERNEL_ARCH_AARCH64_INCLUDE_INTERRUPT_H_

#include <cstdint>

#include "cpu/cpu.hpp"
#include "interrupt_base.h"
#include "singleton.hpp"
#include "sk_stdio.h"

class Interrupt final : public InterruptBase {
public:
Interrupt();

/// @name 构造/析构函数
/// @{
Interrupt(const Interrupt &) = delete;
Interrupt(Interrupt &&) = delete;
auto operator=(const Interrupt &) -> Interrupt & = delete;
auto operator=(Interrupt &&) -> Interrupt & = delete;
~Interrupt() = default;
/// @}

/**
* @brief 执行中断处理
* @param cause 中断或异常号
* @param context 中断上下文
*/
void Do(uint64_t cause, uint8_t *context) override;

/**
* @brief 注册中断处理函数
* @param cause 中断原因
* @param func 处理函数
*/
void RegisterInterruptFunc(uint64_t cause, InterruptFunc func) override;

private:
};

/// 全局 elf 对象,需要在相应体系结构初始化时重新初始化
[[maybe_unused]] static Singleton<Interrupt> kInterrupt
__attribute__((init_priority(101)));

#endif /* SIMPLEKERNEL_SRC_KERNEL_ARCH_AARCH64_INCLUDE_INTERRUPT_H_ */
19 changes: 19 additions & 0 deletions src/kernel/arch/aarch64/macro.S
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

/**
* @file macro.S
* @brief aarch64 汇编宏
* @author Zone.N ([email protected])
* @version 1.0
* @date 2024-04-24
* @copyright MIT LICENSE
* https://github.com/Simple-XX/SimpleKernel
* @par change log:
* <table>
* <tr><th>Date<th>Author<th>Description
* <tr><td>2024-04-24<td>Zone.N ([email protected])<td>创建文件
* </table>
*/

// clang-format off

// clang-format on
Loading
Loading