summaryrefslogtreecommitdiff
path: root/tests/test/support
diff options
context:
space:
mode:
authorhathach <[email protected]>2013-04-21 15:09:54 +0700
committerhathach <[email protected]>2013-04-21 15:09:54 +0700
commita493fab7532c7410becd96079e7d749024271296 (patch)
treefd4ace39d98935992b72d00531b11a7922823b70 /tests/test/support
parent357888a5e5dbb574db44bb29b3a07499c0d531c1 (diff)
separate fake ehci's run async & period list
refractor list_find_previous_item & list_remove_qhd to act on ehci_link_t* instead of ehci_qhd_t* fully support 1ms, 2ms, 4ms, 8ms for period list (each list has a dummy queue head) - change period list structure limit the maximum polling interval to 256 ms add max_loop static MAX number of iteration for list_find_previous_item add test for close 256ms polling interrupt
Diffstat (limited to 'tests/test/support')
-rw-r--r--tests/test/support/ehci_controller.c56
-rw-r--r--tests/test/support/ehci_controller.h2
2 files changed, 37 insertions, 21 deletions
diff --git a/tests/test/support/ehci_controller.c b/tests/test/support/ehci_controller.c
index d785109a1..14a13f827 100644
--- a/tests/test/support/ehci_controller.c
+++ b/tests/test/support/ehci_controller.c
@@ -88,42 +88,58 @@ void ehci_controller_control_xfer_proceed(uint8_t dev_addr, uint8_t p_data[])
hcd_isr( usbh_devices[dev_addr].core_id );
}
-bool complete_all_qtd_in_list(ehci_qhd_t *head)
+void complete_qtd_in_qhd(ehci_qhd_t *p_qhd)
+{
+ if ( !p_qhd->qtd_overlay.halted )
+ {
+ while(!p_qhd->qtd_overlay.next.terminate)
+ {
+ ehci_qtd_t* p_qtd = (ehci_qtd_t*) align32(p_qhd->qtd_overlay.next.address);
+ p_qtd->active = 0;
+ p_qhd->qtd_overlay = *p_qtd;
+ }
+ }
+}
+
+bool complete_all_qtd_in_async(ehci_qhd_t *head)
{
ehci_qhd_t *p_qhd = head;
do
{
- if ( !p_qhd->qtd_overlay.halted )
- {
- while(!p_qhd->qtd_overlay.next.terminate)
- {
- ehci_qtd_t* p_qtd = (ehci_qtd_t*) align32(p_qhd->qtd_overlay.next.address);
- p_qtd->active = 0;
- p_qhd->qtd_overlay = *p_qtd;
- }
- }
- if (!p_qhd->next.terminate)
- {
- p_qhd = (ehci_qhd_t*) align32(p_qhd->next.address);
- }
- else
- {
- break;
- }
+ complete_qtd_in_qhd(p_qhd);
+ p_qhd = (ehci_qhd_t*) align32(p_qhd->next.address);
}while(p_qhd != head); // stop if loop around
return true;
}
+bool complete_all_qtd_in_period(ehci_link_t *head)
+{
+ while(!head->terminate)
+ {
+ uint32_t queue_type = head->type;
+ head = (ehci_link_t*) align32(head->address);
+
+ if ( queue_type == EHCI_QUEUE_ELEMENT_QHD)
+ {
+ complete_qtd_in_qhd( (ehci_qhd_t*) head );
+ }
+ }
+ return true;
+}
+
void ehci_controller_run(uint8_t hostid)
{
//------------- Async List -------------//
ehci_registers_t* const regs = get_operational_register(hostid);
- complete_all_qtd_in_list((ehci_qhd_t*) regs->async_list_base);
+ complete_all_qtd_in_async((ehci_qhd_t*) regs->async_list_base);
//------------- Period List -------------//
- complete_all_qtd_in_list( get_period_head(hostid, 1) );
+ for(uint8_t i=1; i <= EHCI_FRAMELIST_SIZE; i *= 2)
+ {
+ complete_all_qtd_in_period( get_period_head(hostid, i) );
+ }
regs->usb_sts = EHCI_INT_MASK_NXP_ASYNC | EHCI_INT_MASK_NXP_PERIODIC;
hcd_isr(hostid);
diff --git a/tests/test/support/ehci_controller.h b/tests/test/support/ehci_controller.h
index 5b8206762..32a0d4cdc 100644
--- a/tests/test/support/ehci_controller.h
+++ b/tests/test/support/ehci_controller.h
@@ -66,7 +66,7 @@ void ehci_controller_device_unplug(uint8_t hostid);
ehci_registers_t* get_operational_register(uint8_t hostid);
ehci_link_t* get_period_frame_list(uint8_t hostid);
ehci_qhd_t* get_async_head(uint8_t hostid);
-ehci_qhd_t* get_period_head(uint8_t hostid, uint8_t interval_ms);
+ehci_link_t* get_period_head(uint8_t hostid, uint8_t interval_ms);
ehci_qhd_t* get_control_qhd(uint8_t dev_addr);
ehci_qtd_t* get_control_qtds(uint8_t dev_addr);
ehci_qhd_t* qhd_get_from_pipe_handle(pipe_handle_t pipe_hdl);