Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

riscv64: boot from PLO #448

Merged
merged 7 commits into from
Jan 30, 2024
Merged

riscv64: boot from PLO #448

merged 7 commits into from
Jan 30, 2024

Conversation

lukileczo
Copy link
Member

@lukileczo lukileczo commented Sep 7, 2023

Description

  • Adapt initialization code to booting from PLO
  • Reformat code and apply MISRA
  • Refactor interrupt handling - properly handle 2 interrupt controllers (CLINT and PLIC), simplify interrupt dispatcher
  • Add (partial) support for SBI calls in version 0.2 and higher.
  • Modify kernel stack handling: use hal_cpuKernelStack variable to store kstack value - same approach as on sparcv8leon3. Previously kstack was set incorrectly, causing exception after fork. Variable use here is the most optimal, as when in the future we'll use more cores, tp register will have to be reserved in kernel.

Motivation and Context

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

How Has This Been Tested?

  • Already covered by automatic testing.
  • New test added: (add PR link here).
  • Tested by hand on: riscv64-generic-qemu

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing linter checks and tests passed.
  • My changes generate no new compilation warnings for any of the targets.

Special treatment

hal/riscv64/plic.c Outdated Show resolved Hide resolved
hal/riscv64/plic.c Show resolved Hide resolved
hal/riscv64/plic.c Show resolved Hide resolved
hal/riscv64/plic.c Show resolved Hide resolved
hal/riscv64/plic.c Show resolved Hide resolved
hal/riscv64/exceptions.c Outdated Show resolved Hide resolved
hal/riscv64/plic.h Outdated Show resolved Hide resolved
hal/riscv64/plic.h Outdated Show resolved Hide resolved
hal/riscv64/interrupts.c Show resolved Hide resolved
hal/riscv64/interrupts.c Show resolved Hide resolved
@lukileczo lukileczo force-pushed the lukileczo/rtos-550 branch 2 times, most recently from 76f10e2 to 8265626 Compare January 2, 2024 15:00
@lukileczo lukileczo force-pushed the lukileczo/rtos-550 branch 9 times, most recently from f79f6f4 to 568d225 Compare January 9, 2024 08:47
hal/riscv64/plic.c Outdated Show resolved Hide resolved
hal/riscv64/plic.c Show resolved Hide resolved
hal/riscv64/plic.c Show resolved Hide resolved
@phoenix-rtos phoenix-rtos deleted a comment from github-actions bot Jan 12, 2024
@lukileczo lukileczo marked this pull request as ready for review January 12, 2024 11:12
@lukileczo lukileczo force-pushed the lukileczo/rtos-550 branch 2 times, most recently from 58f54ca to 290441b Compare January 17, 2024 15:03
Copy link
Member

@agkaminski agkaminski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only spaces nitpicks, otherwise LGTM

/* interrupts */


static inline void hal_cpuDisableInterrupts(void)
{
__asm__ ("csrc sstatus, 2");
__asm__ volatile("csrc sstatus, 2");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

silly clang-format thinks this is a function

Suggested change
__asm__ volatile("csrc sstatus, 2");
__asm__ volatile ("csrc sstatus, 2");

: "=r" (*(cycles_t *)cb));
return;
/* clang-format off */
__asm__ volatile("rdcycle %0" : "=r"(*(cycles_t *)cb));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
__asm__ volatile("rdcycle %0" : "=r"(*(cycles_t *)cb));
__asm__ volatile ("rdcycle %0" : "=r" (*(cycles_t *)cb));

- simplify interrupt handling code
- fix timer interval setting
- properly handle interrupts from CLINT and PLIC
- remove reading from exec-only pages - mapping is now done correctly

JIRA: RTOS-550
Modified kstack approach to be the same as on LEON3.
Previously kstack wasn't set correctly,
resulting in `fork` failure.

JIRA: RTOS-550
@agkaminski agkaminski merged commit a1980f4 into master Jan 30, 2024
9 of 22 checks passed
@agkaminski agkaminski deleted the lukileczo/rtos-550 branch January 30, 2024 11:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants