Skip to content

Commit 96756b3

Browse files
committed
Add functions to get top and limit stack
1 parent 30c9ad2 commit 96756b3

5 files changed

Lines changed: 38 additions & 0 deletions

File tree

ports/atmel-samd/supervisor/port.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,14 @@ void reset_cpu(void) {
271271
reset();
272272
}
273273

274+
uint32_t *port_stack_get_limit(void) {
275+
return &_ebss;
276+
}
277+
278+
uint32_t *port_stack_get_top(void) {
279+
return &_estack;
280+
}
281+
274282
// Place the word to save 8k from the end of RAM so we and the bootloader don't clobber it.
275283
#ifdef SAMD21
276284
uint32_t* safe_word = (uint32_t*) (HMCRAMC0_ADDR + HMCRAMC0_SIZE - 0x2000);

ports/cxd56/supervisor/port.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,14 @@ void reset_port(void) {
6767
void reset_to_bootloader(void) {
6868
}
6969

70+
uint32_t *port_stack_get_limit(void) {
71+
return &_ebss;
72+
}
73+
74+
uint32_t *port_stack_get_top(void) {
75+
return &_estack;
76+
}
77+
7078
extern uint32_t _ebss;
7179

7280
// Place the word to save just after our BSS section that gets blanked.

ports/nrf/supervisor/port.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,14 @@ void reset_cpu(void) {
146146
NVIC_SystemReset();
147147
}
148148

149+
uint32_t *port_stack_get_limit(void) {
150+
return &_ebss;
151+
}
152+
153+
uint32_t *port_stack_get_top(void) {
154+
return &_estack;
155+
}
156+
149157
extern uint32_t _ebss;
150158
// Place the word to save just after our BSS section that gets blanked.
151159
void port_set_saved_word(uint32_t value) {

ports/stm32f4/supervisor/port.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,14 @@ void reset_cpu(void) {
6767
NVIC_SystemReset();
6868
}
6969

70+
uint32_t *port_stack_get_limit(void) {
71+
return &_ebss;
72+
}
73+
74+
uint32_t *port_stack_get_top(void) {
75+
return &_estack;
76+
}
77+
7078
extern uint32_t _ebss;
7179
// Place the word to save just after our BSS section that gets blanked.
7280
void port_set_saved_word(uint32_t value) {

supervisor/port.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,12 @@ void reset_board(void);
5454
// Reset to the bootloader
5555
void reset_to_bootloader(void);
5656

57+
// Get stack limit address
58+
uint32_t *port_stack_get_limit(void);
59+
60+
// Get stack top address
61+
uint32_t *port_stack_get_top(void);
62+
5763
// Save and retrieve a word from memory that is preserved over reset. Used for safe mode.
5864
void port_set_saved_word(uint32_t);
5965
uint32_t port_get_saved_word(void);

0 commit comments

Comments
 (0)