cpu/esp32: platform independent code for thread_arch, irq_arch and exception#18247
Closed
gschorcht wants to merge 5 commits intoRIOT-OS:masterfrom
Closed
cpu/esp32: platform independent code for thread_arch, irq_arch and exception#18247gschorcht wants to merge 5 commits intoRIOT-OS:masterfrom
gschorcht wants to merge 5 commits intoRIOT-OS:masterfrom
Conversation
Xtensa-specific code was moved from thread_arch.c to thread_arch_xtensa.c. RISC-V code has been added to thread_arch_riscv.c. This allows to handle both Xtensa and RISC-V based ESP SoCs.
Xtensa-specific code was moved from irq_arch.c to irq_arch_xtensa.c. RISC-V code has been added to irq_arch_riscv.c. This allows to handle both Xtensa and RISC-V based ESP SoCs.
Contributor
Author
|
If necessary, the PR could be split into seperate PRs. |
Contributor
Author
|
@benpicco The PR still seems to have a lot of changes, but
The files If it helps, I could further split this PR into two PRs, one with the changes that move platform dependent code to the platform dependent files The changes in |
This was referenced Jun 25, 2022
Contributor
Author
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Contribution description
This PR is a splitt-off from PR #17841. It provides a platform independent implementation of
thread_arch.c,irq_arch.candexception.cso that it can be used for Xtensa-based and RISC-V based ESP32x SoC variants.For that purpose the platform dependent code is moved from
thread_arch.c,irq_arch.c,exception.ctothread_arch_xtensa.c,irq_arch_xtensa.c,exception_xtensa.candthread_arch_riscv.c,irq_arch_riscv.c,exception.c_riscv, respectively. Furthermore, someDEBUGmessages are fixed to be platform independent.Background:
thread_arch_xtensa.cis not really independent of the used ESP SoC. Although ESP8266 and ESP32 share most of the code, that's whythread_arch_xtensa.cis defined incpu/esp_common, they require some SoC specific code, especially inthread_yield_*functions. These functions are something very special to ESP SoCs and not common for Xtensa cores.vectors.Sfor for RISC-V interrupt handling andportasm.Sfor RISC-V context switching from ESP-IDF, because they are needed by other ESP-IDF functions, e.g. by the startup function, which we also use directly from ESP-IDF. Unfortunately, they are not compatible with the RISC-V implementation incpu/riscv_common. They use a different context frame structure, a different interrupt context structure, a different interrupt/exception handling and a different startup function. Even if we could reuse some parts ofriscv_common, including a common folder in the compilation always means all or nothing. Therefore we can't usecpu/riscv_commonat all.irq_disable/irq_restoreinriscv_commononly reset/set theMIEbit inmstatusregister while the implementation for RISC-V based ESPs requires to change the value of the SoC specific interrupt level registerINTERRUPT_CORE0_CPU_INT_THRESH_REG.Thus, neither is the Xtensa code general enough to justify a
cpu/xtensa_commonfolder, nor are the thread or interrupt handling for RISC-V based ESP compatible with the implementation inriscv_common.Therefore,
thread_arch.c,irq_arch.c,exception.ctothread_arch_xtensa.c,irq_arch_xtensa.c,exception_xtensa.candthread_arch_riscv.c,irq_arch_riscv.c,exception.c_riscv, respectively.Testing procedure
Issues/PRs references
Split-off from PR #17841