| 
									
										
										
										
											2019-03-20 16:11:42 +07:00
										 |  |  | /* 
 | 
					
						
							|  |  |  |  * The MIT License (MIT) | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Copyright (c) 2018, hathach (tinyusb.org) | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Permission is hereby granted, free of charge, to any person obtaining a copy | 
					
						
							|  |  |  |  * of this software and associated documentation files (the "Software"), to deal | 
					
						
							|  |  |  |  * in the Software without restriction, including without limitation the rights | 
					
						
							|  |  |  |  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | 
					
						
							|  |  |  |  * copies of the Software, and to permit persons to whom the Software is | 
					
						
							|  |  |  |  * furnished to do so, subject to the following conditions: | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * The above copyright notice and this permission notice shall be included in | 
					
						
							|  |  |  |  * all copies or substantial portions of the Software. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | 
					
						
							|  |  |  |  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | 
					
						
							|  |  |  |  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | 
					
						
							|  |  |  |  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | 
					
						
							|  |  |  |  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | 
					
						
							|  |  |  |  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | 
					
						
							|  |  |  |  * THE SOFTWARE. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * This file is part of the TinyUSB stack. | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2013-02-27 16:19:40 +07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-11 00:40:21 +07:00
										 |  |  | #include <stdlib.h>
 | 
					
						
							| 
									
										
										
										
											2013-02-27 16:19:40 +07:00
										 |  |  | #include "unity.h"
 | 
					
						
							|  |  |  | #include "tusb_option.h"
 | 
					
						
							| 
									
										
										
										
											2014-04-17 20:40:34 +07:00
										 |  |  | #include "tusb_errors.h"
 | 
					
						
							| 
									
										
										
										
											2013-02-27 16:19:40 +07:00
										 |  |  | #include "binary.h"
 | 
					
						
							| 
									
										
										
										
											2013-06-05 11:23:41 +07:00
										 |  |  | #include "type_helper.h"
 | 
					
						
							| 
									
										
										
										
											2013-03-02 00:09:24 +07:00
										 |  |  | 
 | 
					
						
							|  |  |  | #include "hal.h"
 | 
					
						
							| 
									
										
										
										
											2013-03-05 14:26:36 +07:00
										 |  |  | #include "hcd.h"
 | 
					
						
							| 
									
										
										
										
											2013-02-27 16:19:40 +07:00
										 |  |  | #include "ehci.h"
 | 
					
						
							| 
									
										
										
										
											2013-05-11 00:40:21 +07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-09 13:05:48 +07:00
										 |  |  | #include "ehci_controller_fake.h"
 | 
					
						
							| 
									
										
										
										
											2013-05-11 00:40:21 +07:00
										 |  |  | #include "mock_osal.h"
 | 
					
						
							|  |  |  | #include "mock_usbh_hcd.h"
 | 
					
						
							| 
									
										
										
										
											2013-02-27 16:19:40 +07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-07 00:47:16 +07:00
										 |  |  | usbh_device_t _usbh_devices[CFG_TUSB_HOST_DEVICE_MAX+1]; | 
					
						
							| 
									
										
										
										
											2013-03-05 14:26:36 +07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-02-27 16:19:40 +07:00
										 |  |  | //--------------------------------------------------------------------+
 | 
					
						
							|  |  |  | // Setup/Teardown + helper declare
 | 
					
						
							|  |  |  | //--------------------------------------------------------------------+
 | 
					
						
							|  |  |  | void setUp(void) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2013-03-04 01:00:25 +07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-02-27 16:19:40 +07:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void tearDown(void) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-02-27 17:14:59 +07:00
										 |  |  | //--------------------------------------------------------------------+
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | //--------------------------------------------------------------------+
 | 
					
						
							| 
									
										
										
										
											2013-02-27 16:19:40 +07:00
										 |  |  | void test_struct_alignment(void) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 32, __alignof__(ehci_qhd_t) ); | 
					
						
							|  |  |  | //  TEST_ASSERT_EQUAL( 32, __alignof__(ehci_qtd_t) ); ehci_qtd_t is used to declare overlay variable in qhd --> cannot declare with ATTR_ALIGNED(32)
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 32, __alignof__(ehci_itd_t) ); | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 32, __alignof__(ehci_sitd_t) ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void test_struct_size(void) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2013-05-09 17:48:19 +07:00
										 |  |  |   if (4 < sizeof(void*)) // running tests in x64 environment
 | 
					
						
							|  |  |  |   { | 
					
						
							| 
									
										
										
										
											2013-05-09 17:52:18 +07:00
										 |  |  |     TEST_ASSERT_EQUAL( 64 - 8, offsetof(ehci_qhd_t, p_qtd_list_head) ); // 64 - 2x 32-bit pointer qtds
 | 
					
						
							| 
									
										
										
										
											2013-05-09 17:48:19 +07:00
										 |  |  |   }else | 
					
						
							|  |  |  |   { | 
					
						
							|  |  |  |     TEST_ASSERT_EQUAL( 64, sizeof(ehci_qhd_t) ); | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2013-02-27 16:19:40 +07:00
										 |  |  |   TEST_ASSERT_EQUAL( 32, sizeof(ehci_qtd_t) ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 64, sizeof(ehci_itd_t) ); | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 32, sizeof(ehci_sitd_t) ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 4, sizeof(ehci_link_t) ); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-02-27 17:14:59 +07:00
										 |  |  | //--------------------------------------------------------------------+
 | 
					
						
							|  |  |  | // EHCI Data Structure
 | 
					
						
							|  |  |  | //--------------------------------------------------------------------+
 | 
					
						
							| 
									
										
										
										
											2013-02-27 16:19:40 +07:00
										 |  |  | void test_qtd_structure(void) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 0, offsetof(ehci_qtd_t, next)); | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 4, offsetof(ehci_qtd_t, alternate)); | 
					
						
							| 
									
										
										
										
											2013-03-27 11:51:44 +07:00
										 |  |  |   TEST_ASSERT_EQUAL( 5, BITFIELD_OFFSET_OF_UINT32(ehci_qtd_t, 1, used)); | 
					
						
							| 
									
										
										
										
											2013-02-27 16:19:40 +07:00
										 |  |  | 
 | 
					
						
							|  |  |  |   //------------- Word 2 -------------//
 | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 0, BITFIELD_OFFSET_OF_UINT32(ehci_qtd_t, 2, pingstate_err) ); | 
					
						
							| 
									
										
										
										
											2013-03-06 15:08:09 +07:00
										 |  |  |   TEST_ASSERT_EQUAL( 1, BITFIELD_OFFSET_OF_UINT32(ehci_qtd_t, 2, non_hs_split_state) ); | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 2, BITFIELD_OFFSET_OF_UINT32(ehci_qtd_t, 2, non_hs_period_missed_uframe)); | 
					
						
							| 
									
										
										
										
											2013-02-27 16:19:40 +07:00
										 |  |  |   TEST_ASSERT_EQUAL( 3, BITFIELD_OFFSET_OF_UINT32(ehci_qtd_t, 2, xact_err) ); | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 4, BITFIELD_OFFSET_OF_UINT32(ehci_qtd_t, 2, babble_err) ); | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 5, BITFIELD_OFFSET_OF_UINT32(ehci_qtd_t, 2, buffer_err) ); | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 6, BITFIELD_OFFSET_OF_UINT32(ehci_qtd_t, 2, halted) ); | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 7, BITFIELD_OFFSET_OF_UINT32(ehci_qtd_t, 2, active) ); | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 8, BITFIELD_OFFSET_OF_UINT32(ehci_qtd_t, 2, pid) ); | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 10, BITFIELD_OFFSET_OF_UINT32(ehci_qtd_t, 2, cerr) ); | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 12, BITFIELD_OFFSET_OF_UINT32(ehci_qtd_t, 2, current_page) ); | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 15, BITFIELD_OFFSET_OF_UINT32(ehci_qtd_t, 2, int_on_complete) ); | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 16, BITFIELD_OFFSET_OF_UINT32(ehci_qtd_t, 2, total_bytes) ); | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 31, BITFIELD_OFFSET_OF_UINT32(ehci_qtd_t, 2, data_toggle) ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 12, offsetof(ehci_qtd_t, buffer)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void test_qhd_structure(void) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 0, offsetof(ehci_qhd_t, next)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   //------------- Word 1 -------------//
 | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 0, BITFIELD_OFFSET_OF_UINT32(ehci_qhd_t, 1, device_address) ); | 
					
						
							| 
									
										
										
										
											2013-03-13 12:29:44 +07:00
										 |  |  |   TEST_ASSERT_EQUAL( 7, BITFIELD_OFFSET_OF_UINT32(ehci_qhd_t, 1, non_hs_period_inactive_next_xact) ); | 
					
						
							| 
									
										
										
										
											2013-02-27 16:19:40 +07:00
										 |  |  |   TEST_ASSERT_EQUAL( 8, BITFIELD_OFFSET_OF_UINT32(ehci_qhd_t, 1, endpoint_number) ); | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 12, BITFIELD_OFFSET_OF_UINT32(ehci_qhd_t, 1, endpoint_speed) ); | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 14, BITFIELD_OFFSET_OF_UINT32(ehci_qhd_t, 1, data_toggle_control) ); | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 15, BITFIELD_OFFSET_OF_UINT32(ehci_qhd_t, 1, head_list_flag) ); | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 16, BITFIELD_OFFSET_OF_UINT32(ehci_qhd_t, 1, max_package_size) ); | 
					
						
							| 
									
										
										
										
											2013-03-03 12:31:18 +07:00
										 |  |  |   TEST_ASSERT_EQUAL( 27, BITFIELD_OFFSET_OF_UINT32(ehci_qhd_t, 1, non_hs_control_endpoint) ); | 
					
						
							| 
									
										
										
										
											2013-02-27 16:19:40 +07:00
										 |  |  |   TEST_ASSERT_EQUAL( 28, BITFIELD_OFFSET_OF_UINT32(ehci_qhd_t, 1, nak_count_reload) ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   //------------- Word 2 -------------//
 | 
					
						
							| 
									
										
										
										
											2013-03-06 14:55:02 +07:00
										 |  |  |   TEST_ASSERT_EQUAL( 0, BITFIELD_OFFSET_OF_UINT32(ehci_qhd_t, 2, interrupt_smask) ); | 
					
						
							| 
									
										
										
										
											2013-03-06 22:21:42 +07:00
										 |  |  |   TEST_ASSERT_EQUAL( 8, BITFIELD_OFFSET_OF_UINT32(ehci_qhd_t, 2, non_hs_interrupt_cmask) ); | 
					
						
							| 
									
										
										
										
											2013-02-27 16:19:40 +07:00
										 |  |  |   TEST_ASSERT_EQUAL( 16, BITFIELD_OFFSET_OF_UINT32(ehci_qhd_t, 2, hub_address) ); | 
					
						
							| 
									
										
										
										
											2013-03-05 14:26:36 +07:00
										 |  |  |   TEST_ASSERT_EQUAL( 23, BITFIELD_OFFSET_OF_UINT32(ehci_qhd_t, 2, hub_port) ); | 
					
						
							| 
									
										
										
										
											2013-02-27 16:19:40 +07:00
										 |  |  |   TEST_ASSERT_EQUAL( 30, BITFIELD_OFFSET_OF_UINT32(ehci_qhd_t, 2, mult) ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 3*4, offsetof(ehci_qhd_t, qtd_addr)); | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 4*4, offsetof(ehci_qhd_t, qtd_overlay)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-02-27 16:50:05 +07:00
										 |  |  | void test_itd_structure(void) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 0, offsetof(ehci_itd_t, next)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   // Each Transaction Word
 | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 0  , BITFIELD_OFFSET_OF_MEMBER(ehci_itd_t, xact[0], offset) ); | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 12 , BITFIELD_OFFSET_OF_MEMBER(ehci_itd_t, xact[0], page_select) ); | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 15 , BITFIELD_OFFSET_OF_MEMBER(ehci_itd_t, xact[0], int_on_complete) ); | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 16 , BITFIELD_OFFSET_OF_MEMBER(ehci_itd_t, xact[0], length) ); | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 28 , BITFIELD_OFFSET_OF_MEMBER(ehci_itd_t, xact[0], error) ); | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 29 , BITFIELD_OFFSET_OF_MEMBER(ehci_itd_t, xact[0], babble_err) ); | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 30 , BITFIELD_OFFSET_OF_MEMBER(ehci_itd_t, xact[0], buffer_err) ); | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 31 , BITFIELD_OFFSET_OF_MEMBER(ehci_itd_t, xact[0], active) ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 9*4, offsetof(ehci_itd_t, BufferPointer)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void test_sitd_structure(void) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 0, offsetof(ehci_sitd_t, next)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   //------------- Word 1 -------------//
 | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 0, BITFIELD_OFFSET_OF_UINT32(ehci_sitd_t, 1, device_address) ); | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 8, BITFIELD_OFFSET_OF_UINT32(ehci_sitd_t, 1, endpoint_number) ); | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 16, BITFIELD_OFFSET_OF_UINT32(ehci_sitd_t, 1, hub_address) ); | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 24, BITFIELD_OFFSET_OF_UINT32(ehci_sitd_t, 1, port_number) ); | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 31, BITFIELD_OFFSET_OF_UINT32(ehci_sitd_t, 1, direction) ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   //------------- Word 2 -------------//
 | 
					
						
							| 
									
										
										
										
											2013-03-06 14:55:02 +07:00
										 |  |  |   TEST_ASSERT_EQUAL( 4*2, offsetof(ehci_sitd_t, interrupt_smask)); | 
					
						
							| 
									
										
										
										
											2013-03-06 22:21:42 +07:00
										 |  |  |   TEST_ASSERT_EQUAL( 4*2+1, offsetof(ehci_sitd_t, non_hs_interrupt_cmask)); | 
					
						
							| 
									
										
										
										
											2013-02-27 16:50:05 +07:00
										 |  |  | 
 | 
					
						
							|  |  |  |   //------------- Word 3 -------------//
 | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 1, BITFIELD_OFFSET_OF_UINT32(ehci_sitd_t, 3, split_state) ); | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 2, BITFIELD_OFFSET_OF_UINT32(ehci_sitd_t, 3, missed_uframe)); | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 3, BITFIELD_OFFSET_OF_UINT32(ehci_sitd_t, 3, xact_err) ); | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 4, BITFIELD_OFFSET_OF_UINT32(ehci_sitd_t, 3, babble_err) ); | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 5, BITFIELD_OFFSET_OF_UINT32(ehci_sitd_t, 3, buffer_err) ); | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 6, BITFIELD_OFFSET_OF_UINT32(ehci_sitd_t, 3, error) ); | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 7, BITFIELD_OFFSET_OF_UINT32(ehci_sitd_t, 3, active) ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 8, BITFIELD_OFFSET_OF_UINT32(ehci_sitd_t, 3, cmask_progress) ); | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 16, BITFIELD_OFFSET_OF_UINT32(ehci_sitd_t, 3, total_bytes) ); | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 30, BITFIELD_OFFSET_OF_UINT32(ehci_sitd_t, 3, page_select) ); | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 31, BITFIELD_OFFSET_OF_UINT32(ehci_sitd_t, 3, int_on_complete) ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   //------------- Word 4 -------------//
 | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 4*4, offsetof(ehci_sitd_t, buffer)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 4*6, offsetof(ehci_sitd_t, back)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-02-27 17:14:59 +07:00
										 |  |  | //--------------------------------------------------------------------+
 | 
					
						
							|  |  |  | // EHCI Register Interface
 | 
					
						
							|  |  |  | //--------------------------------------------------------------------+
 | 
					
						
							|  |  |  | void test_register_offset(void) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 0x00, offsetof(ehci_registers_t, usb_cmd)); | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 0x04, offsetof(ehci_registers_t, usb_sts)); | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 0x08, offsetof(ehci_registers_t, usb_int_enable)); | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 0x0C, offsetof(ehci_registers_t, frame_index)); | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 0x10, offsetof(ehci_registers_t, ctrl_ds_seg)); | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 0x14, offsetof(ehci_registers_t, periodic_list_base)); | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 0x18, offsetof(ehci_registers_t, async_list_base)); | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 0x1C, offsetof(ehci_registers_t, tt_control)); // NXP specific
 | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 0x40, offsetof(ehci_registers_t, config_flag)); // NXP not used
 | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 0x44, offsetof(ehci_registers_t, portsc)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void test_register_usbcmd(void) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 0  , BITFIELD_OFFSET_OF_MEMBER(ehci_registers_t, usb_cmd_bit, run_stop) ); | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 1  , BITFIELD_OFFSET_OF_MEMBER(ehci_registers_t, usb_cmd_bit, reset) ); | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 2  , BITFIELD_OFFSET_OF_MEMBER(ehci_registers_t, usb_cmd_bit, framelist_size) ); | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 4  , BITFIELD_OFFSET_OF_MEMBER(ehci_registers_t, usb_cmd_bit, periodic_enable) ); | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 5  , BITFIELD_OFFSET_OF_MEMBER(ehci_registers_t, usb_cmd_bit, async_enable) ); | 
					
						
							| 
									
										
										
										
											2018-12-10 19:01:28 +07:00
										 |  |  |   TEST_ASSERT_EQUAL( 6  , BITFIELD_OFFSET_OF_MEMBER(ehci_registers_t, usb_cmd_bit, advance_async) ); | 
					
						
							| 
									
										
										
										
											2013-02-27 17:14:59 +07:00
										 |  |  |   TEST_ASSERT_EQUAL( 7  , BITFIELD_OFFSET_OF_MEMBER(ehci_registers_t, usb_cmd_bit, light_reset) ); | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 8  , BITFIELD_OFFSET_OF_MEMBER(ehci_registers_t, usb_cmd_bit, async_park) ); | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 11 , BITFIELD_OFFSET_OF_MEMBER(ehci_registers_t, usb_cmd_bit, async_park_enable) ); | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 15 , BITFIELD_OFFSET_OF_MEMBER(ehci_registers_t, usb_cmd_bit, nxp_framelist_size_msb) ); | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 16 , BITFIELD_OFFSET_OF_MEMBER(ehci_registers_t, usb_cmd_bit, int_threshold) ); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-02-27 17:31:51 +07:00
										 |  |  | void test_register_usbsts(void) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2013-03-01 19:32:53 +07:00
										 |  |  |   TEST_ASSERT_EQUAL( 0  , BITFIELD_OFFSET_OF_MEMBER(ehci_registers_t, usb_sts_bit, usb)); | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 1  , BITFIELD_OFFSET_OF_MEMBER(ehci_registers_t, usb_sts_bit, usb_error)); | 
					
						
							| 
									
										
										
										
											2013-02-27 17:31:51 +07:00
										 |  |  |   TEST_ASSERT_EQUAL( 2  , BITFIELD_OFFSET_OF_MEMBER(ehci_registers_t, usb_sts_bit, port_change_detect)); | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 3  , BITFIELD_OFFSET_OF_MEMBER(ehci_registers_t, usb_sts_bit, framelist_rollover)); | 
					
						
							| 
									
										
										
										
											2013-03-02 00:09:24 +07:00
										 |  |  |   TEST_ASSERT_EQUAL( 4  , BITFIELD_OFFSET_OF_MEMBER(ehci_registers_t, usb_sts_bit, pci_host_system_error)); | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 5  , BITFIELD_OFFSET_OF_MEMBER(ehci_registers_t, usb_sts_bit, async_advance)); | 
					
						
							| 
									
										
										
										
											2013-04-21 00:28:25 +07:00
										 |  |  |   TEST_ASSERT_EQUAL( 7  , BITFIELD_OFFSET_OF_MEMBER(ehci_registers_t, usb_sts_bit, nxp_int_sof)); | 
					
						
							| 
									
										
										
										
											2013-02-27 17:31:51 +07:00
										 |  |  |   TEST_ASSERT_EQUAL( 12 , BITFIELD_OFFSET_OF_MEMBER(ehci_registers_t, usb_sts_bit, hc_halted)); | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 13 , BITFIELD_OFFSET_OF_MEMBER(ehci_registers_t, usb_sts_bit, reclamation)); | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 14 , BITFIELD_OFFSET_OF_MEMBER(ehci_registers_t, usb_sts_bit, period_schedule_status)); | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 15 , BITFIELD_OFFSET_OF_MEMBER(ehci_registers_t, usb_sts_bit, async_schedule_status)); | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 18 , BITFIELD_OFFSET_OF_MEMBER(ehci_registers_t, usb_sts_bit, nxp_int_async)); | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 19 , BITFIELD_OFFSET_OF_MEMBER(ehci_registers_t, usb_sts_bit, nxp_int_period)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-02 00:09:24 +07:00
										 |  |  | void test_register_usbint(void) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 0  , BITFIELD_OFFSET_OF_MEMBER(ehci_registers_t, usb_int_enable_bit, usb)); | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 1  , BITFIELD_OFFSET_OF_MEMBER(ehci_registers_t, usb_int_enable_bit, usb_error)); | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 2  , BITFIELD_OFFSET_OF_MEMBER(ehci_registers_t, usb_int_enable_bit, port_change_detect)); | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 3  , BITFIELD_OFFSET_OF_MEMBER(ehci_registers_t, usb_int_enable_bit, framelist_rollover)); | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 4  , BITFIELD_OFFSET_OF_MEMBER(ehci_registers_t, usb_int_enable_bit, pci_host_system_error)); | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 5  , BITFIELD_OFFSET_OF_MEMBER(ehci_registers_t, usb_int_enable_bit, async_advance)); | 
					
						
							| 
									
										
										
										
											2013-04-21 00:28:25 +07:00
										 |  |  |   TEST_ASSERT_EQUAL( 7  , BITFIELD_OFFSET_OF_MEMBER(ehci_registers_t, usb_int_enable_bit, nxp_int_sof)); | 
					
						
							| 
									
										
										
										
											2013-03-02 00:09:24 +07:00
										 |  |  |   TEST_ASSERT_EQUAL( 18 , BITFIELD_OFFSET_OF_MEMBER(ehci_registers_t, usb_int_enable_bit, nxp_int_async)); | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 19 , BITFIELD_OFFSET_OF_MEMBER(ehci_registers_t, usb_int_enable_bit, nxp_int_period)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-02-27 17:57:53 +07:00
										 |  |  | void test_register_portsc(void) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 0  , BITFIELD_OFFSET_OF_MEMBER(ehci_registers_t, portsc_bit, current_connect_status)); | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 1  , BITFIELD_OFFSET_OF_MEMBER(ehci_registers_t, portsc_bit, connect_status_change)); | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 2  , BITFIELD_OFFSET_OF_MEMBER(ehci_registers_t, portsc_bit, port_enable)); | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 3  , BITFIELD_OFFSET_OF_MEMBER(ehci_registers_t, portsc_bit, port_enable_change)); | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 4  , BITFIELD_OFFSET_OF_MEMBER(ehci_registers_t, portsc_bit, over_current_active)); | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 5  , BITFIELD_OFFSET_OF_MEMBER(ehci_registers_t, portsc_bit, over_current_change)); | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 6  , BITFIELD_OFFSET_OF_MEMBER(ehci_registers_t, portsc_bit, force_port_resume)); | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 7  , BITFIELD_OFFSET_OF_MEMBER(ehci_registers_t, portsc_bit, suspend)); | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 8  , BITFIELD_OFFSET_OF_MEMBER(ehci_registers_t, portsc_bit, port_reset)); | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 9  , BITFIELD_OFFSET_OF_MEMBER(ehci_registers_t, portsc_bit, nxp_highspeed_status)); | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 10 , BITFIELD_OFFSET_OF_MEMBER(ehci_registers_t, portsc_bit, line_status)); | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 12 , BITFIELD_OFFSET_OF_MEMBER(ehci_registers_t, portsc_bit, port_power)); | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 13 , BITFIELD_OFFSET_OF_MEMBER(ehci_registers_t, portsc_bit, port_owner)); | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 14 , BITFIELD_OFFSET_OF_MEMBER(ehci_registers_t, portsc_bit, port_indicator_control)); | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 16 , BITFIELD_OFFSET_OF_MEMBER(ehci_registers_t, portsc_bit, port_test_control)); | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 20 , BITFIELD_OFFSET_OF_MEMBER(ehci_registers_t, portsc_bit, wake_on_connect_enable)); | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 21 , BITFIELD_OFFSET_OF_MEMBER(ehci_registers_t, portsc_bit, wake_on_disconnect_enable)); | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 22 , BITFIELD_OFFSET_OF_MEMBER(ehci_registers_t, portsc_bit, wake_on_over_current_enable)); | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 23 , BITFIELD_OFFSET_OF_MEMBER(ehci_registers_t, portsc_bit, nxp_phy_clock_disable)); | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 24 , BITFIELD_OFFSET_OF_MEMBER(ehci_registers_t, portsc_bit, nxp_port_force_fullspeed)); | 
					
						
							|  |  |  |   TEST_ASSERT_EQUAL( 26 , BITFIELD_OFFSET_OF_MEMBER(ehci_registers_t, portsc_bit, nxp_port_speed)); | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2013-02-27 17:31:51 +07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-02-27 18:49:28 +07:00
										 |  |  | //--------------------------------------------------------------------+
 | 
					
						
							| 
									
										
										
										
											2013-02-28 15:03:18 +07:00
										 |  |  | // EHCI Data Organization
 | 
					
						
							| 
									
										
										
										
											2013-02-27 18:49:28 +07:00
										 |  |  | //--------------------------------------------------------------------+
 | 
					
						
							| 
									
										
										
										
											2013-02-28 17:00:51 +07:00
										 |  |  | void test_ehci_data(void) | 
					
						
							| 
									
										
										
										
											2013-02-28 15:03:18 +07:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2013-03-04 16:21:41 +07:00
										 |  |  |   for(uint32_t i=0; i<CONTROLLER_HOST_NUMBER; i++) | 
					
						
							| 
									
										
										
										
											2013-03-03 12:37:44 +07:00
										 |  |  |   { | 
					
						
							| 
									
										
										
										
											2013-03-05 14:26:36 +07:00
										 |  |  |     uint8_t hostid = i+TEST_CONTROLLER_HOST_START_INDEX; | 
					
						
							| 
									
										
										
										
											2013-03-03 12:37:44 +07:00
										 |  |  |     TEST_ASSERT_BITS_LOW(4096-1, (uint32_t)get_period_frame_list(hostid) ); | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2013-02-27 18:49:28 +07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-11 00:40:21 +07:00
										 |  |  |   // TODO more tests on ehci_data
 | 
					
						
							| 
									
										
										
										
											2013-02-28 17:00:51 +07:00
										 |  |  | } |