-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New: Put in place SUPERVISOR, HYPERVISOR and USER mode enable parameters
New: Add documentation on privilege modes, description and design Change: Rework MSTATUS, aligning it with latest privilege spec and create a function to format it
- Loading branch information
Showing
7 changed files
with
403 additions
and
151 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
# Privilege Modes Support | ||
|
||
FRISCV supports machine mode as default mode. it's always implemented as required by the | ||
specification. The core can also support user, supervisor and hypervisor modes, activable | ||
all by paramters, `USER_MODE`, `SUPERVISOR_MODE`, `HYPERVISOR_MODE`. | ||
|
||
All modes use the same `XLEN` width. If `XLEN` = 32 bits, `MXLEN`, `SXLEN`, `UXLEN` and | ||
`HXLEN` will be setup to 32 bits. | ||
|
||
The software navigates through the privilege levels with ECALL / xRET instructions | ||
|
||
``` | ||
┌────────────────────────────────┐ | ||
│ MACHINE │ | ||
└────────────────────────────────┘ | ||
│ ▲ | ||
MRET │ │ ECALL | ||
▼ │ | ||
┌────────────────────────────────┐ | ||
│ SUPERVISOR │ | ||
└────────────────────────────────┘ | ||
│ ▲ | ||
SRET │ │ ECALL | ||
▼ │ | ||
┌────────────────────────────────┐ | ||
│ USER │ | ||
└────────────────────────────────┘ | ||
``` | ||
|
||
CSR registers address encodes inner attributes: | ||
|
||
``` | ||
11/10 9/8 7/4 3/0 | ||
┌───────┬───────────┬───────────┬───────────┐ | ||
│ R/W │ Privilege │ Use │ Address │ | ||
└───────┴───────────┴───────────┴───────────┘ | ||
``` | ||
|
||
Bit[11:10]: | ||
- `11`: read-only | ||
- Others: read/write | ||
|
||
Bits [9:8]: | ||
- `00`: User | ||
- `01`: Supervisor | ||
- `10`: Hypervisor | ||
- `11`: Machine | ||
|
||
|
||
# TODO | ||
|
||
Plan: | ||
- 1. user mode | ||
- 2. supervisor mode + virtual memory support | ||
- 3. hypervisor mode | ||
- 4. debug mode | ||
|
||
1. user mode | ||
|
||
- Support interrupts | ||
- disable them for lower mode. If is SUPERVISOR, USER interrupts are disabled | ||
- interrupts for higher mode are enabled, whatever xIE bit. If is SUPERVISOR, | ||
HYPERVISOR interrupt are enabled | ||
- previous privilege mode interrupt is stored in xPP to support nested trap | ||
- medeleg & mideleg | ||
- delegate an trap to a mode means this mode can handle it. Traps never transition from | ||
a more-privileged mode to a less-privileged mode (page 45) | ||
- Implement MSTATUS | ||
- Support virtual memory for supervisor mode (TVM correct support) | ||
- Support timer extension for each modes | ||
- Support priv mode in cache stages | ||
- V & F extensions support: XS, FS, VS fields |
Oops, something went wrong.