yhzhang0128 / egos-2000

Envision a future where every student can read all the code of a teaching operating system.
Other
2.2k stars 157 forks source link

Port to RISV64 and baremetal run on VF2 #6

Closed strlcat closed 1 year ago

strlcat commented 1 year ago

I'm really interested in this project, unfortunately it seems it is nailed to RV32 as for now.

However, SBCs like VisionFive2 and Star64 emerge, and there will be more RV64 actual hardware in the future.

Are there plans to port it to RV64? Run on real hardware?

yhzhang0128 commented 1 year ago

I'm really interested in this project, unfortunately it seems it is nailed to RV32 as for now.

However, SBCs like VisionFive2 and Star64 emerge, and there will be more RV64 actual hardware in the future.

Are there plans to port it to RV64? Run on real hardware?

yhzhang0128 commented 1 year ago

Sorry I accidentally pressed the close button and closed this issue.

Although I don’t have this plan, I think it is not difficult. I guess the key is to modify ‘grass/context.S’ since most other parts of this OS are written in C so that you can compile them to RV64 with the right compiler flag.

strlcat commented 1 year ago

Are there any other specifics to keep in mind? Does it talk 16550A style uart? Is changing base address 0x20400000 is enough to keep it going? So many questions, I hope to see answers :) VF2's config: 16550A uart is at 0x10000000 Kernel load address 0x40200000 (OpenSBI sits at 0x40000000), S-Mode. If one might want to run from M-Mode, then SRAM is available at 0x08000000, but idk how U-Boot SPL calls it.

yhzhang0128 commented 1 year ago

You may wish to take a look at earth/bus_uart.c. In particular, the uart_put and uart_get functions are just few lines and you may need to modify them for VF2. For example, use the address 0x10000000.

In terms of adjusting memory map, please refer to issue #4.

I don’t have a good answer to the S-mode or M-mode part. You may need to modify several assembly. For example, change mret, mstatus, etc. to sret, sstatus, etc.