├── .gitignore ├── LICENSE └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | 5 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 6 | # More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html 7 | Cargo.lock 8 | 9 | # These are backup files generated by rustfmt 10 | **/*.rs.bk 11 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 oscomp 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # proj7-terminus 2 | ### 项目描述 3 | 当前大学本科学生做OS实验的一个问题是对底层硬件不够了解,如果能够通过实践实现一个能运行OS的CPU模拟器,那在后续对CPU与OS的交互会理解更加清晰和透彻。如果这个模拟器还能提供相应的调试分析功能,那么会大大简化对OS学习和实验的难度。 4 | 5 | 为此,我们采用了如下的规划思路: 6 | - 我们选择了能帮助OS设计实现的RISC-V硬件模拟平台 7 | - 在软件编程语言方面,我们选择了Rust编程语言 8 | - 尽量比较全面地支持与OS相关的硬件模块 9 | 10 | 当前项目实现源码: 11 | - https://github.com/shady831213/terminus 12 | - https://github.com/shady831213/trantor 13 | 14 | ### 所属赛道 15 | 16 | 2021全国大学生操作系统比赛的“OS功能设计”赛道 17 | 18 | ### 参赛要求 19 | - 以小组为单位参赛,最多三人一个小组,且小组成员是来自同一所高校的本科生(2021年春季学期或之后本科毕业的大一~大四的学生) 20 | - 如学生参加了多个项目,参赛学生选择一个自己参加的项目参与评奖 21 | - 请遵循“2021全国大学生操作系统比赛”的章程和技术方案要求 22 | 23 | ### 项目导师 24 | 25 | 李旸 26 | - github https://github.com/shady831213/ 27 | - email shady831213@126.com 28 | 29 | ### 难度 30 | 31 | 初等~中等 32 | 33 | ### 特征(已经完成) 34 | - [x] RV32/64I 35 | - [x] MADFC 36 | - [x] M/S/U priviledge 37 | - [x] Pass all riscv_tests 38 | - [x] CLINT and Timer 39 | - [x] HTIF console 40 | - [x] FDT generation 41 | - [x] Multi Cores 42 | - [x] Boot Linux(up) 43 | - [x] Emu mode binary 44 | - [x] Boot Linux(smp) 45 | - [x] PLIC 46 | - [x] VirtIO console 47 | - [x] VirtIO disk 48 | - [x] VirtIO network 49 | - [x] framebuffer 50 | - [x] VirtIO keyboard 51 | - [x] VirtIO mouse 52 | - [x] Cosimulation with HDL 53 | 54 | ### 文档 55 | 56 | 57 | ### License 58 | 59 | - MIT license 60 | 61 | ## 预期目标 62 | 63 | ### 注意:下面的内容是建议内容,不要求必须全部完成。选择本项目的同学也可与导师联系,提出自己的新想法,如导师认可,可加入预期目标 64 | 65 | 在现有terminus的基础上,进一步完成如下目标: 66 | 67 | ### 第一题:分阶段重新实现terminus 68 | 69 | - 该题目请参考[trantor](https://github.com/shady831213/trantor), 帮你一步一步实现自己的模拟器 70 | - 与导师协商,形成一系列的小步骤,参考目前的代码,重新按小步骤实现RISC-V模拟器 71 | - 在每个步骤完成后,能够有测试用例,并尽量与OS课程中涉及的内容相关 72 | - 撰写实验设计与分析文档 73 | 74 | ### 第二题:支持调试能力 75 | 76 | - 对terminus增加基于OPENOCD+GDB的调试功能 77 | - 能够使用cargo的测试框架通过[riscv-test/debug](https://github.com/riscv/riscv-tests/tree/master/debug) 的所有test 78 | - 能够通过GDB/LLDB来在terminus上对APP(U态)、OS(S态)、SBI(M态)进行源码级调试 79 | - 能够跨U/S/M态综合调试APP/OS/SBI 80 | - 撰写实验设计与分析文档 81 | 82 | ### 第三题:支持动态分析 83 | - 在SMP/多核模式下,能分析死锁情况 84 | - 能记录并分析系统出现crash时,模拟器保存的最近的N条指令的机器执行状态,帮助定位出错原因 85 | - 在SMP/多核模式下,能快速重现并分析同步互斥异常的情况 86 | 87 | ### 第四题:支持对新硬件的模拟 88 | 89 | - 支持对Kendryte K210开发板的模拟 90 | - 支持对SFIVE开发板的模拟 91 | 92 | ### 第五题:支持任意一种sbi实现 93 | - 移植一种sbi实现,例如[opensbi](https://github.com/riscv/opensbi),到terminus仿真器 94 | - 可以通过该sib实现 boot linux 95 | - 可参考[terminus_bl](https://github.com/shady831213/terminus_bl) 96 | 97 | ### 第六题:支持其他操作系统 98 | - 任选其它操作系统,例如[rcore](https://github.com/rcore-os/rCore)、[zephyr](https://github.com/zephyrproject-rtos/zephyr), 可以在terminus仿真器上运行 99 | 100 | ### 第七题:支持riscv vector extension 101 | - 在terminus上增加RVV 102 | - 能够使用cargo的测试框架通过[riscv-test](https://github.com/riscv/riscv-tests) 中的vector测试 103 | 104 | ### 第八题: 支持和verilog/systemverilog模型协同仿真 105 | - 通过ffi+dpi,使terminus可以运行在verilog/systemverilog环境中 106 | - 可以在verilog/systemverilog环境中,控制terminus,指定特定core执行特定步长,可以出发terminus的中断,可以获取terminus的状态等 107 | - 任选rtl simulator, 如verilator, vcs, xrun等 108 | - 可以尝试实现verilog/systemverilog的device + terminus的协同仿真 109 | - 可参考[terminus_cosim](https://github.com/shady831213/terminus_cosim), [vfw_rs](https://github.com/shady831213/vfw_rs), [mailbox_rs](https://github.com/shady831213/mailbox_rs) 110 | --------------------------------------------------------------------------------