mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-17 10:32:44 +01:00
core: cpu: provide function to acquire ISR stack usage
This commit is contained in:
parent
720136491a
commit
53df3e8b57
@ -58,6 +58,11 @@ typedef void *(*thread_task_func_t)(void *arg);
|
|||||||
*/
|
*/
|
||||||
char *thread_arch_stack_init(thread_task_func_t task_func, void *arg, void *stack_start, int stack_size);
|
char *thread_arch_stack_init(thread_task_func_t task_func, void *arg, void *stack_start, int stack_size);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the number of bytes used on the ISR stack
|
||||||
|
*/
|
||||||
|
int thread_arch_isr_stack_usage(void);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Print the current stack to stdout
|
* @brief Print the current stack to stdout
|
||||||
*/
|
*/
|
||||||
|
@ -28,6 +28,13 @@ void thread_yield_higher(void)
|
|||||||
__asm__("svc 0\n");
|
__asm__("svc 0\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* This function calculates the ISR_usage */
|
||||||
|
int thread_arch_isr_stack_usage(void)
|
||||||
|
{
|
||||||
|
/* TODO */
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
/*----------------------------------------------------------------------------
|
/*----------------------------------------------------------------------------
|
||||||
* Processor specific routine - here for ARM7
|
* Processor specific routine - here for ARM7
|
||||||
* sizeof(void*) = sizeof(int)
|
* sizeof(void*) = sizeof(int)
|
||||||
|
@ -198,6 +198,13 @@ void thread_arch_stack_print(void)
|
|||||||
printf("stack size: %u bytes\n", size);
|
printf("stack size: %u bytes\n", size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* This function calculates the ISR_usage */
|
||||||
|
int thread_arch_isr_stack_usage(void)
|
||||||
|
{
|
||||||
|
/* TODO */
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
void thread_arch_start_threading(void) __attribute__((naked));
|
void thread_arch_start_threading(void) __attribute__((naked));
|
||||||
void thread_arch_start_threading(void)
|
void thread_arch_start_threading(void)
|
||||||
{
|
{
|
||||||
|
@ -48,6 +48,15 @@ extern "C" {
|
|||||||
#define ARCH_HAS_ATOMIC_COMPARE_AND_SWAP 1
|
#define ARCH_HAS_ATOMIC_COMPARE_AND_SWAP 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Interrupt stack canary value
|
||||||
|
*
|
||||||
|
* @note 0xe7fe is the ARM Thumb machine code equivalent of asm("bl #-2\n") or
|
||||||
|
* 'while (1);', i.e. an infinite loop.
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
|
#define STACK_CANARY_WORD (0xE7FEE7FEu)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Initialization of the CPU
|
* @brief Initialization of the CPU
|
||||||
*/
|
*/
|
||||||
|
@ -100,6 +100,9 @@
|
|||||||
#include "irq.h"
|
#include "irq.h"
|
||||||
#include "cpu.h"
|
#include "cpu.h"
|
||||||
|
|
||||||
|
extern uint32_t _estack;
|
||||||
|
extern uint32_t _sstack;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Noticeable marker marking the beginning of a stack segment
|
* @brief Noticeable marker marking the beginning of a stack segment
|
||||||
*
|
*
|
||||||
@ -251,6 +254,15 @@ void thread_arch_stack_print(void)
|
|||||||
printf("current stack size: %i byte\n", count);
|
printf("current stack size: %i byte\n", count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* This function returns the number of bytes used on the ISR stack */
|
||||||
|
int thread_arch_isr_stack_usage(void)
|
||||||
|
{
|
||||||
|
uint32_t *ptr = &_sstack;
|
||||||
|
|
||||||
|
while (*(ptr++) == STACK_CANARY_WORD) {}
|
||||||
|
return (ISR_STACKSIZE - (ptr - &_sstack));
|
||||||
|
}
|
||||||
|
|
||||||
__attribute__((naked)) void NORETURN thread_arch_start_threading(void)
|
__attribute__((naked)) void NORETURN thread_arch_start_threading(void)
|
||||||
{
|
{
|
||||||
__asm__ volatile (
|
__asm__ volatile (
|
||||||
|
@ -31,14 +31,6 @@
|
|||||||
#include "panic.h"
|
#include "panic.h"
|
||||||
#include "vectors_cortexm.h"
|
#include "vectors_cortexm.h"
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Interrupt stack canary value
|
|
||||||
*
|
|
||||||
* @note 0xe7fe is the ARM Thumb machine code equivalent of __asm__("bl #-2\n") or
|
|
||||||
* 'while (1);', i.e. an infinite loop.
|
|
||||||
*/
|
|
||||||
#define STACK_CANARY_WORD 0xE7FEE7FEu
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Memory markers, defined in the linker script
|
* @brief Memory markers, defined in the linker script
|
||||||
* @{
|
* @{
|
||||||
|
@ -33,6 +33,13 @@ __attribute__((naked)) void thread_yield_higher(void)
|
|||||||
UNREACHABLE();
|
UNREACHABLE();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* This function calculates the ISR_usage */
|
||||||
|
int thread_arch_isr_stack_usage(void)
|
||||||
|
{
|
||||||
|
/* TODO */
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
NORETURN void cpu_switch_context_exit(void)
|
NORETURN void cpu_switch_context_exit(void)
|
||||||
{
|
{
|
||||||
sched_active_thread = sched_threads[0];
|
sched_active_thread = sched_threads[0];
|
||||||
|
@ -74,6 +74,13 @@ void thread_print_stack(void)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* This function calculates the ISR_usage */
|
||||||
|
int thread_arch_isr_stack_usage(void)
|
||||||
|
{
|
||||||
|
/* TODO */
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
char *thread_stack_init(thread_task_func_t task_func, void *arg, void *stack_start, int stacksize)
|
char *thread_stack_init(thread_task_func_t task_func, void *arg, void *stack_start, int stacksize)
|
||||||
{
|
{
|
||||||
char *stk;
|
char *stk;
|
||||||
|
25
cpu/x86/x86_thread_arch.c
Normal file
25
cpu/x86/x86_thread_arch.c
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2016 Freie Universität Berlin
|
||||||
|
*
|
||||||
|
* This file is subject to the terms and conditions of the GNU Lesser
|
||||||
|
* General Public License v2.1. See the file LICENSE in the top level
|
||||||
|
* directory for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @{
|
||||||
|
*
|
||||||
|
* @file
|
||||||
|
* @author Martine Lenders <mlenders@inf.fu-berlin.de>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "thread_arch.h"
|
||||||
|
|
||||||
|
/* This function calculates the ISR_usage */
|
||||||
|
int thread_arch_isr_stack_usage(void)
|
||||||
|
{
|
||||||
|
/* TODO */
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @} */
|
Loading…
Reference in New Issue
Block a user