Skip to content

Commit

Permalink
doc: update README
Browse files Browse the repository at this point in the history
Signed-off-by: Zone.N <Zone.NiuZH@hotmail.com>
  • Loading branch information
MRNIU committed Sep 12, 2023
1 parent bce62b1 commit f0c7d81
Show file tree
Hide file tree
Showing 3 changed files with 271 additions and 54 deletions.
111 changes: 57 additions & 54 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,92 +1,95 @@

[![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)
![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)

[English](./README_ENG.md) | [中文](./README.md)

# SimpleKernel

## 关键词

- kernel
- x86_64, riscv64, aarch64
- osdev
- bare metal
- c++, cmake
- uefi, opensbi

## 简介

# boot
提供了各个阶段完成度不同的内核,你可以从自己喜欢的地方开始。

## 本分支新增特性
## 新增特性

参考 [MRNIU/cmake-kernel](https://github.com/MRNIU/cmake-kernel) 的构建系统,包括以下特性
本分支是 SImpleKernel 的首个分支。在本分支中,完成了构建系统的基础搭建、基本的文档部署与自动化测试,当然还有最重要的,有基于 uefi 的 x86_64 内核与由 opensbi 启动的 riscv64 内核,可以在 qemu 上运行,并实现了简单的屏幕输出。

- [x] 对第三方依赖的支持/构建
- 构建系统

自动下载并编译第三方依赖
参考 [MRNIU/cmake-kernel](https://github.com/MRNIU/cmake-kernel) 的构建系统,详细解释见 [doc/build_system.md](./doc/build_system.md)

自动生成相关 licence
- 基于 gnu-efi 引导的 x86_64 内核

目前支持的第三方资源
编译后生成 boot.efi 与 kernel.elf,进入 uefi 环境后首先执行 boot.efi,初始化完成后跳转到 kernel.elf 执行

| 第三方内容 | 描述 | 类型 | 正在使用 |
| :----------------------------------------------------------: | :-------------------------------------------: | :----------: | :------: |
| [CPM](https://github.com/cpm-cmake/CPM.cmake) | cmake 包管理 | cmake module ||
| [CPMLicences.cmake](https://github.com/TheLartians/CPMLicenses.cmake) | 为第三方包生成 licence | cmake module ||
| [google/googletest](https://github.com/google/googletest) | 测试 |||
| [easylogingpp](https://github.com/amrayn/easyloggingpp) | 日志 || |
| [rttr](https://github.com/rttrorg/rttr) | c++ 反射库,在设备驱动部分用 || |
| [Format.cmake](https://github.com/TheLartians/Format.cmake) | 代码格式化,支持 clang-format 与 cmake-format | cmake module | |
| [FreeImage](http://freeimage.sourceforge.net/) | 图片渲染 || |
| [Freetype](https://www.freetype.org/) | 字体渲染 || |
| [opensbi](https://github.com/riscv-software-src/opensbi) | riscv 引导 |||
| [gnu-efi](https://sourceforge.net/projects/gnu-efi/) | gnu uefi 引导 |||
| [ovmf](SimpleKernel/3rd/ovmf) | qemu 使用的 uefi 固件 | bin ||
| [edk2](https://github.com/tianocore/edk2) | 构建 qemu 使用的 uefi 固件 ovmf || |
| [libcxxrt](https://github.com/libcxxrt/libcxxrt) | c++ 运行时支持 |||
- 基于 opensbi 引导的 riscv64 内核

- [x] 文档生成
由 opensbi 进行初始化,直接跳转到内核地址,进入内核逻辑时为 S 态

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

- [x] 构建内核
github action 会将文档部署到 https://simple-xx.github.io/SimpleKernel/ (仅 main 分支)

生成内核 elf 文件
- 基于 CPM 的第三方资源管理

- [x] 运行内核
`3rd.cmake` 中使用 CPM 的功能自动下载、集成第三方资源

在 qemu 上运行内核
- 测试

- [x] 代码格式化
支持 单元测试、集成测试、系统测试,引入 gtest 作为测试框架,同时统计了测试覆盖率

格式化全部代码
- 代码分析

- [x] 测试
引入 cppcheck、clang-tidy、sanitize 工具提前发现错误

单元测试 集成测试 系统测试
- 代码格式化

- [x] CI
使用 llvm 风格

- docker

github action、codecov
支持使用 docker 构建,详细使用方法见 [doc/docker.md](./doc/docker.md)

- [x] 调试
## 已支持

使用 make debug 等进入调试模式
见 新增特性

从系统启动到进入内核
## 依赖

- x86_64,aarch64 通过 uefi 进行引导
- riscv64 通过 opensbi 进行引导
[CPM](https://github.com/cpm-cmake/CPM.cmake)

## 已支持的全部特性
[CPMLicences.cmake](https://github.com/TheLartians/CPMLicenses.cmake)

- [x] build
[google/googletest](https://github.com/google/googletest)

内核构建与调试
[opensbi](https://github.com/riscv-software-src/opensbi)

- [x] doxygen
[doxygen](https://www.doxygen.nl/)

基于 doxygen 的文档生成
[lcov](https://github.com/linux-test-project/lcov)

- [x] CI

github action,github pages,code coverage,ut it st
[gcc](https://gcc.gnu.org/)

- [x] x86_64
[qemu](https://www.qemu.org/)

基于 gnu-efi 的 x86_64 uefi 引导
[cppcheck](https://cppcheck.sourceforge.io/)

- [x] riscv64
[clang-tidy](https://clang.llvm.org/extra/clang-tidy/)

基于 opensbi 的 riscv64 架构支持
[clang-format](https://clang.llvm.org/docs/ClangFormat.html)

- [x] 3rd
[gnu-efi](https://sourceforge.net/projects/gnu-efi/)

对依赖的第三方库的自动下载、编译
97 changes: 97 additions & 0 deletions README_ENG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
[![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)
![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)

[English](./README_ENG.md) | [中文](./README.md)

# SimpleKernel

## Key Words

- kernel
- x86_64, riscv64, aarch64
- osdev
- bare metal
- c++, cmake
- uefi, opensbi

## Introduction

SimpleKernel, a simple kernel for learning. Contains the basic functionality of an operating system

Kernels with different levels of completion are available, and you can start from where you like.

## What's NEW

This branch is the first branch of SImpleKernel. In this branch, the foundation of the build system is completed, basic documentation deployment and automated testing, and of course the most important, there is a uefi based x86_64 kernel and riscv64 kernel started by opensbi, which can run on qemu, and achieve simple screen output.

- Build system

Reference [MRNIU/cmake-kernel](https://github.com/MRNIU/cmake-kernel) build system, a detailed explanation see [doc/build_system.md](./doc/build_system.md)

- x86_64 kernel based on gnu-efi boot

After compiling, boot.efi and kernel.elf are generated. After entering uefi environment, boot.efi is executed first. After initialization, kernel.elf is executed

- riscv64 kernel based on opensbi boot

Initializing by opensbi, it jumps directly to the kernel address and enters the S state when entering the kernel logic

- Doxygen-based document generation and automatic deployment

Making the action will document deployment to https://simple-xx.github.io/SimpleKernel/ (the main branch only)

- Third-party resource management based on CPM

Use CPM's functionality in '3rd.cmake' to automatically download and integrate third-party resources

- Test

Support unit testing, integration testing, system testing, the introduction of gtest as a test framework, while the test coverage statistics

- Code analysis

Introduce cppcheck, clang-tidy, and sanitize tools to detect errors in advance

- Code formatting

Use the llvm style

- docker

Supports building with docker, see [doc/docker.md](./doc/docker.md)

## Supported

See What's NEW

## Dependencies

[CPM](https://github.com/cpm-cmake/CPM.cmake)

[CPMLicences.cmake](https://github.com/TheLartians/CPMLicenses.cmake)

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

[opensbi](https://github.com/riscv-software-src/opensbi)

[doxygen](https://www.doxygen.nl/)

[lcov](https://github.com/linux-test-project/lcov)

[gcc](https://gcc.gnu.org/)

[qemu](https://www.qemu.org/)

[cppcheck](https://cppcheck.sourceforge.io/)

[clang-tidy](https://clang.llvm.org/extra/clang-tidy/)

[clang-format](https://clang.llvm.org/docs/ClangFormat.html)

[gnu-efi](https://sourceforge.net/projects/gnu-efi/)

117 changes: 117 additions & 0 deletions doc/build_system.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
# 构建系统

## 目录及文件介绍

```shell
.
├── 3rd // 第三方源文件
├── CMakeLists.txt // 最上层 cmake
├── CMakePresets.json // 预定义的 cmake 配置
├── Dockerfile // docker 配置
├── LICENSE // MIT 与 ANTI996
├── README.md // README
├── build_riscv64 // riscv64 架构的构建目录
├── build_x86_64 // x86_64 架构的构建目录
├── cmake // cmake 模块目录
│ ├── 3rd.cmake // 管理第三方资源
│ ├── add_header.cmake // 为 target 添加头文件
│ ├── clang.cmake // clang 工具链配置
│ ├── compile_config.cmake // 编译选项
│ ├── functions.cmake // 辅助函数
│ ├── project_config.cmake // 项目配置
│ ├── x86_64-riscv64-gcc.cmake // host 为 x86_64,target 为 riscv64 的工具链
│ └── x86_64-x86_64-gcc.cmake // host 为 x86_64,target 为 x86_64 的工具链
├── doc // 文档目录
│ ├── CMakeLists.txt // 生成 doxygen 文档
│ ├── UEFI_Spec_2_10_Aug29.pdf // UEFI 协议文档
│ ├── build.md // 本文件
│ └── docker.md // docker 使用方法
├── run.sh // 一键运行脚本
├── src // 代码目录
│ ├── CMakeLists.txt //
│ ├── boot // 引导程序目录
│ │ ├── CMakeLists.txt //
│ │ ├── boot.cpp //
│ │ ├── graphics.cpp //
│ │ ├── include //
│ │ │ ├── boot.h //
│ │ │ ├── load_elf.h //
│ │ │ └── ostream.hpp //
│ │ ├── load_elf.cpp //
│ │ ├── memory.cpp //
│ │ └── ostream.cpp //
│ └── kernel // 内核目录
│ ├── CMakeLists.txt //
│ ├── arch // 架构相关代码
│ │ ├── CMakeLists.txt //
│ │ ├── aarch64 //
│ │ │ └── arch.cpp //
│ │ ├── arch.cpp //
│ │ ├── include //
│ │ │ └── arch.h //
│ │ ├── riscv64 //
│ │ │ ├── arch.cpp //
│ │ │ ├── boot.S //
│ │ │ └── link.ld // 链接脚本
│ │ └── x86_64 //
│ │ └── arch.cpp //
│ ├── driver // 驱动目录
│ │ ├── CMakeLists.txt //
│ │ ├── driver.cpp //
│ │ └── include //
│ │ └── driver.h //
│ ├── include // 内核头文件目录
│ │ └── kernel.h //
│ ├── libc // libc 目录
│ │ ├── CMakeLists.txt //
│ │ ├── include //
│ │ │ └── libc.h //
│ │ └── libc.c //
│ ├── libcxx // libcxx 目录
│ │ ├── CMakeLists.txt //
│ │ ├── include //
│ │ │ └── libcxx.h //
│ │ └── libcxx.cpp //
│ └── main.cpp // 内核入口
├── test // 测试目录
│ ├── CMakeLists.txt //
│ ├── integration_test // 集成测试
│ │ ├── CMakeLists.txt //
│ │ └── example.cpp //
│ ├── system_test // 系统测试
│ │ ├── CMakeLists.txt //
│ │ ├── gnu_efi_test // 测试 gnu-efi
│ │ │ ├── CMakeLists.txt //
│ │ │ ├── README.md //
│ │ │ ├── boot.cpp //
│ │ │ └── main.cpp //
│ │ └── opensbi_test // 测试 opensbi
│ │ ├── CMakeLists.txt //
│ │ └── boot.cpp //
│ └── unit_test // 单元测试
│ ├── CMakeLists.txt //
│ └── example.cpp //
└── tools // 其它工具
├── cppcheck-suppressions.xml // cppcheck 配置文件
├── ovmf // ovmf 文件目录
│ └── OVMF_x86_64.fd //
└── startup.nsh.in // uefi 初始化配置输入文件
```

每个子模块都有自己的 cmake 文件,上级 cmake 通过 add_subdirectory 将其引入,同时传递由 config.cmake 设置的变量。

所有内核相关代码都在 src 目录下,其中

1. boot 是引导程序,在生成时为一个独立的 elf 文件。
2. arch 目录下存放了体系结构相关的代码,在有涉及到体系结构内容时应当将实现放在这里,向外提供统接口。
3. driver 目录下是设备驱动。在内核开发初期,可以将驱动代码与内核一起编译,在后期应当提供独立文件。
4. kernel 目录是内核的核心逻辑,内存管理、任务管理等。
5. libc 与 libcxx 是 c/c++ 库的位置,提供内核可用的相关接口。

## 命名规范

- 系统测试

以测试内容为名称的文件夹。

cmake project 名为 xxx-test,如 gnu-efi-test。

0 comments on commit f0c7d81

Please sign in to comment.