diff options
37 files changed, 898 insertions, 711 deletions
diff --git a/demos/ARMCM4-STM32F303-DISCOVERY/chconf.h b/demos/ARMCM4-STM32F303-DISCOVERY/chconf.h index 7b8a8389b..0e93aa661 100644 --- a/demos/ARMCM4-STM32F303-DISCOVERY/chconf.h +++ b/demos/ARMCM4-STM32F303-DISCOVERY/chconf.h @@ -303,20 +303,6 @@ #endif
/**
- * @brief C-runtime allocator.
- * @details If enabled the the heap allocator APIs just wrap the C-runtime
- * @p malloc() and @p free() functions.
- *
- * @note The default is @p FALSE.
- * @note Requires @p CH_USE_HEAP.
- * @note The C-runtime may or may not require @p CH_USE_MEMCORE, see the
- * appropriate documentation.
- */
-#if !defined(CH_USE_MALLOC_HEAP) || defined(__DOXYGEN__)
-#define CH_USE_MALLOC_HEAP FALSE
-#endif
-
-/**
* @brief Memory Pools Allocator APIs.
* @details If enabled then the memory pools allocator APIs are included
* in the kernel.
diff --git a/os/hal/include/io_channel.h b/os/hal/include/io_channel.h index af90b431e..b0c21a9ee 100644 --- a/os/hal/include/io_channel.h +++ b/os/hal/include/io_channel.h @@ -230,7 +230,7 @@ typedef struct { #define _base_asynchronous_channel_data \
_base_channel_data \
/* I/O condition event source.*/ \
- EventSource event;
+ event_source_t event;
/**
* @extends BaseChannelVMT
@@ -264,11 +264,11 @@ typedef struct { *
* @param[in] ip pointer to a @p BaseAsynchronousChannel or derived
* class
- * @return A pointer to an @p EventSource object.
+ * @return A pointer to an @p event_source_t object.
*
* @api
*/
-#define chnGetEventSource(ip) (&((ip)->event))
+#define chnGetevent_source_t(ip) (&((ip)->event))
/**
* @brief Adds status flags to the listeners's flags mask.
diff --git a/os/hal/platforms/STM32/USARTv2/serial_lld.c b/os/hal/platforms/STM32/USARTv2/serial_lld.c index 5209c499b..85f6b059c 100644 --- a/os/hal/platforms/STM32/USARTv2/serial_lld.c +++ b/os/hal/platforms/STM32/USARTv2/serial_lld.c @@ -124,7 +124,7 @@ static void usart_deinit(USART_TypeDef *u) { * @param[in] isr USART ISR register value
*/
static void set_error(SerialDriver *sdp, uint32_t isr) {
- flagsmask_t sts = 0;
+ eventflags_t sts = 0;
if (isr & USART_ISR_ORE)
sts |= SD_OVERRUN_ERROR;
diff --git a/os/kernel/include/ch.h b/os/kernel/include/ch.h index 1237a3ae9..a7cafb581 100644 --- a/os/kernel/include/ch.h +++ b/os/kernel/include/ch.h @@ -128,19 +128,6 @@ typedef struct thread thread_t; #include "chdynamic.h"
#include "chqueues.h"
#include "chstreams.h"
-#include "chfiles.h"
-
-#if !defined(__DOXYGEN__)
-extern WORKING_AREA(_idle_thread_wa, PORT_IDLE_THREAD_STACK_SIZE);
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
- void _idle_thread(void *p);
-#ifdef __cplusplus
-}
-#endif
#endif /* _CH_H_ */
diff --git a/os/kernel/include/chdynamic.h b/os/kernel/include/chdynamic.h index a8ba91a86..752fee90c 100644 --- a/os/kernel/include/chdynamic.h +++ b/os/kernel/include/chdynamic.h @@ -74,11 +74,11 @@ extern "C" { thread_t *chThdAddRef(thread_t *tp);
void chThdRelease(thread_t *tp);
#if CH_USE_HEAP
- thread_t *chThdCreateFromHeap(MemoryHeap *heapp, size_t size,
+ thread_t *chThdCreateFromHeap(memory_heap_t *heapp, size_t size,
tprio_t prio, tfunc_t pf, void *arg);
#endif
#if CH_USE_MEMPOOLS
- thread_t *chThdCreateFromMemoryPool(MemoryPool *mp, tprio_t prio,
+ thread_t *chThdCreateFromMemoryPool(memory_pool_t *mp, tprio_t prio,
tfunc_t pf, void *arg);
#endif
#ifdef __cplusplus
diff --git a/os/kernel/include/chevents.h b/os/kernel/include/chevents.h index 2cedea7b9..4fe072050 100644 --- a/os/kernel/include/chevents.h +++ b/os/kernel/include/chevents.h @@ -50,32 +50,30 @@ /* Module data structures and types. */
/*===========================================================================*/
-typedef struct EventListener EventListener;
+typedef struct event_listener event_listener_t;
/**
* @brief Event Listener structure.
*/
-struct EventListener {
- EventListener *el_next; /**< @brief Next Event Listener
- registered on the Event
- Source. */
+struct event_listener {
+ event_listener_t *el_next; /**< @brief Next Event Listener
+ registered on the event
+ source. */
thread_t *el_listener; /**< @brief Thread interested in the
- Event Source. */
- eventmask_t el_mask; /**< @brief Event flags mask associated
- by the thread to the Event
- Source. */
- flagsmask_t el_flags; /**< @brief Flags added to the listener
+ event source. */
+ eventmask_t el_mask; /**< @brief Event identifiers mask. */
+ eventflags_t el_flags; /**< @brief Flags added to the listener
by the event source.*/
};
/**
* @brief Event Source structure.
*/
-typedef struct EventSource {
- EventListener *es_next; /**< @brief First Event Listener
+typedef struct event_source {
+ event_listener_t *es_next; /**< @brief First Event Listener
registered on the Event
Source. */
-} EventSource;
+} event_source_t;
/**
* @brief Event Handler callback function.
@@ -111,7 +109,7 @@ typedef void (*evhandler_t)(eventid_t); *
* @param name the name of the event source variable
*/
-#define EVENTSOURCE_DECL(name) EventSource name = _EVENTSOURCE_DATA(name)
+#define EVENTSOURCE_DECL(name) event_source_t name = _EVENTSOURCE_DATA(name)
/*===========================================================================*/
/* External declarations. */
@@ -120,18 +118,18 @@ typedef void (*evhandler_t)(eventid_t); #ifdef __cplusplus
extern "C" {
#endif
- void chEvtRegisterMask(EventSource *esp,
- EventListener *elp,
+ void chEvtRegisterMask(event_source_t *esp,
+ event_listener_t *elp,
eventmask_t mask);
- void chEvtUnregister(EventSource *esp, EventListener *elp);
+ void chEvtUnregister(event_source_t *esp, event_listener_t *elp);
eventmask_t chEvtGetAndClearEvents(eventmask_t mask);
eventmask_t chEvtAddEvents(eventmask_t mask);
- flagsmask_t chEvtGetAndClearFlags(EventListener *elp);
- flagsmask_t chEvtGetAndClearFlagsI(EventListener *elp);
+ eventflags_t chEvtGetAndClearFlags(event_listener_t *elp);
+ eventflags_t chEvtGetAndClearFlagsI(event_listener_t *elp);
void chEvtSignal(thread_t *tp, eventmask_t mask);
void chEvtSignalI(thread_t *tp, eventmask_t mask);
- void chEvtBroadcastFlags(EventSource *esp, flagsmask_t flags);
- void chEvtBroadcastFlagsI(EventSource *esp, flagsmask_t flags);
+ void chEvtBroadcastFlags(event_source_t *esp, eventflags_t flags);
+ void chEvtBroadcastFlagsI(event_source_t *esp, eventflags_t flags);
void chEvtDispatch(const evhandler_t *handlers, eventmask_t mask);
#if CH_OPTIMIZE_SPEED || !CH_USE_EVENTS_TIMEOUT
eventmask_t chEvtWaitOne(eventmask_t mask);
@@ -160,15 +158,15 @@ extern "C" { /**
* @brief Initializes an Event Source.
* @note This function can be invoked before the kernel is initialized
- * because it just prepares a @p EventSource structure.
+ * because it just prepares a @p event_source_t structure.
*
- * @param[in] esp pointer to the @p EventSource structure
+ * @param[in] esp pointer to the @p event_source_t structure
*
* @init
*/
-static inline void chEvtInit(EventSource *esp) {
+static inline void chEvtInit(event_source_t *esp) {
- esp->es_next = (EventListener *)(void *)esp;
+ esp->es_next = (event_listener_t *)(void *)esp;
}
/**
@@ -176,8 +174,8 @@ static inline void chEvtInit(EventSource *esp) { * @note Multiple Event Listeners can use the same event identifier, the
* listener will share the callback function.
*
- * @param[in] esp pointer to the @p EventSource structure
- * @param[out] elp pointer to the @p EventListener structure
+ * @param[in] esp pointer to the @p event_source_t structure
+ * @param[out] elp pointer to the @p event_listener_t structure
* @param[in] eid numeric identifier assigned to the Event Listener. The
* identifier is used as index for the event callback
* function.
@@ -186,21 +184,21 @@ static inline void chEvtInit(EventSource *esp) { *
* @api
*/
-static inline void chEvtRegister(EventSource *esp,
- EventListener *elp,
+static inline void chEvtRegister(event_source_t *esp,
+ event_listener_t *elp,
eventid_t eid) {
chEvtRegisterMask(esp, elp, EVENT_MASK(eid));
}
/**
- * @brief Verifies if there is at least one @p EventListener registered.
+ * @brief Verifies if there is at least one @p event_listener_t registered.
*
- * @param[in] esp pointer to the @p EventSource structure
+ * @param[in] esp pointer to the @p event_source_t structure
*
* @iclass
*/
-static inline bool chEvtIsListeningI(EventSource *esp) {
+static inline bool chEvtIsListeningI(event_source_t *esp) {
return (bool)((void *)esp != (void *)esp->es_next);
}
@@ -209,11 +207,11 @@ static inline bool chEvtIsListeningI(EventSource *esp) { * @brief Signals all the Event Listeners registered on the specified Event
* Source.
*
- * @param[in] esp pointer to the @p EventSource structure
+ * @param[in] esp pointer to the @p event_source_t structure
*
* @api
*/
-static inline void chEvtBroadcast(EventSource *esp) {
+static inline void chEvtBroadcast(event_source_t *esp) {
chEvtBroadcastFlags(esp, 0);
}
@@ -226,11 +224,11 @@ static inline void chEvtBroadcast(EventSource *esp) { * interrupt handlers always reschedule on exit so an explicit
* reschedule must not be performed in ISRs.
*
- * @param[in] esp pointer to the @p EventSource structure
+ * @param[in] esp pointer to the @p event_source_t structure
*
* @iclass
*/
-static inline void chEvtBroadcastI(EventSource *esp) {
+static inline void chEvtBroadcastI(event_source_t *esp) {
chEvtBroadcastFlagsI(esp, 0);
}
diff --git a/os/kernel/include/chfiles.h b/os/kernel/include/chfiles.h deleted file mode 100644 index ad2974ad8..000000000 --- a/os/kernel/include/chfiles.h +++ /dev/null @@ -1,165 +0,0 @@ -/*
- ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010,
- 2011,2012,2013 Giovanni Di Sirio.
-
- 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/>.
-*/
-
-/**
- * @file chfiles.h
- * @brief Data files.
- * @details This header defines abstract interfaces useful to access generic
- * data files in a standardized way.
- *
- * @addtogroup data_files
- * @details This module define an abstract interface for generic data files by
- * extending the @p BaseSequentialStream interface. Note that no code
- * is present, data files are just abstract interface-like structures,
- * you should look at the systems as to a set of abstract C++ classes
- * (even if written in C). This system has the advantage to make the
- * access to streams independent from the implementation logic.<br>
- * The data files interface can be used as base class for high level
- * object types such as an API for a File System implementation.
- * @{
- */
-
-#ifndef _CHFILES_H_
-#define _CHFILES_H_
-
-/**
- * @brief No error return code.
- */
-#define FILE_OK 0
-
-/**
- * @brief Error code from the file stream methods.
- */
-#define FILE_ERROR 0xFFFFFFFFUL
-
-/**
- * @brief File offset type.
- */
-typedef uint32_t fileoffset_t;
-
-/**
- * @brief BaseFileStream specific methods.
- */
-#define _base_file_stream_methods \
- _base_sequential_stream_methods \
- /* File close method.*/ \
- uint32_t (*close)(void *instance); \
- /* Get last error code method.*/ \
- int (*geterror)(void *instance); \
- /* File get size method.*/ \
- fileoffset_t (*getsize)(void *instance); \
- /* File get current position method.*/ \
- fileoffset_t (*getposition)(void *instance); \
- /* File seek method.*/ \
- uint32_t (*lseek)(void *instance, fileoffset_t offset);
-
-/**
- * @brief @p BaseFileStream specific data.
- * @note It is empty because @p BaseFileStream is only an interface
- * without implementation.
- */
-#define _base_file_stream_data \
- _base_sequential_stream_data
-
-/**
- * @extends BaseSequentialStreamVMT
- *
- * @brief @p BaseFileStream virtual methods table.
- */
-struct BaseFileStreamVMT {
- _base_file_stream_methods
-};
-
-/**
- * @extends BaseSequentialStream
- *
- * @brief Base file stream class.
- * @details This class represents a generic file data stream.
- */
-typedef struct {
- /** @brief Virtual Methods Table.*/
- const struct BaseFileStreamVMT *vmt;
- _base_file_stream_data
-} BaseFileStream;
-
-/**
- * @name Macro Functions (BaseFileStream)
- * @{
- */
-/**
- * @brief Base file Stream close.
- * @details The function closes a file stream.
- *
- * @param[in] ip pointer to a @p BaseFileStream or derived class
- * @return The operation status.
- * @retval FILE_OK no error.
- * @retval FILE_ERROR operation failed.
- *
- * @api
- */
-#define chFileStreamClose(ip) ((ip)->vmt->close(ip))
-
-/**
- * @brief Returns an implementation dependent error code.
- *
- * @param[in] ip pointer to a @p BaseFileStream or derived class
- * @return Implementation dependent error code.
- *
- * @api
- */
-#define chFileStreamGetError(ip) ((ip)->vmt->geterror(ip))
-
-/**
- * @brief Returns the current file size.
- *
- * @param[in] ip pointer to a @p BaseFileStream or derived class
- * @return The file size.
- *
- * @api
- */
-#define chFileStreamGetSize(ip) ((ip)->vmt->getsize(ip))
-
-/**
- * @brief Returns the current file pointer position.
- *
- * @param[in] ip pointer to a @p BaseFileStream or derived class
- * @return The current position inside the file.
- *
- * @api
- */
-#define chFileStreamGetPosition(ip) ((ip)->vmt->getposition(ip))
-
-/**
- * @brief Moves the file current pointer to an absolute position.
- *
- * @param[in] ip pointer to a @p BaseFileStream or derived class
- * @param[in] offset new absolute position
- * @return The operation status.
- * @retval FILE_OK no error.
- * @retval FILE_ERROR operation failed.
- *
- * @api
- */
-#define chFileStreamSeek(ip, offset) ((ip)->vmt->lseek(ip, offset))
-/** @} */
-
-#endif /* _CHFILES_H_ */
-
-/** @} */
diff --git a/os/kernel/include/chheap.h b/os/kernel/include/chheap.h index 8a54d7290..03c1643ab 100644 --- a/os/kernel/include/chheap.h +++ b/os/kernel/include/chheap.h @@ -31,18 +31,34 @@ #if CH_USE_HEAP || defined(__DOXYGEN__)
-/*
- * Module dependencies check.
- */
-#if !CH_USE_MEMCORE && !CH_USE_MALLOC_HEAP
-#error "CH_USE_HEAP requires CH_USE_MEMCORE or CH_USE_MALLOC_HEAP"
+/*===========================================================================*/
+/* Module constants. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module pre-compile time settings. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Derived constants and error checks. */
+/*===========================================================================*/
+
+#if !CH_USE_MEMCORE
+#error "CH_USE_HEAP requires CH_USE_MEMCORE"
#endif
#if !CH_USE_MUTEXES && !CH_USE_SEMAPHORES
#error "CH_USE_HEAP requires CH_USE_MUTEXES and/or CH_USE_SEMAPHORES"
#endif
-typedef struct memory_heap MemoryHeap;
+/*===========================================================================*/
+/* Module data structures and types. */
+/*===========================================================================*/
+
+/**
+ * @brief Type of a memory heap.
+ */
+typedef struct memory_heap memory_heap_t;
/**
* @brief Memory heap block header.
@@ -52,7 +68,7 @@ union heap_header { struct {
union {
union heap_header *next; /**< @brief Next block in free list. */
- MemoryHeap *heap; /**< @brief Block owner heap. */
+ memory_heap_t *heap; /**< @brief Block owner heap. */
} u; /**< @brief Overlapped fields. */
size_t size; /**< @brief Size of the memory block. */
} h;
@@ -66,26 +82,36 @@ struct memory_heap { this heap. */
union heap_header h_free; /**< @brief Free blocks list header. */
#if CH_USE_MUTEXES
- Mutex h_mtx; /**< @brief Heap access mutex. */
+ mutex_t h_mtx; /**< @brief Heap access mutex. */
#else
- Semaphore h_sem; /**< @brief Heap access semaphore. */
+ semaphore_t h_sem; /**< @brief Heap access semaphore. */
#endif
};
+/*===========================================================================*/
+/* Module macros. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* External declarations. */
+/*===========================================================================*/
+
#ifdef __cplusplus
extern "C" {
#endif
void _heap_init(void);
-#if !CH_USE_MALLOC_HEAP
- void chHeapInit(MemoryHeap *heapp, void *buf, size_t size);
-#endif
- void *chHeapAlloc(MemoryHeap *heapp, size_t size);
+ void chHeapInit(memory_heap_t *heapp, void *buf, size_t size);
+ void *chHeapAlloc(memory_heap_t *heapp, size_t size);
void chHeapFree(void *p);
- size_t chHeapStatus(MemoryHeap *heapp, size_t *sizep);
+ size_t chHeapStatus(memory_heap_t *heapp, size_t *sizep);
#ifdef __cplusplus
}
#endif
+/*===========================================================================*/
+/* Module inline functions. */
+/*===========================================================================*/
+
#endif /* CH_USE_HEAP */
#endif /* _CHHEAP_H_ */
diff --git a/os/kernel/include/chmboxes.h b/os/kernel/include/chmboxes.h index 388ef07a6..6cb903e82 100644 --- a/os/kernel/include/chmboxes.h +++ b/os/kernel/include/chmboxes.h @@ -31,13 +31,26 @@ #if CH_USE_MAILBOXES || defined(__DOXYGEN__)
-/*
- * Module dependencies check.
- */
+/*===========================================================================*/
+/* Module constants. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module pre-compile time settings. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Derived constants and error checks. */
+/*===========================================================================*/
+
#if !CH_USE_SEMAPHORES
#error "CH_USE_MAILBOXES requires CH_USE_SEMAPHORES"
#endif
+/*===========================================================================*/
+/* Module data structures and types. */
+/*===========================================================================*/
+
/**
* @brief Structure representing a mailbox object.
*/
@@ -52,39 +65,79 @@ typedef struct { @p semaphore_t. */
semaphore_t mb_emptysem; /**< @brief Empty counter
@p semaphore_t. */
-} Mailbox;
+} mailbox_t;
+
+/*===========================================================================*/
+/* Module macros. */
+/*===========================================================================*/
+
+/**
+ * @brief Data part of a static mailbox initializer.
+ * @details This macro should be used when statically initializing a
+ * mailbox that is part of a bigger structure.
+ *
+ * @param[in] name the name of the mailbox variable
+ * @param[in] buffer pointer to the mailbox buffer area
+ * @param[in] size size of the mailbox buffer area
+ */
+#define _MAILBOX_DATA(name, buffer, size) { \
+ (msg_t *)(buffer), \
+ (msg_t *)(buffer) + size, \
+ (msg_t *)(buffer), \
+ (msg_t *)(buffer), \
+ _SEMAPHORE_DATA(name.mb_fullsem, 0), \
+ _SEMAPHORE_DATA(name.mb_emptysem, size), \
+}
+
+/**
+ * @brief Static mailbox initializer.
+ * @details Statically initialized mailboxes require no explicit
+ * initialization using @p chMBInit().
+ *
+ * @param[in] name the name of the mailbox variable
+ * @param[in] buffer pointer to the mailbox buffer area
+ * @param[in] size size of the mailbox buffer area
+ */
+#define MAILBOX_DECL(name, buffer, size) \
+ mailbox_t name = _MAILBOX_DATA(name, buffer, size)
+
+/*===========================================================================*/
+/* External declarations. */
+/*===========================================================================*/
#ifdef __cplusplus
extern "C" {
#endif
- void chMBInit(Mailbox *mbp, msg_t *buf, cnt_t n);
- void chMBReset(Mailbox *mbp);
- msg_t chMBPost(Mailbox *mbp, msg_t msg, systime_t timeout);
- msg_t chMBPostS(Mailbox *mbp, msg_t msg, systime_t timeout);
- msg_t chMBPostI(Mailbox *mbp, msg_t msg);
- msg_t chMBPostAhead(Mailbox *mbp, msg_t msg, systime_t timeout);
- msg_t chMBPostAheadS(Mailbox *mbp, msg_t msg, systime_t timeout);
- msg_t chMBPostAheadI(Mailbox *mbp, msg_t msg);
- msg_t chMBFetch(Mailbox *mbp, msg_t *msgp, systime_t timeout);
- msg_t chMBFetchS(Mailbox *mbp, msg_t *msgp, systime_t timeout);
- msg_t chMBFetchI(Mailbox *mbp, msg_t *msgp);
+ void chMBInit(mailbox_t *mbp, msg_t *buf, cnt_t n);
+ void chMBReset(mailbox_t *mbp);
+ msg_t chMBPost(mailbox_t *mbp, msg_t msg, systime_t timeout);
+ msg_t chMBPostS(mailbox_t *mbp, msg_t msg, systime_t timeout);
+ msg_t chMBPostI(mailbox_t *mbp, msg_t msg);
+ msg_t chMBPostAhead(mailbox_t *mbp, msg_t msg, systime_t timeout);
+ msg_t chMBPostAheadS(mailbox_t *mbp, msg_t msg, systime_t timeout);
+ msg_t chMBPostAheadI(mailbox_t *mbp, msg_t msg);
+ msg_t chMBFetch(mailbox_t *mbp, msg_t *msgp, systime_t timeout);
+ msg_t chMBFetchS(mailbox_t *mbp, msg_t *msgp, systime_t timeout);
+ msg_t chMBFetchI(mailbox_t *mbp, msg_t *msgp);
#ifdef __cplusplus
}
#endif
-/**
- * @name Macro Functions
- * @{
- */
+/*===========================================================================*/
+/* Module inline functions. */
+/*===========================================================================*/
+
/**
* @brief Returns the mailbox buffer size.
*
- * @param[in] mbp the pointer to an initialized Mailbox object
+ * @param[in] mbp the pointer to an initialized mailbox_t object
*
* @iclass
*/
-#define chMBSizeI(mbp) \
- ((mbp)->mb_top - (mbp)->mb_buffer)
+static inline size_t chMBSizeI(mailbox_t *mbp) {
+
+ return (size_t)(mbp->mb_top - mbp->mb_buffer);
+}
/**
* @brief Returns the number of free message slots into a mailbox.
@@ -93,12 +146,17 @@ extern "C" { * @note The returned value can be less than zero when there are waiting
* threads on the internal semaphore.
*
- * @param[in] mbp the pointer to an initialized Mailbox object
+ * @param[in] mbp the pointer to an initialized mailbox_t object
* @return The number of empty message slots.
*
* @iclass
*/
-#define chMBGetFreeCountI(mbp) chSemGetCounterI(&(mbp)->mb_emptysem)
+static inline cnt_t chMBGetFreeCountI(mailbox_t *mbp) {
+
+ chDbgCheckClassI();
+
+ return chSemGetCounterI(&mbp->mb_emptysem);
+}
/**
* @brief Returns the number of used message slots into a mailbox.
@@ -107,12 +165,17 @@ extern "C" { * @note The returned value can be less than zero when there are waiting
* threads on the internal semaphore.
*
- * @param[in] mbp the pointer to an initialized Mailbox object
+ * @param[in] mbp the pointer to an initialized mailbox_t object
* @return The number of queued messages.
*
* @iclass
*/
-#define chMBGetUsedCountI(mbp) chSemGetCounterI(&(mbp)->mb_fullsem)
+static inline cnt_t chMBGetUsedCountI(mailbox_t *mbp) {
+
+ chDbgCheckClassI();
+
+ return chSemGetCounterI(&mbp->mb_fullsem);
+}
/**
* @brief Returns the next message in the queue without removing it.
@@ -123,38 +186,12 @@ extern "C" { *
* @iclass
*/
-#define chMBPeekI(mbp) (*(mbp)->mb_rdptr)
-/** @} */
+static inline cnt_t chMBPeekI(mailbox_t *mbp) {
-/**
- * @brief Data part of a static mailbox initializer.
- * @details This macro should be used when statically initializing a
- * mailbox that is part of a bigger structure.
- *
- * @param[in] name the name of the mailbox variable
- * @param[in] buffer pointer to the mailbox buffer area
- * @param[in] size size of the mailbox buffer area
- */
-#define _MAILBOX_DATA(name, buffer, size) { \
- (msg_t *)(buffer), \
- (msg_t *)(buffer) + size, \
- (msg_t *)(buffer), \
- (msg_t *)(buffer), \
- _SEMAPHORE_DATA(name.mb_fullsem, 0), \
- _SEMAPHORE_DATA(name.mb_emptysem, size), \
-}
+ chDbgCheckClassI();
-/**
- * @brief Static mailbox initializer.
- * @details Statically initialized mailboxes require no explicit
- * initialization using @p chMBInit().
- *
- * @param[in] name the name of the mailbox variable
- * @param[in] buffer pointer to the mailbox buffer area
- * @param[in] size size of the mailbox buffer area
- */
-#define MAILBOX_DECL(name, buffer, size) \
- Mailbox name = _MAILBOX_DATA(name, buffer, size)
+ return *mbp->mb_rdptr;
+}
#endif /* CH_USE_MAILBOXES */
diff --git a/os/kernel/include/chmemcore.h b/os/kernel/include/chmemcore.h index 4f75bd043..dbc5d5d60 100644 --- a/os/kernel/include/chmemcore.h +++ b/os/kernel/include/chmemcore.h @@ -29,6 +29,24 @@ #ifndef _CHMEMCORE_H_
#define _CHMEMCORE_H_
+#if CH_USE_MEMCORE || defined(__DOXYGEN__)
+
+/*===========================================================================*/
+/* Module constants. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module pre-compile time settings. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Derived constants and error checks. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module data structures and types. */
+/*===========================================================================*/
+
/**
* @brief Memory get function.
* @note This type must be assignment compatible with the @p chMemAlloc()
@@ -36,6 +54,10 @@ */
typedef void *(*memgetfunc_t)(size_t size);
+/*===========================================================================*/
+/* Module macros. */
+/*===========================================================================*/
+
/**
* @name Alignment support macros
*/
@@ -66,7 +88,9 @@ typedef void *(*memgetfunc_t)(size_t size); #define MEM_IS_ALIGNED(p) (((size_t)(p) & MEM_ALIGN_MASK) == 0)
/** @} */
-#if CH_USE_MEMCORE || defined(__DOXYGEN__)
+/*===========================================================================*/
+/* External declarations. */
+/*===========================================================================*/
#ifdef __cplusplus
extern "C" {
@@ -79,6 +103,10 @@ extern "C" { }
#endif
+/*===========================================================================*/
+/* Module inline functions. */
+/*===========================================================================*/
+
#endif /* CH_USE_MEMCORE */
#endif /* _CHMEMCORE_H_ */
diff --git a/os/kernel/include/chmempools.h b/os/kernel/include/chmempools.h index 80d6eeaf2..f211ec1d1 100644 --- a/os/kernel/include/chmempools.h +++ b/os/kernel/include/chmempools.h @@ -31,6 +31,26 @@ #if CH_USE_MEMPOOLS || defined(__DOXYGEN__)
+/*===========================================================================*/
+/* Module constants. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module pre-compile time settings. */
+/*===========================================================================*/
+
+#if !CH_USE_MEMCORE
+#error "CH_USE_MEMPOOLS requires CH_USE_MEMCORE"
+#endif
+
+/*===========================================================================*/
+/* Derived constants and error checks. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module data structures and types. */
+/*===========================================================================*/
+
/**
* @brief Memory pool free object header.
*/
@@ -46,9 +66,13 @@ typedef struct { struct pool_header *mp_next; /**< @brief Pointer to the header. */
size_t mp_object_size; /**< @brief Memory pool objects
size. */
- memgetfunc_t mp_provider; /**< @brief Memory blocks provider for
- this pool. */
-} MemoryPool;
+ memgetfunc_t mp_provider; /**< @brief Memory blocks provider
+ for this pool. */
+} memory_pool_t;
+
+/*===========================================================================*/
+/* Module macros. */
+/*===========================================================================*/
/**
* @brief Data part of a static memory pool initializer.
@@ -73,12 +97,29 @@ typedef struct { * if the pool is not allowed to grow automatically
*/
#define MEMORYPOOL_DECL(name, size, provider) \
- MemoryPool name = _MEMORYPOOL_DATA(name, size, provider)
+ memory_pool_t name = _MEMORYPOOL_DATA(name, size, provider)
+
+/*===========================================================================*/
+/* External declarations. */
+/*===========================================================================*/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+ void chPoolInit(memory_pool_t *mp, size_t size, memgetfunc_t provider);
+ void chPoolLoadArray(memory_pool_t *mp, void *p, size_t n);
+ void *chPoolAllocI(memory_pool_t *mp);
+ void *chPoolAlloc(memory_pool_t *mp);
+ void chPoolFreeI(memory_pool_t *mp, void *objp);
+ void chPoolFree(memory_pool_t *mp, void *objp);
+#ifdef __cplusplus
+}
+#endif
+
+/*===========================================================================*/
+/* Module inline functions. */
+/*===========================================================================*/
-/**
- * @name Macro Functions
- * @{
- */
/**
* @brief Adds an object to a memory pool.
* @pre The memory pool must be already been initialized.
@@ -89,12 +130,15 @@ typedef struct { * @note This function is just an alias for @p chPoolFree() and has been
* added for clarity.
*
- * @param[in] mp pointer to a @p MemoryPool structure
+ * @param[in] mp pointer to a @p memory_pool_t structure
* @param[in] objp the pointer to the object to be added
*
* @api
*/
-#define chPoolAdd(mp, objp) chPoolFree(mp, objp)
+static inline void chPoolAdd(memory_pool_t *mp, void *objp) {
+
+ chPoolFree(mp, objp);
+}
/**
* @brief Adds an object to a memory pool.
@@ -106,26 +150,17 @@ typedef struct { * @note This function is just an alias for @p chPoolFree() and has been
* added for clarity.
*
- * @param[in] mp pointer to a @p MemoryPool structure
+ * @param[in] mp pointer to a @p memory_pool_t structure
* @param[in] objp the pointer to the object to be added
*
* @iclass
*/
-#define chPoolAddI(mp, objp) chPoolFreeI(mp, objp)
-/** @} */
+static inline void chPoolAddI(memory_pool_t *mp, void *objp) {
-#ifdef __cplusplus
-extern "C" {
-#endif
- void chPoolInit(MemoryPool *mp, size_t size, memgetfunc_t provider);
- void chPoolLoadArray(MemoryPool *mp, void *p, size_t n);
- void *chPoolAllocI(MemoryPool *mp);
- void *chPoolAlloc(MemoryPool *mp);
- void chPoolFreeI(MemoryPool *mp, void *objp);
- void chPoolFree(MemoryPool *mp, void *objp);
-#ifdef __cplusplus
+ chDbgCheckClassI();
+
+ chPoolFreeI(mp, objp);
}
-#endif
#endif /* CH_USE_MEMPOOLS */
diff --git a/os/kernel/include/chmsg.h b/os/kernel/include/chmsg.h index be3103db9..1e9099c73 100644 --- a/os/kernel/include/chmsg.h +++ b/os/kernel/include/chmsg.h @@ -31,17 +31,55 @@ #if CH_USE_MESSAGES || defined(__DOXYGEN__)
-/**
- * @name Macro Functions
- * @{
- */
+/*===========================================================================*/
+/* Module constants. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module pre-compile time settings. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Derived constants and error checks. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module data structures and types. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module macros. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* External declarations. */
+/*===========================================================================*/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+ msg_t chMsgSend(thread_t *tp, msg_t msg);
+ thread_t * chMsgWait(void);
+ void chMsgRelease(thread_t *tp, msg_t msg);
+#ifdef __cplusplus
+}
+#endif
+
+/*===========================================================================*/
+/* External declarations. */
+/*===========================================================================*/
+
/**
* @brief Evaluates to TRUE if the thread has pending messages.
*
* @iclass
*/
-#define chMsgIsPendingI(tp) \
- ((tp)->p_msgqueue.p_next != (thread_t *)&(tp)->p_msgqueue)
+static inline bool chMsgIsPendingI(thread_t *tp) {
+
+ chDbgCheckClassI();
+
+ return (bool)(tp->p_msgqueue.p_next != (thread_t *)&tp->p_msgqueue);
+}
/**
* @brief Returns the message carried by the specified thread.
@@ -53,7 +91,10 @@ *
* @api
*/
-#define chMsgGet(tp) ((tp)->p_msg)
+static inline msg_t chMsgGet(thread_t *tp) {
+
+ return tp->p_msg;
+}
/**
* @brief Releases the thread waiting on top of the messages queue.
@@ -65,18 +106,12 @@ *
* @sclass
*/
-#define chMsgReleaseS(tp, msg) chSchWakeupS(tp, msg)
-/** @} */
+static inline void chMsgReleaseS(thread_t *tp, msg_t msg) {
-#ifdef __cplusplus
-extern "C" {
-#endif
- msg_t chMsgSend(thread_t *tp, msg_t msg);
- thread_t * chMsgWait(void);
- void chMsgRelease(thread_t *tp, msg_t msg);
-#ifdef __cplusplus
+ chDbgCheckClassS();
+
+ chSchWakeupS(tp, msg);
}
-#endif
#endif /* CH_USE_MESSAGES */
diff --git a/os/kernel/include/chmtx.h b/os/kernel/include/chmtx.h index bc0057e80..589caccba 100644 --- a/os/kernel/include/chmtx.h +++ b/os/kernel/include/chmtx.h @@ -31,32 +31,37 @@ #if CH_USE_MUTEXES || defined(__DOXYGEN__)
+/*===========================================================================*/
+/* Module constants. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module pre-compile time settings. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Derived constants and error checks. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module data structures and types. */
+/*===========================================================================*/
+
/**
* @brief Mutex structure.
*/
-typedef struct Mutex {
+typedef struct mutex {
threads_queue_t m_queue; /**< @brief Queue of the threads sleeping
- on this Mutex. */
+ on this mutex. */
thread_t *m_owner; /**< @brief Owner @p thread_t pointer or
@p NULL. */
- struct Mutex *m_next; /**< @brief Next @p Mutex into an
+ mutex_t *m_next; /**< @brief Next @p mutex_t into an
owner-list or @p NULL. */
-} Mutex;
+} mutex_t;
-#ifdef __cplusplus
-extern "C" {
-#endif
- void chMtxInit(Mutex *mp);
- void chMtxLock(Mutex *mp);
- void chMtxLockS(Mutex *mp);
- bool_t chMtxTryLock(Mutex *mp);
- bool_t chMtxTryLockS(Mutex *mp);
- Mutex *chMtxUnlock(void);
- Mutex *chMtxUnlockS(void);
- void chMtxUnlockAll(void);
-#ifdef __cplusplus
-}
-#endif
+/*===========================================================================*/
+/* Module macros. */
+/*===========================================================================*/
/**
* @brief Data part of a static mutex initializer.
@@ -74,20 +79,45 @@ extern "C" { *
* @param[in] name the name of the mutex variable
*/
-#define MUTEX_DECL(name) Mutex name = _MUTEX_DATA(name)
+#define MUTEX_DECL(name) mutex_t name = _MUTEX_DATA(name)
+
+/*===========================================================================*/
+/* External declarations. */
+/*===========================================================================*/
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+ void chMtxInit(mutex_t *mp);
+ void chMtxLock(mutex_t *mp);
+ void chMtxLockS(mutex_t *mp);
+ bool_t chMtxTryLock(mutex_t *mp);
+ bool_t chMtxTryLockS(mutex_t *mp);
+ mutex_t *chMtxUnlock(void);
+ mutex_t *chMtxUnlockS(void);
+ void chMtxUnlockAll(void);
+#ifdef __cplusplus
+}
+#endif
+
+/*===========================================================================*/
+/* Module inline functions. */
+/*===========================================================================*/
/**
- * @name Macro Functions
- * @{
- */
-/**
- * @brief Returns @p TRUE if the mutex queue contains at least a waiting
+ * @brief Returns @p true if the mutex queue contains at least a waiting
* thread.
*
+ * @deprecated
* @sclass
*/
-#define chMtxQueueNotEmptyS(mp) queue_notempty(&(mp)->m_queue)
-/** @} */
+static inline bool chMtxQueueNotEmptyS(mutex_t *mp) {
+
+ chDbgCheckClassS();
+
+ return queue_notempty(&mp->m_queue);
+}
#endif /* CH_USE_MUTEXES */
diff --git a/os/kernel/include/chregistry.h b/os/kernel/include/chregistry.h index 552e9d598..b176058ce 100644 --- a/os/kernel/include/chregistry.h +++ b/os/kernel/include/chregistry.h @@ -31,6 +31,22 @@ #if CH_USE_REGISTRY || defined(__DOXYGEN__)
+/*===========================================================================*/
+/* Module constants. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module pre-compile time settings. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Derived constants and error checks. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module data structures and types. */
+/*===========================================================================*/
+
/**
* @brief ChibiOS/RT memory signature record.
*/
@@ -57,39 +73,10 @@ typedef struct { uint8_t cf_off_time; /**< @brief Offset of @p p_time field. */
} chdebug_t;
-/**
- * @name Macro Functions
- * @{
- */
-/**
- * @brief Sets the current thread name.
- * @pre This function only stores the pointer to the name if the option
- * @p CH_USE_REGISTRY is enabled else no action is performed.
- *
- * @param[in] p thread name as a zero terminated string
- *
- * @api
- */
-#define chRegSetThreadName(p) (currp->p_name = (p))
-
-/**
- * @brief Returns the name of the specified thread.
- * @pre This function only returns the pointer to the name if the option
- * @p CH_USE_REGISTRY is enabled else @p NULL is returned.
- *
- * @param[in] tp pointer to the thread
- *
- * @return Thread name as a zero terminated string.
- * @retval NULL if the thread name has not been set.
- */
-#define chRegGetThreadName(tp) ((tp)->p_name)
-/** @} */
-#else /* !CH_USE_REGISTRY */
-#define chRegSetThreadName(p)
-#define chRegGetThreadName(tp) NULL
-#endif /* !CH_USE_REGISTRY */
+/*===========================================================================*/
+/* Module macros. */
+/*===========================================================================*/
-#if CH_USE_REGISTRY || defined(__DOXYGEN__)
/**
* @brief Removes a thread from the registry list.
* @note This macro is not meant for use in application code.
@@ -113,6 +100,10 @@ typedef struct { (tp)->p_older->p_newer = rlist.r_older = (tp); \
}
+/*===========================================================================*/
+/* External declarations. */
+/*===========================================================================*/
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -123,6 +114,52 @@ extern "C" { }
#endif
+/*===========================================================================*/
+/* Module inline functions. */
+/*===========================================================================*/
+
+/**
+ * @brief Sets the current thread name.
+ * @pre This function only stores the pointer to the name if the option
+ * @p CH_USE_REGISTRY is enabled else no action is performed.
+ *
+ * @param[in] p thread name as a zero terminated string
+ *
+ * @api
+ */
+static inline void chRegSetThreadName(const char *name) {
+
+#if CH_USE_REGISTRY
+ currp->p_name = name;
+#else
+ (void)name;
+#endif
+}
+
+/**
+ * @brief Returns the name of the specified thread.
+ * @pre This function only returns the pointer to the name if the option
+ * @p CH_USE_REGISTRY is enabled else @p NULL is returned.
+ *
+ * @param[in] tp pointer to the thread
+ *
+ * @return Thread name as a zero terminated string.
+ * @retval NULL if the thread name has not been set.
+ *
+ * @iclass
+ */
+static inline const char *chRegGetThreadNameI(thread_t *tp) {
+
+ chDbgCheckClassI();
+
+#if CH_USE_REGISTRY
+ return tp->p_name;
+#else
+ (void)tp;
+ return NULL;
+#endif
+}
+
#endif /* CH_USE_REGISTRY */
#endif /* _CHREGISTRY_H_ */
diff --git a/os/kernel/include/chsys.h b/os/kernel/include/chsys.h index a1f59f38e..5585117b6 100644 --- a/os/kernel/include/chsys.h +++ b/os/kernel/include/chsys.h @@ -29,45 +29,94 @@ #ifndef _CHSYS_H_
#define _CHSYS_H_
+/*===========================================================================*/
+/* Module constants. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module pre-compile time settings. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Derived constants and error checks. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module data structures and types. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module macros. */
+/*===========================================================================*/
+
/**
- * @name Macro Functions
- * @{
+ * @name ISRs abstraction macros
*/
-#if !CH_NO_IDLE_THREAD || defined(__DOXYGEN__)
/**
- * @brief Returns a pointer to the idle thread.
- * @pre In order to use this function the option @p CH_NO_IDLE_THREAD
- * must be disabled.
- * @note The reference counter of the idle thread is not incremented but
- * it is not strictly required being the idle thread a static
- * object.
+ * @brief IRQ handler enter code.
+ * @note Usually IRQ handlers functions are also declared naked.
+ * @note On some architectures this macro can be empty.
*
- * @return Pointer to the idle thread.
+ * @special
+ */
+#define CH_IRQ_PROLOGUE() \
+ PORT_IRQ_PROLOGUE(); \
+ dbg_check_enter_isr();
+
+/**
+ * @brief IRQ handler exit code.
+ * @note Usually IRQ handlers function are also declared naked.
+ * @note This macro usually performs the final reschedule by using
+ * @p chSchIsPreemptionRequired() and @p chSchDoReschedule().
*
- * @api
+ * @special
*/
-#define chSysGetIdleThread() (rlist.r_queue.p_prev)
-#endif
+#define CH_IRQ_EPILOGUE() \
+ dbg_check_leave_isr(); \
+ PORT_IRQ_EPILOGUE();
+
+/**
+ * @brief Standard normal IRQ handler declaration.
+ * @note @p id can be a function name or a vector number depending on the
+ * port implementation.
+ *
+ * @special
+ */
+#define CH_IRQ_HANDLER(id) PORT_IRQ_HANDLER(id)
+/** @} */
/**
- * @brief Halts the system.
- * @details This function is invoked by the operating system when an
- * unrecoverable error is detected, for example because a programming
- * error in the application code that triggers an assertion while
- * in debug mode.
- * @note Can be invoked from any system state.
+ * @name Fast ISRs abstraction macros
+ */
+/**
+ * @brief Standard fast IRQ handler declaration.
+ * @note @p id can be a function name or a vector number depending on the
+ * port implementation.
+ * @note Not all architectures support fast interrupts.
*
* @special
*/
-#if !defined(SYSTEM_HALT_HOOK) || defined(__DOXYGEN__)
-#define chSysHalt() port_halt()
-#else
-#define chSysHalt() { \
- SYSTEM_HALT_HOOK(); \
- port_halt(); \
+#define CH_FAST_IRQ_HANDLER(id) PORT_FAST_IRQ_HANDLER(id)
+/** @} */
+
+/*===========================================================================*/
+/* External declarations. */
+/*===========================================================================*/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+ void chSysInit(void);
+ void chSysHalt(void);
+ void chSysTimerHandlerI(void);
+#ifdef __cplusplus
}
#endif
+/*===========================================================================*/
+/* Module inline functions. */
+/*===========================================================================*/
+
/**
* @brief Performs a context switch.
* @note Not a user function, it is meant to be invoked by the scheduler
@@ -78,10 +127,11 @@ *
* @special
*/
-#define chSysSwitch(ntp, otp) { \
- dbg_trace(otp); \
- THREAD_CONTEXT_SWITCH_HOOK(ntp, otp); \
- port_switch(ntp, otp); \
+static inline void chSysSwitch(thread_t *ntp, thread_t *otp) {
+
+ dbg_trace(otp);
+ THREAD_CONTEXT_SWITCH_HOOK(ntp, otp);
+ port_switch(ntp, otp);
}
/**
@@ -92,9 +142,10 @@ *
* @special
*/
-#define chSysDisable() { \
- port_disable(); \
- dbg_check_disable(); \
+static inline void chSysDisable(void) {
+
+ port_disable();
+ dbg_check_disable();
}
/**
@@ -108,9 +159,10 @@ *
* @special
*/
-#define chSysSuspend() { \
- port_suspend(); \
- dbg_check_suspend(); \
+static inline void chSysSuspend(void) {
+
+ port_suspend();
+ dbg_check_suspend();
}
/**
@@ -122,9 +174,10 @@ *
* @special
*/
-#define chSysEnable() { \
- dbg_check_enable(); \
- port_enable(); \
+static inline void chSysEnable(void) {
+
+ dbg_check_enable();
+ port_enable();
}
/**
@@ -132,9 +185,10 @@ *
* @special
*/
-#define chSysLock() { \
- port_lock(); \
- dbg_check_lock(); \
+static inline void chSysLock(void) {
+
+ port_lock();
+ dbg_check_lock();
}
/**
@@ -142,9 +196,10 @@ *
* @special
*/
-#define chSysUnlock() { \
- dbg_check_unlock(); \
- port_unlock(); \
+static inline void chSysUnlock(void) {
+
+ dbg_check_unlock();
+ port_unlock();
}
/**
@@ -159,9 +214,10 @@ *
* @special
*/
-#define chSysLockFromIsr() { \
- port_lock_from_isr(); \
- dbg_check_lock_from_isr(); \
+static inline void chSysLockFromIsr(void) {
+
+ port_lock_from_isr();
+ dbg_check_lock_from_isr();
}
/**
@@ -177,70 +233,11 @@ *
* @special
*/
-#define chSysUnlockFromIsr() { \
- dbg_check_unlock_from_isr(); \
- port_unlock_from_isr(); \
-}
-/** @} */
-
-/**
- * @name ISRs abstraction macros
- */
-/**
- * @brief IRQ handler enter code.
- * @note Usually IRQ handlers functions are also declared naked.
- * @note On some architectures this macro can be empty.
- *
- * @special
- */
-#define CH_IRQ_PROLOGUE() \
- PORT_IRQ_PROLOGUE(); \
- dbg_check_enter_isr();
-
-/**
- * @brief IRQ handler exit code.
- * @note Usually IRQ handlers function are also declared naked.
- * @note This macro usually performs the final reschedule by using
- * @p chSchIsPreemptionRequired() and @p chSchDoReschedule().
- *
- * @special
- */
-#define CH_IRQ_EPILOGUE() \
- dbg_check_leave_isr(); \
- PORT_IRQ_EPILOGUE();
-
-/**
- * @brief Standard normal IRQ handler declaration.
- * @note @p id can be a function name or a vector number depending on the
- * port implementation.
- *
- * @special
- */
-#define CH_IRQ_HANDLER(id) PORT_IRQ_HANDLER(id)
-/** @} */
-
-/**
- * @name Fast ISRs abstraction macros
- */
-/**
- * @brief Standard fast IRQ handler declaration.
- * @note @p id can be a function name or a vector number depending on the
- * port implementation.
- * @note Not all architectures support fast interrupts.
- *
- * @special
- */
-#define CH_FAST_IRQ_HANDLER(id) PORT_FAST_IRQ_HANDLER(id)
-/** @} */
+static inline void chSysUnlockFromIsr(void) {
-#ifdef __cplusplus
-extern "C" {
-#endif
- void chSysInit(void);
- void chSysTimerHandlerI(void);
-#ifdef __cplusplus
+ dbg_check_unlock_from_isr();
+ port_unlock_from_isr();
}
-#endif
#endif /* _CHSYS_H_ */
diff --git a/os/kernel/include/chthreads.h b/os/kernel/include/chthreads.h index 452ffd37d..c46103faf 100644 --- a/os/kernel/include/chthreads.h +++ b/os/kernel/include/chthreads.h @@ -95,7 +95,7 @@ /* Forward declaration required by the mutexes stack structure present
in every thread.*/
#if CH_USE_MUTEXES
-typedef struct Mutex Mutex;
+typedef struct mutex mutex_t;
#endif
/**
@@ -238,7 +238,7 @@ typedef struct thread { * @brief List of the mutexes owned by this thread.
* @note The list is terminated by a @p NULL in this field.
*/
- Mutex *p_mtxlist;
+ mutex_t *p_mtxlist;
/**
* @brief Thread's own, non-inherited, priority.
*/
diff --git a/os/kernel/src/chcond.c b/os/kernel/src/chcond.c index 5903e062f..6b718c7f9 100644 --- a/os/kernel/src/chcond.c +++ b/os/kernel/src/chcond.c @@ -200,7 +200,7 @@ msg_t chCondWait(condition_variable_t *cp) { */
msg_t chCondWaitS(condition_variable_t *cp) {
thread_t *ctp = currp;
- Mutex *mp;
+ mutex_t *mp;
msg_t msg;
chDbgCheckClassS();
@@ -285,7 +285,7 @@ msg_t chCondWaitTimeout(condition_variable_t *cp, systime_t time) { * @sclass
*/
msg_t chCondWaitTimeoutS(condition_variable_t *cp, systime_t time) {
- Mutex *mp;
+ mutex_t *mp;
msg_t msg;
chDbgCheckClassS();
diff --git a/os/kernel/src/chdynamic.c b/os/kernel/src/chdynamic.c index 76d4ba561..21c81fc24 100644 --- a/os/kernel/src/chdynamic.c +++ b/os/kernel/src/chdynamic.c @@ -144,7 +144,7 @@ void chThdRelease(thread_t *tp) { *
* @api
*/
-thread_t *chThdCreateFromHeap(MemoryHeap *heapp, size_t size,
+thread_t *chThdCreateFromHeap(memory_heap_t *heapp, size_t size,
tprio_t prio, tfunc_t pf, void *arg) {
void *wsp;
thread_t *tp;
@@ -193,7 +193,7 @@ thread_t *chThdCreateFromHeap(MemoryHeap *heapp, size_t size, *
* @api
*/
-thread_t *chThdCreateFromMemoryPool(MemoryPool *mp, tprio_t prio,
+thread_t *chThdCreateFromMemoryPool(memory_pool_t *mp, tprio_t prio,
tfunc_t pf, void *arg) {
void *wsp;
thread_t *tp;
diff --git a/os/kernel/src/chevents.c b/os/kernel/src/chevents.c index 5685f285f..1206b61fe 100644 --- a/os/kernel/src/chevents.c +++ b/os/kernel/src/chevents.c @@ -93,14 +93,16 @@ * @note Multiple Event Listeners can specify the same bits to be ORed to
* different threads.
*
- * @param[in] esp pointer to the @p EventSource structure
- * @param[in] elp pointer to the @p EventListener structure
+ * @param[in] esp pointer to the @p event_source_t structure
+ * @param[in] elp pointer to the @p event_listener_t structure
* @param[in] mask the mask of event flags to be ORed to the thread when
* the event source is broadcasted
*
* @api
*/
-void chEvtRegisterMask(EventSource *esp, EventListener *elp, eventmask_t mask) {
+void chEvtRegisterMask(event_source_t *esp,
+ event_listener_t *elp,
+ eventmask_t mask) {
chDbgCheck((esp != NULL) && (elp != NULL), "chEvtRegisterMask");
@@ -121,19 +123,19 @@ void chEvtRegisterMask(EventSource *esp, EventListener *elp, eventmask_t mask) { * operations in inverse order of the register operations (elements
* are found on top of the list).
*
- * @param[in] esp pointer to the @p EventSource structure
- * @param[in] elp pointer to the @p EventListener structure
+ * @param[in] esp pointer to the @p event_source_t structure
+ * @param[in] elp pointer to the @p event_listener_t structure
*
* @api
*/
-void chEvtUnregister(EventSource *esp, EventListener *elp) {
- EventListener *p;
+void chEvtUnregister(event_source_t *esp, event_listener_t *elp) {
+ event_listener_t *p;
chDbgCheck((esp != NULL) && (elp != NULL), "chEvtUnregister");
- p = (EventListener *)esp;
+ p = (event_listener_t *)esp;
chSysLock();
- while (p->el_next != (EventListener *)esp) {
+ while (p->el_next != (event_listener_t *)esp) {
if (p->el_next == elp) {
p->el_next = elp->el_next;
break;
@@ -186,27 +188,27 @@ eventmask_t chEvtAddEvents(eventmask_t mask) { * @brief Signals all the Event Listeners registered on the specified Event
* Source.
* @details This function variants ORs the specified event flags to all the
- * threads registered on the @p EventSource in addition to the event
- * flags specified by the threads themselves in the
- * @p EventListener objects.
+ * threads registered on the @p event_source_t in addition to the
+ * event flags specified by the threads themselves in the
+ * @p event_listener_t objects.
* @post This function does not reschedule so a call to a rescheduling
* function must be performed before unlocking the kernel. Note that
* interrupt handlers always reschedule on exit so an explicit
* reschedule must not be performed in ISRs.
*
- * @param[in] esp pointer to the @p EventSource structure
+ * @param[in] esp pointer to the @p event_source_t structure
* @param[in] flags the flags set to be added to the listener flags mask
*
* @iclass
*/
-void chEvtBroadcastFlagsI(EventSource *esp, flagsmask_t flags) {
- EventListener *elp;
+void chEvtBroadcastFlagsI(event_source_t *esp, eventflags_t flags) {
+ event_listener_t *elp;
chDbgCheckClassI();
chDbgCheck(esp != NULL, "chEvtBroadcastMaskI");
elp = esp->es_next;
- while (elp != (EventListener *)esp) {
+ while (elp != (event_listener_t *)esp) {
elp->el_flags |= flags;
chEvtSignalI(elp->el_listener, elp->el_mask);
elp = elp->el_next;
@@ -214,18 +216,18 @@ void chEvtBroadcastFlagsI(EventSource *esp, flagsmask_t flags) { }
/**
- * @brief Returns the flags associated to an @p EventListener.
- * @details The flags are returned and the @p EventListener flags mask is
+ * @brief Returns the flags associated to an @p event_listener_t.
+ * @details The flags are returned and the @p event_listener_t flags mask is
* cleared.
*
- * @param[in] elp pointer to the @p EventListener structure
+ * @param[in] elp pointer to the @p event_listener_t structure
* @return The flags added to the listener by the associated
* event source.
*
* @iclass
*/
-flagsmask_t chEvtGetAndClearFlags(EventListener *elp) {
- flagsmask_t flags;
+eventflags_t chEvtGetAndClearFlags(event_listener_t *elp) {
+ eventflags_t flags;
chSysLock();
@@ -284,16 +286,16 @@ void chEvtSignalI(thread_t *tp, eventmask_t mask) { * @brief Signals all the Event Listeners registered on the specified Event
* Source.
* @details This function variants ORs the specified event flags to all the
- * threads registered on the @p EventSource in addition to the event
- * flags specified by the threads themselves in the
- * @p EventListener objects.
+ * threads registered on the @p event_source_t in addition to the
+ * event flags specified by the threads themselves in the
+ * @p event_listener_t objects.
*
- * @param[in] esp pointer to the @p EventSource structure
+ * @param[in] esp pointer to the @p event_source_t structure
* @param[in] flags the flags set to be added to the listener flags mask
*
* @api
*/
-void chEvtBroadcastFlags(EventSource *esp, flagsmask_t flags) {
+void chEvtBroadcastFlags(event_source_t *esp, eventflags_t flags) {
chSysLock();
chEvtBroadcastFlagsI(esp, flags);
@@ -302,18 +304,18 @@ void chEvtBroadcastFlags(EventSource *esp, flagsmask_t flags) { }
/**
- * @brief Returns the flags associated to an @p EventListener.
- * @details The flags are returned and the @p EventListener flags mask is
+ * @brief Returns the flags associated to an @p event_listener_t.
+ * @details The flags are returned and the @p event_listener_t flags mask is
* cleared.
*
- * @param[in] elp pointer to the @p EventListener structure
+ * @param[in] elp pointer to the @p event_listener_t structure
* @return The flags added to the listener by the associated
* event source.
*
* @iclass
*/
-flagsmask_t chEvtGetAndClearFlagsI(EventListener *elp) {
- flagsmask_t flags;
+eventflags_t chEvtGetAndClearFlagsI(event_listener_t *elp) {
+ eventflags_t flags;
flags = elp->el_flags;
elp->el_flags = 0;
@@ -444,8 +446,8 @@ eventmask_t chEvtWaitAll(eventmask_t mask) { * @details The function waits for one event among those specified in
* @p mask to become pending then the event is cleared and returned.
* @note One and only one event is served in the function, the one with the
- * lowest event id. The function is meant to be invoked into a loop in
- * order to serve all the pending events.<br>
+ * lowest event id. The function is meant to be invoked into a loop
+ * in order to serve all the pending events.<br>
* This means that Event Listeners with a lower event identifier have
* an higher priority.
*
diff --git a/os/kernel/src/chheap.c b/os/kernel/src/chheap.c index 23bcff6b4..4f20d3920 100644 --- a/os/kernel/src/chheap.c +++ b/os/kernel/src/chheap.c @@ -29,10 +29,6 @@ * are functionally equivalent to the usual @p malloc() and @p free()
* library functions. The main difference is that the OS heap APIs
* are guaranteed to be thread safe.<br>
- * By enabling the @p CH_USE_MALLOC_HEAP option the heap manager
- * will use the runtime-provided @p malloc() and @p free() as
- * back end for the heap APIs instead of the system provided
- * allocator.
* @pre In order to use the heap APIs the @p CH_USE_HEAP option must
* be enabled in @p chconf.h.
* @{
@@ -42,7 +38,9 @@ #if CH_USE_HEAP || defined(__DOXYGEN__)
-#if !CH_USE_MALLOC_HEAP || defined(__DOXYGEN__)
+/*===========================================================================*/
+/* Module local definitions. */
+/*===========================================================================*/
/*
* Defaults on the best synchronization mechanism available.
@@ -55,10 +53,30 @@ #define H_UNLOCK(h) chSemSignal(&(h)->h_sem)
#endif
+/*===========================================================================*/
+/* Module exported variables. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module local types. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module local variables. */
+/*===========================================================================*/
+
/**
* @brief Default heap descriptor.
*/
-static MemoryHeap default_heap;
+static memory_heap_t default_heap;
+
+/*===========================================================================*/
+/* Module local functions. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module exported functions. */
+/*===========================================================================*/
/**
* @brief Initializes the default heap.
@@ -80,8 +98,6 @@ void _heap_init(void) { * @brief Initializes a memory heap from a static memory area.
* @pre Both the heap buffer base and the heap size must be aligned to
* the @p stkalign_t type size.
- * @pre In order to use this function the option @p CH_USE_MALLOC_HEAP
- * must be disabled.
*
* @param[out] heapp pointer to the memory heap descriptor to be initialized
* @param[in] buf heap buffer base
@@ -89,7 +105,7 @@ void _heap_init(void) { *
* @init
*/
-void chHeapInit(MemoryHeap *heapp, void *buf, size_t size) {
+void chHeapInit(memory_heap_t *heapp, void *buf, size_t size) {
union heap_header *hp;
chDbgCheck(MEM_IS_ALIGNED(buf) && MEM_IS_ALIGNED(size), "chHeapInit");
@@ -122,7 +138,7 @@ void chHeapInit(MemoryHeap *heapp, void *buf, size_t size) { *
* @api
*/
-void *chHeapAlloc(MemoryHeap *heapp, size_t size) {
+void *chHeapAlloc(memory_heap_t *heapp, size_t size) {
union heap_header *qp, *hp, *fp;
if (heapp == NULL)
@@ -186,7 +202,7 @@ void *chHeapAlloc(MemoryHeap *heapp, size_t size) { */
void chHeapFree(void *p) {
union heap_header *qp, *hp;
- MemoryHeap *heapp;
+ memory_heap_t *heapp;
chDbgCheck(p != NULL, "chHeapFree");
@@ -229,8 +245,6 @@ void chHeapFree(void *p) { * @brief Reports the heap status.
* @note This function is meant to be used in the test suite, it should
* not be really useful for the application code.
- * @note This function is not implemented when the @p CH_USE_MALLOC_HEAP
- * configuration option is used (it always returns zero).
*
* @param[in] heapp pointer to a heap descriptor or @p NULL in order to
* access the default heap.
@@ -240,7 +254,7 @@ void chHeapFree(void *p) { *
* @api
*/
-size_t chHeapStatus(MemoryHeap *heapp, size_t *sizep) {
+size_t chHeapStatus(memory_heap_t *heapp, size_t *sizep) {
union heap_header *qp;
size_t n, sz;
@@ -259,60 +273,6 @@ size_t chHeapStatus(MemoryHeap *heapp, size_t *sizep) { return n;
}
-#else /* CH_USE_MALLOC_HEAP */
-
-#include <stdlib.h>
-
-#if CH_USE_MUTEXES
-#define H_LOCK() chMtxLock(&hmtx)
-#define H_UNLOCK() chMtxUnlock()
-static Mutex hmtx;
-#elif CH_USE_SEMAPHORES
-#define H_LOCK() chSemWait(&hsem)
-#define H_UNLOCK() chSemSignal(&hsem)
-static Semaphore hsem;
-#endif
-
-void _heap_init(void) {
-
-#if CH_USE_MUTEXES
- chMtxInit(&hmtx);
-#else
- chSemInit(&hsem, 1);
-#endif
-}
-
-void *chHeapAlloc(MemoryHeap *heapp, size_t size) {
- void *p;
-
- chDbgCheck(heapp == NULL, "chHeapAlloc");
-
- H_LOCK();
- p = malloc(size);
- H_UNLOCK();
- return p;
-}
-
-void chHeapFree(void *p) {
-
- chDbgCheck(p != NULL, "chHeapFree");
-
- H_LOCK();
- free(p);
- H_UNLOCK();
-}
-
-size_t chHeapStatus(MemoryHeap *heapp, size_t *sizep) {
-
- chDbgCheck(heapp == NULL, "chHeapStatus");
-
- if (sizep)
- *sizep = 0;
- return 0;
-}
-
-#endif /* CH_USE_MALLOC_HEAP */
-
#endif /* CH_USE_HEAP */
/** @} */
diff --git a/os/kernel/src/chmboxes.c b/os/kernel/src/chmboxes.c index 6f09a8d26..16f303daf 100644 --- a/os/kernel/src/chmboxes.c +++ b/os/kernel/src/chmboxes.c @@ -53,16 +53,38 @@ #include "ch.h"
#if CH_USE_MAILBOXES || defined(__DOXYGEN__)
+
+/*===========================================================================*/
+/* Module exported variables. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module local types. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module local variables. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module local functions. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module exported functions. */
+/*===========================================================================*/
+
/**
- * @brief Initializes a Mailbox object.
+ * @brief Initializes a @p mailbox_t object.
*
- * @param[out] mbp the pointer to the Mailbox structure to be initialized
+ * @param[out] mbp the pointer to the @p mailbox_t structure to be
+ * initialized
* @param[in] buf pointer to the messages buffer as an array of @p msg_t
* @param[in] n number of elements in the buffer array
*
* @init
*/
-void chMBInit(Mailbox *mbp, msg_t *buf, cnt_t n) {
+void chMBInit(mailbox_t *mbp, msg_t *buf, cnt_t n) {
chDbgCheck((mbp != NULL) && (buf != NULL) && (n > 0), "chMBInit");
@@ -73,15 +95,15 @@ void chMBInit(Mailbox *mbp, msg_t *buf, cnt_t n) { }
/**
- * @brief Resets a Mailbox object.
+ * @brief Resets a @p mailbox_t object.
* @details All the waiting threads are resumed with status @p RDY_RESET and
* the queued messages are lost.
*
- * @param[in] mbp the pointer to an initialized Mailbox object
+ * @param[in] mbp the pointer to an initialized @p mailbox_t object
*
* @api
*/
-void chMBReset(Mailbox *mbp) {
+void chMBReset(mailbox_t *mbp) {
chDbgCheck(mbp != NULL, "chMBReset");
@@ -98,7 +120,7 @@ void chMBReset(Mailbox *mbp) { * @details The invoking thread waits until a empty slot in the mailbox becomes
* available or the specified time runs out.
*
- * @param[in] mbp the pointer to an initialized Mailbox object
+ * @param[in] mbp the pointer to an initialized @p mailbox_t object
* @param[in] msg the message to be posted on the mailbox
* @param[in] time the number of ticks before the operation timeouts,
* the following special values are allowed:
@@ -112,7 +134,7 @@ void chMBReset(Mailbox *mbp) { *
* @api
*/
-msg_t chMBPost(Mailbox *mbp, msg_t msg, systime_t time) {
+msg_t chMBPost(mailbox_t *mbp, msg_t msg, systime_t time) {
msg_t rdymsg;
chSysLock();
@@ -126,7 +148,7 @@ msg_t chMBPost(Mailbox *mbp, msg_t msg, systime_t time) { * @details The invoking thread waits until a empty slot in the mailbox becomes
* available or the specified time runs out.
*
- * @param[in] mbp the pointer to an initialized Mailbox object
+ * @param[in] mbp the pointer to an initialized @p mailbox_t object
* @param[in] msg the message to be posted on the mailbox
* @param[in] time the number of ticks before the operation timeouts,
* the following special values are allowed:
@@ -140,7 +162,7 @@ msg_t chMBPost(Mailbox *mbp, msg_t msg, systime_t time) { *
* @sclass
*/
-msg_t chMBPostS(Mailbox *mbp, msg_t msg, systime_t time) {
+msg_t chMBPostS(mailbox_t *mbp, msg_t msg, systime_t time) {
msg_t rdymsg;
chDbgCheckClassS();
@@ -162,7 +184,7 @@ msg_t chMBPostS(Mailbox *mbp, msg_t msg, systime_t time) { * @details This variant is non-blocking, the function returns a timeout
* condition if the queue is full.
*
- * @param[in] mbp the pointer to an initialized Mailbox object
+ * @param[in] mbp the pointer to an initialized @p mailbox_t object
* @param[in] msg the message to be posted on the mailbox
* @return The operation status.
* @retval RDY_OK if a message has been correctly posted.
@@ -171,7 +193,7 @@ msg_t chMBPostS(Mailbox *mbp, msg_t msg, systime_t time) { *
* @iclass
*/
-msg_t chMBPostI(Mailbox *mbp, msg_t msg) {
+msg_t chMBPostI(mailbox_t *mbp, msg_t msg) {
chDbgCheckClassI();
chDbgCheck(mbp != NULL, "chMBPostI");
@@ -191,7 +213,7 @@ msg_t chMBPostI(Mailbox *mbp, msg_t msg) { * @details The invoking thread waits until a empty slot in the mailbox becomes
* available or the specified time runs out.
*
- * @param[in] mbp the pointer to an initialized Mailbox object
+ * @param[in] mbp the pointer to an initialized @p mailbox_t object
* @param[in] msg the message to be posted on the mailbox
* @param[in] time the number of ticks before the operation timeouts,
* the following special values are allowed:
@@ -205,7 +227,7 @@ msg_t chMBPostI(Mailbox *mbp, msg_t msg) { *
* @api
*/
-msg_t chMBPostAhead(Mailbox *mbp, msg_t msg, systime_t time) {
+msg_t chMBPostAhead(mailbox_t *mbp, msg_t msg, systime_t time) {
msg_t rdymsg;
chSysLock();
@@ -219,7 +241,7 @@ msg_t chMBPostAhead(Mailbox *mbp, msg_t msg, systime_t time) { * @details The invoking thread waits until a empty slot in the mailbox becomes
* available or the specified time runs out.
*
- * @param[in] mbp the pointer to an initialized Mailbox object
+ * @param[in] mbp the pointer to an initialized @p mailbox_t object
* @param[in] msg the message to be posted on the mailbox
* @param[in] time the number of ticks before the operation timeouts,
* the following special values are allowed:
@@ -233,7 +255,7 @@ msg_t chMBPostAhead(Mailbox *mbp, msg_t msg, systime_t time) { *
* @sclass
*/
-msg_t chMBPostAheadS(Mailbox *mbp, msg_t msg, systime_t time) {
+msg_t chMBPostAheadS(mailbox_t *mbp, msg_t msg, systime_t time) {
msg_t rdymsg;
chDbgCheckClassS();
@@ -255,7 +277,7 @@ msg_t chMBPostAheadS(Mailbox *mbp, msg_t msg, systime_t time) { * @details This variant is non-blocking, the function returns a timeout
* condition if the queue is full.
*
- * @param[in] mbp the pointer to an initialized Mailbox object
+ * @param[in] mbp the pointer to an initialized @p mailbox_t object
* @param[in] msg the message to be posted on the mailbox
* @return The operation status.
* @retval RDY_OK if a message has been correctly posted.
@@ -264,7 +286,7 @@ msg_t chMBPostAheadS(Mailbox *mbp, msg_t msg, systime_t time) { *
* @iclass
*/
-msg_t chMBPostAheadI(Mailbox *mbp, msg_t msg) {
+msg_t chMBPostAheadI(mailbox_t *mbp, msg_t msg) {
chDbgCheckClassI();
chDbgCheck(mbp != NULL, "chMBPostAheadI");
@@ -284,7 +306,7 @@ msg_t chMBPostAheadI(Mailbox *mbp, msg_t msg) { * @details The invoking thread waits until a message is posted in the mailbox
* or the specified time runs out.
*
- * @param[in] mbp the pointer to an initialized Mailbox object
+ * @param[in] mbp the pointer to an initialized @p mailbox_t object
* @param[out] msgp pointer to a message variable for the received message
* @param[in] time the number of ticks before the operation timeouts,
* the following special values are allowed:
@@ -298,7 +320,7 @@ msg_t chMBPostAheadI(Mailbox *mbp, msg_t msg) { *
* @api
*/
-msg_t chMBFetch(Mailbox *mbp, msg_t *msgp, systime_t time) {
+msg_t chMBFetch(mailbox_t *mbp, msg_t *msgp, systime_t time) {
msg_t rdymsg;
chSysLock();
@@ -312,7 +334,7 @@ msg_t chMBFetch(Mailbox *mbp, msg_t *msgp, systime_t time) { * @details The invoking thread waits until a message is posted in the mailbox
* or the specified time runs out.
*
- * @param[in] mbp the pointer to an initialized Mailbox object
+ * @param[in] mbp the pointer to an initialized @p mailbox_t object
* @param[out] msgp pointer to a message variable for the received message
* @param[in] time the number of ticks before the operation timeouts,
* the following special values are allowed:
@@ -326,7 +348,7 @@ msg_t chMBFetch(Mailbox *mbp, msg_t *msgp, systime_t time) { *
* @sclass
*/
-msg_t chMBFetchS(Mailbox *mbp, msg_t *msgp, systime_t time) {
+msg_t chMBFetchS(mailbox_t *mbp, msg_t *msgp, systime_t time) {
msg_t rdymsg;
chDbgCheckClassS();
@@ -348,7 +370,7 @@ msg_t chMBFetchS(Mailbox *mbp, msg_t *msgp, systime_t time) { * @details This variant is non-blocking, the function returns a timeout
* condition if the queue is empty.
*
- * @param[in] mbp the pointer to an initialized Mailbox object
+ * @param[in] mbp the pointer to an initialized @p mailbox_t object
* @param[out] msgp pointer to a message variable for the received message
* @return The operation status.
* @retval RDY_OK if a message has been correctly fetched.
@@ -357,7 +379,7 @@ msg_t chMBFetchS(Mailbox *mbp, msg_t *msgp, systime_t time) { *
* @iclass
*/
-msg_t chMBFetchI(Mailbox *mbp, msg_t *msgp) {
+msg_t chMBFetchI(mailbox_t *mbp, msg_t *msgp) {
chDbgCheckClassI();
chDbgCheck((mbp != NULL) && (msgp != NULL), "chMBFetchI");
diff --git a/os/kernel/src/chmemcore.c b/os/kernel/src/chmemcore.c index 0ff26bc76..76f415743 100644 --- a/os/kernel/src/chmemcore.c +++ b/os/kernel/src/chmemcore.c @@ -48,9 +48,29 @@ #if CH_USE_MEMCORE || defined(__DOXYGEN__)
+/*===========================================================================*/
+/* Module exported variables. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module local types. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module local variables. */
+/*===========================================================================*/
+
static uint8_t *nextmem;
static uint8_t *endmem;
+/*===========================================================================*/
+/* Module local functions. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module exported functions. */
+/*===========================================================================*/
+
/**
* @brief Low level memory manager initialization.
*
@@ -60,10 +80,12 @@ void _core_init(void) { #if CH_MEMCORE_SIZE == 0
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_NEXT(CH_MEMCORE_SIZE)/MEM_ALIGN_SIZE];
+
nextmem = (uint8_t *)&buffer[0];
endmem = (uint8_t *)&buffer[MEM_ALIGN_NEXT(CH_MEMCORE_SIZE)/MEM_ALIGN_SIZE];
#endif
diff --git a/os/kernel/src/chmempools.c b/os/kernel/src/chmempools.c index 44faa057a..b52f0b6d9 100644 --- a/os/kernel/src/chmempools.c +++ b/os/kernel/src/chmempools.c @@ -39,10 +39,31 @@ #include "ch.h"
#if CH_USE_MEMPOOLS || defined(__DOXYGEN__)
+
+/*===========================================================================*/
+/* Module exported variables. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module local types. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module local variables. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module local functions. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module exported functions. */
+/*===========================================================================*/
+
/**
* @brief Initializes an empty memory pool.
*
- * @param[out] mp pointer to a @p MemoryPool structure
+ * @param[out] mp pointer to a @p memory_pool_t structure
* @param[in] size the size of the objects contained in this memory pool,
* the minimum accepted size is the size of a pointer to
* void.
@@ -52,7 +73,7 @@ *
* @init
*/
-void chPoolInit(MemoryPool *mp, size_t size, memgetfunc_t provider) {
+void chPoolInit(memory_pool_t *mp, size_t size, memgetfunc_t provider) {
chDbgCheck((mp != NULL) && (size >= sizeof(void *)), "chPoolInit");
@@ -68,13 +89,13 @@ void chPoolInit(MemoryPool *mp, size_t size, memgetfunc_t provider) { * memory pool.
* @post The memory pool contains the elements of the input array.
*
- * @param[in] mp pointer to a @p MemoryPool structure
+ * @param[in] mp pointer to a @p memory_pool_t structure
* @param[in] p pointer to the array first element
* @param[in] n number of elements in the array
*
* @api
*/
-void chPoolLoadArray(MemoryPool *mp, void *p, size_t n) {
+void chPoolLoadArray(memory_pool_t *mp, void *p, size_t n) {
chDbgCheck((mp != NULL) && (n != 0), "chPoolLoadArray");
@@ -89,13 +110,13 @@ void chPoolLoadArray(MemoryPool *mp, void *p, size_t n) { * @brief Allocates an object from a memory pool.
* @pre The memory pool must be already been initialized.
*
- * @param[in] mp pointer to a @p MemoryPool structure
+ * @param[in] mp pointer to a @p memory_pool_t structure
* @return The pointer to the allocated object.
* @retval NULL if pool is empty.
*
* @iclass
*/
-void *chPoolAllocI(MemoryPool *mp) {
+void *chPoolAllocI(memory_pool_t *mp) {
void *objp;
chDbgCheckClassI();
@@ -112,13 +133,13 @@ void *chPoolAllocI(MemoryPool *mp) { * @brief Allocates an object from a memory pool.
* @pre The memory pool must be already been initialized.
*
- * @param[in] mp pointer to a @p MemoryPool structure
+ * @param[in] mp pointer to a @p memory_pool_t structure
* @return The pointer to the allocated object.
* @retval NULL if pool is empty.
*
* @api
*/
-void *chPoolAlloc(MemoryPool *mp) {
+void *chPoolAlloc(memory_pool_t *mp) {
void *objp;
chSysLock();
@@ -134,12 +155,12 @@ void *chPoolAlloc(MemoryPool *mp) { * memory pool.
* @pre The object must be properly aligned to contain a pointer to void.
*
- * @param[in] mp pointer to a @p MemoryPool structure
+ * @param[in] mp pointer to a @p memory_pool_t structure
* @param[in] objp the pointer to the object to be released
*
* @iclass
*/
-void chPoolFreeI(MemoryPool *mp, void *objp) {
+void chPoolFreeI(memory_pool_t *mp, void *objp) {
struct pool_header *php = objp;
chDbgCheckClassI();
@@ -156,12 +177,12 @@ void chPoolFreeI(MemoryPool *mp, void *objp) { * memory pool.
* @pre The object must be properly aligned to contain a pointer to void.
*
- * @param[in] mp pointer to a @p MemoryPool structure
+ * @param[in] mp pointer to a @p memory_pool_t structure
* @param[in] objp the pointer to the object to be released
*
* @api
*/
-void chPoolFree(MemoryPool *mp, void *objp) {
+void chPoolFree(memory_pool_t *mp, void *objp) {
chSysLock();
chPoolFreeI(mp, objp);
diff --git a/os/kernel/src/chmsg.c b/os/kernel/src/chmsg.c index 50e489915..b53f91979 100644 --- a/os/kernel/src/chmsg.c +++ b/os/kernel/src/chmsg.c @@ -48,12 +48,32 @@ #if CH_USE_MESSAGES || defined(__DOXYGEN__)
+/*===========================================================================*/
+/* Module exported variables. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module local types. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module local variables. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module local functions. */
+/*===========================================================================*/
+
#if CH_USE_MESSAGES_PRIORITY
#define msg_insert(tp, qp) prio_insert(tp, qp)
#else
#define msg_insert(tp, qp) queue_insert(tp, qp)
#endif
+/*===========================================================================*/
+/* Module exported functions. */
+/*===========================================================================*/
+
/**
* @brief Sends a message to the specified thread.
* @details The sender is stopped until the receiver executes a
diff --git a/os/kernel/src/chmtx.c b/os/kernel/src/chmtx.c index f70dd9b20..84e868a3f 100644 --- a/os/kernel/src/chmtx.c +++ b/os/kernel/src/chmtx.c @@ -69,14 +69,34 @@ #if CH_USE_MUTEXES || defined(__DOXYGEN__)
+/*===========================================================================*/
+/* Module exported variables. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module local types. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module local variables. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module local functions. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module exported functions. */
+/*===========================================================================*/
+
/**
- * @brief Initializes s @p Mutex structure.
+ * @brief Initializes s @p mutex_t structure.
*
- * @param[out] mp pointer to a @p Mutex structure
+ * @param[out] mp pointer to a @p mutex_t structure
*
* @init
*/
-void chMtxInit(Mutex *mp) {
+void chMtxInit(mutex_t *mp) {
chDbgCheck(mp != NULL, "chMtxInit");
@@ -89,11 +109,11 @@ void chMtxInit(Mutex *mp) { * @post The mutex is locked and inserted in the per-thread stack of owned
* mutexes.
*
- * @param[in] mp pointer to the @p Mutex structure
+ * @param[in] mp pointer to the @p mutex_t structure
*
* @api
*/
-void chMtxLock(Mutex *mp) {
+void chMtxLock(mutex_t *mp) {
chSysLock();
@@ -107,11 +127,11 @@ void chMtxLock(Mutex *mp) { * @post The mutex is locked and inserted in the per-thread stack of owned
* mutexes.
*
- * @param[in] mp pointer to the @p Mutex structure
+ * @param[in] mp pointer to the @p mutex_t structure
*
* @sclass
*/
-void chMtxLockS(Mutex *mp) {
+void chMtxLockS(mutex_t *mp) {
thread_t *ctp = currp;
chDbgCheckClassS();
@@ -123,18 +143,20 @@ void chMtxLockS(Mutex *mp) { boosting the priority of all the affected threads to equal the priority
of the running thread requesting the mutex.*/
thread_t *tp = mp->m_owner;
+
/* Does the running thread have higher priority than the mutex
owning thread? */
while (tp->p_prio < ctp->p_prio) {
/* Make priority of thread tp match the running thread's priority.*/
tp->p_prio = ctp->p_prio;
+
/* The following states need priority queues reordering.*/
switch (tp->p_state) {
case THD_STATE_WTMTX:
/* Re-enqueues the mutex owner with its new priority.*/
queue_prio_insert(queue_dequeue(tp),
(threads_queue_t *)tp->p_u.wtobjp);
- tp = ((Mutex *)tp->p_u.wtobjp)->m_owner;
+ tp = ((mutex_t *)tp->p_u.wtobjp)->m_owner;
continue;
#if CH_USE_CONDVARS | \
(CH_USE_SEMAPHORES && CH_USE_SEMAPHORES_PRIORITY) | \
@@ -164,10 +186,12 @@ void chMtxLockS(Mutex *mp) { }
break;
}
+
/* Sleep on the mutex.*/
queue_prio_insert(ctp, &mp->m_queue);
ctp->p_u.wtobjp = mp;
chSchGoSleepS(THD_STATE_WTMTX);
+
/* It is assumed that the thread performing the unlock operation assigns
the mutex to this thread.*/
chDbgAssert(mp->m_owner == ctp, "chMtxLockS(), #1", "not owner");
@@ -191,14 +215,14 @@ void chMtxLockS(Mutex *mp) { * priority inheritance mechanism because it does not try to
* enter a sleep state.
*
- * @param[in] mp pointer to the @p Mutex structure
+ * @param[in] mp pointer to the @p mutex_t structure
* @return The operation status.
* @retval TRUE if the mutex has been successfully acquired
* @retval FALSE if the lock attempt failed.
*
* @api
*/
-bool_t chMtxTryLock(Mutex *mp) {
+bool_t chMtxTryLock(mutex_t *mp) {
bool_t b;
chSysLock();
@@ -219,20 +243,21 @@ bool_t chMtxTryLock(Mutex *mp) { * priority inheritance mechanism because it does not try to
* enter a sleep state.
*
- * @param[in] mp pointer to the @p Mutex structure
+ * @param[in] mp pointer to the @p mutex_t structure
* @return The operation status.
* @retval TRUE if the mutex has been successfully acquired
* @retval FALSE if the lock attempt failed.
*
* @sclass
*/
-bool_t chMtxTryLockS(Mutex *mp) {
+bool_t chMtxTryLockS(mutex_t *mp) {
chDbgCheckClassS();
chDbgCheck(mp != NULL, "chMtxTryLockS");
if (mp->m_owner != NULL)
return FALSE;
+
mp->m_owner = currp;
mp->m_next = currp->p_mtxlist;
currp->p_mtxlist = mp;
@@ -249,21 +274,24 @@ bool_t chMtxTryLockS(Mutex *mp) { *
* @api
*/
-Mutex *chMtxUnlock(void) {
+mutex_t *chMtxUnlock(void) {
thread_t *ctp = currp;
- Mutex *ump, *mp;
+ mutex_t *ump, *mp;
chSysLock();
+
chDbgAssert(ctp->p_mtxlist != NULL,
"chMtxUnlock(), #1",
"owned mutexes list empty");
chDbgAssert(ctp->p_mtxlist->m_owner == ctp,
"chMtxUnlock(), #2",
"ownership failure");
- /* Removes the top Mutex from the thread's owned mutexes list and marks it
+
+ /* Removes the top mutex from the thread's owned mutexes list and marks it
as not owned.*/
ump = ctp->p_mtxlist;
ctp->p_mtxlist = ump->m_next;
+
/* If a thread is waiting on the mutex then the fun part begins.*/
if (chMtxQueueNotEmptyS(ump)) {
thread_t *tp;
@@ -280,9 +308,11 @@ Mutex *chMtxUnlock(void) { newprio = mp->m_queue.p_next->p_prio;
mp = mp->m_next;
}
+
/* Assigns to the current thread the highest priority among all the
waiting threads.*/
ctp->p_prio = newprio;
+
/* Awakens the highest priority thread waiting for the unlocked mutex and
assigns the mutex to it.*/
tp = queue_fifo_remove(&ump->m_queue);
@@ -309,9 +339,9 @@ Mutex *chMtxUnlock(void) { *
* @sclass
*/
-Mutex *chMtxUnlockS(void) {
+mutex_t *chMtxUnlockS(void) {
thread_t *ctp = currp;
- Mutex *ump, *mp;
+ mutex_t *ump, *mp;
chDbgCheckClassS();
chDbgAssert(ctp->p_mtxlist != NULL,
@@ -321,10 +351,11 @@ Mutex *chMtxUnlockS(void) { "chMtxUnlockS(), #2",
"ownership failure");
- /* Removes the top Mutex from the owned mutexes list and marks it as not
+ /* Removes the top mutex from the owned mutexes list and marks it as not
owned.*/
ump = ctp->p_mtxlist;
ctp->p_mtxlist = ump->m_next;
+
/* If a thread is waiting on the mutex then the fun part begins.*/
if (chMtxQueueNotEmptyS(ump)) {
thread_t *tp;
@@ -339,9 +370,11 @@ Mutex *chMtxUnlockS(void) { priority will have at least that priority.*/
if (chMtxQueueNotEmptyS(mp) && (mp->m_queue.p_next->p_prio > newprio))
newprio = mp->m_queue.p_next->p_prio;
+
mp = mp->m_next;
}
ctp->p_prio = newprio;
+
/* Awakens the highest priority thread waiting for the unlocked mutex and
assigns the mutex to it.*/
tp = queue_fifo_remove(&ump->m_queue);
@@ -372,7 +405,7 @@ void chMtxUnlockAll(void) { chSysLock();
if (ctp->p_mtxlist != NULL) {
do {
- Mutex *ump = ctp->p_mtxlist;
+ mutex_t *ump = ctp->p_mtxlist;
ctp->p_mtxlist = ump->m_next;
if (chMtxQueueNotEmptyS(ump)) {
thread_t *tp = queue_fifo_remove(&ump->m_queue);
diff --git a/os/kernel/src/chregistry.c b/os/kernel/src/chregistry.c index d567393c1..832ef0ce9 100644 --- a/os/kernel/src/chregistry.c +++ b/os/kernel/src/chregistry.c @@ -50,9 +50,29 @@ #if CH_USE_REGISTRY || defined(__DOXYGEN__)
+/*===========================================================================*/
+/* Module exported variables. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module local types. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module local variables. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module local functions. */
+/*===========================================================================*/
+
#define _offsetof(st, m) \
((size_t)((char *)&((st *)0)->m - (char *)0))
+/*===========================================================================*/
+/* Module exported functions. */
+/*===========================================================================*/
+
/*
* OS signature in ROM plus debug-related information.
*/
diff --git a/os/kernel/src/chsem.c b/os/kernel/src/chsem.c index 73d156c02..8ddba8523 100644 --- a/os/kernel/src/chsem.c +++ b/os/kernel/src/chsem.c @@ -61,12 +61,32 @@ #if CH_USE_SEMAPHORES || defined(__DOXYGEN__)
+/*===========================================================================*/
+/* Module exported variables. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module local types. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module local variables. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module local functions. */
+/*===========================================================================*/
+
#if CH_USE_SEMAPHORES_PRIORITY
#define sem_insert(tp, qp) prio_insert(tp, qp)
#else
#define sem_insert(tp, qp) queue_insert(tp, qp)
#endif
+/*===========================================================================*/
+/* Module exported functions. */
+/*===========================================================================*/
+
/**
* @brief Initializes a semaphore with the specified counter value.
*
diff --git a/os/kernel/src/chsys.c b/os/kernel/src/chsys.c index f960d9b79..578de3ccf 100644 --- a/os/kernel/src/chsys.c +++ b/os/kernel/src/chsys.c @@ -35,12 +35,30 @@ #include "ch.h"
+/*===========================================================================*/
+/* Module exported variables. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module local types. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module local variables. */
+/*===========================================================================*/
+
#if !CH_NO_IDLE_THREAD || defined(__DOXYGEN__)
/**
* @brief Idle thread working area.
*/
-WORKING_AREA(_idle_thread_wa, PORT_IDLE_THREAD_STACK_SIZE);
+static WORKING_AREA(_idle_thread_wa, PORT_IDLE_THREAD_STACK_SIZE);
+#endif /* CH_NO_IDLE_THREAD */
+
+/*===========================================================================*/
+/* Module local functions. */
+/*===========================================================================*/
+#if !CH_NO_IDLE_THREAD || defined(__DOXYGEN__)
/**
* @brief This function implements the idle thread infinite loop.
* @details The function puts the processor in the lowest power mode capable
@@ -51,7 +69,7 @@ WORKING_AREA(_idle_thread_wa, PORT_IDLE_THREAD_STACK_SIZE); *
* @param[in] p the thread parameter, unused in this scenario
*/
-void _idle_thread(void *p) {
+static void _idle_thread(void *p) {
(void)p;
chRegSetThreadName("idle");
@@ -62,6 +80,10 @@ void _idle_thread(void *p) { }
#endif /* CH_NO_IDLE_THREAD */
+/*===========================================================================*/
+/* Module exported functions. */
+/*===========================================================================*/
+
/**
* @brief ChibiOS/RT initialization.
* @details After executing this function the current instructions stream
@@ -117,6 +139,29 @@ void chSysInit(void) { }
/**
+ * @brief Halts the system.
+ * @details This function is invoked by the operating system when an
+ * unrecoverable error is detected, for example because a programming
+ * error in the application code that triggers an assertion while
+ * in debug mode.
+ * @note Can be invoked from any system state.
+ *
+ * @special
+ */
+void chSysHalt(void) {
+
+ chSysDisable();
+
+#if defined(SYSTEM_HALT_HOOK) || defined(__DOXYGEN__)
+ SYSTEM_HALT_HOOK();
+#endif
+
+ /* Harmless infinite loop.*/
+ while (true)
+ ;
+}
+
+/**
* @brief Handles time ticks for round robin preemption and timer increments.
* @details Decrements the remaining time quantum of the running thread
* and preempts it when the quantum is used up. Increments system
diff --git a/os/kernel/templates/chconf.h b/os/kernel/templates/chconf.h index 1e570c3cc..652a6adee 100644 --- a/os/kernel/templates/chconf.h +++ b/os/kernel/templates/chconf.h @@ -307,20 +307,6 @@ #endif
/**
- * @brief C-runtime allocator.
- * @details If enabled the the heap allocator APIs just wrap the C-runtime
- * @p malloc() and @p free() functions.
- *
- * @note The default is @p FALSE.
- * @note Requires @p CH_USE_HEAP.
- * @note The C-runtime may or may not require @p CH_USE_MEMCORE, see the
- * appropriate documentation.
- */
-#if !defined(CH_USE_MALLOC_HEAP) || defined(__DOXYGEN__)
-#define CH_USE_MALLOC_HEAP FALSE
-#endif
-
-/**
* @brief Memory Pools Allocator APIs.
* @details If enabled then the memory pools allocator APIs are included
* in the kernel.
diff --git a/os/kernel/templates/chtypes.h b/os/kernel/templates/chtypes.h index 52efee447..5bf0ff0f0 100644 --- a/os/kernel/templates/chtypes.h +++ b/os/kernel/templates/chtypes.h @@ -73,16 +73,21 @@ typedef uint32_t tprio_t; typedef int32_t msg_t;
/**
- * @brief Event Id, use fastest signed.
+ * @brief Numeric event identifier, use fastest signed.
*/
typedef int32_t eventid_t;
/**
- * @brief Event Mask, recommended fastest unsigned.
+ * @brief Mask of event identifiers, recommended fastest unsigned.
*/
typedef uint32_t eventmask_t;
/**
+ * @brief Mask of event flags, recommended fastest unsigned.
+ */
+typedef uint32_t eventflags_t;
+
+/**
* @brief System Time, recommended fastest unsigned.
*/
typedef uint32_t systime_t;
diff --git a/os/kernel/templates/module.h b/os/kernel/templates/module.h index 4761a947c..a76b8177e 100644 --- a/os/kernel/templates/module.h +++ b/os/kernel/templates/module.h @@ -66,12 +66,12 @@ extern "C" { }
#endif
-#endif /* CH_USE_XXX */
-
-#endif /* _CHXXX_H_ */
-
/*===========================================================================*/
/* Module inline functions. */
/*===========================================================================*/
+#endif /* CH_USE_XXX */
+
+#endif /* _CHXXX_H_ */
+
/** @} */
diff --git a/os/ports/GCC/ARMCMx/chtypes.h b/os/ports/GCC/ARMCMx/chtypes.h index a94ae24ae..2d61d0250 100644 --- a/os/ports/GCC/ARMCMx/chtypes.h +++ b/os/ports/GCC/ARMCMx/chtypes.h @@ -40,9 +40,9 @@ typedef uint8_t trefs_t; /**< Thread references counter. */ typedef uint8_t tslices_t; /**< Thread time slices counter. */
typedef uint32_t tprio_t; /**< Thread priority. */
typedef int32_t msg_t; /**< Inter-thread message. */
-typedef int32_t eventid_t; /**< Event Id. */
-typedef uint32_t eventmask_t; /**< Event mask. */
-typedef uint32_t flagsmask_t; /**< Event flags. */
+typedef int32_t eventid_t; /**< Numeric event identifier. */
+typedef uint32_t eventmask_t; /**< Mask of event identifiers. */
+typedef uint32_t eventflags_t; /**< Mask of event flags. */
typedef uint32_t systime_t; /**< System time. */
typedef int32_t cnt_t; /**< Resources counter. */
diff --git a/test/testbmk.c b/test/testbmk.c index 957f634ac..e117d9120 100644 --- a/test/testbmk.c +++ b/test/testbmk.c @@ -58,7 +58,7 @@ static semaphore_t sem1;
#if CH_USE_MUTEXES || defined(__DOXYGEN__)
-static Mutex mtx1;
+static mutex_t mtx1;
#endif
static msg_t thread1(void *p) {
@@ -650,15 +650,15 @@ static void bmk13_execute(void) { test_println(" bytes");
#if CH_USE_EVENTS || defined(__DOXYGEN__)
test_print("--- EventS: ");
- test_printn(sizeof(EventSource));
+ test_printn(sizeof(event_source_t));
test_println(" bytes");
test_print("--- EventL: ");
- test_printn(sizeof(EventListener));
+ test_printn(sizeof(event_listener_t));
test_println(" bytes");
#endif
#if CH_USE_MUTEXES || defined(__DOXYGEN__)
test_print("--- Mutex : ");
- test_printn(sizeof(Mutex));
+ test_printn(sizeof(mutex_t));
test_println(" bytes");
#endif
#if CH_USE_CONDVARS || defined(__DOXYGEN__)
@@ -673,7 +673,7 @@ static void bmk13_execute(void) { #endif
#if CH_USE_MAILBOXES || defined(__DOXYGEN__)
test_print("--- MailB.: ");
- test_printn(sizeof(Mailbox));
+ test_printn(sizeof(mailbox_t));
test_println(" bytes");
#endif
}
diff --git a/test/testdyn.c b/test/testdyn.c index ebfb00a4b..15664ee07 100644 --- a/test/testdyn.c +++ b/test/testdyn.c @@ -51,10 +51,10 @@ #if CH_USE_DYNAMIC || defined(__DOXYGEN__)
#if (CH_USE_HEAP && !CH_USE_MALLOC_HEAP) || defined(__DOXYGEN__)
-static MemoryHeap heap1;
+static memory_heap_t heap1;
#endif
#if CH_USE_MEMPOOLS || defined(__DOXYGEN__)
-static MemoryPool mp1;
+static memory_pool_t mp1;
#endif
/**
diff --git a/test/testevt.c b/test/testevt.c index 5daa7f1e3..188a6fe2e 100644 --- a/test/testevt.c +++ b/test/testevt.c @@ -83,7 +83,7 @@ static void h3(eventid_t id) {(void)id;test_emit_token('C');} static ROMCONST evhandler_t evhndl[] = {h1, h2, h3};
static void evt1_execute(void) {
- EventListener el1, el2;
+ event_listener_t el1, el2;
/*
* Testing chEvtRegisterMask() and chEvtUnregister().
@@ -148,7 +148,7 @@ static msg_t thread2(void *p) { static void evt2_execute(void) {
eventmask_t m;
- EventListener el1, el2;
+ event_listener_t el1, el2;
systime_t target_time;
/*
diff --git a/test/testheap.c b/test/testheap.c index 9baa95d82..e160143aa 100644 --- a/test/testheap.c +++ b/test/testheap.c @@ -48,7 +48,7 @@ #define SIZE 16
-static MemoryHeap test_heap;
+static memory_heap_t test_heap;
/**
* @page test_heap_001 Allocation and fragmentation test
diff --git a/test/testmbox.c b/test/testmbox.c index b1fe675cc..35a22b88c 100644 --- a/test/testmbox.c +++ b/test/testmbox.c @@ -155,7 +155,7 @@ static void mbox1_execute(void) { /*
* Testing I-Class.
*/
- chSysLock()
+ chSysLock();
msg1 = chMBPostI(&mb1, 'A');
test_assert(22, msg1 == RDY_OK, "wrong wake-up message");
msg1 = chMBPostI(&mb1, 'B');
|