2009-10-11 19:43:13 +00:00
|
|
|
/*
|
2011-03-18 18:38:08 +00:00
|
|
|
ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010,
|
2014-07-26 09:06:28 +00:00
|
|
|
2011,2012,2013,2014 Giovanni Di Sirio.
|
2009-10-11 19:43:13 +00:00
|
|
|
|
|
|
|
This file is part of ChibiOS/RT.
|
|
|
|
|
|
|
|
ChibiOS/RT is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
ChibiOS/RT is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2010-02-27 08:54:22 +00:00
|
|
|
* @file chmemcore.h
|
2010-02-06 12:31:09 +00:00
|
|
|
* @brief Core memory manager macros and structures.
|
|
|
|
*
|
2009-10-16 17:45:19 +00:00
|
|
|
* @addtogroup memcore
|
2009-10-11 19:43:13 +00:00
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
2010-02-27 08:54:22 +00:00
|
|
|
#ifndef _CHMEMCORE_H_
|
|
|
|
#define _CHMEMCORE_H_
|
2009-10-11 19:43:13 +00:00
|
|
|
|
2013-07-20 10:12:44 +00:00
|
|
|
#if CH_CFG_USE_MEMCORE || defined(__DOXYGEN__)
|
2013-07-19 14:51:35 +00:00
|
|
|
|
|
|
|
/*===========================================================================*/
|
|
|
|
/* Module constants. */
|
|
|
|
/*===========================================================================*/
|
|
|
|
|
|
|
|
/*===========================================================================*/
|
|
|
|
/* Module pre-compile time settings. */
|
|
|
|
/*===========================================================================*/
|
|
|
|
|
|
|
|
/*===========================================================================*/
|
|
|
|
/* Derived constants and error checks. */
|
|
|
|
/*===========================================================================*/
|
|
|
|
|
|
|
|
/*===========================================================================*/
|
|
|
|
/* Module data structures and types. */
|
|
|
|
/*===========================================================================*/
|
|
|
|
|
2009-10-16 17:45:19 +00:00
|
|
|
/**
|
2010-02-06 12:31:09 +00:00
|
|
|
* @brief Memory get function.
|
|
|
|
* @note This type must be assignment compatible with the @p chMemAlloc()
|
|
|
|
* function.
|
2009-10-16 17:45:19 +00:00
|
|
|
*/
|
|
|
|
typedef void *(*memgetfunc_t)(size_t size);
|
|
|
|
|
2013-07-19 14:51:35 +00:00
|
|
|
/*===========================================================================*/
|
|
|
|
/* Module macros. */
|
|
|
|
/*===========================================================================*/
|
|
|
|
|
2011-08-22 17:18:52 +00:00
|
|
|
/**
|
|
|
|
* @name Alignment support macros
|
|
|
|
*/
|
2011-02-24 14:57:38 +00:00
|
|
|
/**
|
|
|
|
* @brief Alignment size constant.
|
|
|
|
*/
|
|
|
|
#define MEM_ALIGN_SIZE sizeof(stkalign_t)
|
|
|
|
|
2009-10-11 19:43:13 +00:00
|
|
|
/**
|
2010-02-06 12:31:09 +00:00
|
|
|
* @brief Alignment mask constant.
|
2009-10-11 19:43:13 +00:00
|
|
|
*/
|
2011-02-24 14:57:38 +00:00
|
|
|
#define MEM_ALIGN_MASK (MEM_ALIGN_SIZE - 1)
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Alignment helper macro.
|
|
|
|
*/
|
|
|
|
#define MEM_ALIGN_PREV(p) ((size_t)(p) & ~MEM_ALIGN_MASK)
|
2009-10-11 19:43:13 +00:00
|
|
|
|
|
|
|
/**
|
2010-02-06 12:31:09 +00:00
|
|
|
* @brief Alignment helper macro.
|
2009-10-11 19:43:13 +00:00
|
|
|
*/
|
2011-02-24 14:57:38 +00:00
|
|
|
#define MEM_ALIGN_NEXT(p) MEM_ALIGN_PREV((size_t)(p) + MEM_ALIGN_MASK)
|
2009-10-16 17:45:19 +00:00
|
|
|
|
|
|
|
/**
|
2010-02-06 12:31:09 +00:00
|
|
|
* @brief Returns whatever a pointer or memory size is aligned to
|
|
|
|
* the type @p align_t.
|
2009-10-16 17:45:19 +00:00
|
|
|
*/
|
|
|
|
#define MEM_IS_ALIGNED(p) (((size_t)(p) & MEM_ALIGN_MASK) == 0)
|
2011-08-22 17:18:52 +00:00
|
|
|
/** @} */
|
2009-10-11 19:43:13 +00:00
|
|
|
|
2013-07-19 14:51:35 +00:00
|
|
|
/*===========================================================================*/
|
|
|
|
/* External declarations. */
|
|
|
|
/*===========================================================================*/
|
2009-10-17 09:21:59 +00:00
|
|
|
|
2009-10-11 19:43:13 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
2011-03-29 14:51:08 +00:00
|
|
|
void _core_init(void);
|
2009-10-16 17:45:19 +00:00
|
|
|
void *chCoreAlloc(size_t size);
|
|
|
|
void *chCoreAllocI(size_t size);
|
2014-11-19 10:43:27 +00:00
|
|
|
size_t chCoreGetStatusX(void);
|
2009-10-11 19:43:13 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2013-07-19 14:51:35 +00:00
|
|
|
/*===========================================================================*/
|
|
|
|
/* Module inline functions. */
|
|
|
|
/*===========================================================================*/
|
|
|
|
|
2013-07-20 10:12:44 +00:00
|
|
|
#endif /* CH_CFG_USE_MEMCORE */
|
2009-10-11 19:43:13 +00:00
|
|
|
|
2010-02-27 08:54:22 +00:00
|
|
|
#endif /* _CHMEMCORE_H_ */
|
2009-10-11 19:43:13 +00:00
|
|
|
|
|
|
|
/** @} */
|