aboutsummaryrefslogtreecommitdiffstats
path: root/os
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2010-02-03 18:40:10 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2010-02-03 18:40:10 +0000
commit217d1529c1a126054fbdb9e071cd103194fd499e (patch)
tree0212fbc965624d57f2d69da9d1cb8008b445c6a7 /os
parente32275f84af6e07cbe737262ce90c75f69b9a1c1 (diff)
downloadChibiOS-217d1529c1a126054fbdb9e071cd103194fd499e.tar.gz
ChibiOS-217d1529c1a126054fbdb9e071cd103194fd499e.tar.bz2
ChibiOS-217d1529c1a126054fbdb9e071cd103194fd499e.zip
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1564 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os')
-rw-r--r--os/kernel/include/memcore.h1
-rw-r--r--os/kernel/src/chmemcore.c30
-rw-r--r--os/kernel/src/chregistry.c2
3 files changed, 22 insertions, 11 deletions
diff --git a/os/kernel/include/memcore.h b/os/kernel/include/memcore.h
index 7c11e03c3..d9675f1db 100644
--- a/os/kernel/include/memcore.h
+++ b/os/kernel/include/memcore.h
@@ -64,6 +64,7 @@ extern "C" {
void core_init(void);
void *chCoreAlloc(size_t size);
void *chCoreAllocI(size_t size);
+ size_t chCoreFree(void);
#ifdef __cplusplus
}
#endif
diff --git a/os/kernel/src/chmemcore.c b/os/kernel/src/chmemcore.c
index 65962bde1..6cf42788b 100644
--- a/os/kernel/src/chmemcore.c
+++ b/os/kernel/src/chmemcore.c
@@ -32,9 +32,8 @@ static uint8_t *nextmem;
static uint8_t *endmem;
/**
- * @brief Low level memory manager initialization.
- *
- * @note Internal use only.
+ * @brief Low level memory manager initialization.
+ * @note Internal use only.
*/
void core_init(void) {
#if CH_MEMCORE_SIZE == 0
@@ -50,15 +49,15 @@ void core_init(void) {
}
/**
- * @brief Allocates a memory block.
+ * @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>.
*
*
- * @param[in] size the size of the block to be allocated
- * @return A pointer to the allocated memory block.
- * @retval NULL allocation failed, core memory exhausted.
+ * @param[in] size the size of the block to be allocated
+ * @return A pointer to the allocated memory block.
+ * @retval NULL allocation failed, core memory exhausted.
*/
void *chCoreAlloc(size_t size) {
void *p;
@@ -70,14 +69,14 @@ 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
* type @p align_t so it is not possible to allocate less than
* <code>sizeof(align_t)</code>.
*
- * @param[in] size the size of the block to be allocated.
- * @return A pointer to the allocated memory block.
- * @retval NULL allocation failed, core memory exhausted.
+ * @param[in] size the size of the block to be allocated.
+ * @return A pointer to the allocated memory block.
+ * @retval NULL allocation failed, core memory exhausted.
*/
void *chCoreAllocI(size_t size) {
void *p;
@@ -90,6 +89,15 @@ void *chCoreAllocI(size_t size) {
return p;
}
+/**
+ * @brief Core memory left.
+ *
+ * @return The size, in bytes, of the free core memory.
+ */
+size_t chCoreFree(void) {
+
+ return (size_t)(endmem - nextmem);
+}
#endif /* CH_USE_MEMCORE */
/** @} */
diff --git a/os/kernel/src/chregistry.c b/os/kernel/src/chregistry.c
index 186d97e35..b02d5f1fb 100644
--- a/os/kernel/src/chregistry.c
+++ b/os/kernel/src/chregistry.c
@@ -33,6 +33,8 @@
* the main thread unless it terminated.
* @note A reference is added to the returned thread in order to make sure
* it status is not lost.
+ * @note This function cannot return @p NULL because there is always at
+ * least one thread in the system.
*
* @return A reference to the first thread.
*/