polarfire-soc / polarfire-soc-documentation

PolarFire SoC Documentation
Other
37 stars 19 forks source link

What is "u mode" and "s mode"? #44

Closed plwalsh closed 2 years ago

plwalsh commented 2 years ago

The src/application/inc/common.h header file in every example contains an enum definition for COMMAND_TYPE. For example:

https://github.com/polarfire-soc/polarfire-soc-bare-metal-examples/blob/acdddf3a903aa7e7b82961559965466760fa74fd/driver-examples/mss/mpfs-hal/mpfs-hal-simple-demo/src/application/inc/common.h#L21-L26

What is meant by "start hart in u mode or s mode"? And are there any examples of using these commands?

mallynch commented 2 years ago

This is for future use. Bare metal apps are only currently supporting m-mode. The roadmap has addition of s-mode support in the bare metal examples later this year.

plwalsh commented 2 years ago

Thanks, @mallynch. What exactly do "m-mode", "s-mode", and "u-mode" all mean? I'm a bit new to this type of work.

mallynch commented 2 years ago

Hi @plwalsh , modes are a mechanism which facilitates separating software into privilege's levels, m-mode being the most privileged. Follow the following link for an introduction: https://www.five-embeddev.com/riscv-isa-manual/latest/priv-intro.html

plwalsh commented 2 years ago

Thanks for the link! I'll give it a read through for a better understanding.