fixed osal critical section protect adapt 64bits CPU.
This commit is contained in:
@@ -45,7 +45,7 @@ if GetDepend(['PKG_CHERRYUSB_USING_DEVICE']):
|
|||||||
CPPDEFINES += ['USB_BASE=0x40080000UL']
|
CPPDEFINES += ['USB_BASE=0x40080000UL']
|
||||||
if GetDepend(['CHERRYUSB_USING_MUSB']):
|
if GetDepend(['CHERRYUSB_USING_MUSB']):
|
||||||
src += Glob('port/musb/usb_dc_musb.c')
|
src += Glob('port/musb/usb_dc_musb.c')
|
||||||
if GetDepend(['CHERRYUSB_USING_CDC_DEMO']):
|
if GetDepend(['CHERRYUSB_USING_CDC_DEMO']):
|
||||||
src += Glob('demo/cdc_acm_template.c')
|
src += Glob('demo/cdc_acm_template.c')
|
||||||
|
|
||||||
# USB HOST
|
# USB HOST
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ static uint32_t g_devinuse = 0;
|
|||||||
|
|
||||||
static int usbh_cdc_acm_devno_alloc(struct usbh_cdc_acm *priv)
|
static int usbh_cdc_acm_devno_alloc(struct usbh_cdc_acm *priv)
|
||||||
{
|
{
|
||||||
uint32_t flags;
|
size_t flags;
|
||||||
int devno;
|
int devno;
|
||||||
|
|
||||||
flags = usb_osal_enter_critical_section();
|
flags = usb_osal_enter_critical_section();
|
||||||
@@ -68,7 +68,7 @@ static void usbh_cdc_acm_devno_free(struct usbh_cdc_acm *priv)
|
|||||||
int devno = priv->minor;
|
int devno = priv->minor;
|
||||||
|
|
||||||
if (devno >= 0 && devno < 32) {
|
if (devno >= 0 && devno < 32) {
|
||||||
uint32_t flags = usb_osal_enter_critical_section();
|
size_t flags = usb_osal_enter_critical_section();
|
||||||
g_devinuse &= ~(1 << devno);
|
g_devinuse &= ~(1 << devno);
|
||||||
usb_osal_leave_critical_section(flags);
|
usb_osal_leave_critical_section(flags);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ static uint32_t g_devinuse = 0;
|
|||||||
|
|
||||||
static int usbh_hid_devno_alloc(struct usbh_hid *priv)
|
static int usbh_hid_devno_alloc(struct usbh_hid *priv)
|
||||||
{
|
{
|
||||||
uint32_t flags;
|
size_t flags;
|
||||||
int devno;
|
int devno;
|
||||||
|
|
||||||
flags = usb_osal_enter_critical_section();
|
flags = usb_osal_enter_critical_section();
|
||||||
@@ -68,7 +68,7 @@ static void usbh_hid_devno_free(struct usbh_hid *priv)
|
|||||||
int devno = priv->minor;
|
int devno = priv->minor;
|
||||||
|
|
||||||
if (devno >= 0 && devno < 32) {
|
if (devno >= 0 && devno < 32) {
|
||||||
uint32_t flags = usb_osal_enter_critical_section();
|
size_t size_t = usb_osal_enter_critical_section();
|
||||||
g_devinuse &= ~(1 << devno);
|
g_devinuse &= ~(1 << devno);
|
||||||
usb_osal_leave_critical_section(flags);
|
usb_osal_leave_critical_section(flags);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ static inline void usbh_hub_unregister(struct usbh_hub *hub)
|
|||||||
|
|
||||||
static int usbh_hub_devno_alloc(struct usbh_hub *hub)
|
static int usbh_hub_devno_alloc(struct usbh_hub *hub)
|
||||||
{
|
{
|
||||||
uint32_t flags;
|
size_t flags;
|
||||||
int devno;
|
int devno;
|
||||||
|
|
||||||
flags = usb_osal_enter_critical_section();
|
flags = usb_osal_enter_critical_section();
|
||||||
@@ -88,7 +88,7 @@ static void usbh_hub_devno_free(struct usbh_hub *hub)
|
|||||||
int devno = hub->index;
|
int devno = hub->index;
|
||||||
|
|
||||||
if (devno >= 2 && devno < 32) {
|
if (devno >= 2 && devno < 32) {
|
||||||
uint32_t flags = usb_osal_enter_critical_section();
|
size_t flags = usb_osal_enter_critical_section();
|
||||||
g_devinuse &= ~(1 << devno);
|
g_devinuse &= ~(1 << devno);
|
||||||
usb_osal_leave_critical_section(flags);
|
usb_osal_leave_critical_section(flags);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ static uint32_t g_devinuse = 0;
|
|||||||
|
|
||||||
static int usbh_msc_devno_alloc(struct usbh_msc *priv)
|
static int usbh_msc_devno_alloc(struct usbh_msc *priv)
|
||||||
{
|
{
|
||||||
uint32_t flags;
|
size_t flags;
|
||||||
int devno;
|
int devno;
|
||||||
|
|
||||||
flags = usb_osal_enter_critical_section();
|
flags = usb_osal_enter_critical_section();
|
||||||
@@ -69,7 +69,7 @@ static void usbh_msc_devno_free(struct usbh_msc *priv)
|
|||||||
int devno = priv->sdchar - 'a';
|
int devno = priv->sdchar - 'a';
|
||||||
|
|
||||||
if (devno >= 0 && devno < 26) {
|
if (devno >= 0 && devno < 26) {
|
||||||
uint32_t flags = usb_osal_enter_critical_section();
|
size_t flags = usb_osal_enter_critical_section();
|
||||||
g_devinuse &= ~(1 << devno);
|
g_devinuse &= ~(1 << devno);
|
||||||
usb_osal_leave_critical_section(flags);
|
usb_osal_leave_critical_section(flags);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -171,7 +171,7 @@ void usbh_hport_activate(struct usbh_hubport *hport)
|
|||||||
|
|
||||||
void usbh_hport_deactivate(struct usbh_hubport *hport)
|
void usbh_hport_deactivate(struct usbh_hubport *hport)
|
||||||
{
|
{
|
||||||
uint32_t flags;
|
size_t flags;
|
||||||
|
|
||||||
/* Don't free the control pipe of root hub ports! */
|
/* Don't free the control pipe of root hub ports! */
|
||||||
if (hport->parent != NULL && hport->ep0 != NULL) {
|
if (hport->parent != NULL && hport->ep0 != NULL) {
|
||||||
@@ -674,7 +674,7 @@ static int usbh_portchange_wait(struct usbh_hubport **hport)
|
|||||||
{
|
{
|
||||||
struct usbh_hubport *connport = NULL;
|
struct usbh_hubport *connport = NULL;
|
||||||
uint32_t recved_event;
|
uint32_t recved_event;
|
||||||
uint32_t flags;
|
size_t flags;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
/* Loop until a change in connection state is detected */
|
/* Loop until a change in connection state is detected */
|
||||||
@@ -775,7 +775,7 @@ static void usbh_portchange_detect_thread(void *argument)
|
|||||||
|
|
||||||
void usbh_external_hport_connect(struct usbh_hubport *hport)
|
void usbh_external_hport_connect(struct usbh_hubport *hport)
|
||||||
{
|
{
|
||||||
uint32_t flags;
|
size_t flags;
|
||||||
|
|
||||||
usbh_hport_activate(hport);
|
usbh_hport_activate(hport);
|
||||||
|
|
||||||
@@ -790,7 +790,7 @@ void usbh_external_hport_connect(struct usbh_hubport *hport)
|
|||||||
|
|
||||||
void usbh_external_hport_disconnect(struct usbh_hubport *hport)
|
void usbh_external_hport_disconnect(struct usbh_hubport *hport)
|
||||||
{
|
{
|
||||||
uint32_t flags;
|
size_t flags;
|
||||||
|
|
||||||
flags = usb_osal_enter_critical_section();
|
flags = usb_osal_enter_critical_section();
|
||||||
|
|
||||||
|
|||||||
@@ -51,8 +51,8 @@ void usb_osal_event_delete(usb_osal_event_t event);
|
|||||||
int usb_osal_event_recv(usb_osal_event_t event, uint32_t set, uint32_t *recved);
|
int usb_osal_event_recv(usb_osal_event_t event, uint32_t set, uint32_t *recved);
|
||||||
int usb_osal_event_send(usb_osal_event_t event, uint32_t set);
|
int usb_osal_event_send(usb_osal_event_t event, uint32_t set);
|
||||||
|
|
||||||
uint32_t usb_osal_enter_critical_section(void);
|
size_t usb_osal_enter_critical_section(void);
|
||||||
void usb_osal_leave_critical_section(uint32_t flag);
|
void usb_osal_leave_critical_section(size_t flag);
|
||||||
|
|
||||||
void usb_osal_msleep(uint32_t delay);
|
void usb_osal_msleep(uint32_t delay);
|
||||||
|
|
||||||
|
|||||||
@@ -131,13 +131,13 @@ int usb_osal_event_send(usb_osal_event_t event, uint32_t set)
|
|||||||
return (ret == pdPASS) ? 0 : -1;
|
return (ret == pdPASS) ? 0 : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t usb_osal_enter_critical_section(void)
|
size_t usb_osal_enter_critical_section(void)
|
||||||
{
|
{
|
||||||
taskENTER_CRITICAL();
|
taskENTER_CRITICAL();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void usb_osal_leave_critical_section(uint32_t flag)
|
void usb_osal_leave_critical_section(size_t flag)
|
||||||
{
|
{
|
||||||
taskEXIT_CRITICAL();
|
taskEXIT_CRITICAL();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -117,17 +117,17 @@ int usb_osal_event_send(usb_osal_event_t event, uint32_t set)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t usb_osal_enter_critical_section(void)
|
size_t usb_osal_enter_critical_section(void)
|
||||||
{
|
{
|
||||||
return rt_hw_interrupt_disable();
|
return rt_hw_interrupt_disable();
|
||||||
}
|
}
|
||||||
|
|
||||||
void usb_osal_leave_critical_section(uint32_t flag)
|
void usb_osal_leave_critical_section(size_t flag)
|
||||||
{
|
{
|
||||||
rt_hw_interrupt_enable(flag);
|
rt_hw_interrupt_enable(flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
void usb_osal_msleep(uint32_t delay)
|
void usb_osal_msleep(uint32_t delay)
|
||||||
{
|
{
|
||||||
rt_thread_mdelay(rt_tick_from_millisecond(delay));
|
rt_thread_mdelay(delay);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
void usb_workqueue_submit(struct usb_workqueue *queue, struct usb_work *work, usb_worker_t worker, void *arg, uint32_t ticks)
|
void usb_workqueue_submit(struct usb_workqueue *queue, struct usb_work *work, usb_worker_t worker, void *arg, uint32_t ticks)
|
||||||
{
|
{
|
||||||
uint32_t flags;
|
size_t flags;
|
||||||
flags = usb_osal_enter_critical_section();
|
flags = usb_osal_enter_critical_section();
|
||||||
usb_dlist_remove(&work->list);
|
usb_dlist_remove(&work->list);
|
||||||
work->worker = worker;
|
work->worker = worker;
|
||||||
@@ -47,7 +47,7 @@ struct usb_workqueue g_lpworkq = { NULL };
|
|||||||
static void usbh_hpwork_thread(void *argument)
|
static void usbh_hpwork_thread(void *argument)
|
||||||
{
|
{
|
||||||
struct usb_work *work;
|
struct usb_work *work;
|
||||||
uint32_t flags;
|
size_t flags;
|
||||||
int ret;
|
int ret;
|
||||||
struct usb_workqueue *queue = (struct usb_workqueue *)argument;
|
struct usb_workqueue *queue = (struct usb_workqueue *)argument;
|
||||||
while (1) {
|
while (1) {
|
||||||
@@ -70,7 +70,7 @@ static void usbh_hpwork_thread(void *argument)
|
|||||||
static void usbh_lpwork_thread(void *argument)
|
static void usbh_lpwork_thread(void *argument)
|
||||||
{
|
{
|
||||||
struct usb_work *work;
|
struct usb_work *work;
|
||||||
uint32_t flags;
|
size_t flags;
|
||||||
int ret;
|
int ret;
|
||||||
struct usb_workqueue *queue = (struct usb_workqueue *)argument;
|
struct usb_workqueue *queue = (struct usb_workqueue *)argument;
|
||||||
while (1) {
|
while (1) {
|
||||||
|
|||||||
@@ -1299,7 +1299,7 @@ errout_with_qh:
|
|||||||
|
|
||||||
static int usb_ehci_ioc_setup(struct usb_ehci_epinfo_s *epinfo)
|
static int usb_ehci_ioc_setup(struct usb_ehci_epinfo_s *epinfo)
|
||||||
{
|
{
|
||||||
uint32_t flags;
|
size_t flags;
|
||||||
int ret = -ENODEV;
|
int ret = -ENODEV;
|
||||||
|
|
||||||
DEBUGASSERT(rhport && epinfo && !epinfo->iocwait);
|
DEBUGASSERT(rhport && epinfo && !epinfo->iocwait);
|
||||||
@@ -1353,7 +1353,7 @@ static int usb_ehci_ioc_setup(struct usb_ehci_epinfo_s *epinfo)
|
|||||||
#ifdef CONFIG_USBHOST_ASYNCH
|
#ifdef CONFIG_USBHOST_ASYNCH
|
||||||
static int usb_ehci_ioc_async_setup(struct usb_ehci_epinfo_s *epinfo, usbh_asynch_callback_t callback, void *arg)
|
static int usb_ehci_ioc_async_setup(struct usb_ehci_epinfo_s *epinfo, usbh_asynch_callback_t callback, void *arg)
|
||||||
{
|
{
|
||||||
uint32_t flags;
|
size_t flags;
|
||||||
int ret = -ENODEV;
|
int ret = -ENODEV;
|
||||||
|
|
||||||
DEBUGASSERT(rhport && epinfo && !epinfo->iocwait);
|
DEBUGASSERT(rhport && epinfo && !epinfo->iocwait);
|
||||||
@@ -2536,7 +2536,7 @@ int usb_ep_cancel(usbh_epinfo_t ep)
|
|||||||
void *arg;
|
void *arg;
|
||||||
#endif
|
#endif
|
||||||
uint32_t *bp;
|
uint32_t *bp;
|
||||||
uint32_t flags;
|
size_t flags;
|
||||||
bool iocwait;
|
bool iocwait;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
|||||||
@@ -302,7 +302,7 @@ static void usb_musb_chan_free(struct usb_musb_chan *chan)
|
|||||||
|
|
||||||
static int usb_musb_chan_waitsetup(struct usb_musb_chan *chan)
|
static int usb_musb_chan_waitsetup(struct usb_musb_chan *chan)
|
||||||
{
|
{
|
||||||
uint32_t flags;
|
size_t flags;
|
||||||
int ret = -ENODEV;
|
int ret = -ENODEV;
|
||||||
|
|
||||||
flags = usb_osal_enter_critical_section();
|
flags = usb_osal_enter_critical_section();
|
||||||
@@ -346,7 +346,7 @@ static int usb_musb_chan_waitsetup(struct usb_musb_chan *chan)
|
|||||||
#ifdef CONFIG_USBHOST_ASYNCH
|
#ifdef CONFIG_USBHOST_ASYNCH
|
||||||
static int usb_musb_chan_asynchsetup(struct usb_musb_chan *chan, usbh_asynch_callback_t callback, void *arg)
|
static int usb_musb_chan_asynchsetup(struct usb_musb_chan *chan, usbh_asynch_callback_t callback, void *arg)
|
||||||
{
|
{
|
||||||
uint32_t flags;
|
size_t flags;
|
||||||
int ret = -ENODEV;
|
int ret = -ENODEV;
|
||||||
|
|
||||||
flags = usb_osal_enter_critical_section();
|
flags = usb_osal_enter_critical_section();
|
||||||
@@ -890,7 +890,7 @@ int usbh_ep_intr_async_transfer(usbh_epinfo_t ep, uint8_t *buffer, uint32_t bufl
|
|||||||
int usb_ep_cancel(usbh_epinfo_t ep)
|
int usb_ep_cancel(usbh_epinfo_t ep)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
uint32_t flags;
|
size_t flags;
|
||||||
struct usb_musb_chan *chan;
|
struct usb_musb_chan *chan;
|
||||||
uint8_t chidx = (uint8_t)ep;
|
uint8_t chidx = (uint8_t)ep;
|
||||||
#ifdef CONFIG_USBHOST_ASYNCH
|
#ifdef CONFIG_USBHOST_ASYNCH
|
||||||
|
|||||||
@@ -147,7 +147,7 @@ static inline void usb_synopsys_chan_freeall(void)
|
|||||||
|
|
||||||
static int usb_synopsys_chan_waitsetup(struct usb_synopsys_chan *chan)
|
static int usb_synopsys_chan_waitsetup(struct usb_synopsys_chan *chan)
|
||||||
{
|
{
|
||||||
uint32_t flags;
|
size_t flags;
|
||||||
int ret = -ENODEV;
|
int ret = -ENODEV;
|
||||||
|
|
||||||
flags = usb_osal_enter_critical_section();
|
flags = usb_osal_enter_critical_section();
|
||||||
@@ -191,7 +191,7 @@ static int usb_synopsys_chan_waitsetup(struct usb_synopsys_chan *chan)
|
|||||||
#ifdef CONFIG_USBHOST_ASYNCH
|
#ifdef CONFIG_USBHOST_ASYNCH
|
||||||
static int usb_synopsys_chan_asynchsetup(struct usb_synopsys_chan *chan, usbh_asynch_callback_t callback, void *arg)
|
static int usb_synopsys_chan_asynchsetup(struct usb_synopsys_chan *chan, usbh_asynch_callback_t callback, void *arg)
|
||||||
{
|
{
|
||||||
uint32_t flags;
|
size_t flags;
|
||||||
int ret = -ENODEV;
|
int ret = -ENODEV;
|
||||||
|
|
||||||
flags = usb_osal_enter_critical_section();
|
flags = usb_osal_enter_critical_section();
|
||||||
@@ -681,7 +681,7 @@ errout_with_mutex:
|
|||||||
|
|
||||||
int usbh_ep_intr_transfer(usbh_epinfo_t ep, uint8_t *buffer, uint32_t buflen, uint32_t timeout)
|
int usbh_ep_intr_transfer(usbh_epinfo_t ep, uint8_t *buffer, uint32_t buflen, uint32_t timeout)
|
||||||
{
|
{
|
||||||
uint32_t flags;
|
size_t flags;
|
||||||
uint32_t retries;
|
uint32_t retries;
|
||||||
int ret;
|
int ret;
|
||||||
struct usb_synopsys_chan *chan;
|
struct usb_synopsys_chan *chan;
|
||||||
@@ -752,7 +752,7 @@ int usbh_ep_bulk_async_transfer(usbh_epinfo_t ep, uint8_t *buffer, uint32_t bufl
|
|||||||
int usbh_ep_intr_async_transfer(usbh_epinfo_t ep, uint8_t *buffer, uint32_t buflen, usbh_asynch_callback_t callback, void *arg)
|
int usbh_ep_intr_async_transfer(usbh_epinfo_t ep, uint8_t *buffer, uint32_t buflen, usbh_asynch_callback_t callback, void *arg)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
uint32_t flags;
|
size_t flags;
|
||||||
struct usb_synopsys_chan *chan;
|
struct usb_synopsys_chan *chan;
|
||||||
struct usb_synopsys_priv *priv = &g_usbhost;
|
struct usb_synopsys_priv *priv = &g_usbhost;
|
||||||
uint8_t chidx = (uint8_t)ep;
|
uint8_t chidx = (uint8_t)ep;
|
||||||
@@ -785,7 +785,7 @@ int usbh_ep_intr_async_transfer(usbh_epinfo_t ep, uint8_t *buffer, uint32_t bufl
|
|||||||
int usb_ep_cancel(usbh_epinfo_t ep)
|
int usb_ep_cancel(usbh_epinfo_t ep)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
uint32_t flags;
|
size_t flags;
|
||||||
struct usb_synopsys_chan *chan;
|
struct usb_synopsys_chan *chan;
|
||||||
struct usb_synopsys_priv *priv = &g_usbhost;
|
struct usb_synopsys_priv *priv = &g_usbhost;
|
||||||
#ifdef CONFIG_USBHOST_ASYNCH
|
#ifdef CONFIG_USBHOST_ASYNCH
|
||||||
|
|||||||
Reference in New Issue
Block a user