Kernel events improvements.

git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@4667 35acf78f-673a-0410-8e92-d51de3d6d3f4
master
gdisirio 2012-09-16 08:31:38 +00:00
parent 98c5ccf6b8
commit 5b39691e9e
15 changed files with 95 additions and 29 deletions

View File

@ -17,6 +17,9 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
Concepts and parts of this file have been contributed by Scott (skute).
*/
/**
* @file chevents.h
@ -45,6 +48,8 @@ struct EventListener {
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
bu the event source.*/
};
/**
@ -166,8 +171,8 @@ extern "C" {
void chEvtUnregister(EventSource *esp, EventListener *elp);
eventmask_t chEvtClearFlags(eventmask_t mask);
eventmask_t chEvtAddFlags(eventmask_t mask);
void chEvtSignalFlags(Thread *tp, eventmask_t mask);
void chEvtSignalFlagsI(Thread *tp, eventmask_t mask);
void chEvtSignal(Thread *tp, eventmask_t mask);
void chEvtSignalI(Thread *tp, eventmask_t mask);
void chEvtBroadcastFlags(EventSource *esp, eventmask_t mask);
void chEvtBroadcastFlagsI(EventSource *esp, eventmask_t mask);
void chEvtDispatch(const evhandler_t *handlers, eventmask_t mask);

View File

@ -17,6 +17,9 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
Concepts and parts of this file have been contributed by Scott (skute).
*/
/**
* @file chevents.c
@ -81,6 +84,7 @@ void chEvtRegisterMask(EventSource *esp, EventListener *elp, eventmask_t mask) {
esp->es_next = elp;
elp->el_listener = currp;
elp->el_mask = mask;
elp->el_flags = 0;
chSysUnlock();
}
@ -154,25 +158,25 @@ eventmask_t chEvtAddFlags(eventmask_t mask) {
}
/**
* @brief Adds (OR) a set of event flags on the specified @p Thread.
* @brief Adds a set of event flags directly to specified @p Thread.
*
* @param[in] tp the thread to be signaled
* @param[in] mask the event flags set to be ORed
*
* @api
*/
void chEvtSignalFlags(Thread *tp, eventmask_t mask) {
void chEvtSignal(Thread *tp, eventmask_t mask) {
chDbgCheck(tp != NULL, "chEvtSignal");
chSysLock();
chEvtSignalFlagsI(tp, mask);
chEvtSignalI(tp, mask);
chSchRescheduleS();
chSysUnlock();
}
/**
* @brief Adds (OR) a set of event flags on the specified @p Thread.
* @brief Adds a set of event flags directly to specified @p Thread.
* @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
@ -183,7 +187,7 @@ void chEvtSignalFlags(Thread *tp, eventmask_t mask) {
*
* @iclass
*/
void chEvtSignalFlagsI(Thread *tp, eventmask_t mask) {
void chEvtSignalI(Thread *tp, eventmask_t mask) {
chDbgCheckClassI();
chDbgCheck(tp != NULL, "chEvtSignalI");
@ -206,14 +210,14 @@ void chEvtSignalFlagsI(Thread *tp, eventmask_t mask) {
* @p EventListener objects.
*
* @param[in] esp pointer to the @p EventSource structure
* @param[in] mask the event flags set to be ORed
* @param[in] flags the flags set to be added to the listener flags mask
*
* @api
*/
void chEvtBroadcastFlags(EventSource *esp, eventmask_t mask) {
void chEvtBroadcastFlags(EventSource *esp, flagsmask_t flags) {
chSysLock();
chEvtBroadcastFlagsI(esp, mask);
chEvtBroadcastFlagsI(esp, flags);
chSchRescheduleS();
chSysUnlock();
}
@ -231,11 +235,11 @@ void chEvtBroadcastFlags(EventSource *esp, eventmask_t mask) {
* reschedule must not be performed in ISRs.
*
* @param[in] esp pointer to the @p EventSource structure
* @param[in] mask the event flags set to be ORed
* @param[in] flags the flags set to be added to the listener flags mask
*
* @iclass
*/
void chEvtBroadcastFlagsI(EventSource *esp, eventmask_t mask) {
void chEvtBroadcastFlagsI(EventSource *esp, flagsmask_t flags) {
EventListener *elp;
chDbgCheckClassI();
@ -243,11 +247,54 @@ void chEvtBroadcastFlagsI(EventSource *esp, eventmask_t mask) {
elp = esp->es_next;
while (elp != (EventListener *)esp) {
chEvtSignalFlagsI(elp->el_listener, elp->el_mask | mask);
elp->el_flags |= flags;
chEvtSignalI(elp->el_listener, elp->el_mask);
elp = elp->el_next;
}
}
/**
* @brief Returns the flags associated to an @p EventListener.
* @details The flags are returned and the @p EventListener flags mask is
* cleared.
*
* @param[in] elp pointer to the @p EventListener structure
* @return The flags added to the listener by the associated
* event source.
*
* @iclass
*/
flagsmask_t chEvtGetAndClearFlagsI(EventListener *elp) {
flagsmask_t flags;
flags = elp->el_flags;
elp->el_flags = 0;
return flags;
}
/**
* @brief Returns the flags associated to an @p EventListener.
* @details The flags are returned and the @p EventListener flags mask is
* cleared.
*
* @param[in] elp pointer to the @p EventListener structure
* @return The flags added to the listener by the associated
* event source.
*
* @iclass
*/
flagsmask_t chEvtGetAndClearFlags(EventListener *elp) {
flagsmask_t flags;
chSysLock();
flags = elp->el_flags;
elp->el_flags = 0;
chSysUnlock();
return flags;
}
/**
* @brief Invokes the event handlers associated to an event flags mask.
*

View File

@ -46,7 +46,8 @@ 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; /**< Events mask. */
typedef uint32_t eventmask_t; /**< Event mask. */
typedef uint32_t flagsmask_t; /**< Event flags. */
typedef uint32_t systime_t; /**< System time. */
typedef int32_t cnt_t; /**< Resources counter. */

View File

@ -44,7 +44,8 @@ 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; /**< Events mask. */
typedef uint32_t eventmask_t; /**< Event mask. */
typedef uint32_t flagsmask_t; /**< Event flags. */
typedef uint32_t systime_t; /**< System time. */
typedef int32_t cnt_t; /**< Resources counter. */

View File

@ -46,7 +46,8 @@ typedef uint8_t tslices_t; /**< Thread time slices counter. */
typedef uint8_t tprio_t; /**< Thread priority. */
typedef int16_t msg_t; /**< Inter-thread message. */
typedef uint8_t eventid_t; /**< Event Id. */
typedef uint8_t eventmask_t; /**< Events mask. */
typedef uint8_t eventmask_t; /**< Event mask. */
typedef uint8_t flagsmask_t; /**< Event flags. */
typedef uint16_t systime_t; /**< System time. */
typedef int8_t cnt_t; /**< Resources counter. */

View File

@ -46,7 +46,8 @@ typedef uint8_t tslices_t; /**< Thread time slices counter. */
typedef uint16_t tprio_t; /**< Thread priority. */
typedef int16_t msg_t; /**< Inter-thread message. */
typedef int16_t eventid_t; /**< Event Id. */
typedef uint16_t eventmask_t; /**< Events mask. */
typedef uint16_t eventmask_t; /**< Event mask. */
typedef uint16_t flagsmask_t; /**< Event flags. */
typedef uint16_t systime_t; /**< System time. */
typedef int16_t cnt_t; /**< Resources counter. */

View File

@ -58,7 +58,8 @@ 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; /**< Events mask. */
typedef uint32_t eventmask_t; /**< Event mask. */
typedef uint32_t flagsmask_t; /**< Event flags. */
typedef uint32_t systime_t; /**< System time. */
typedef int32_t cnt_t; /**< Resources counter. */

View File

@ -38,7 +38,8 @@ 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; /**< Events mask. */
typedef uint32_t eventmask_t; /**< Event mask. */
typedef uint32_t flagsmask_t; /**< Event flags. */
typedef uint32_t systime_t; /**< System time. */
typedef int32_t cnt_t; /**< Resources counter. */

View File

@ -44,7 +44,8 @@ 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; /**< Events mask. */
typedef uint32_t eventmask_t; /**< Event mask. */
typedef uint32_t flagsmask_t; /**< Event flags. */
typedef uint32_t systime_t; /**< System time. */
typedef int32_t cnt_t; /**< Resources counter. */

View File

@ -45,7 +45,8 @@ typedef uint8_t tslices_t; /**< Thread time slices counter. */
typedef uint8_t tprio_t; /**< Thread priority. */
typedef int16_t msg_t; /**< Inter-thread message. */
typedef int8_t eventid_t; /**< Event Id. */
typedef uint8_t eventmask_t; /**< Events mask. */
typedef uint8_t eventmask_t; /**< Event mask. */
typedef uint8_t flagsmask_t; /**< Event flags. */
typedef uint16_t systime_t; /**< System time. */
typedef int8_t cnt_t; /**< Resources counter. */

View File

@ -55,7 +55,8 @@ typedef uint8_t tslices_t; /**< Thread time slices counter. */
typedef uint8_t tprio_t; /**< Thread priority. */
typedef int16_t msg_t; /**< Inter-thread message. */
typedef int8_t eventid_t; /**< Event Id. */
typedef uint8_t eventmask_t; /**< Events mask. */
typedef uint8_t eventmask_t; /**< Event mask. */
typedef uint8_t flagsmask_t; /**< Event flags. */
typedef uint16_t systime_t; /**< System time. */
typedef int8_t cnt_t; /**< Resources counter. */

View File

@ -44,7 +44,8 @@ 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; /**< Events mask. */
typedef uint32_t eventmask_t; /**< Event mask. */
typedef uint32_t flagsmask_t; /**< Event flags. */
typedef uint32_t systime_t; /**< System time. */
typedef int32_t cnt_t; /**< Resources counter. */

View File

@ -55,7 +55,8 @@ typedef uint8_t tslices_t; /**< Thread time slices counter. */
typedef uint8_t tprio_t; /**< Thread priority. */
typedef int16_t msg_t; /**< Inter-thread message. */
typedef int8_t eventid_t; /**< Event Id. */
typedef uint8_t eventmask_t; /**< Events mask. */
typedef uint8_t eventmask_t; /**< Event mask. */
typedef uint8_t flagsmask_t; /**< Event flags. */
typedef uint16_t systime_t; /**< System time. */
typedef int8_t cnt_t; /**< Resources counter. */

View File

@ -85,6 +85,9 @@
*** 2.5.1 ***
- FIX: Fixed Data available event not generated in serial_usb driver (bug
3567992).
- NEW: Improved the kernel events subsystem, now event sources can associate
source-specific flags to the listener, the flags can then be retrieved
using the new APIs chEvtGetAndClearFlags() and chEvtGetAndClearFlagsI().
- NEW: Added VLE support to the Power Architecture GCC port.
- NEW: Reorganized the Power Architecture GCC port along the lines of the
ARMCMx port, now it can support multiple core types.

View File

@ -137,7 +137,7 @@ static void evt2_setup(void) {
static msg_t thread1(void *p) {
chThdSleepMilliseconds(50);
chEvtSignalFlags((Thread *)p, 1);
chEvtSignal((Thread *)p, 1);
return 0;
}