-
Notifications
You must be signed in to change notification settings - Fork 208
Store the last TaskId in the RTC registers #2162
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
Draft
labbott
wants to merge
4
commits into
master
Choose a base branch
from
discount_watchdog
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,5 @@ | |
|
||
fn main() { | ||
build_util::expose_target_board(); | ||
build_util::expose_m_profile().unwrap(); | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
// This Source Code Form is subject to the terms of the Mozilla Public | ||
// License, v. 2.0. If a copy of the MPL was not distributed with this | ||
// file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
|
||
// | ||
// If you are cutting-and-pasting this code into another kernel (and that | ||
// kernel is armv6m), it is hoped that you will cut-and-paste this compile | ||
// error along with it and take heed of its admonition! | ||
// | ||
#[cfg(not(any(armv7m, armv8m)))] | ||
compile_error!("ringbuf is unsound in the kernel on armv6m"); | ||
|
||
use ringbuf::*; | ||
|
||
#[derive(Copy, Clone, PartialEq)] | ||
enum Event { | ||
SyscallEnter(u32), | ||
SyscallExit, | ||
SecondarySyscallEnter, | ||
SecondarySyscallExit, | ||
IsrEnter, | ||
IsrExit, | ||
TimerIsrEnter, | ||
TimerIsrExit, | ||
ContextSwitch(usize), | ||
} | ||
|
||
#[derive(Copy, Clone, PartialEq)] | ||
enum Trace { | ||
Event(Event), | ||
None, | ||
} | ||
|
||
ringbuf!(Trace, 128, Trace::None); | ||
|
||
fn trace(event: Event) { | ||
ringbuf_entry!(Trace::Event(event)); | ||
} | ||
|
||
fn syscall_enter(nr: u32) { | ||
trace(Event::SyscallEnter(nr)); | ||
} | ||
|
||
fn syscall_exit() { | ||
trace(Event::SyscallExit); | ||
} | ||
|
||
fn secondary_syscall_enter() { | ||
trace(Event::SecondarySyscallEnter); | ||
} | ||
|
||
fn secondary_syscall_exit() { | ||
trace(Event::SecondarySyscallExit); | ||
} | ||
|
||
fn isr_enter() { | ||
trace(Event::IsrEnter); | ||
} | ||
|
||
fn isr_exit() { | ||
trace(Event::IsrExit); | ||
} | ||
|
||
fn timer_isr_enter() { | ||
trace(Event::TimerIsrEnter); | ||
} | ||
|
||
fn timer_isr_exit() { | ||
trace(Event::TimerIsrExit); | ||
} | ||
|
||
fn context_switch(addr: usize) { | ||
let rtc = unsafe { &*stm32h7::stm32h753::RTC::ptr() }; | ||
rtc.bkpr[0].modify(|_, w| w.bkp().bits(addr as u32)); | ||
trace(Event::ContextSwitch(addr)); | ||
} | ||
|
||
static TRACING: kern::profiling::EventsTable = kern::profiling::EventsTable { | ||
syscall_enter, | ||
syscall_exit, | ||
secondary_syscall_enter, | ||
secondary_syscall_exit, | ||
isr_enter, | ||
isr_exit, | ||
timer_isr_enter, | ||
timer_isr_exit, | ||
context_switch, | ||
}; | ||
|
||
pub fn table() -> &'static kern::profiling::EventsTable { | ||
let rtc = unsafe { &*stm32h7::stm32h753::RTC::ptr() }; | ||
|
||
// Unlock | ||
rtc.wpr.write(|w| w.key().bits(0xca)); | ||
rtc.wpr.write(|w| w.key().bits(0x53)); | ||
|
||
// don't erase! | ||
rtc.tampcr.modify(|_, w| { | ||
w.tamp3noerase() | ||
.set_bit() | ||
.tamp2noerase() | ||
.set_bit() | ||
.tamp1noerase() | ||
.set_bit() | ||
}); | ||
|
||
// Save our last state | ||
let last = rtc.bkpr[0].read().bkp().bits(); | ||
// And rotate | ||
rtc.bkpr[1].modify(|_, w| w.bkp().bits(last)); | ||
|
||
&TRACING | ||
} |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Cosmo SPD task API | ||
// | ||
// Right now, this doesn't actually do anything, but it lets us use the idol | ||
// runtime for notifications / dispatch. | ||
Interface( | ||
name: "Bork", | ||
ops: { | ||
"ping": ( | ||
doc: "blocks until the server is running", | ||
args: {}, | ||
reply: Simple("()"), | ||
idempotent: true, | ||
), | ||
"wave_bye_bye": ( | ||
doc: "wave bye bye", | ||
args: {}, | ||
reply: Simple("()"), | ||
idempotent: true, | ||
), | ||
|
||
}, | ||
) | ||
|
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand this change, unless it was broken before?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The existing profiling just stores the base of the task, which is both fast and may have been fine for cliff's debugging (thanks again cliff for adding this). I was struggling to figure out how to go from task base to useful information so I did the calculation here. If we really hate this, we can get humility to do this work for us.