forked from apache/nuttx
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RISC-V: Implement option to run NuttX in supervisor mode (S-mode)
- Add config "ARCH_USE_S_MODE" which controls whether the kernel runs in M-mode or S-mode - Add more MSTATUS and most of the SSTATUS register definitions - Add more MIP flags for interrupt delegation - Add handling of interrupts from S-mode - Add handling of FPU from S-mode - Add new context handling functions that are not dependent on the trap handlers / ecall NOTE: S-mode requires a companion SW (SBI) which is not yet implemented, thus S-mode is not usable as is, yet.
- Loading branch information
Showing
24 changed files
with
1,050 additions
and
112 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
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
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
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,93 @@ | ||
/**************************************************************************** | ||
* arch/risc-v/include/mode.h | ||
* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. The | ||
* ASF licenses this file to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance with the | ||
* License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations | ||
* under the License. | ||
* | ||
****************************************************************************/ | ||
|
||
#ifndef __ARCH_RISCV_INCLUDE_MODE_H | ||
#define __ARCH_RISCV_INCLUDE_MODE_H | ||
|
||
/**************************************************************************** | ||
* Included Files | ||
****************************************************************************/ | ||
|
||
#include <nuttx/config.h> | ||
|
||
#include <arch/csr.h> | ||
#include <arch/irq.h> | ||
|
||
/**************************************************************************** | ||
* Pre-processor Definitions | ||
****************************************************************************/ | ||
|
||
#ifdef CONFIG_ARCH_USE_S_MODE | ||
|
||
/* CSR definitions */ | ||
|
||
# define CSR_STATUS sstatus /* Global status register */ | ||
# define CSR_EPC sepc /* Exception program counter */ | ||
# define CSR_IE sie /* Interrupt enable register */ | ||
|
||
/* In status register */ | ||
|
||
# define STATUS_IE SSTATUS_SIE /* Global interrupt enable */ | ||
# define STATUS_PIE SSTATUS_SPIE /* Previous interrupt enable */ | ||
# define STATUS_PPP SSTATUS_SPPS /* Previous privilege */ | ||
# define STATUS_SUM SSTATUS_SUM /* Access to user memory */ | ||
|
||
/* Interrupt bits */ | ||
|
||
# define IE_EIE SIE_SEIE /* External interrupt enable */ | ||
# define IE_SIE SIE_SSIE /* Software interrupt enable */ | ||
# define IE_TIE SIE_STIE /* Timer interrupt enable */ | ||
|
||
/* External, timer and software interrupt */ | ||
|
||
# define RISCV_IRQ_EXT RISCV_IRQ_SEXT /* PLIC IRQ */ | ||
# define RISCV_IRQ_TIMER RISCV_IRQ_STIMER /* Timer IRQ */ | ||
# define RISCV_IRQ_SOFT RISCV_IRQ_SSOFT /* SW IRQ */ | ||
|
||
#else | ||
|
||
/* CSR definitions */ | ||
|
||
# define CSR_STATUS mstatus /* Global status register */ | ||
# define CSR_EPC mepc /* Exception program counter */ | ||
# define CSR_IE mie /* Interrupt enable register */ | ||
|
||
/* In status register */ | ||
|
||
# define STATUS_IE MSTATUS_MIE /* Global interrupt enable */ | ||
# define STATUS_PIE MSTATUS_MPIE /* Previous interrupt enable */ | ||
# define STATUS_PPP MSTATUS_MPPM /* Previous privilege */ | ||
# define STATUS_SUM 0 /* Not needed in M-mode */ | ||
|
||
/* Interrupt bits */ | ||
|
||
# define IE_EIE MIE_MEIE /* External interrupt enable */ | ||
# define IE_SIE MIE_MSIE /* Software interrupt enable */ | ||
# define IE_TIE MIE_MTIE /* Timer interrupt enable */ | ||
|
||
/* External, timer and software interrupt */ | ||
|
||
# define RISCV_IRQ_EXT RISCV_IRQ_MEXT /* PLIC IRQ */ | ||
# define RISCV_IRQ_TIMER RISCV_IRQ_MTIMER /* Timer IRQ */ | ||
# define RISCV_IRQ_SOFT RISCV_IRQ_MSOFT /* SW IRQ */ | ||
|
||
#endif | ||
|
||
#endif /* __ARCH_RISCV_INCLUDE_MODE_H */ |
Oops, something went wrong.