aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2011-02-24 14:57:38 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2011-02-24 14:57:38 +0000
commit24594525990ee1769ee933261b821211b4c299e8 (patch)
tree78fadffd9ad2173941eff2d7a096d593a9e0f15e
parenta55d3c6e6b8d14d6310382f149593df231925c17 (diff)
downloadChibiOS-24594525990ee1769ee933261b821211b4c299e8.tar.gz
ChibiOS-24594525990ee1769ee933261b821211b4c299e8.tar.bz2
ChibiOS-24594525990ee1769ee933261b821211b4c299e8.zip
Fixed bugs 3191107 and 3191112.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@2762 35acf78f-673a-0410-8e92-d51de3d6d3f4
-rw-r--r--os/kernel/include/chmemcore.h14
-rw-r--r--os/kernel/include/chmempools.h2
-rw-r--r--os/kernel/src/chheap.c2
-rw-r--r--os/kernel/src/chmemcore.c38
-rw-r--r--os/kernel/src/chmempools.c2
-rw-r--r--readme.txt7
-rw-r--r--todo.txt2
7 files changed, 41 insertions, 26 deletions
diff --git a/os/kernel/include/chmemcore.h b/os/kernel/include/chmemcore.h
index f42478125..58cb318b2 100644
--- a/os/kernel/include/chmemcore.h
+++ b/os/kernel/include/chmemcore.h
@@ -36,14 +36,24 @@
typedef void *(*memgetfunc_t)(size_t size);
/**
+ * @brief Alignment size constant.
+ */
+#define MEM_ALIGN_SIZE sizeof(stkalign_t)
+
+/**
* @brief Alignment mask constant.
*/
-#define MEM_ALIGN_MASK (sizeof(stkalign_t) - 1)
+#define MEM_ALIGN_MASK (MEM_ALIGN_SIZE - 1)
+
+/**
+ * @brief Alignment helper macro.
+ */
+#define MEM_ALIGN_PREV(p) ((size_t)(p) & ~MEM_ALIGN_MASK)
/**
* @brief Alignment helper macro.
*/
-#define MEM_ALIGN_SIZE(p) (((size_t)(p) + MEM_ALIGN_MASK) & ~MEM_ALIGN_MASK)
+#define MEM_ALIGN_NEXT(p) MEM_ALIGN_PREV((size_t)(p) + MEM_ALIGN_MASK)
/**
* @brief Returns whatever a pointer or memory size is aligned to
diff --git a/os/kernel/include/chmempools.h b/os/kernel/include/chmempools.h
index 1c2e2aa70..9dbe332c8 100644
--- a/os/kernel/include/chmempools.h
+++ b/os/kernel/include/chmempools.h
@@ -59,7 +59,7 @@ typedef struct {
* @param[in] provider memory provider function for the memory pool
*/
#define _MEMORYPOOL_DATA(name, size, provider) \
- {NULL, MEM_ALIGN_SIZE(size), provider}
+ {NULL, MEM_ALIGN_NEXT(size), provider}
/**
* @brief Static memory pool initializer in hungry mode.
diff --git a/os/kernel/src/chheap.c b/os/kernel/src/chheap.c
index 13db7cf6b..c655e3852 100644
--- a/os/kernel/src/chheap.c
+++ b/os/kernel/src/chheap.c
@@ -125,7 +125,7 @@ void *chHeapAlloc(MemoryHeap *heapp, size_t size) {
if (heapp == NULL)
heapp = &default_heap;
- size = MEM_ALIGN_SIZE(size);
+ size = MEM_ALIGN_NEXT(size);
qp = &heapp->h_free;
H_LOCK(heapp);
diff --git a/os/kernel/src/chmemcore.c b/os/kernel/src/chmemcore.c
index 69d3014a5..1fed481c5 100644
--- a/os/kernel/src/chmemcore.c
+++ b/os/kernel/src/chmemcore.c
@@ -24,18 +24,20 @@
* @addtogroup memcore
* @details Core Memory Manager related APIs and services.
* <h2>Operation mode</h2>
- * The core memory manager is a simplified allocator that only allows
- * to allocate memory blocks without the possibility to free them.<br>
- * This allocator is meant as a memory blocks provider for the other
- * allocators such as:
+ * The core memory manager is a simplified allocator that only
+ * allows to allocate memory blocks without the possibility to
+ * free them.<br>
+ * This allocator is meant as a memory blocks provider for the
+ * other allocators such as:
* - C-Runtime allocator (through a compiler specific adapter module).
* - Heap allocator (see @ref heaps).
* - Memory pools allocator (see @ref pools).
* .
- * By having a centralized memory provider the various allocators can
- * coexist and share the main memory.<br>
- * This allocator, alone, is also useful for very simple applications
- * that just require a simple way to get memory blocks.
+ * By having a centralized memory provider the various allocators
+ * can coexist and share the main memory.<br>
+ * This allocator, alone, is also useful for very simple
+ * applications that just require a simple way to get memory
+ * blocks.
* @pre In order to use the core memory manager APIs the @p CH_USE_MEMCORE
* option must be enabled in @p chconf.h.
* @{
@@ -57,22 +59,20 @@ void core_init(void) {
#if CH_MEMCORE_SIZE == 0
extern uint8_t __heap_base__;
extern uint8_t __heap_end__;
- nextmem = &__heap_base__;
- endmem = &__heap_end__;
+ nextmem = (uint8_t *)MEM_ALIGN_NEXT(&__heap_base__);
+ endmem = (uint8_t *)MEM_ALIGN_PREV(&__heap_end__);
#else
- static stkalign_t buffer[MEM_ALIGN_SIZE(CH_MEMCORE_SIZE) /
- sizeof(stkalign_t)];
+ static stkalign_t buffer[MEM_ALIGN_NEXT(CH_MEMCORE_SIZE)/MEM_ALIGN_SIZE];
nextmem = (uint8_t *)&buffer[0];
- endmem = (uint8_t *)&buffer[MEM_ALIGN_SIZE(CH_MEMCORE_SIZE) /
- sizeof(stkalign_t)];
+ endmem = (uint8_t *)&buffer[MEM_ALIGN_NEXT(CH_MEMCORE_SIZE)/MEM_ALIGN_SIZE];
#endif
}
/**
* @brief Allocates a memory block.
* @details The size of the returned block is aligned to the alignment
- * type @p stkalign_t so it is not possible to allocate less
- * than <code>sizeof(stkalign_t)</code>.
+ * type so it is not possible to allocate less
+ * than <code>MEM_ALIGN_SIZE</code>.
*
* @param[in] size the size of the block to be allocated
* @return A pointer to the allocated memory block.
@@ -92,8 +92,8 @@ void *chCoreAlloc(size_t size) {
/**
* @brief Allocates a memory block.
* @details The size of the returned block is aligned to the alignment
- * type @p align_t so it is not possible to allocate less than
- * <code>sizeof(align_t)</code>.
+ * type so it is not possible to allocate less than
+ * <code>MEM_ALIGN_SIZE</code>.
*
* @param[in] size the size of the block to be allocated.
* @return A pointer to the allocated memory block.
@@ -104,7 +104,7 @@ void *chCoreAlloc(size_t size) {
void *chCoreAllocI(size_t size) {
void *p;
- size = MEM_ALIGN_SIZE(size);
+ size = MEM_ALIGN_NEXT(size);
if ((size_t)(endmem - nextmem) < size)
return NULL;
p = nextmem;
diff --git a/os/kernel/src/chmempools.c b/os/kernel/src/chmempools.c
index 054823af0..83e6366f4 100644
--- a/os/kernel/src/chmempools.c
+++ b/os/kernel/src/chmempools.c
@@ -55,7 +55,7 @@ void chPoolInit(MemoryPool *mp, size_t size, memgetfunc_t provider) {
chDbgCheck((mp != NULL) && (size >= sizeof(void *)), "chPoolInit");
mp->mp_next = NULL;
- mp->mp_object_size = MEM_ALIGN_SIZE(size);
+ mp->mp_object_size = MEM_ALIGN_NEXT(size);
mp->mp_provider = provider;
}
diff --git a/readme.txt b/readme.txt
index 3d91239d1..8516b1c41 100644
--- a/readme.txt
+++ b/readme.txt
@@ -69,8 +69,13 @@
*****************************************************************************
*** 2.3.0 ***
+- FIX: Fixed Cortex-Mx linker scripts alignment of __heap_base__, the
+ correct alignment is now enforced at runtime into core_init() in order
+ to make the OS integration easier (bug 3191112)(backported to 2.2.2).
+- FIX: Fixed error in function chCoreAllocI() function documentation (bug
+ 3191107)(backported to 2.2.2).
- FIX: Fixed minor problem with memory pools (bug 3190512)(backported to
- 2.2.1).
+ 2.2.2).
- FIX: Stack overflow in CM0 ports when nearing interrupts saturation (bug
3187105)(backported to 2.2.1).
- FIX: Fixed error in _BSEMAPHORE_DATA macro (bug 3184139)(backported to
diff --git a/todo.txt b/todo.txt
index 44c0c464f..90d631345 100644
--- a/todo.txt
+++ b/todo.txt
@@ -37,7 +37,7 @@ X Transactional flash file system implementation.
X I2C device driver class support and at least one implementation.
X Shared DMA channels support in the STM32/STM8L HALs.
X RAM ISR vectors support in the STM32 HAL.
-X New device driver models: Clock, Systick, RTC, WDG, DAC, Power Monitor.
+X New device driver models: Clock, Systick, PT, RTC, WDG, DAC, Power Monitor.
Later but within 2.x.x
- Batch testing of the ARM7/ARMCMx port using OpenOCD, with reports.