aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal/include
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2016-11-03 12:43:09 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2016-11-03 12:43:09 +0000
commite1d8e5357927f0748fef013fb4bddebe781c60a8 (patch)
tree389cb8d73a94f53adc36d690fb8336d29cca55ea /os/hal/include
parent13537cb7240240e6c7f915aa4d2aa6772034003b (diff)
downloadChibiOS-e1d8e5357927f0748fef013fb4bddebe781c60a8.tar.gz
ChibiOS-e1d8e5357927f0748fef013fb4bddebe781c60a8.tar.bz2
ChibiOS-e1d8e5357927f0748fef013fb4bddebe781c60a8.zip
Tentative USB suspend fix.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@9898 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/hal/include')
-rw-r--r--os/hal/include/hal_buffers.h56
-rw-r--r--os/hal/include/hal_serial_usb.h3
2 files changed, 52 insertions, 7 deletions
diff --git a/os/hal/include/hal_buffers.h b/os/hal/include/hal_buffers.h
index 21835b260..7d776f4a7 100644
--- a/os/hal/include/hal_buffers.h
+++ b/os/hal/include/hal_buffers.h
@@ -62,6 +62,10 @@ struct io_buffers_queue {
*/
threads_queue_t waiting;
/**
+ * @brief Queue suspended state flag.
+ */
+ bool suspended;
+ /**
* @brief Active buffers counter.
*/
volatile size_t bcounter;
@@ -171,6 +175,48 @@ typedef io_buffers_queue_t output_buffers_queue_t;
#define bqGetLinkX(bqp) ((bqp)->link)
/**
+ * @brief Return the suspended state of the queue.
+ *
+ * @param[in] bqp pointer to an @p io_buffers_queue_t structure
+ * @return The suspended state.
+ * @retval false if blocking access to the queue is enabled.
+ * @retval true if blocking access to the queue is suspended.
+ *
+ * @xclass
+ */
+#define bqIsSuspendedX(bqp) ((bqp)->suspended)
+
+/**
+ * @brief Puts the queue in suspended state.
+ * @details When the queue is put in suspended state all waiting threads are
+ * woken with message @p MSG_RESET and subsequent attempt at waiting
+ * on the queue will result in an immediate return with @p MSG_RESET
+ * message.
+ * @note The content of the queue is not altered, queues can be accessed
+ * is suspended state until a blocking operation is met then a
+ * @p MSG_RESET occurs.
+ *
+ * @param[in] bqp pointer to an @p io_buffers_queue_t structure
+ *
+ * @iclass
+ */
+#define bqSuspendI(bqp) { \
+ (bqp)->suspended = true; \
+ osalThreadDequeueAllI(&(bqp)->waiting, MSG_RESET); \
+}
+
+/**
+ * @brief Resumes normal queue operations.
+ *
+ * @param[in] bqp pointer to an @p io_buffers_queue_t structure
+ *
+ * @xclass
+ */
+#define bqResumeX(bqp) { \
+ (bqp)->suspended = false; \
+}
+
+/**
* @brief Evaluates to @p TRUE if the specified input buffers queue is empty.
*
* @param[in] ibqp pointer to an @p input_buffers_queue_t structure
@@ -232,9 +278,8 @@ typedef io_buffers_queue_t output_buffers_queue_t;
#ifdef __cplusplus
extern "C" {
#endif
- void ibqObjectInit(input_buffers_queue_t *ibqp, uint8_t *bp,
- size_t size, size_t n,
- bqnotify_t infy, void *link);
+ void ibqObjectInit(input_buffers_queue_t *ibqp, bool suspended, uint8_t *bp,
+ size_t size, size_t n, bqnotify_t infy, void *link);
void ibqResetI(input_buffers_queue_t *ibqp);
uint8_t *ibqGetEmptyBufferI(input_buffers_queue_t *ibqp);
void ibqPostFullBufferI(input_buffers_queue_t *ibqp, size_t size);
@@ -247,9 +292,8 @@ extern "C" {
msg_t ibqGetTimeout(input_buffers_queue_t *ibqp, systime_t timeout);
size_t ibqReadTimeout(input_buffers_queue_t *ibqp, uint8_t *bp,
size_t n, systime_t timeout);
- void obqObjectInit(output_buffers_queue_t *obqp, uint8_t *bp,
- size_t size, size_t n,
- bqnotify_t onfy, void *link);
+ void obqObjectInit(output_buffers_queue_t *obqp, bool suspended, uint8_t *bp,
+ size_t size, size_t n, bqnotify_t onfy, void *link);
void obqResetI(output_buffers_queue_t *obqp);
uint8_t *obqGetFullBufferI(output_buffers_queue_t *obqp,
size_t *sizep);
diff --git a/os/hal/include/hal_serial_usb.h b/os/hal/include/hal_serial_usb.h
index d0d3c6cd2..9d3e016b8 100644
--- a/os/hal/include/hal_serial_usb.h
+++ b/os/hal/include/hal_serial_usb.h
@@ -177,7 +177,8 @@ extern "C" {
void sduObjectInit(SerialUSBDriver *sdup);
void sduStart(SerialUSBDriver *sdup, const SerialUSBConfig *config);
void sduStop(SerialUSBDriver *sdup);
- void sduDisconnectI(SerialUSBDriver *sdup);
+ void sduSuspendHookI(SerialUSBDriver *sdup);
+ void sduWakeupHookI(SerialUSBDriver *sdup);
void sduConfigureHookI(SerialUSBDriver *sdup);
bool sduRequestsHook(USBDriver *usbp);
void sduSOFHookI(SerialUSBDriver *sdup);