summaryrefslogtreecommitdiff
path: root/class
diff options
context:
space:
mode:
authorsakumisu <[email protected]>2023-02-18 15:18:49 +0800
committersakumisu <[email protected]>2023-02-18 15:19:52 +0800
commit75ddfc8e4dd708cbd95df75ffb3df2fb1da639ff (patch)
treed608046ba99c5dc28fb8a1007a38f09b483885f3 /class
parent2baec4fd32e4b5955a4602e8eaa346368e22b8b6 (diff)
move hub and hport variable into common ram to reduce nocache ram usage
Diffstat (limited to 'class')
-rw-r--r--class/audio/usbh_audio.c4
-rw-r--r--class/cdc/usbh_cdc_acm.c6
-rw-r--r--class/hid/usbh_hid.c8
-rw-r--r--class/hub/usbh_hub.c17
-rw-r--r--class/msc/usbh_msc.c2
-rw-r--r--class/video/usbh_video.c8
-rw-r--r--class/wireless/usbh_rndis.c8
7 files changed, 28 insertions, 25 deletions
diff --git a/class/audio/usbh_audio.c b/class/audio/usbh_audio.c
index 875bd5a2..38f3bb81 100644
--- a/class/audio/usbh_audio.c
+++ b/class/audio/usbh_audio.c
@@ -48,7 +48,7 @@ static void usbh_audio_devno_free(struct usbh_audio *audio_class)
int usbh_audio_open(struct usbh_audio *audio_class, const char *name, uint32_t samp_freq)
{
- struct usb_setup_packet *setup = &audio_class->hport->setup;
+ struct usb_setup_packet *setup = audio_class->hport->setup;
struct usb_endpoint_descriptor *ep_desc;
uint8_t mult;
uint16_t mps;
@@ -120,7 +120,7 @@ freq_found:
int usbh_audio_close(struct usbh_audio *audio_class, const char *name)
{
- struct usb_setup_packet *setup = &audio_class->hport->setup;
+ struct usb_setup_packet *setup = audio_class->hport->setup;
struct usb_endpoint_descriptor *ep_desc;
int ret;
uint8_t intf = 0xff;
diff --git a/class/cdc/usbh_cdc_acm.c b/class/cdc/usbh_cdc_acm.c
index 825b7cbf..bf1babb8 100644
--- a/class/cdc/usbh_cdc_acm.c
+++ b/class/cdc/usbh_cdc_acm.c
@@ -38,7 +38,7 @@ static void usbh_cdc_acm_devno_free(struct usbh_cdc_acm *cdc_acm_class)
int usbh_cdc_acm_set_line_coding(struct usbh_cdc_acm *cdc_acm_class, struct cdc_line_coding *line_coding)
{
- struct usb_setup_packet *setup = &cdc_acm_class->hport->setup;
+ struct usb_setup_packet *setup = cdc_acm_class->hport->setup;
setup->bmRequestType = USB_REQUEST_DIR_OUT | USB_REQUEST_CLASS | USB_REQUEST_RECIPIENT_INTERFACE;
setup->bRequest = CDC_REQUEST_SET_LINE_CODING;
@@ -53,7 +53,7 @@ int usbh_cdc_acm_set_line_coding(struct usbh_cdc_acm *cdc_acm_class, struct cdc_
int usbh_cdc_acm_get_line_coding(struct usbh_cdc_acm *cdc_acm_class, struct cdc_line_coding *line_coding)
{
- struct usb_setup_packet *setup = &cdc_acm_class->hport->setup;
+ struct usb_setup_packet *setup = cdc_acm_class->hport->setup;
int ret;
setup->bmRequestType = USB_REQUEST_DIR_IN | USB_REQUEST_CLASS | USB_REQUEST_RECIPIENT_INTERFACE;
@@ -72,7 +72,7 @@ int usbh_cdc_acm_get_line_coding(struct usbh_cdc_acm *cdc_acm_class, struct cdc_
int usbh_cdc_acm_set_line_state(struct usbh_cdc_acm *cdc_acm_class, bool dtr, bool rts)
{
- struct usb_setup_packet *setup = &cdc_acm_class->hport->setup;
+ struct usb_setup_packet *setup = cdc_acm_class->hport->setup;
setup->bmRequestType = USB_REQUEST_DIR_OUT | USB_REQUEST_CLASS | USB_REQUEST_RECIPIENT_INTERFACE;
setup->bRequest = CDC_REQUEST_SET_CONTROL_LINE_STATE;
diff --git a/class/hid/usbh_hid.c b/class/hid/usbh_hid.c
index 4fb4a534..23ee2a05 100644
--- a/class/hid/usbh_hid.c
+++ b/class/hid/usbh_hid.c
@@ -39,7 +39,7 @@ static void usbh_hid_devno_free(struct usbh_hid *hid_class)
static int usbh_hid_get_report_descriptor(struct usbh_hid *hid_class, uint8_t *buffer)
{
- struct usb_setup_packet *setup = &hid_class->hport->setup;
+ struct usb_setup_packet *setup = hid_class->hport->setup;
int ret;
setup->bmRequestType = USB_REQUEST_DIR_IN | USB_REQUEST_STANDARD | USB_REQUEST_RECIPIENT_INTERFACE;
@@ -58,7 +58,7 @@ static int usbh_hid_get_report_descriptor(struct usbh_hid *hid_class, uint8_t *b
int usbh_hid_set_idle(struct usbh_hid *hid_class, uint8_t report_id, uint8_t duration)
{
- struct usb_setup_packet *setup = &hid_class->hport->setup;
+ struct usb_setup_packet *setup = hid_class->hport->setup;
setup->bmRequestType = USB_REQUEST_DIR_OUT | USB_REQUEST_CLASS | USB_REQUEST_RECIPIENT_INTERFACE;
setup->bRequest = HID_REQUEST_SET_IDLE;
@@ -71,7 +71,7 @@ int usbh_hid_set_idle(struct usbh_hid *hid_class, uint8_t report_id, uint8_t dur
int usbh_hid_get_idle(struct usbh_hid *hid_class, uint8_t *buffer)
{
- struct usb_setup_packet *setup = &hid_class->hport->setup;
+ struct usb_setup_packet *setup = hid_class->hport->setup;
int ret;
setup->bmRequestType = USB_REQUEST_DIR_IN | USB_REQUEST_CLASS | USB_REQUEST_RECIPIENT_INTERFACE;
@@ -90,7 +90,7 @@ int usbh_hid_get_idle(struct usbh_hid *hid_class, uint8_t *buffer)
int usbh_hid_set_protocol(struct usbh_hid *hid_class, uint8_t protocol)
{
- struct usb_setup_packet *setup = &hid_class->hport->setup;
+ struct usb_setup_packet *setup = hid_class->hport->setup;
setup->bmRequestType = USB_REQUEST_DIR_OUT | USB_REQUEST_CLASS | USB_REQUEST_RECIPIENT_INTERFACE;
setup->bRequest = HID_REQUEST_SET_PROTOCOL;
diff --git a/class/hub/usbh_hub.c b/class/hub/usbh_hub.c
index ae4c70b0..09557d3a 100644
--- a/class/hub/usbh_hub.c
+++ b/class/hub/usbh_hub.c
@@ -17,16 +17,17 @@
static uint32_t g_devinuse = 0;
USB_NOCACHE_RAM_SECTION USB_MEM_ALIGNX uint8_t g_hub_buf[32];
+USB_NOCACHE_RAM_SECTION USB_MEM_ALIGNX uint8_t g_hub_intbuf[CONFIG_USBHOST_MAX_EXTHUBS + 1][1];
usb_slist_t hub_class_head = USB_SLIST_OBJECT_INIT(hub_class_head);
usb_osal_thread_t hub_thread;
usb_osal_mq_t hub_mq;
-USB_NOCACHE_RAM_SECTION struct usbh_hub roothub;
+struct usbh_hub roothub;
#if CONFIG_USBHOST_MAX_EXTHUBS > 0
-USB_NOCACHE_RAM_SECTION struct usbh_hub exthub[CONFIG_USBHOST_MAX_EXTHUBS];
+struct usbh_hub exthub[CONFIG_USBHOST_MAX_EXTHUBS];
#endif
extern int usbh_hport_activate_ep0(struct usbh_hubport *hport);
extern int usbh_hport_deactivate_ep0(struct usbh_hubport *hport);
@@ -74,7 +75,7 @@ static int _usbh_hub_get_hub_descriptor(struct usbh_hub *hub, uint8_t *buffer)
struct usb_setup_packet *setup;
int ret;
- setup = &hub->parent->setup;
+ setup = hub->parent->setup;
setup->bmRequestType = USB_REQUEST_DIR_IN | USB_REQUEST_CLASS | USB_REQUEST_RECIPIENT_DEVICE;
setup->bRequest = USB_REQUEST_GET_DESCRIPTOR;
@@ -95,7 +96,7 @@ static int _usbh_hub_get_status(struct usbh_hub *hub, uint8_t *buffer)
struct usb_setup_packet *setup;
int ret;
- setup = &hub->parent->setup;
+ setup = hub->parent->setup;
setup->bmRequestType = USB_REQUEST_DIR_IN | USB_REQUEST_CLASS | USB_REQUEST_RECIPIENT_DEVICE;
setup->bRequest = HUB_REQUEST_GET_STATUS;
@@ -116,7 +117,7 @@ static int _usbh_hub_get_portstatus(struct usbh_hub *hub, uint8_t port, struct h
struct usb_setup_packet *setup;
int ret;
- setup = &hub->parent->setup;
+ setup = hub->parent->setup;
setup->bmRequestType = USB_REQUEST_DIR_IN | USB_REQUEST_CLASS | USB_REQUEST_RECIPIENT_OTHER;
setup->bRequest = HUB_REQUEST_GET_STATUS;
@@ -136,7 +137,7 @@ static int _usbh_hub_set_feature(struct usbh_hub *hub, uint8_t port, uint8_t fea
{
struct usb_setup_packet *setup;
- setup = &hub->parent->setup;
+ setup = hub->parent->setup;
setup->bmRequestType = USB_REQUEST_DIR_OUT | USB_REQUEST_CLASS | USB_REQUEST_RECIPIENT_OTHER;
setup->bRequest = HUB_REQUEST_SET_FEATURE;
@@ -151,7 +152,7 @@ static int _usbh_hub_clear_feature(struct usbh_hub *hub, uint8_t port, uint8_t f
{
struct usb_setup_packet *setup;
- setup = &hub->parent->setup;
+ setup = hub->parent->setup;
setup->bmRequestType = USB_REQUEST_DIR_OUT | USB_REQUEST_CLASS | USB_REQUEST_RECIPIENT_OTHER;
setup->bRequest = HUB_REQUEST_CLEAR_FEATURE;
@@ -310,6 +311,7 @@ static int usbh_hub_connect(struct usbh_hubport *hport, uint8_t intf)
usbh_hub_register(hub);
USB_LOG_INFO("Register HUB Class:%s\r\n", hport->config.intf[intf].devname);
+ hub->int_buffer = g_hub_intbuf[hub->index - 1];
usbh_int_urb_fill(&hub->intin_urb, hub->intin, hub->int_buffer, 1, 0, hub_int_complete_callback, hub);
usbh_submit_urb(&hub->intin_urb);
return 0;
@@ -572,6 +574,7 @@ static void usbh_hub_thread_wakeup(struct usbh_hub *hub)
void usbh_roothub_thread_wakeup(uint8_t port)
{
+ roothub.int_buffer = g_hub_intbuf[roothub.index - 1];
roothub.int_buffer[0] |= (1 << port);
usbh_hub_thread_wakeup(&roothub);
}
diff --git a/class/msc/usbh_msc.c b/class/msc/usbh_msc.c
index 5c644322..9d053099 100644
--- a/class/msc/usbh_msc.c
+++ b/class/msc/usbh_msc.c
@@ -40,7 +40,7 @@ static void usbh_msc_devno_free(struct usbh_msc *msc_class)
static int usbh_msc_get_maxlun(struct usbh_msc *msc_class, uint8_t *buffer)
{
- struct usb_setup_packet *setup = &msc_class->hport->setup;
+ struct usb_setup_packet *setup = msc_class->hport->setup;
setup->bmRequestType = USB_REQUEST_DIR_IN | USB_REQUEST_CLASS | USB_REQUEST_RECIPIENT_INTERFACE;
setup->bRequest = MSC_REQUEST_GET_MAX_LUN;
diff --git a/class/video/usbh_video.c b/class/video/usbh_video.c
index 0aba1af9..07070e53 100644
--- a/class/video/usbh_video.c
+++ b/class/video/usbh_video.c
@@ -97,7 +97,7 @@ static void usbh_video_devno_free(struct usbh_video *video_class)
int usbh_video_get_cur(struct usbh_video *video_class, uint8_t intf, uint8_t entity_id, uint8_t cs, uint8_t *buf, uint16_t len)
{
- struct usb_setup_packet *setup = &video_class->hport->setup;
+ struct usb_setup_packet *setup = video_class->hport->setup;
int ret;
setup->bmRequestType = USB_REQUEST_DIR_IN | USB_REQUEST_CLASS | USB_REQUEST_RECIPIENT_INTERFACE;
@@ -116,7 +116,7 @@ int usbh_video_get_cur(struct usbh_video *video_class, uint8_t intf, uint8_t ent
int usbh_video_set_cur(struct usbh_video *video_class, uint8_t intf, uint8_t entity_id, uint8_t cs, uint8_t *buf, uint16_t len)
{
- struct usb_setup_packet *setup = &video_class->hport->setup;
+ struct usb_setup_packet *setup = video_class->hport->setup;
setup->bmRequestType = USB_REQUEST_DIR_OUT | USB_REQUEST_CLASS | USB_REQUEST_RECIPIENT_INTERFACE;
setup->bRequest = VIDEO_REQUEST_SET_CUR;
@@ -156,7 +156,7 @@ int usbh_video_open(struct usbh_video *video_class,
uint16_t wHeight,
uint8_t altsetting)
{
- struct usb_setup_packet *setup = &video_class->hport->setup;
+ struct usb_setup_packet *setup = video_class->hport->setup;
struct usb_endpoint_descriptor *ep_desc;
uint8_t mult;
uint16_t mps;
@@ -246,7 +246,7 @@ int usbh_video_open(struct usbh_video *video_class,
int usbh_video_close(struct usbh_video *video_class)
{
- struct usb_setup_packet *setup = &video_class->hport->setup;
+ struct usb_setup_packet *setup = video_class->hport->setup;
int ret = 0;
USB_LOG_INFO("Close video device\r\n");
diff --git a/class/wireless/usbh_rndis.c b/class/wireless/usbh_rndis.c
index 46164117..49feb491 100644
--- a/class/wireless/usbh_rndis.c
+++ b/class/wireless/usbh_rndis.c
@@ -13,7 +13,7 @@ USB_NOCACHE_RAM_SECTION USB_MEM_ALIGNX uint8_t g_rndis_buf[1024];
static int usbh_rndis_init_msg_transfer(struct usbh_rndis *rndis_class)
{
- struct usb_setup_packet *setup = &rndis_class->hport->setup;
+ struct usb_setup_packet *setup = rndis_class->hport->setup;
int ret = 0;
rndis_initialize_msg_t *cmd;
rndis_initialize_cmplt_t *resp;
@@ -60,7 +60,7 @@ static int usbh_rndis_init_msg_transfer(struct usbh_rndis *rndis_class)
int usbh_rndis_query_msg_transfer(struct usbh_rndis *rndis_class, uint32_t oid, uint32_t query_len, uint8_t *info, uint32_t *info_len)
{
- struct usb_setup_packet *setup = &rndis_class->hport->setup;
+ struct usb_setup_packet *setup = rndis_class->hport->setup;
int ret = 0;
rndis_query_msg_t *cmd;
rndis_query_cmplt_t *resp;
@@ -111,7 +111,7 @@ int usbh_rndis_query_msg_transfer(struct usbh_rndis *rndis_class, uint32_t oid,
static int usbh_rndis_set_msg_transfer(struct usbh_rndis *rndis_class, uint32_t oid, uint8_t *info, uint32_t info_len)
{
- struct usb_setup_packet *setup = &rndis_class->hport->setup;
+ struct usb_setup_packet *setup = rndis_class->hport->setup;
int ret = 0;
rndis_set_msg_t *cmd;
rndis_set_cmplt_t *resp;
@@ -188,7 +188,7 @@ int usbh_rndis_bulk_in_transfer(struct usbh_rndis *rndis_class, uint8_t *buffer,
int usbh_rndis_keepalive(struct usbh_rndis *rndis_class)
{
- struct usb_setup_packet *setup = &rndis_class->hport->setup;
+ struct usb_setup_packet *setup = rndis_class->hport->setup;
int ret = 0;
rndis_keepalive_msg_t *cmd;
rndis_keepalive_cmplt_t *resp;