aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2013-08-26 13:01:28 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2013-08-26 13:01:28 +0000
commit611c3138873b38fd26c19c43ce3436fe0528604a (patch)
tree3c277815a727c52170d2ca76555ffaa53810a4be /os/hal
parent5901a354ef4dbc849a3f6ed9539597c27cdb3810 (diff)
downloadChibiOS-611c3138873b38fd26c19c43ce3436fe0528604a.tar.gz
ChibiOS-611c3138873b38fd26c19c43ce3436fe0528604a.tar.bz2
ChibiOS-611c3138873b38fd26c19c43ce3436fe0528604a.zip
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6225 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/hal')
-rw-r--r--os/hal/osal/chibios/osal.h36
-rw-r--r--os/hal/platforms/STM32/USBv1/usb_lld.c20
-rw-r--r--os/hal/platforms/STM32/USBv1/usb_lld.h4
3 files changed, 46 insertions, 14 deletions
diff --git a/os/hal/osal/chibios/osal.h b/os/hal/osal/chibios/osal.h
index 937b0f38e..55141960b 100644
--- a/os/hal/osal/chibios/osal.h
+++ b/os/hal/osal/chibios/osal.h
@@ -119,6 +119,13 @@
#if 0
/**
+ * @brief Type of a system status word.
+ */
+typedef uint32_t syssts_t;
+#endif
+
+#if 0
+/**
* @brief Type of a message.
*/
typedef int32_t msg_t;
@@ -390,6 +397,35 @@ static inline void osalSysUnlockFromISR(void) {
}
/**
+ * @brief Returns the execution context and enters the kernel lock mode.
+ * @details This functions enters into a critical zone and can be called
+ * from any context. Because its flexibility it is less efficient
+ * than @p chSysLock() which is preferable when the calling context
+ * is known.
+ *
+ * @return The previous system status, the encoding of this
+ * status word is architecture-dependent and opaque.
+ *
+ * @xclass
+ */
+static inline syssts_t osalSysGetAndLockX(void) {
+
+ return chSysGetAndLockX();
+}
+
+/**
+ * @brief Restores the specified execution status.
+ *
+ * @param[in] sts the system status to be restored.
+ *
+ * @xclass
+ */
+static inline void osalSysRestoreLockX(syssts_t sts) {
+
+ chSysRestoreLockX(sts);
+}
+
+/**
* @brief Polled delay.
* @note The real delay is always few cycles in excess of the specified
* value.
diff --git a/os/hal/platforms/STM32/USBv1/usb_lld.c b/os/hal/platforms/STM32/USBv1/usb_lld.c
index bdf202a81..6f1dbc099 100644
--- a/os/hal/platforms/STM32/USBv1/usb_lld.c
+++ b/os/hal/platforms/STM32/USBv1/usb_lld.c
@@ -24,7 +24,6 @@
#include <string.h>
-#include "ch.h"
#include "hal.h"
#if HAL_USE_USB || defined(__DOXYGEN__)
@@ -177,9 +176,10 @@ static void usb_packet_read_to_queue(stm32_usb_descriptor_t *udp,
/* Updating queue.*/
osalSysLockFromISR();
+
iqp->q_counter += n;
- while (queue_notempty(&iqp->q_waiting))
- chSchReadyI(queue_fifo_remove(&iqp->q_waiting))->p_u.rdymsg = Q_OK;
+ osalQueueWakeupAllI(&iqp->q_waiting, Q_OK);
+
osalSysUnlockFromISR();
}
@@ -222,6 +222,7 @@ static void usb_packet_write_from_buffer(stm32_usb_descriptor_t *udp,
static void usb_packet_write_from_queue(stm32_usb_descriptor_t *udp,
output_queue_t *oqp, size_t n) {
size_t nhw;
+ syssts_t sts;
uint32_t *pmap = USB_ADDR2PTR(udp->TXADDR0);
udp->TXCOUNT0 = (uint16_t)n;
@@ -246,18 +247,13 @@ static void usb_packet_write_from_queue(stm32_usb_descriptor_t *udp,
oqp->q_rdptr = oqp->q_buffer;
}
- /* Updating queue. Note, the lock is done in this unusual way because this
- function can be called from both ISR and thread context so the kind
- of lock function to be invoked cannot be decided beforehand.*/
- port_lock();
- _dbg_enter_lock();
+ /* Updating queue.*/
+ sts = osalSysGetAndLockX();
oqp->q_counter += n;
- while (queue_notempty(&oqp->q_waiting))
- chSchReadyI(queue_fifo_remove(&oqp->q_waiting))->p_u.rdymsg = Q_OK;
+ osalQueueWakeupAllI(&oqp->q_waiting, Q_OK);
- _dbg_leave_lock();
- port_unlock();
+ osalSysRestoreLockX(sts);
}
/*===========================================================================*/
diff --git a/os/hal/platforms/STM32/USBv1/usb_lld.h b/os/hal/platforms/STM32/USBv1/usb_lld.h
index aae229754..042129758 100644
--- a/os/hal/platforms/STM32/USBv1/usb_lld.h
+++ b/os/hal/platforms/STM32/USBv1/usb_lld.h
@@ -114,7 +114,7 @@ typedef struct {
/**
* @brief Buffer mode, queue or linear.
*/
- bool_t txqueued;
+ bool txqueued;
/**
* @brief Requested transmit transfer size.
*/
@@ -147,7 +147,7 @@ typedef struct {
/**
* @brief Buffer mode, queue or linear.
*/
- bool_t rxqueued;
+ bool rxqueued;
/**
* @brief Requested receive transfer size.
*/