From: bernie Date: Sun, 10 Aug 2008 13:34:57 +0000 (+0000) Subject: ASSERT_VALID_PTR(): Make bottom of memory a per-CPU constant X-Git-Tag: 2.0.0~339 X-Git-Url: https://codewiz.org/gitweb?a=commitdiff_plain;h=33b33ae4a68da6dba63e2cdff3c42edfcfc5ba89;p=bertos.git ASSERT_VALID_PTR(): Make bottom of memory a per-CPU constant git-svn-id: https://src.develer.com/svnoss/bertos/trunk@1595 38d2e660-2303-0410-9eaa-f027e97ec537 --- diff --git a/bertos/cfg/debug.h b/bertos/cfg/debug.h index 0c8bfec0..02c04894 100644 --- a/bertos/cfg/debug.h +++ b/bertos/cfg/debug.h @@ -169,14 +169,16 @@ * memory regions. This helps catching pointers taken from * struct/class memebers when the struct pointer was NULL. */ - #define ASSERT_VALID_PTR(p) ((void)(LIKELY((p) >= 0x200) ? 0 : __invalid_ptr(p, #p, THIS_FILE, __LINE__))) + #define ASSERT_VALID_PTR(p) ((void)(LIKELY((p) >= (void *)CPU_RAM_START) \ + ? 0 : __invalid_ptr(p, #p, THIS_FILE, __LINE__))) /** * Check that the given pointer is not pointing to invalid memory. * * \see ASSERT_VALID_PTR() */ - #define ASSERT_VALID_PTR_OR_NULL(p) ((void)(LIKELY((p == NULL) || ((p) >= 0x200)) ? 0 : __invalid_ptr((p), #p, THIS_FILE, __LINE__))) + #define ASSERT_VALID_PTR_OR_NULL(p) ((void)(LIKELY((p == NULL) || ((p) >= (void *)CPU_RAM_START)) \ + ? 0 : __invalid_ptr((p), #p, THIS_FILE, __LINE__))) #if !CONFIG_KDEBUG_DISABLE_TRACE #define TRACE __trace(__func__) diff --git a/bertos/cpu/attr.h b/bertos/cpu/attr.h index 1e469e6a..59748126 100644 --- a/bertos/cpu/attr.h +++ b/bertos/cpu/attr.h @@ -74,6 +74,9 @@ #define CPU_BYTE_ORDER CPU_LITTLE_ENDIAN #define CPU_HARVARD 0 + /// Valid pointers should be >= than this value (used for debug) + #define CPU_RAM_START 0x100 + #elif CPU_X86 #define NOP asm volatile ("nop") @@ -96,6 +99,9 @@ #define CPU_REG_BITS 32 #endif + /// Valid pointers should be >= than this value (used for debug) + #define CPU_RAM_START 0x1000 + #elif CPU_ARM /* Register counts include SREG too */ @@ -106,6 +112,9 @@ #define CPU_SP_ON_EMPTY_SLOT 0 #define CPU_HARVARD 0 + /// Valid pointers should be >= than this value (used for debug) + #define CPU_RAM_START 0x200 + #ifdef __IAR_SYSTEMS_ICC__ #warning Check CPU_BYTE_ORDER #define CPU_BYTE_ORDER (__BIG_ENDIAN__ ? CPU_BIG_ENDIAN : CPU_LITTLE_ENDIAN) @@ -174,12 +183,15 @@ /* Register counts include SREG too */ #define CPU_REG_BITS (CPU_PPC32 ? 32 : 64) #define CPU_REGS_CNT FIXME - #define CPU_SAVED_REGS_CNT FIXME + #define CPU_SAVED_REGS_CNT 1 // FIXME #define CPU_STACK_GROWS_UPWARD 0 //FIXME #define CPU_SP_ON_EMPTY_SLOT 0 //FIXME #define CPU_BYTE_ORDER (__BIG_ENDIAN__ ? CPU_BIG_ENDIAN : CPU_LITTLE_ENDIAN) #define CPU_HARVARD 0 + /// Valid pointers should be >= than this value (used for debug) + #define CPU_RAM_START 0x1000 + #elif CPU_DSP56K #define NOP asm(nop) @@ -199,6 +211,9 @@ #define SIZEOF_LONG 2 #define SIZEOF_PTR 1 + /// Valid pointers should be >= than this value (used for debug) + #define CPU_RAM_START 0x200 + #elif CPU_AVR #define NOP asm volatile ("nop" ::) @@ -220,6 +235,9 @@ */ #define CPU_REG_INIT_VALUE(reg) (reg == 0 ? 0x80 : 0) + /// Valid pointers should be >= than this value (used for debug) + #define CPU_RAM_START 0x100 + #else #error No CPU_... defined. #endif