template <bool manage_lifetime, typename gtest_base>

class TestFixture

Defined at line 710 of file ../../src/devices/usb/drivers/dwc3/dwc3-test-fixture.h

Test is templated on a parameter which, if true, will have the harness start and stop the driver.

Otherwise, it is the individual test(s) responsibility to start and stop the driver.

Protected Members

uint32_t ver_number_
atomic dctl_val_
atomic dsts_val_
atomic ver_number31_
atomic ver_type31_
atomic stuck_reset_test_
atomic stuck_halt_test_
atomic vbus_high_
mutex dctl_mutex_
function_impl dctl_callback_
BackgroundDriverTest dut_

Public Methods

Dwc3::UserEndpoint & GetUserEndpoint (Dwc3 & drv, uint8_t ep_num)

Defined at line 716 of file ../../src/devices/usb/drivers/dwc3/dwc3-test-fixture.h

uint8_t UsbAddressToEpNum (uint8_t addr)

Defined at line 722 of file ../../src/devices/usb/drivers/dwc3/dwc3-test-fixture.h

const zx::bti & GetBti (const Dwc3 & drv)

Defined at line 724 of file ../../src/devices/usb/drivers/dwc3/dwc3-test-fixture.h

void TriggerEpTransferNotReady (Dwc3 & drv, uint8_t ep_num, uint32_t stage)

Defined at line 726 of file ../../src/devices/usb/drivers/dwc3/dwc3-test-fixture.h

void TriggerEpTransferComplete (Dwc3 & drv, uint8_t ep_num, uint32_t residual, bool spr)

Defined at line 730 of file ../../src/devices/usb/drivers/dwc3/dwc3-test-fixture.h

void TriggerEpTransferInProgress (Dwc3 & drv, uint8_t ep_num, uint32_t residual, bool spr)

Defined at line 760 of file ../../src/devices/usb/drivers/dwc3/dwc3-test-fixture.h

void TriggerEpTransferStarted (Dwc3 & drv, uint8_t ep_num, uint32_t rsrc_id)

Defined at line 788 of file ../../src/devices/usb/drivers/dwc3/dwc3-test-fixture.h

void TriggerEpTransferEnded (Dwc3 & drv, uint8_t ep_num)

Defined at line 792 of file ../../src/devices/usb/drivers/dwc3/dwc3-test-fixture.h

void TriggerConnectionDone (Dwc3 & drv)

Defined at line 796 of file ../../src/devices/usb/drivers/dwc3/dwc3-test-fixture.h

void TriggerConnectionPlugIn (::fuchsia_hardware_usb_descriptor::wire::UsbSpeed speed)

Defined at line 802 of file ../../src/devices/usb/drivers/dwc3/dwc3-test-fixture.h

auto DeferClearDepcmdCallbacks (uint8_t ep_num)

Returns an RAII guard that restores DEPCMD register callbacks for the endpoint to their default

no-op state on scope exit. Note: FakeMmioReg does not maintain internal storage and invokes

its callbacks directly, so restoring the constructor defaults ([](){}) is required to avoid

null fit::function invocations on subsequent register accesses.

Defined at line 833 of file ../../src/devices/usb/drivers/dwc3/dwc3-test-fixture.h

auto DeferClearDctlCallback ()

Returns an RAII guard that clears the DCTL callback on scope exit.

Defined at line 844 of file ../../src/devices/usb/drivers/dwc3/dwc3-test-fixture.h

auto DeferClearDstsCallback ()

Returns an RAII guard that restores the DSTS read callback to Read_DSTS() on scope exit.

Defined at line 849 of file ../../src/devices/usb/drivers/dwc3/dwc3-test-fixture.h

std::vector<fuchsia_hardware_usb_request::Request> CreateVmoBuffer (const fidl::SyncClient<fuchsia_hardware_usb_endpoint::Endpoint> & sync_client, size_t size, size_t buffer_size, uint8_t vmo_id)

Defined at line 857 of file ../../src/devices/usb/drivers/dwc3/dwc3-test-fixture.h

void QueueRequestsAndWaitForStartTransfer (uint8_t ep_addr, const fidl::SyncClient<fuchsia_hardware_usb_endpoint::Endpoint> & sync_client, std::vector<fuchsia_hardware_usb_request::Request> requests)

Defined at line 894 of file ../../src/devices/usb/drivers/dwc3/dwc3-test-fixture.h

void SetUpAndPowerOnEndpoints ()

Defined at line 919 of file ../../src/devices/usb/drivers/dwc3/dwc3-test-fixture.h

void SetUp ()

Defined at line 925 of file ../../src/devices/usb/drivers/dwc3/dwc3-test-fixture.h

void TearDown ()

Defined at line 961 of file ../../src/devices/usb/drivers/dwc3/dwc3-test-fixture.h

void SetDctlCallback (fit::function<void ()> cb)

Defined at line 975 of file ../../src/devices/usb/drivers/dwc3/dwc3-test-fixture.h

Protected Methods

PlatformExtension * GetPlatformExtension (Dwc3 & drv)

Defined at line 799 of file ../../src/devices/usb/drivers/dwc3/dwc3-test-fixture.h

uint32_t Read_GHWPARAMS3 ()

Section 1.2.22 of the DWC3 Programmer's guide

DWC_USB31_CACHE_TOTAL_XFER_RESOURCES : 32

DWC_USB31_NUM_IN_EPS : 16

DWC_USB31_NUM_EPS : 32

DWC_USB31_VENDOR_CTL_INTERFACE : 0

DWC_USB31_HSPHY_DWIDTH : 2

DWC_USB31_HSPHY_INTERFACE : 1

DWC_USB31_SSPHY_INTERFACE : 2

Defined at line 990 of file ../../src/devices/usb/drivers/dwc3/dwc3-test-fixture.h

uint32_t Read_DCTL ()

Section 1.4.2 of the DWC3 Programmer's guide

Defined at line 995 of file ../../src/devices/usb/drivers/dwc3/dwc3-test-fixture.h

void Write_DCTL (uint32_t val)

Defined at line 996 of file ../../src/devices/usb/drivers/dwc3/dwc3-test-fixture.h

uint32_t Read_DSTS ()

Defined at line 1034 of file ../../src/devices/usb/drivers/dwc3/dwc3-test-fixture.h

uint32_t Read_GSNPSID ()

Section 1.2.9 of the DWC3 Programmer's guide

core_id = 0x5533

version = 1.60a

Defined at line 1040 of file ../../src/devices/usb/drivers/dwc3/dwc3-test-fixture.h

uint32_t Read_USB31_VER_NUMBER ()

Defined at line 1041 of file ../../src/devices/usb/drivers/dwc3/dwc3-test-fixture.h

uint32_t Read_USB31_VER_TYPE ()

Defined at line 1042 of file ../../src/devices/usb/drivers/dwc3/dwc3-test-fixture.h

zx_status_t WaitForPhy ()

There's an inherent race in the way this test is set up between the three threads: the

foreground testing thread, the background driver thread, and the environment thread the fakes

are running on. Driving the driver's dispatcher to an idle state and then tearing down the test

will race with the environment's dispatcher execution of the Watch handler. If the environment

dispatcher is torn down before the side effects of the Watch handler execute, ~FakeUsbPhy()

will sometimes fail. To resolve this race, the foreground testing thread needs to be

synchronized against the environment thread and wait for the fakes to catch up.

Defined at line 1064 of file ../../src/devices/usb/drivers/dwc3/dwc3-test-fixture.h