/*FUNCTION*---------------------------------------------------------------- * * Function Name : _usb_dci_vusb20_set_test_mode * Returned Value : None * Comments : * sets/resets the test mode * *END*--------------------------------------------------------------------*/ void _usb_dci_vusb20_set_test_mode ( /* [IN] Handle to the USB device */ _usb_device_handle handle, /* [IN] Test mode */ uint_16 test_mode ) { /* Body */ USB_DEV_STATE_STRUCT_PTR usb_dev_ptr; VUSB20_REG_STRUCT_PTR dev_ptr; uint_32 temp; ARC_DEBUG_TRACE(ARC_DEBUG_FLAG_ANY, "set_test_mode\n"); usb_dev_ptr = (USB_DEV_STATE_STRUCT_PTR)handle; dev_ptr = (VUSB20_REG_STRUCT_PTR)usb_dev_ptr->DEV_PTR; temp = USB_32BIT_LE(dev_ptr->REGISTERS.OPERATIONAL_DEVICE_REGISTERS.ENDPTCTRLX[0]); dev_ptr->REGISTERS.OPERATIONAL_DEVICE_REGISTERS.ENDPTCTRLX[0] = USB_32BIT_LE((temp | EHCI_EPCTRL_TX_DATA_TOGGLE_RST)); if (test_mode == ARC_USB_TEST_MODE_TEST_PACKET) { USB_memcopy(test_packet, usb_dev_ptr->TEST_PKT_PTR, USB_TEST_MODE_TEST_PACKET_LENGTH); _usb_device_send_data(handle, 0, usb_dev_ptr->TEST_PKT_PTR, USB_TEST_MODE_TEST_PACKET_LENGTH); } /* Endif */ temp = USB_32BIT_LE(dev_ptr->REGISTERS.OPERATIONAL_DEVICE_REGISTERS.PORTSCX[0]); temp &= ~EHCI_PORTSCX_W1C_BITS; dev_ptr->REGISTERS.OPERATIONAL_DEVICE_REGISTERS.PORTSCX[0] = USB_32BIT_LE(temp | ((uint_32)test_mode << 8)); } /* EndBody */
/**************************************************************************//*! * * @name msc_read_format_capacity_command * * @brief allows the host to request a list of the possible capacities that * can be formatted on the currently installed medium * * @param controller_ID: To identify the controller * @param cbw_ptr : pointer to Command Block Wrapper sent by host * @param csw_residue_ptr: pointer to dCSWDataResidue of Command Status Wrapper * @param csw_status_ptr : pointer to bCSWStatus of Command Status Wrapper * * @return error * *****************************************************************************/ uint_8 msc_read_format_capacity_command ( uint_8 controller_ID, PTR_CBW cbw_ptr, uint_32* csw_residue_ptr, uint_8* csw_status_ptr ) { uint_8 i; /* general variable for counting in loop */ uint_8 error = USBERR_TX_FAILED; /* size of data to be sent in data phase for this command*/ uint_32 response_size; uint_16 allocation_length = (uint_16)((cbw_ptr->command_block[7] << 8) | cbw_ptr->command_block[8]); uint_8_ptr response_data_ptr;/* pointer to data to be sent in data phase for this command*/ uint_8 num_formattable_cap_desc = (uint_8)(g_msc_scsi.formatted_disk ? (IMPLEMENTING_DISK_DRIVE?0x02:0x03):0x00); /* gives the number of Formattable Capacity Descriptor to be sent by device in response to read format capacities command */ /* 0x03 is number of formattable capacity desc. for HD while for DD its 2 if formatted drive is there */ CAPACITY_LIST_HEADER_STRUCT capacity_list_header = {0x00,0x00,0x00,0x00}; /* Initializing all fields */ CURR_MAX_CAPACITY_DESC_STRUCT curr_max_cap_header; FORMATTABLE_CAP_DESC formattable_cap_descriptor; uint_32 desc_code = (uint_32)(g_msc_scsi.formatted_disk?FORMATTED_MEDIA: UNFORMATTED_MEDIA); #if (!defined LITTLE_ENDIAN) formattable_cap_descriptor.num_blocks = g_msc_scsi.device_info.total_lba_device_supports; formattable_cap_descriptor.block_len = g_msc_scsi.device_info.length_of_each_lba_of_device; #else formattable_cap_descriptor.num_blocks = BYTESWAP32(g_msc_scsi.device_info.total_lba_device_supports); formattable_cap_descriptor.block_len = BYTESWAP32(g_msc_scsi.device_info.length_of_each_lba_of_device); #endif /* initialize sense code values */ g_msc_scsi.request_sense.sense_key = NO_SENSE; g_msc_scsi.request_sense.add_sense_code = NO_SENSE; g_msc_scsi.request_sense.add_sense_code_qual = NO_SENSE; capacity_list_header.capacity_list_len = (uint_8)(num_formattable_cap_desc * 8); #if (!defined LITTLE_ENDIAN) curr_max_cap_header.num_blocks = g_msc_scsi.device_info.total_lba_device_supports; curr_max_cap_header.desc_code_and_block_len = (desc_code << 24)| g_msc_scsi.device_info.length_of_each_lba_of_device; #else curr_max_cap_header.num_blocks = BYTESWAP32(g_msc_scsi.device_info.total_lba_device_supports); curr_max_cap_header.desc_code_and_block_len = BYTESWAP32((desc_code << 24)| g_msc_scsi.device_info.length_of_each_lba_of_device); #endif response_size = sizeof(capacity_list_header) + sizeof(curr_max_cap_header)+ sizeof(formattable_cap_descriptor) * num_formattable_cap_desc; if(response_size > allocation_length) { /* comparing the length of data available with allocation length value sent in CBW which indicates the length of buffer host has reserved for data phase of this command */ response_size = allocation_length; } /* reserving memory for response data */ response_data_ptr = (uint_8_ptr)response_data_array; USB_memcopy(&capacity_list_header, response_data_ptr, sizeof(capacity_list_header)); USB_memcopy(&curr_max_cap_header, response_data_ptr + sizeof(capacity_list_header),sizeof(curr_max_cap_header)); if(g_msc_scsi.formatted_disk) { for(i = 0; i < num_formattable_cap_desc; i++) { USB_memcopy(&formattable_cap_descriptor, response_data_ptr + sizeof(capacity_list_header) + sizeof(curr_max_cap_header)+ sizeof(formattable_cap_descriptor) * i, sizeof(formattable_cap_descriptor)); } } g_msc_scsi.thirteen_case_struct.controller_ID = controller_ID; g_msc_scsi.thirteen_case_struct.host_expected_data_len = cbw_ptr->data_length; g_msc_scsi.thirteen_case_struct.host_expected_direction = (uint_8)(cbw_ptr->flag >> USB_CBW_DIRECTION_SHIFT); g_msc_scsi.thirteen_case_struct.device_expected_data_len = response_size; g_msc_scsi.thirteen_case_struct.device_expected_direction = USB_SEND; g_msc_scsi.thirteen_case_struct.csw_status_ptr = csw_status_ptr; g_msc_scsi.thirteen_case_struct.csw_residue_ptr = csw_residue_ptr; g_msc_scsi.thirteen_case_struct.buffer_ptr = response_data_ptr; g_msc_scsi.thirteen_case_struct.lba_txrx_select = FALSE; error = msc_thirteen_cases_check(&(g_msc_scsi.thirteen_case_struct)); return error; }