make "used" member of ehci_qtd_t into reserved place of buffer[1] (with assert check in hcd init)
This commit is contained in:
parent
1b610cf26f
commit
644f0d3932
|
@ -98,6 +98,7 @@ void setUp(void)
|
||||||
usbh_device_info_pool[i].core_id = hostid;
|
usbh_device_info_pool[i].core_id = hostid;
|
||||||
usbh_device_info_pool[i].hub_addr = hub_addr;
|
usbh_device_info_pool[i].hub_addr = hub_addr;
|
||||||
usbh_device_info_pool[i].hub_port = hub_port;
|
usbh_device_info_pool[i].hub_port = hub_port;
|
||||||
|
usbh_device_info_pool[i].speed = TUSB_SPEED_HIGH;
|
||||||
}
|
}
|
||||||
|
|
||||||
async_head = get_async_head( hostid );
|
async_head = get_async_head( hostid );
|
||||||
|
@ -228,5 +229,3 @@ void test_control_xfer_set(void)
|
||||||
TEST_ASSERT_TRUE(p_status->data_toggle);
|
TEST_ASSERT_TRUE(p_status->data_toggle);
|
||||||
TEST_ASSERT_EQUAL(EHCI_PID_IN, p_status->pid);
|
TEST_ASSERT_EQUAL(EHCI_PID_IN, p_status->pid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -134,6 +134,7 @@ void test_qtd_structure(void)
|
||||||
TEST_ASSERT_EQUAL( 31, BITFIELD_OFFSET_OF_UINT32(ehci_qtd_t, 2, data_toggle) );
|
TEST_ASSERT_EQUAL( 31, BITFIELD_OFFSET_OF_UINT32(ehci_qtd_t, 2, data_toggle) );
|
||||||
|
|
||||||
TEST_ASSERT_EQUAL( 12, offsetof(ehci_qtd_t, buffer));
|
TEST_ASSERT_EQUAL( 12, offsetof(ehci_qtd_t, buffer));
|
||||||
|
TEST_ASSERT_EQUAL( 16, offsetof(ehci_qtd_t, used));
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_qhd_structure(void)
|
void test_qhd_structure(void)
|
||||||
|
|
|
@ -72,6 +72,7 @@
|
||||||
ENTRY(TUSB_ERROR_OSAL_TASK_FAILED)\
|
ENTRY(TUSB_ERROR_OSAL_TASK_FAILED)\
|
||||||
ENTRY(TUSB_ERROR_OSAL_QUEUE_FAILED)\
|
ENTRY(TUSB_ERROR_OSAL_QUEUE_FAILED)\
|
||||||
ENTRY(TUSB_ERROR_OSAL_SEMAPHORE_FAILED)\
|
ENTRY(TUSB_ERROR_OSAL_SEMAPHORE_FAILED)\
|
||||||
|
ENTRY(TUSB_ERROR_EHCI_NOT_ENOUGH_QTD)\
|
||||||
ENTRY(TUSB_ERROR_FAILED)\
|
ENTRY(TUSB_ERROR_FAILED)\
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -117,6 +117,9 @@ tusb_error_t hcd_controller_init(uint8_t hostid) ATTR_WARN_UNUSED_RESULT;
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
tusb_error_t hcd_init(void)
|
tusb_error_t hcd_init(void)
|
||||||
{
|
{
|
||||||
|
// oops, ehci_qtd_t:used must be at Reserved places in EHCI specs
|
||||||
|
ASSERT(offsetof(ehci_qtd_t, used) == 16, TUSB_ERROR_HCD_FAILED); // TODO can be removed after an THOROUGH checked
|
||||||
|
|
||||||
//------------- Data Structure init -------------//
|
//------------- Data Structure init -------------//
|
||||||
memclr_(&ehci_data, sizeof(ehci_data_t));
|
memclr_(&ehci_data, sizeof(ehci_data_t));
|
||||||
|
|
||||||
|
@ -365,7 +368,6 @@ pipe_handle_t hcd_pipe_open(uint8_t dev_addr, tusb_descriptor_endpoint_t const *
|
||||||
{
|
{
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSERT( index < EHCI_MAX_QHD, null_handle);
|
ASSERT( index < EHCI_MAX_QHD, null_handle);
|
||||||
|
|
||||||
ehci_qhd_t * const p_qhd = &ehci_data.device[dev_addr].qhd[index];
|
ehci_qhd_t * const p_qhd = &ehci_data.device[dev_addr].qhd[index];
|
||||||
|
@ -390,6 +392,18 @@ pipe_handle_t hcd_pipe_open(uint8_t dev_addr, tusb_descriptor_endpoint_t const *
|
||||||
return (pipe_handle_t) { .dev_addr = dev_addr, .xfer_type = p_endpoint_desc->bmAttributes.xfer, .index = index};
|
return (pipe_handle_t) { .dev_addr = dev_addr, .xfer_type = p_endpoint_desc->bmAttributes.xfer, .index = index};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tusb_error_t hcd_pipe_xfer(pipe_handle_t pipe_hdl, uint8_t buffer[], uint16_t total_byte)
|
||||||
|
{
|
||||||
|
//------------- find a free qtd -------------//
|
||||||
|
// uint8_t index=0;
|
||||||
|
// while( index<EHCI_MAX_QTD && ehci_data.device[dev_addr].qtd[index].used )
|
||||||
|
// {
|
||||||
|
// index++;
|
||||||
|
// }
|
||||||
|
// ASSERT( index < EHCI_MAX_QHD, TUSB_ERROR_EHCI_NOT_ENOUGH_QTD);
|
||||||
|
|
||||||
|
return TUSB_ERROR_NONE;
|
||||||
|
}
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// HELPER
|
// HELPER
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
|
|
|
@ -124,17 +124,7 @@ typedef struct {
|
||||||
ehci_link_t next;
|
ehci_link_t next;
|
||||||
|
|
||||||
/// Word 1: Alternate Next QTD Pointer (not used)
|
/// Word 1: Alternate Next QTD Pointer (not used)
|
||||||
/// Used to store management information
|
ehci_link_t alternate;
|
||||||
union{
|
|
||||||
ehci_link_t alternate; ///< Alternate Next QTD Pointer (not used)
|
|
||||||
struct {
|
|
||||||
uint32_t : 5; ///< reserved this for alternate
|
|
||||||
|
|
||||||
// HCD information
|
|
||||||
uint32_t used : 1; ///< indicate this qTD is occupied
|
|
||||||
uint32_t : 0; // padding to the end of current storage unit
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
/// Word 2: qTQ Token
|
/// Word 2: qTQ Token
|
||||||
volatile uint32_t pingstate_err : 1 ; ///< If the QH.EPSfield indicates a High-speed device and the PID_Codeindicates an OUT endpoint, then this is the state bit for the Ping protocol. 0b=OUT 1b=PING
|
volatile uint32_t pingstate_err : 1 ; ///< If the QH.EPSfield indicates a High-speed device and the PID_Codeindicates an OUT endpoint, then this is the state bit for the Ping protocol. 0b=OUT 1b=PING
|
||||||
|
@ -157,8 +147,16 @@ typedef struct {
|
||||||
// End of Word 2
|
// End of Word 2
|
||||||
|
|
||||||
/// Buffer Page Pointer List, Each element in the list is a 4K page aligned, physical memory address. The lower 12 bits in each pointer are reserved (except for the first one) as each memory pointer must reference the start of a 4K page
|
/// Buffer Page Pointer List, Each element in the list is a 4K page aligned, physical memory address. The lower 12 bits in each pointer are reserved (except for the first one) as each memory pointer must reference the start of a 4K page
|
||||||
|
union {
|
||||||
uint32_t buffer[5];
|
uint32_t buffer[5];
|
||||||
} ehci_qtd_t; // XXX qtd is used to declare overlay in ehci_qhd_t, we cannot put ATTR_ALIGNED(32) here
|
struct {
|
||||||
|
uint32_t reserve_1;
|
||||||
|
uint8_t used; // used is the LSB of buffer[1]
|
||||||
|
uint8_t reserved_2[3];
|
||||||
|
uint32_t reserved_3[3];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
} ehci_qtd_t; // XXX qtd is used to declare overlay in ehci_qhd_t -> cannot be declared with ATTR_ALIGNED(32)
|
||||||
|
|
||||||
/// Queue Head (section 3.6)
|
/// Queue Head (section 3.6)
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|
|
@ -80,7 +80,7 @@ tusb_error_t hcd_pipe_control_xfer(uint8_t dev_addr, tusb_std_request_t const *
|
||||||
tusb_error_t hcd_pipe_control_close(uint8_t dev_addr) ATTR_WARN_UNUSED_RESULT;
|
tusb_error_t hcd_pipe_control_close(uint8_t dev_addr) ATTR_WARN_UNUSED_RESULT;
|
||||||
|
|
||||||
pipe_handle_t hcd_pipe_open(uint8_t dev_addr, tusb_descriptor_endpoint_t const * endpoint_desc) ATTR_WARN_UNUSED_RESULT;
|
pipe_handle_t hcd_pipe_open(uint8_t dev_addr, tusb_descriptor_endpoint_t const * endpoint_desc) ATTR_WARN_UNUSED_RESULT;
|
||||||
tusb_error_t hcd_pipe_xfer(pipe_handle_t pipe_hdl, uint8_t buffer[]) ATTR_WARN_UNUSED_RESULT;
|
tusb_error_t hcd_pipe_xfer(pipe_handle_t pipe_hdl, uint8_t buffer[], uint16_t total_byte) ATTR_WARN_UNUSED_RESULT;
|
||||||
tusb_error_t hcd_pipe_close(pipe_handle_t pipe_hdl) ATTR_WARN_UNUSED_RESULT;
|
tusb_error_t hcd_pipe_close(pipe_handle_t pipe_hdl) ATTR_WARN_UNUSED_RESULT;
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
|
|
Loading…
Reference in New Issue