aboutsummaryrefslogtreecommitdiffstats
path: root/os/kernel/src/chmemcore.c
diff options
context:
space:
mode:
authorbarthess <barthess@35acf78f-673a-0410-8e92-d51de3d6d3f4>2011-06-07 14:34:59 +0000
committerbarthess <barthess@35acf78f-673a-0410-8e92-d51de3d6d3f4>2011-06-07 14:34:59 +0000
commit5cad241306f64d0a3c0f7829421e4bf8f4b18fbe (patch)
treeebbcad6d0cdb19fa5ef0bf5f6dc5cf80dfbdc4d1 /os/kernel/src/chmemcore.c
parent152f34a80c6ffe5fd17809732272823091b854e8 (diff)
parentaec912f13f9aa85cd677353fa556f679c3832970 (diff)
downloadChibiOS-5cad241306f64d0a3c0f7829421e4bf8f4b18fbe.tar.gz
ChibiOS-5cad241306f64d0a3c0f7829421e4bf8f4b18fbe.tar.bz2
ChibiOS-5cad241306f64d0a3c0f7829421e4bf8f4b18fbe.zip
I2C. Merged code from trunk.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/i2c_dev@3036 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/kernel/src/chmemcore.c')
-rw-r--r--os/kernel/src/chmemcore.c47
1 files changed, 24 insertions, 23 deletions
diff --git a/os/kernel/src/chmemcore.c b/os/kernel/src/chmemcore.c
index 69d3014a5..311d170c5 100644
--- a/os/kernel/src/chmemcore.c
+++ b/os/kernel/src/chmemcore.c
@@ -1,5 +1,6 @@
/*
- ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010 Giovanni Di Sirio.
+ ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010,
+ 2011 Giovanni Di Sirio.
This file is part of ChibiOS/RT.
@@ -24,18 +25,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.
* @{
@@ -53,26 +56,24 @@ static uint8_t *endmem;
*
* @notapi
*/
-void core_init(void) {
+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__;
+ extern uint8_t __heap_base__[];
+ extern uint8_t __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 +93,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 +105,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;