## about riscv-pke (Proxy Kernel for Education, a.k.a. PKE) ##
----------
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/Computer System Engineering courses, 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 as well as some of Computer Organization/Architecture, 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): device and file (conducted on a PYNQ FPGA board + an Arduino toy car).
The experiments in the REPO may be different (with more actual labs) from the above list with the passing of time.
From the angle of education on Operating System Engineering, 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 application and proxy OS kernel (sometimes, also the RISC-V machine emulated by using [Spike](https://github.com/riscv/riscv-isa-sim), or an FPGA board with a soft RISC-V core); 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:zyshao@hust.edu.cn) 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 contain
没有合适的资源?快使用搜索试试~ 我知道了~
华中科技大学操作系统实验 riscv-pke.zip
共40个文件
h:17个
c:15个
s:3个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 28 浏览量
2024-04-22
23:03:41
上传
评论
收藏 35KB ZIP 举报
温馨提示
华中科技大学操作系统实验 riscv-pke.zip
资源推荐
资源详情
资源评论
收起资源包目录
华中科技大学操作系统实验 riscv-pke.zip (40个子文件)
riscv-pke-lab1_1_syscall
Makefile 4KB
spike_interface
spike_htif.c 4KB
spike_file.h 2KB
spike_memory.h 111B
spike_htif.h 3KB
spike_utils.h 1KB
spike_utils.c 3KB
spike_memory.c 2KB
dts_parse.c 3KB
atomic.h 2KB
dts_parse.h 2KB
spike_file.c 4KB
.spike.cfg 301B
user
user.lds 190B
user_lib.c 1KB
user_lib.h 103B
app_helloworld.c 307B
util
functions.h 413B
types.h 418B
snprintf.c 2KB
string.c 2KB
load_store.S 1KB
snprintf.h 227B
string.h 415B
README.md 10KB
kernel
kernel.lds 2KB
riscv.h 6KB
process.h 721B
kernel.c 1KB
syscall.c 1KB
elf.c 4KB
config.h 491B
elf.h 2KB
syscall.h 371B
process.c 2KB
machine
mentry.S 1KB
minit.c 4KB
strap_vector.S 2KB
strap.c 2KB
strap.h 76B
共 40 条
- 1
资源评论
小码蚁.
- 粉丝: 2664
- 资源: 4483
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功