## About riscv-pke (Proxy Kernel for Education, PKE for short) ##
----------
Documents in Chinese can be found [here](https://gitee.com/hustos/pke-doc). There is still no dedicated documents in English yet, but the in-line comments in our codes as well as the self-explaining names for variables and functions will help on your journey of PKE.
PKE is an open source project (see [LICENSE.txt](./LICENSE.txt) for license information) for the educational purpose of the Operating System Engineering course, given to undergraduate students majored in CS (Computer Science) or EECS ( Electrical Engineering and Computer Science) in universities.
PKE provides a series of labs that cover the engineering-side knowledge points of the Operating System, including:
Lab1(3 basic labs+2 challenge labs): traps (syscalls), exceptions and interrupts (IRQs in Intel terminology).
Lab2 (3 basic labs+2 challenge labs): memory management.
Lab3 (3 basic labs+2 challenge labs): processes.
Lab4 (3 basic labs): devices (tied with experiments on RISC-V on PYNQ).
Lab5: file systems (not presented yet).
The experiments in the REPO may be different (with more actual labs) from the above list with the passing of time.
Different from many famous OS educational projects (like [xv6](https://pdos.csail.mit.edu/6.828/2020/xv6.html) (JOS when earlier) used in MIT 6.828 and [ucore](https://github.com/oscourse-tsinghua/ucore-rv) taught in Tsinghua University) that use complete or near-complete OS kernels containing almost everything like process management, file systems and many other modules, *PKE is **NOT** a complete OS kernel (actually, PKE never intends to be one of them.)*.
PKE is built around the idea of Proxy Kernel (proposed in [PK](https://github.com/riscv/riscv-pk), an open source project of the RISC-V software ecology), that emphasizes to construct a "just-enough" OS kernel for a given application. With such an idea, we design a series of labs in PKE that gradually "upgrades" the OS kernel by giving a set of applications, from simple to complex. During the upgradations, you can learn more and more sophisticated ideas of modern operating systems, and more importantly, play with them by following the labs, one after another.
In each lab, PKE starts with an application (placed in the *./user/* folder, with the "app_" prefix) and an *incomplete* proxy OS kernel. During the lab, you need to 1) understand the interaction between applicaion and proxy OS kernel (sometimes, also the RISC-V machine emulated by using [Spike](https://github.com/riscv/riscv-isa-sim)); 2) follow the code from the given application to the OS kernel based on the understanding; 3) complete the proxy OS kernel to make the application (or the system) to execute correctly and smoothly.
In the labs of PKE, we tried our best to control and minimize the code scale of each lab, hoping to help you to stay focus on the key components of Operating System, and minimize the efforts at the same time. [Contact us](mailto:[email protected]) if you have further suggestions on reducing the code scale, thanks in advance!
Environment configuration
----------
**1. Install Operating system (Virtual machine or Windows Subversion Linux)**
(preferred) Ubuntu 16.04LTS or higher, 64-bit
**2. Install tools for building cross-compiler and emluator**
```bash
$ sudo apt-get install autoconf automake autotools-dev curl python3 libmpc-dev libmpfr-dev libgmp-dev gawk build-essential bison flex
```
**3. Install RISC-V cross-compiler**
```bash
$ export RISCV=/path-to-install-RISCV-toolchains
$ git clone --recursive https://github.com/riscv/riscv-gnu-toolchain.git
$ cd riscv-gnu-toolchain
$ ./configure --prefix=$RISCV
$ make -j$(nproc)
$ sudo make install
```
In above commands, *$(nproc)* stands for the number of threads you want to invoke during building. Generelly, *$(nproc)* should equal to the number of cores that your computer have. After this step, you should find executables, like riscv64-unknown-elf-gcc, riscv64-unknown-elf-gdb, riscv64-unknown-elf-objdump, and many others (with the name prefix of "riscv64-unknown-elf-") in your */path-to-install-RISCV-toolchains/bin* directory.
**4. Install emulator (Spike)**
```bash
$ sudo apt-get install device-tree-compiler
$ git clone https://github.com/riscv/riscv-isa-sim.git
$ cd riscv-isa-sim
$ mkdir build
$ cd build
$ ../configure --prefix=$RISCV
$ make -j$(nproc)
$ sudo make install
```
After this step, you should find executables like spike, spike-dasm in your */path-to-install-RISCV-toolchains/bin* directory.
**5. Clone PKE REPO**
```bash
$ git clone https://github.com/MrShawCode/riscv-pke.git
```
After this step, you will have the pke directory containing the PKE labs.
**6. Build/Run PKE**
```bash
$ make [run]
```
**7. (optional) Install OpenOCD for debugging**
```bash
$ git clone https://github.com/riscv/riscv-openocd.git
$ cd openocd
$ ./bootstrap (when building from the git repository)
$ ./configure --prefix=$RISCV
$ make -j$(nproc)
$ sudo make install
```
After installing OpenOCD, you can debug the PKE kernel. Simply use following command:
```bash
$ make gdb
```
Start the first lab
----------
In this lab, we are going to learn the basic priciples of trap (also called as the **syscall** in many textbooks).
A trap (for example, *printf* that is in our daily use) is generally issued by an application, and evetually handled by the kernel. It is very important for an OS to provide such facility, since applications running in less priviledged modes (e.g., User-mode in RISC-V) need to frequently perform legal operations like I/Os that require to be conducted in higher priviledge modes (e.g., Supervisor or Machine modes in RISC-V).
Lab1_1 gives an application in "user/lab1_1_helloworld.c", whose main() function calls a function *printu* that has the same functionality as *printf*, but under a slightly different name. *printu* is defined in "user/do_print.c", and actually invokes the trap by the *ecall* instruction (see the inline assemblies in the function of *do_user_print*).
#### Code structure of Lab1_1
----------
The structure of Lab1_1 is listed in the following:
.
├── LICENSE.txt
├── Makefile
├── README.md
├── .spike.cfg
├── kernel
│ ├── config.h
│ ├── elf.c
│ ├── elf.h
│ ├── kernel.c
│ ├── kernel.lds
│ ├── machine
│ │ ├── mentry.S
│ │ └── minit.c
│ ├── process.c
│ ├── process.h
│ ├── riscv.h
│ ├── strap.c
│ ├── strap.h
│ ├── strap_vector.S
│ ├── syscall.c
│ └── syscall.h
├── spike_interface
│ ├── atomic.h
│ ├── dts_parse.c
│ ├── dts_parse.h
│ ├── spike_file.c
│ ├── spike_file.h
│ ├── spike_htif.c
│ ├── spike_htif.h
│ ├── spike_memory.c
│ ├── spike_memory.h
│ ├── spike_utils.c
│ └── spike_utils.h
├── user
│ ├── app_helloworld.c
│ ├── user.lds
│ ├── user_lib.c
│ └── user_lib.h
└── util
├── functions.h
├── load_store.S
├── snprintf.c
├── snprintf.h
├── string.c
├── string.h
└── types.h
The root directory mainly contains the documents (i.e., the md files), the license text and importantly, the make file (named as *Makefile*). The *kernel* sub-directory contains the OS kernel
华中科技大学操作系统实验作业.zip
版权申诉
167 浏览量
2024-04-20
17:26:23
上传
评论
收藏 46KB ZIP 举报
小码蚁.
- 粉丝: 2525
- 资源: 4090
最新资源
- 基于STM32驱动MLX90614红外测温模块和OLED屏幕,测温的同时如果超过37度会在屏幕上显示报警信息
- Stability.postman-collection.json
- SQL 语言入门篇-最常用 SQL 语句大全
- mysql查询语句汇总.zip
- typora-x64-v0.9.93,windows,64位,markdown工具,文本编辑器
- 基于C语言的neon_osd_Draw ARM Neon加速OSD点阵设计源码
- 目标检测-工地工人安全设备佩戴检测数据集-3500张图-+对应VOC-COCO-YOLO三种格式标签+数据集划分脚本+训练日志
- 运筹学运输问题综合实验的实验报告
- home - 副本.vue
- imageProcess.py
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈