Crate riscv_stack

Crate riscv_stack 

Source
Expand description

§riscv-stack

Methods for RISCV processors to determine stack size and how much of the stack has been or is being used.

This is a fork of cortex-m-stack but ported to RISCV.

Warning: this crate depends on the _stack_start and _hart_stack_size symbols being set correctly. Correctly means _hart_stack_size is equal among all harts therefore the beginning of each hart’s stack can be found at _stack_start - (_hart_stack_size * hart_id) (with adjustments for alignment). The linker script provided by riscv-rt should satisfy these requirements.

§Immediate stack usage

Use current_stack_in_use or current_stack_free to keep track of the memory usage at run-time.

§Historical stack usage

First paint the stack using repaint_stack and then measure using stack_painted or stack_painted_binary to figure out how much stack was used between these two points.

Constants§

STACK_PAINT_VALUE
The value used to paint the stack.

Functions§

current_stack_fraction
What fraction of the current hart’s stack is currently in use.
current_stack_free
The number of bytes of the current hart’s stack that are currently free.
current_stack_in_use
The number of bytes of the current hart’s stack that are currently in use.
current_stack_ptr
Convenience function to fetch the current hart’s stack pointer.
repaint_stack
Paint the part of the current hart’s stack that is currently not in use.
stack
The Range currently in use for the current hart’s stack.
stack_painted
Finds the number of bytes that have not been overwritten on the current hart’s stack since the last repaint.
stack_painted_binary
Finds the number of bytes that have not been overwritten on the current hart’s stack since the last repaint using binary search.
stack_rev
The Range currently in use for the current hart’s stack, defined in reverse such that Range operations are viable.
stack_size
The number of bytes that are reserved for the current hart’s stack at compile time.