Fixed bugs 3191107 and 3191112.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@2762 35acf78f-673a-0410-8e92-d51de3d6d3f4
This commit is contained in:
parent
a55d3c6e6b
commit
2459452599
|
@ -35,15 +35,25 @@
|
||||||
*/
|
*/
|
||||||
typedef void *(*memgetfunc_t)(size_t size);
|
typedef void *(*memgetfunc_t)(size_t size);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Alignment size constant.
|
||||||
|
*/
|
||||||
|
#define MEM_ALIGN_SIZE sizeof(stkalign_t)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Alignment mask constant.
|
* @brief Alignment mask constant.
|
||||||
*/
|
*/
|
||||||
#define MEM_ALIGN_MASK (sizeof(stkalign_t) - 1)
|
#define MEM_ALIGN_MASK (MEM_ALIGN_SIZE - 1)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Alignment helper macro.
|
* @brief Alignment helper macro.
|
||||||
*/
|
*/
|
||||||
#define MEM_ALIGN_SIZE(p) (((size_t)(p) + MEM_ALIGN_MASK) & ~MEM_ALIGN_MASK)
|
#define MEM_ALIGN_PREV(p) ((size_t)(p) & ~MEM_ALIGN_MASK)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Alignment helper macro.
|
||||||
|
*/
|
||||||
|
#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
|
* @brief Returns whatever a pointer or memory size is aligned to
|
||||||
|
|
|
@ -59,7 +59,7 @@ typedef struct {
|
||||||
* @param[in] provider memory provider function for the memory pool
|
* @param[in] provider memory provider function for the memory pool
|
||||||
*/
|
*/
|
||||||
#define _MEMORYPOOL_DATA(name, size, provider) \
|
#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.
|
* @brief Static memory pool initializer in hungry mode.
|
||||||
|
|
|
@ -125,7 +125,7 @@ void *chHeapAlloc(MemoryHeap *heapp, size_t size) {
|
||||||
if (heapp == NULL)
|
if (heapp == NULL)
|
||||||
heapp = &default_heap;
|
heapp = &default_heap;
|
||||||
|
|
||||||
size = MEM_ALIGN_SIZE(size);
|
size = MEM_ALIGN_NEXT(size);
|
||||||
qp = &heapp->h_free;
|
qp = &heapp->h_free;
|
||||||
H_LOCK(heapp);
|
H_LOCK(heapp);
|
||||||
|
|
||||||
|
|
|
@ -24,18 +24,20 @@
|
||||||
* @addtogroup memcore
|
* @addtogroup memcore
|
||||||
* @details Core Memory Manager related APIs and services.
|
* @details Core Memory Manager related APIs and services.
|
||||||
* <h2>Operation mode</h2>
|
* <h2>Operation mode</h2>
|
||||||
* The core memory manager is a simplified allocator that only allows
|
* The core memory manager is a simplified allocator that only
|
||||||
* to allocate memory blocks without the possibility to free them.<br>
|
* allows to allocate memory blocks without the possibility to
|
||||||
* This allocator is meant as a memory blocks provider for the other
|
* free them.<br>
|
||||||
* allocators such as:
|
* This allocator is meant as a memory blocks provider for the
|
||||||
|
* other allocators such as:
|
||||||
* - C-Runtime allocator (through a compiler specific adapter module).
|
* - C-Runtime allocator (through a compiler specific adapter module).
|
||||||
* - Heap allocator (see @ref heaps).
|
* - Heap allocator (see @ref heaps).
|
||||||
* - Memory pools allocator (see @ref pools).
|
* - Memory pools allocator (see @ref pools).
|
||||||
* .
|
* .
|
||||||
* By having a centralized memory provider the various allocators can
|
* By having a centralized memory provider the various allocators
|
||||||
* coexist and share the main memory.<br>
|
* can coexist and share the main memory.<br>
|
||||||
* This allocator, alone, is also useful for very simple applications
|
* This allocator, alone, is also useful for very simple
|
||||||
* that just require a simple way to get memory blocks.
|
* 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
|
* @pre In order to use the core memory manager APIs the @p CH_USE_MEMCORE
|
||||||
* option must be enabled in @p chconf.h.
|
* option must be enabled in @p chconf.h.
|
||||||
* @{
|
* @{
|
||||||
|
@ -57,22 +59,20 @@ void core_init(void) {
|
||||||
#if CH_MEMCORE_SIZE == 0
|
#if CH_MEMCORE_SIZE == 0
|
||||||
extern uint8_t __heap_base__;
|
extern uint8_t __heap_base__;
|
||||||
extern uint8_t __heap_end__;
|
extern uint8_t __heap_end__;
|
||||||
nextmem = &__heap_base__;
|
nextmem = (uint8_t *)MEM_ALIGN_NEXT(&__heap_base__);
|
||||||
endmem = &__heap_end__;
|
endmem = (uint8_t *)MEM_ALIGN_PREV(&__heap_end__);
|
||||||
#else
|
#else
|
||||||
static stkalign_t buffer[MEM_ALIGN_SIZE(CH_MEMCORE_SIZE) /
|
static stkalign_t buffer[MEM_ALIGN_NEXT(CH_MEMCORE_SIZE)/MEM_ALIGN_SIZE];
|
||||||
sizeof(stkalign_t)];
|
|
||||||
nextmem = (uint8_t *)&buffer[0];
|
nextmem = (uint8_t *)&buffer[0];
|
||||||
endmem = (uint8_t *)&buffer[MEM_ALIGN_SIZE(CH_MEMCORE_SIZE) /
|
endmem = (uint8_t *)&buffer[MEM_ALIGN_NEXT(CH_MEMCORE_SIZE)/MEM_ALIGN_SIZE];
|
||||||
sizeof(stkalign_t)];
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Allocates a memory block.
|
* @brief Allocates a memory block.
|
||||||
* @details The size of the returned block is aligned to the alignment
|
* @details The size of the returned block is aligned to the alignment
|
||||||
* type @p stkalign_t so it is not possible to allocate less
|
* type so it is not possible to allocate less
|
||||||
* than <code>sizeof(stkalign_t)</code>.
|
* than <code>MEM_ALIGN_SIZE</code>.
|
||||||
*
|
*
|
||||||
* @param[in] size the size of the block to be allocated
|
* @param[in] size the size of the block to be allocated
|
||||||
* @return A pointer to the allocated memory block.
|
* @return A pointer to the allocated memory block.
|
||||||
|
@ -92,8 +92,8 @@ void *chCoreAlloc(size_t size) {
|
||||||
/**
|
/**
|
||||||
* @brief Allocates a memory block.
|
* @brief Allocates a memory block.
|
||||||
* @details The size of the returned block is aligned to the alignment
|
* @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
|
* type so it is not possible to allocate less than
|
||||||
* <code>sizeof(align_t)</code>.
|
* <code>MEM_ALIGN_SIZE</code>.
|
||||||
*
|
*
|
||||||
* @param[in] size the size of the block to be allocated.
|
* @param[in] size the size of the block to be allocated.
|
||||||
* @return A pointer to the allocated memory block.
|
* @return A pointer to the allocated memory block.
|
||||||
|
@ -104,7 +104,7 @@ void *chCoreAlloc(size_t size) {
|
||||||
void *chCoreAllocI(size_t size) {
|
void *chCoreAllocI(size_t size) {
|
||||||
void *p;
|
void *p;
|
||||||
|
|
||||||
size = MEM_ALIGN_SIZE(size);
|
size = MEM_ALIGN_NEXT(size);
|
||||||
if ((size_t)(endmem - nextmem) < size)
|
if ((size_t)(endmem - nextmem) < size)
|
||||||
return NULL;
|
return NULL;
|
||||||
p = nextmem;
|
p = nextmem;
|
||||||
|
|
|
@ -55,7 +55,7 @@ void chPoolInit(MemoryPool *mp, size_t size, memgetfunc_t provider) {
|
||||||
chDbgCheck((mp != NULL) && (size >= sizeof(void *)), "chPoolInit");
|
chDbgCheck((mp != NULL) && (size >= sizeof(void *)), "chPoolInit");
|
||||||
|
|
||||||
mp->mp_next = NULL;
|
mp->mp_next = NULL;
|
||||||
mp->mp_object_size = MEM_ALIGN_SIZE(size);
|
mp->mp_object_size = MEM_ALIGN_NEXT(size);
|
||||||
mp->mp_provider = provider;
|
mp->mp_provider = provider;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -69,8 +69,13 @@
|
||||||
*****************************************************************************
|
*****************************************************************************
|
||||||
|
|
||||||
*** 2.3.0 ***
|
*** 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
|
- 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
|
- FIX: Stack overflow in CM0 ports when nearing interrupts saturation (bug
|
||||||
3187105)(backported to 2.2.1).
|
3187105)(backported to 2.2.1).
|
||||||
- FIX: Fixed error in _BSEMAPHORE_DATA macro (bug 3184139)(backported to
|
- FIX: Fixed error in _BSEMAPHORE_DATA macro (bug 3184139)(backported to
|
||||||
|
|
2
todo.txt
2
todo.txt
|
@ -37,7 +37,7 @@ X Transactional flash file system implementation.
|
||||||
X I2C device driver class support and at least one implementation.
|
X I2C device driver class support and at least one implementation.
|
||||||
X Shared DMA channels support in the STM32/STM8L HALs.
|
X Shared DMA channels support in the STM32/STM8L HALs.
|
||||||
X RAM ISR vectors support in the STM32 HAL.
|
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
|
Later but within 2.x.x
|
||||||
- Batch testing of the ARM7/ARMCMx port using OpenOCD, with reports.
|
- Batch testing of the ARM7/ARMCMx port using OpenOCD, with reports.
|
||||||
|
|
Loading…
Reference in New Issue