Removed flags handling in BaseAsynchronousChannel. Modified serial drivers to use the new event flags.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@4671 35acf78f-673a-0410-8e92-d51de3d6d3f4master
parent
dfb876b3a1
commit
f90a0f3790
|
@ -149,16 +149,18 @@ static void termination_handler(eventid_t id) {
|
|||
}
|
||||
}
|
||||
|
||||
static EventListener sd1fel, sd2fel;
|
||||
|
||||
/**
|
||||
* @brief SD1 status change handler.
|
||||
*
|
||||
* @param[in] id event id.
|
||||
*/
|
||||
static void sd1_handler(eventid_t id) {
|
||||
chnflags_t flags;
|
||||
flagsmask_t flags;
|
||||
|
||||
(void)id;
|
||||
flags = chnGetAndClearFlags(&SD1);
|
||||
flags = chEvtGetAndClearFlags(&sd1fel);
|
||||
if ((flags & CHN_CONNECTED) && (shelltp1 == NULL)) {
|
||||
cputs("Init: connection on SD1");
|
||||
shelltp1 = shellCreate(&shell_cfg1, SHELL_WA_SIZE, NORMALPRIO + 1);
|
||||
|
@ -177,10 +179,10 @@ static void sd1_handler(eventid_t id) {
|
|||
* @param[in] id event id.
|
||||
*/
|
||||
static void sd2_handler(eventid_t id) {
|
||||
chnflags_t flags;
|
||||
flagsmask_t flags;
|
||||
|
||||
(void)id;
|
||||
flags = chnGetAndClearFlags(&SD2);
|
||||
flags = chEvtGetAndClearFlags(&sd2fel);
|
||||
if ((flags & CHN_CONNECTED) && (shelltp2 == NULL)) {
|
||||
cputs("Init: connection on SD2");
|
||||
shelltp2 = shellCreate(&shell_cfg2, SHELL_WA_SIZE, NORMALPRIO + 10);
|
||||
|
@ -238,10 +240,8 @@ int main(void) {
|
|||
*/
|
||||
cputs("Shell service started on SD1, SD2");
|
||||
cputs(" - Listening for connections on SD1");
|
||||
(void) chnGetAndClearFlags(&SD1);
|
||||
chEvtRegister(chnGetEventSource(&SD1), &sd1fel, 1);
|
||||
cputs(" - Listening for connections on SD2");
|
||||
(void) chnGetAndClearFlags(&SD2);
|
||||
chEvtRegister(chnGetEventSource(&SD2), &sd2fel, 2);
|
||||
|
||||
/*
|
||||
|
|
|
@ -147,16 +147,18 @@ static void termination_handler(eventid_t id) {
|
|||
}
|
||||
}
|
||||
|
||||
static EventListener sd1fel, sd2fel;
|
||||
|
||||
/**
|
||||
* @brief SD1 status change handler.
|
||||
*
|
||||
* @param[in] id event id.
|
||||
*/
|
||||
static void sd1_handler(eventid_t id) {
|
||||
chnflags_t flags;
|
||||
flagsmask_t flags;
|
||||
|
||||
(void)id;
|
||||
flags = chnGetAndClearFlags(&SD1);
|
||||
flags = chEvtGetAndClearFlags(&sd1fel);
|
||||
if ((flags & CHN_CONNECTED) && (shelltp1 == NULL)) {
|
||||
cputs("Init: connection on SD1");
|
||||
shelltp1 = shellCreate(&shell_cfg1, SHELL_WA_SIZE, NORMALPRIO + 1);
|
||||
|
@ -175,10 +177,10 @@ static void sd1_handler(eventid_t id) {
|
|||
* @param[in] id event id.
|
||||
*/
|
||||
static void sd2_handler(eventid_t id) {
|
||||
chnflags_t flags;
|
||||
flagsmask_t flags;
|
||||
|
||||
(void)id;
|
||||
flags = chnGetAndClearFlags(&SD2);
|
||||
flags = chEvtGetAndClearFlags(&sd2fel);
|
||||
if ((flags & CHN_CONNECTED) && (shelltp2 == NULL)) {
|
||||
cputs("Init: connection on SD2");
|
||||
shelltp2 = shellCreate(&shell_cfg2, SHELL_WA_SIZE, NORMALPRIO + 10);
|
||||
|
@ -201,7 +203,7 @@ static evhandler_t fhandlers[] = {
|
|||
* Simulator main. *
|
||||
*------------------------------------------------------------------------*/
|
||||
int main(void) {
|
||||
EventListener sd1fel, sd2fel, tel;
|
||||
EventListener tel;
|
||||
|
||||
/*
|
||||
* System initializations.
|
||||
|
@ -236,10 +238,8 @@ int main(void) {
|
|||
*/
|
||||
cputs("Shell service started on SD1, SD2");
|
||||
cputs(" - Listening for connections on SD1");
|
||||
(void) chnGetAndClearFlags(&SD1);
|
||||
chEvtRegister(chnGetEventSource(&SD1), &sd1fel, 1);
|
||||
cputs(" - Listening for connections on SD2");
|
||||
(void) chnGetAndClearFlags(&SD2);
|
||||
chEvtRegister(chnGetEventSource(&SD2), &sd2fel, 2);
|
||||
|
||||
/*
|
||||
|
|
|
@ -200,7 +200,7 @@ typedef struct {
|
|||
|
||||
#if CH_USE_EVENTS || defined(__DOXYGEN__)
|
||||
/**
|
||||
* @name I/O status flags
|
||||
* @name I/O status flags added to the event listener
|
||||
* @{
|
||||
*/
|
||||
/** @brief No pending conditions.*/
|
||||
|
@ -217,18 +217,11 @@ typedef struct {
|
|||
#define CHN_TRANSMISSION_END 16
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @brief Type of an I/O condition flags mask.
|
||||
*/
|
||||
typedef uint_fast16_t chnflags_t;
|
||||
|
||||
/**
|
||||
* @brief @p BaseAsynchronousChannel specific methods.
|
||||
*/
|
||||
#define _base_asynchronous_channel_methods \
|
||||
_base_channel_methods \
|
||||
/* Channel read method with timeout specification.*/ \
|
||||
chnflags_t (*getflags)(void *instance);
|
||||
|
||||
/**
|
||||
* @brief @p BaseAsynchronousChannel specific data.
|
||||
|
@ -236,9 +229,7 @@ typedef uint_fast16_t chnflags_t;
|
|||
#define _base_asynchronous_channel_data \
|
||||
_base_channel_data \
|
||||
/* I/O condition event source.*/ \
|
||||
EventSource event; \
|
||||
/* I/O condition flags.*/ \
|
||||
chnflags_t flags;
|
||||
EventSource event;
|
||||
|
||||
/**
|
||||
* @extends BaseChannelVMT
|
||||
|
@ -279,53 +270,22 @@ typedef struct {
|
|||
#define chnGetEventSource(ip) (&((ip)->event))
|
||||
|
||||
/**
|
||||
* @brief Adds status flags to the channel's mask.
|
||||
* @brief Adds status flags to the listeners's flags mask.
|
||||
* @details This function is usually called from the I/O ISRs in order to
|
||||
* notify I/O conditions such as data events, errors, signal
|
||||
* changes etc.
|
||||
*
|
||||
* @param[in] ip pointer to a @p BaseAsynchronousChannel or derived
|
||||
* class
|
||||
* @param[in] mask condition flags to be added to the mask
|
||||
* @param[in] flags condition flags to be added to the listener flags mask
|
||||
*
|
||||
* @iclass
|
||||
*/
|
||||
#define chnAddFlagsI(ip, mask) { \
|
||||
(ip)->flags |= (mask); \
|
||||
chEvtBroadcastI(&(ip)->event); \
|
||||
#define chnAddFlagsI(ip, flags) { \
|
||||
chEvtBroadcastFlagsI(&(ip)->event, flags); \
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Returns and clears the status flags associated to the channel.
|
||||
*
|
||||
* @param[in] ip pointer to a @p BaseAsynchronousChannel or derived
|
||||
* class
|
||||
* @return The condition flags modified since last time this
|
||||
* function was invoked.
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
#define chnGetAndClearFlags(ip) ((ip)->vmt->getflags(ip))
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @brief Default implementation of the @p getflags virtual method.
|
||||
*
|
||||
* @param[in] ip pointer to a @p BaseAsynchronousChannel or derived
|
||||
* class
|
||||
* @return The condition flags modified since last time this
|
||||
* function was invoked.
|
||||
*
|
||||
* @notapi
|
||||
*/
|
||||
#define _chn_get_and_clear_flags_impl(ip) \
|
||||
chnflags_t mask; \
|
||||
chSysLock(); \
|
||||
mask = ((BaseAsynchronousChannel *)(ip))->flags; \
|
||||
((BaseAsynchronousChannel *)(ip))->flags = CHN_NO_ERROR; \
|
||||
chSysUnlock(); \
|
||||
return mask
|
||||
|
||||
#endif /* CH_USE_EVENTS */
|
||||
|
||||
#endif /* _IO_CHANNEL_H_ */
|
||||
|
|
|
@ -139,7 +139,7 @@ static void usart_deinit(AT91PS_USART u) {
|
|||
* @param[in] sdp communication channel associated to the USART
|
||||
*/
|
||||
static void set_error(SerialDriver *sdp, AT91_REG csr) {
|
||||
chnflags_t sts = 0;
|
||||
flagsmask_t sts = 0;
|
||||
|
||||
if (csr & AT91C_US_OVRE)
|
||||
sts |= SD_OVERRUN_ERROR;
|
||||
|
|
|
@ -70,7 +70,7 @@ static const SerialConfig default_config = {
|
|||
/*===========================================================================*/
|
||||
|
||||
static void set_error(uint8_t sra, SerialDriver *sdp) {
|
||||
chnflags_t sts = 0;
|
||||
flagsmask_t sts = 0;
|
||||
uint8_t dor = 0;
|
||||
uint8_t upe = 0;
|
||||
uint8_t fe = 0;
|
||||
|
|
|
@ -101,7 +101,7 @@ static void uart_deinit(LPC_USART_Type *u) {
|
|||
* @param[in] err UART LSR register value
|
||||
*/
|
||||
static void set_error(SerialDriver *sdp, IOREG32 err) {
|
||||
chnflags_t sts = 0;
|
||||
flagsmask_t sts = 0;
|
||||
|
||||
if (err & LSR_OVERRUN)
|
||||
sts |= SD_OVERRUN_ERROR;
|
||||
|
|
|
@ -101,7 +101,7 @@ static void uart_deinit(LPC_UART_TypeDef *u) {
|
|||
* @param[in] err UART LSR register value
|
||||
*/
|
||||
static void set_error(SerialDriver *sdp, IOREG32 err) {
|
||||
chnflags_t sts = 0;
|
||||
flagsmask_t sts = 0;
|
||||
|
||||
if (err & LSR_OVERRUN)
|
||||
sts |= SD_OVERRUN_ERROR;
|
||||
|
|
|
@ -101,7 +101,7 @@ static void uart_deinit(LPC_UART_TypeDef *u) {
|
|||
* @param[in] err UART LSR register value
|
||||
*/
|
||||
static void set_error(SerialDriver *sdp, IOREG32 err) {
|
||||
chnflags_t sts = 0;
|
||||
flagsmask_t sts = 0;
|
||||
|
||||
if (err & LSR_OVERRUN)
|
||||
sts |= SD_OVERRUN_ERROR;
|
||||
|
|
|
@ -106,7 +106,7 @@ static void uart_deinit(UART *u) {
|
|||
* @param[in] err UART LSR register value
|
||||
*/
|
||||
static void set_error(SerialDriver *sdp, IOREG32 err) {
|
||||
chnflags_t sts = 0;
|
||||
flagsmask_t sts = 0;
|
||||
|
||||
if (err & LSR_OVERRUN)
|
||||
sts |= SD_OVERRUN_ERROR;
|
||||
|
|
|
@ -60,7 +60,7 @@ static const SerialConfig default_config = {
|
|||
/*===========================================================================*/
|
||||
|
||||
static void set_error(SerialDriver *sdp, uint8_t urctl) {
|
||||
chnflags_t sts = 0;
|
||||
flagsmask_t sts = 0;
|
||||
|
||||
if (urctl & OE)
|
||||
sts |= SD_OVERRUN_ERROR;
|
||||
|
|
|
@ -117,7 +117,7 @@ static void esci_deinit(volatile struct ESCI_tag *escip) {
|
|||
* @param[in] sr eSCI SR register value
|
||||
*/
|
||||
static void set_error(SerialDriver *sdp, uint32_t sr) {
|
||||
chnflags_t sts = 0;
|
||||
flagsmask_t sts = 0;
|
||||
|
||||
if (sr & 0x08000000)
|
||||
sts |= SD_OVERRUN_ERROR;
|
||||
|
|
|
@ -133,7 +133,7 @@ static void usart_deinit(USART_TypeDef *u) {
|
|||
* @param[in] isr USART ISR register value
|
||||
*/
|
||||
static void set_error(SerialDriver *sdp, uint16_t isr) {
|
||||
chnflags_t sts = 0;
|
||||
flagsmask_t sts = 0;
|
||||
|
||||
if (isr & USART_ISR_ORE)
|
||||
sts |= SD_OVERRUN_ERROR;
|
||||
|
@ -252,7 +252,7 @@ static void usart_deinit(USART_TypeDef *u) {
|
|||
* @param[in] sr USART SR register value
|
||||
*/
|
||||
static void set_error(SerialDriver *sdp, uint16_t sr) {
|
||||
chnflags_t sts = 0;
|
||||
flagsmask_t sts = 0;
|
||||
|
||||
if (sr & USART_SR_ORE)
|
||||
sts |= SD_OVERRUN_ERROR;
|
||||
|
|
|
@ -115,7 +115,7 @@ static void notify3(GenericQueue *qp) {
|
|||
* @notapi
|
||||
*/
|
||||
void sd_lld_set_error(SerialDriver *sdp, uint8_t sr) {
|
||||
chnflags_t sts = 0;
|
||||
flagsmask_t sts = 0;
|
||||
|
||||
if (sr & USART_SR_OR)
|
||||
sts |= SD_OVERRUN_ERROR;
|
||||
|
|
|
@ -73,7 +73,7 @@ static ROMCONST SerialConfig default_config = {
|
|||
/*===========================================================================*/
|
||||
|
||||
static void set_error(SerialDriver *sdp, uint8_t sr) {
|
||||
chnflags_t sts = 0;
|
||||
flagsmask_t sts = 0;
|
||||
|
||||
/* Note, SR register bit definitions are equal for all UARTs so using
|
||||
the UART1 definitions is fine.*/
|
||||
|
|
|
@ -94,14 +94,9 @@ static size_t readt(void *ip, uint8_t *bp, size_t n, systime_t time) {
|
|||
return chIQReadTimeout(&((SerialDriver *)ip)->iqueue, bp, n, time);
|
||||
}
|
||||
|
||||
static chnflags_t getflags(void *ip) {
|
||||
_chn_get_and_clear_flags_impl(ip);
|
||||
}
|
||||
|
||||
static const struct SerialDriverVMT vmt = {
|
||||
write, read, put, get,
|
||||
putt, gett, writet, readt,
|
||||
getflags
|
||||
putt, gett, writet, readt
|
||||
};
|
||||
|
||||
/*===========================================================================*/
|
||||
|
@ -139,7 +134,6 @@ void sdObjectInit(SerialDriver *sdp, qnotify_t inotify, qnotify_t onotify) {
|
|||
|
||||
sdp->vmt = &vmt;
|
||||
chEvtInit(&sdp->event);
|
||||
sdp->flags = CHN_NO_ERROR;
|
||||
sdp->state = SD_STOP;
|
||||
chIQInit(&sdp->iqueue, sdp->ib, SERIAL_BUFFERS_SIZE, inotify, sdp);
|
||||
chOQInit(&sdp->oqueue, sdp->ob, SERIAL_BUFFERS_SIZE, onotify, sdp);
|
||||
|
|
|
@ -103,14 +103,9 @@ static size_t readt(void *ip, uint8_t *bp, size_t n, systime_t time) {
|
|||
return chIQReadTimeout(&((SerialUSBDriver *)ip)->iqueue, bp, n, time);
|
||||
}
|
||||
|
||||
static chnflags_t getflags(void *ip) {
|
||||
_chn_get_and_clear_flags_impl(ip);
|
||||
}
|
||||
|
||||
static const struct SerialUSBDriverVMT vmt = {
|
||||
write, read, put, get,
|
||||
putt, gett, writet, readt,
|
||||
getflags
|
||||
putt, gett, writet, readt
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -197,7 +192,6 @@ void sduObjectInit(SerialUSBDriver *sdup) {
|
|||
|
||||
sdup->vmt = &vmt;
|
||||
chEvtInit(&sdup->event);
|
||||
sdup->flags = CHN_NO_ERROR;
|
||||
sdup->state = SDU_STOP;
|
||||
chIQInit(&sdup->iqueue, sdup->ib, SERIAL_USB_BUFFERS_SIZE, inotify, sdup);
|
||||
chOQInit(&sdup->oqueue, sdup->ob, SERIAL_USB_BUFFERS_SIZE, onotify, sdup);
|
||||
|
@ -256,7 +250,6 @@ void sduStop(SerialUSBDriver *sdup) {
|
|||
void sduConfigureHookI(USBDriver *usbp) {
|
||||
SerialUSBDriver *sdup = usbp->param;
|
||||
|
||||
sdup->flags = CHN_NO_ERROR;
|
||||
chIQResetI(&sdup->iqueue);
|
||||
chOQResetI(&sdup->oqueue);
|
||||
chnAddFlagsI(sdup, CHN_CONNECTED);
|
||||
|
|
|
@ -85,14 +85,18 @@
|
|||
*** 2.5.1 ***
|
||||
- FIX: Fixed Data available event not generated in serial_usb driver (bug
|
||||
3567992).
|
||||
- NEW: Modified serial and serial_usb drivers to use the new event flags
|
||||
mechanism, the previous flags handling in BaseAsynchronousChannel has
|
||||
been removed.
|
||||
- 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().
|
||||
Some old APIs have been renamed to increase consistency of the module.
|
||||
- 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.
|
||||
- NEW: Updated the Power Architecture rules.mk file to put object and listing
|
||||
files into a ./build directory like ARM ports alread do.
|
||||
files into a ./build directory like ARM ports already do.
|
||||
|
||||
*** 2.5.0 ***
|
||||
- FIX: Fixed anomaly in USB enumeration (bug 3565325)(backported to 2.4.3).
|
||||
|
|
Loading…
Reference in New Issue