rcore-os / rCore-Tutorial-v3

Let's write an OS which can run on RISC-V in Rust from scratch!
https://rcore-os.github.io/rCore-Tutorial-Book-v3/index.html
GNU General Public License v3.0
1.65k stars 469 forks source link

rCore in C #34

Closed shili2017 closed 2 years ago

shili2017 commented 3 years ago

Hi rCore team & community,

Currently I am a TA for 3rd Open-Source Chip Project by University (OSCPU, 一生一芯), considering transplant rCore to my own RV CPU. I'm trying to implement rCore in C such that other students could learn it without rust. I've made some surveys but found that other OS for educational purpose written in C still differ a lot from rCore tutorial v3, e.g., xv6, uCore for RISC-V (https://github.com/DeathWish5/ucore-Tutorial), etc.

Thus, I started to implement rcc (rCore in C, https://github.com/shili2017/rcc), aiming at "copying" rCore from rust to C as much as possible, including general design, key data structure, and even function names & variable names, etc. I have started for a while and just completed chapter 4. There may still exist lots of bugs or flaws in design. If you are interested in developing this project, you are welcome to join, contact me, leave some issues or make some pull requests :) If there's any issue like license, please also notify me.

(Btw, it would be great if OSCPU students can run their own OS on their own CPU in the future, which is really cool.)

Thanks!

wyfcyx commented 3 years ago

Hello @shili2017 !

I'm very happy for that! I think it's hard or even impossible to implement an OS which is exactly the same as rCore in C since there is a huge gap between C and Rust such as programming paradigm or level of security. In fact, this is unnecessary. My suggestion is that you can try to concentrate on the core ideas of OS design, and you do not need to pay too much attention on rCore itself. rCore is just a simple example based on a framework which allows everyone to design and implement his own OS. Maybe some data structures or interfaces are not appropriate when using C(I believe they aren't!), feel free to replace them to meet your requirements! However, I think some ideas of Rust are critical to help students understand what programming exactly means and what programming should be like. Even if you are using C, it would be better that you rely on these ideas to design and implement, but maybe you have to use different design patterns.

By the way, I found another C implementation of rCore, and you can find blog series of its author here. I hope that they can help you.

Wish you great success!