diff --git a/arch/Kconfig b/arch/Kconfig index 34026cff9f..2c81f17ca3 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -17,6 +17,7 @@ config ARCH_ARM bool "ARM" select ARCH_HAVE_INTERRUPTSTACK select ARCH_HAVE_VFORK + select ARCH_HAVE_STACKCHECK ---help--- The ARM architectures diff --git a/arch/arm/src/common/up_checkstack.c b/arch/arm/src/common/up_checkstack.c index 273d30d237..2bcd5c5561 100644 --- a/arch/arm/src/common/up_checkstack.c +++ b/arch/arm/src/common/up_checkstack.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/arm/src/common/up_checkstack.c * - * Copyright (C) 2011 Gregory Nutt. All rights reserved. + * Copyright (C) 2011, 2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -134,14 +134,19 @@ size_t up_check_tcbstack(FAR struct tcb_s *tcb) return mark*4; } +ssize_t up_check_tcbstack_remain(FAR struct tcb_s *tcb) +{ + return (ssize_t)tcb->adj_stack_size - (ssize_t)up_check_tcbstack(tcb); +} + size_t up_check_stack(void) { return up_check_tcbstack((FAR struct tcb_s*)g_readytorun.head); } -size_t up_check_stack_remain(void) +ssize_t up_check_stack_remain(void) { - return ((FAR struct tcb_s*)g_readytorun.head)->adj_stack_size - up_check_tcbstack((FAR struct tcb_s*)g_readytorun.head); + return up_check_tcbstack_remain((FAR struct tcb_s*)g_readytorun.head); } #endif /* CONFIG_DEBUG && CONFIG_DEBUG_STACK */ diff --git a/arch/arm/src/common/up_createstack.c b/arch/arm/src/common/up_createstack.c index 634fb9d61f..46bf153586 100644 --- a/arch/arm/src/common/up_createstack.c +++ b/arch/arm/src/common/up_createstack.c @@ -85,7 +85,7 @@ /**************************************************************************** * Name: memset32 * - * On most larger then 8 bit archs this will need to be word aligned so + * On most larger than 8 bit archs this will need to be word aligned so * so maybe some checks should be put in place? * ****************************************************************************/ diff --git a/arch/arm/src/common/up_internal.h b/arch/arm/src/common/up_internal.h index b39f456d07..448735e493 100644 --- a/arch/arm/src/common/up_internal.h +++ b/arch/arm/src/common/up_internal.h @@ -484,28 +484,6 @@ void up_usbuninitialize(void); void up_rnginitialize(void); #endif -/**************************************************************************** - * Name: up_check_stack - * - * Description: - * Determine (approximately) how much stack has been used be searching the - * stack memory for a high water mark. That is, the deepest level of the - * stack that clobbered some recognizable marker in the stack memory. - * - * Input Parameters: - * None - * - * Returned value: - * The estimated amount of stack space used. - * - ****************************************************************************/ - -#if defined(CONFIG_DEBUG) && defined(CONFIG_DEBUG_STACK) -size_t up_check_stack(void); -size_t up_check_tcbstack(FAR struct tcb_s); -size_t up_check_tcbstack_remain(FAR struct tcb_s); -#endif - #endif /* __ASSEMBLY__ */ #endif /* __ARCH_ARM_SRC_COMMON_UP_INTERNAL_H */ diff --git a/arch/avr/Kconfig b/arch/avr/Kconfig index 41b6c72d3f..acfbf6a603 100644 --- a/arch/avr/Kconfig +++ b/arch/avr/Kconfig @@ -44,6 +44,7 @@ endchoice config ARCH_FAMILY_AVR bool default y if ARCH_CHIP_ATMEGA128 || ARCH_CHIP_AT90USB646 || ARCH_CHIP_AT90USB647 || ARCH_CHIP_AT90USB1286 || ARCH_CHIP_AT90USB1287 + select ARCH_HAVE_STACKCHECK config ARCH_FAMILY_AVR32 bool diff --git a/arch/avr/src/avr/avr_internal.h b/arch/avr/src/avr/avr_internal.h index 9cd6c893ea..8fb3fae288 100644 --- a/arch/avr/src/avr/avr_internal.h +++ b/arch/avr/src/avr/avr_internal.h @@ -1,7 +1,7 @@ /**************************************************************************** * arch/avr/src/avr/avr_internal.h * - * Copyright (C) 2011-2012 Gregory Nutt. All rights reserved. + * Copyright (C) 2011-2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -104,7 +104,7 @@ extern uint16_t g_idle_topstack; * ************************************************************************************/ -extern void up_copystate(uint8_t *dest, uint8_t *src); +void up_copystate(uint8_t *dest, uint8_t *src); /************************************************************************************ * Name: up_fullcontextrestore @@ -114,7 +114,7 @@ extern void up_copystate(uint8_t *dest, uint8_t *src); * ************************************************************************************/ -extern void up_fullcontextrestore(uint8_t *restoreregs) noreturn_function; +void up_fullcontextrestore(uint8_t *restoreregs) noreturn_function; /************************************************************************************ * Name: up_switchcontext @@ -124,7 +124,7 @@ extern void up_fullcontextrestore(uint8_t *restoreregs) noreturn_function; * ************************************************************************************/ -extern void up_switchcontext(uint8_t *saveregs, uint8_t *restoreregs); +void up_switchcontext(uint8_t *saveregs, uint8_t *restoreregs); /************************************************************************************ * Name: up_doirq @@ -134,7 +134,7 @@ extern void up_switchcontext(uint8_t *saveregs, uint8_t *restoreregs); * ************************************************************************************/ -extern uint8_t *up_doirq(uint8_t irq, uint8_t *regs); +uint8_t *up_doirq(uint8_t irq, uint8_t *regs); /************************************************************************************ * Name: avr_spiselect, avr_spitatus, and avr_spicmddata @@ -167,33 +167,13 @@ struct spi_dev_s; enum spi_dev_e; #ifdef CONFIG_AVR_SPI -extern void avr_spiselect(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected); -extern uint8_t avr_spistatus(FAR struct spi_dev_s *dev, enum spi_dev_e devid); +void avr_spiselect(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected); +uint8_t avr_spistatus(FAR struct spi_dev_s *dev, enum spi_dev_e devid); #ifdef CONFIG_SPI_CMDDATA -extern int avr_spicmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd); +int avr_spicmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd); #endif #endif -/**************************************************************************** - * Name: up_check_stack - * - * Description: - * Determine (approximately) how much stack has been used be searching the - * stack memory for a high water mark. That is, the deepest level of the - * stack that clobbered some recognizable marker in the stack memory. - * - * Input Parameters: - * None - * - * Returned value: - * The estimated amount of stack space used. - * - ****************************************************************************/ - -#if defined(CONFIG_DEBUG) && defined(CONFIG_DEBUG_STACK) -extern size_t up_check_stack(void); -#endif - #endif /* __ASSEMBLY__ */ #endif /* __ARCH_AVR_SRC_AVR_AVR_INTERNAL_H */ diff --git a/arch/avr/src/avr/up_checkstack.c b/arch/avr/src/avr/up_checkstack.c index e58ee0ca31..6ff0db083a 100644 --- a/arch/avr/src/avr/up_checkstack.c +++ b/arch/avr/src/avr/up_checkstack.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/avr/src/avr/up_checkstack.c * - * Copyright (C) 2011 Gregory Nutt. All rights reserved. + * Copyright (C) 2011, 2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -133,9 +133,19 @@ size_t up_check_tcbstack(FAR struct tcb_s *tcb) return mark; } +ssize_t up_check_tcbstack_remain(FAR struct tcb_s *tcb) +{ + return (ssize_t)tcb->adj_stack_size - (ssize_t)up_check_tcbstack(tcb); +} + size_t up_check_stack(void) { return up_check_tcbstack((FAR struct tcb_s*)g_readytorun.head); } +ssize_t up_check_stack_remain(void) +{ + return up_check_tcbstack_remain((FAR struct tcb_s*)g_readytorun.head); +} + #endif /* CONFIG_DEBUG && CONFIG_DEBUG_STACK */ diff --git a/arch/avr/src/common/up_internal.h b/arch/avr/src/common/up_internal.h index fce3bc6faa..189aa8d339 100644 --- a/arch/avr/src/common/up_internal.h +++ b/arch/avr/src/common/up_internal.h @@ -126,17 +126,17 @@ extern uint32_t _ebss; /* End+1 of .bss */ /* Defined in files with the same name as the function */ -extern void up_boot(void); -extern void up_irqinitialize(void); +void up_boot(void); +void up_irqinitialize(void); #ifdef CONFIG_ARCH_DMA -extern void weak_function up_dmainitialize(void); +void weak_function up_dmainitialize(void); #endif -extern void up_sigdeliver(void); -extern int up_timerisr(int irq, uint32_t *regs); -extern void up_lowputc(char ch); -extern void up_puts(const char *str); -extern void up_lowputs(const char *str); -extern void up_dumpstate(void); +void up_sigdeliver(void); +int up_timerisr(int irq, uint32_t *regs); +void up_lowputc(char ch); +void up_puts(const char *str); +void up_lowputs(const char *str); +void up_dumpstate(void); /* Defined in common/up_allocateheap.c or chip/xxx_allocateheap.c */ @@ -152,13 +152,13 @@ void up_addregion(void); * before the OS gets started (clocks, console, LEDs, etc.) */ -extern void up_lowinit(void); +void up_lowinit(void); /* Defined in chip/xxx_serial.c */ #if CONFIG_NFILE_DESCRIPTORS > 0 -extern void up_earlyserialinit(void); -extern void up_serialinit(void); +void up_earlyserialinit(void); +void up_serialinit(void); #else # define up_earlyserialinit() # define up_serialinit() @@ -167,7 +167,7 @@ extern void up_serialinit(void); /* Defined in drivers/lowconsole.c */ #ifdef CONFIG_DEV_LOWCONSOLE -extern void lowconsole_init(void); +void lowconsole_init(void); #else # define lowconsole_init() #endif @@ -179,8 +179,8 @@ extern void up_timerinit(void); /* Defined in configs//src/up_leds.c */ #ifdef CONFIG_ARCH_LEDS -extern void up_ledon(int led); -extern void up_ledoff(int led); +void up_ledon(int led); +void up_ledoff(int led); #else # define up_ledon(led) # define up_ledoff(led) @@ -189,7 +189,7 @@ extern void up_ledoff(int led); /* Defined in chip/xxx_ethernet.c */ #ifdef CONFIG_NET -extern void up_netinitialize(void); +void up_netinitialize(void); #else # define up_netinitialize() #endif @@ -197,14 +197,12 @@ extern void up_netinitialize(void); /* Defined in chip/xxx_usbdev.c */ #ifdef CONFIG_USBDEV -extern void up_usbinitialize(void); -extern void up_usbuninitialize(void); +void up_usbinitialize(void); +void up_usbuninitialize(void); #else # define up_usbinitialize() # define up_usbuninitialize() #endif #endif /* __ASSEMBLY__ */ - #endif /* __UP_INTERNAL_H */ -