Primary Author: Girish Verma Secondary Author(s): Navya Prabhakar Presenter: Navya Prabhakar...
-
Upload
diego-cast -
Category
Documents
-
view
220 -
download
0
Transcript of Primary Author: Girish Verma Secondary Author(s): Navya Prabhakar Presenter: Navya Prabhakar...
Primary Author: Girish Verma
Secondary Author(s): Navya Prabhakar
Presenter: Navya Prabhakar
Company/Organization: CircuitSutra
USB Modeling Quick Start Package
Presentation Topics
Need for USB Modeling QSP USB Concepts Overview of USB QSP contents Contents of USB QSP
TLM USB Protocol USB Host Socket USB Device Socket USB Host PC Host Controller USB Host PC Device Controller
Results
Need for USB Modeling QSP
Issues with USB Modeling• USB protocol is standardized but no available standard on TLM USB• Developing a model which addresses USB protocol without re-usable
components is time consuming• Testing USB models requires complete protocol stack
Solution
• Provide basic infrastructure to quick start SystemC model development of USB Device controller, USB Host Controller
• Facilitates development and testing of device driver/application stack• Generic USB Device/Host requirements are modeled in convenience
sockets so model developer needs to focus only on device-related modeling
USB Concepts USB Bus
• Supports data exchange between a USB host and USB peripherals
USB Host Controller Manages data transfer between USB Host and USB devices
USB Device Device specification
General information about device Configuration
Groups interfaces Interface
Represent basic functionality Endpoint
Source or sink of data Unique for a device
Device
Configuration 0...
Interface 0 Interface n
Endpoint 0 Endpoint n...
...
Configuration n
USB Communication Interface
• Takes place at electrical/link level and protocol level
• Abstracted as transaction level interface call
• Contains APIs to model communication at high level of abstraction
USB Host and Slave socketso Encapsulate USB communication
Contents of USB QSP
Host Controller
Device Controller
Downstream Bus
Upstream Bus
Forward Interface
BackwardInterface
USB Host Socket
USB Device Socket
Contents of USB QSP
USB Host
Controller
USB HostSocket
USB Host PCDevice
Controller
USBDeviceSocket
USB Host PC
HostController
USB Device
Controller
USB DeviceSocket
USB HostSocket
Payload: tlm_usb_host_payload
Attribute Possible ValuesRequest type Device Reset, Device Suspend, Device Resume, Data Transfer, Sync Frame
Device Address Address of USB device
Endpoint Address Address of USB Endpoint
Transfer Direction Setup, In, Out
Transfer Type Control, Interrupt, Bulk, Isochronous
Data pointer Pointer to data buffer
Data length requested Allocated data length
Used data length Data length valid
Interval Interval between packets (required for Isochronous packets)
Frame number USB frame number
Response Status OK, STALL, NAK, ERROR, INCOMPLETE
sc_interface: tlm_usb_fw_ifCommunication from USB Host Controllerto USB Device Controller
void nb_transport_usb_fw(tlm_usb_host_payload& payload)
TLM USB ProtocolForward Interface
Payload: tlm_usb_device_payload
Attribute Possible ValuesRequest type Port status, Remote wakeup, Initiate SRP, Initiate HNP
Port Status Device Attached, Device removed
Response Status OK, ERROR,INCOMPLETE
sc_interface: tlm_usb_bw_ifCommunication from USB Device Controllerto USB Host Controller
void nb_transport_usb_bw(tlm_usb_device_payload& payload)
TLM USB Protocol
Backward Interface
USB Host Socket sc_port templated with forward interface
Implements the backward interface Inherits from USB Host State
Implements generic USB Device handling Provides convenience APIs for USB device model developer
Callbacks• void usb_port_status (UsbPortState_t port_status, int n);• void usb_request_remote_wakeup();• bool usb_request_srp();• bool usb_request_hnp();
USB Host Socketsc_core::sc_port<usb_fw_transport_if>
usb_host_socket
sc_core::sc_export<usb_bw_transport_if>
UsbHostState
USB Host Controller
Convenience APIs
Callbacks
USB Host Socket
Convenience APIs
void reset();
void start();
void stop();
tlm_usb_transaction_status_t submit_transfer_request (tlm_usb_data_transfer_request_t* data_pkt);
void set_port_state(int port_num, UsbPortState_t port_state);
void get_port_status(uint8_t* buf);
USB Device Socket sc_port templated with backward interface
Implements the forward interface
Inherits from USB Device State Implements generic USB Devicehandling Provides convenience APIs for USB device model developer
Callbacks void device_state_change (device_state_change_t reason); unsigned int handle_ep_request (uint8_t EndPointAddr,int ep_dir,unsigned char* ep_data_ptr, unsigned int ep_data_len_requested); bool handle_ep0_request(usb_control_packet *setup_pkt, uint8_t* buf);
USB Device Socketsc_core::sc_port<usb_bw_transport_if>
usb_device_socket
sc_core::sc_export<usb_fw_transport_if>
UsbDeviceState
Convenience APIs
Callbacks
USB Device Controller
USB Device Socket
Convenience APIs
void enable_endpoint(uint8_t _EndPointAddr, tlm_usb_transfer_type_t _EndPointType, tlm_usb_endpoint_dir_t _EndPointDir, uint16_t _MaxPacketSize,
uint8_t _bInterval); void halt_endpoint(uint8_t _EndPointAddr); void set_device_state(UsbDeviceState_t _DevState); void set_device_address(tlm_usb_device_address _dev_addr); void handle_ep0_standard_req(bool _handle_standard_req = true); void set_device_descriptor(usb_device_descriptor* _p_device_descriptor); void set_config_descriptor(usb_config_descriptor* _p_config_descriptor, int num); void set_string_descriptor(usb_string_descriptor* _p_string_descriptor, int num);
USB Host PC Host Controller
SystemC model USB host controller that encapsulate USB system of host PC
Can connect with USB Device Controller model
Adds a new virtual Host Controller in the Host PC OS
Connects the USB Device Controller to the new virtual Host through set of OS-dependent APIs
Supports Control, Bulk, Interrupt and Isochronous transfers
USB Host PC Host Controller model
User space
Kernel space
Virtual Host ControllerEmulation in kernel
OS dependent API call for VirtualHost Controlleremulation
SC_THREAD Virtual Host Controller OS Adaptor
USB HostSocket
USB Host PC Host Controller model
USB Host PC Host Controller
Linux Version
USB Host PC Host Controller connects with
USB Device model through USB Host Socket
Virtual Host Controller Library provides convenience APIs to interact with virtual Host Controller driver
Virtual Host Controller Linux kernel Virtual Host Controller driver Registers itself to the core layer Forwards URB requests from USB Core
layer to the application OS running on Host System
Virtual Host Controller
USB Core Layer
SC_THREAD
Virtual Host Controller Library
USB HostSocket
USB Host PC Host Controller model
USB Host PC Host Controller
OS running on Host System
Softehci Windows DSF Layer
USB Core Layer
Windows Version
USB Host Controller connects with USB Device model through USB Host Socket
Soft USB• Interfaces with the application to
communicate as a USB Device• Receives URB requests from USB DSF
layer and sends it to the application
Soft ehci • DSF [Device Simulation Framework]• Emulates virtual Host Controller
SC_THREAD
Softusbdll
USB HostSocket
USB Host PC Device Controller model
USB Host PC Device Controller
SystemC model of USB device controller that encapsulate the USB system of host PC
Can connect with USB Host Controller model
Controls the USB Devices connected to Host PC through LIBUSB API
LIBUSB is a C library that provides applications easy access to USB devices
Contains configurable parameters – Product ID and Vendor ID to make the USB device accessible in the Virtual Platform Supports Control, Bulk, Interrupt transfers
USB Port
Host PC/SystemUSB Host Controller on PC
OS running on Host SystemHost Controller Driver
USB HAL Layer
USBDeviceSocket
SC_THREAD LIBUSB API
Created virtual platform having USB device controller booting Linux with USB file storage gadget driver
Able to emulate virtual platform as a USB mass storage device in Host PC
Mounted this USB device on Host PC & successfully performed read, write on virtual platform
Provides support to develop and test device driver/ application stalk on Host PC
Results
Kernel space
Virtual Platform Core
Bus
Memory
USB DeviceController
USBDeviceSocket
USB Host PC HostController
USB HostSocket
Virtual Host Controller emulation in kernel
User space
Virtual Platform Core
Bus
Memory
USB HostController
USB HostSocket
USB Host PC DeviceController
USBDeviceSocket
USB Host Controller on Host PC
User space
Results
USB Port
Created virtual platform having a USB3.0 XHCI Host Controller booting Linux
Host PC is able to connect real USB device to the virtual platform
Successfully able to mount, read, write on USB thumb drive connected to Host PC
Provides support to develop device driver for USB Host Controller on virtual platform
Kernel space
Thank You!!