@@ -1000,7 +1000,7 @@ ot_spi_device_flash_match_command_slot(OtSPIDeviceState *s, uint8_t cmd)
10001000 }
10011001 }
10021002
1003- trace_ot_spi_device_flash_ignored_command (s -> ot_id , "unmatched" , cmd );
1003+ trace_ot_spi_device_flash_unmatched_command (s -> ot_id , cmd );
10041004 return false;
10051005}
10061006
@@ -1533,46 +1533,55 @@ static bool ot_spi_device_flash_try_intercept_hw_command(OtSPIDeviceState *s)
15331533 SpiDeviceFlash * f = & s -> flash ;
15341534
15351535 uint32_t intercept_val32 = s -> spi_regs [R_INTERCEPT_EN ];
1536+ bool intercepted = false;
1537+
15361538 switch (f -> slot ) {
15371539 case SLOT_HW_READ_STATUS1 :
15381540 case SLOT_HW_READ_STATUS2 :
15391541 case SLOT_HW_READ_STATUS3 :
15401542 if (FIELD_EX32 (intercept_val32 , INTERCEPT_EN , STATUS )) {
15411543 ot_spi_device_flash_decode_read_status (s );
1542- return true;
1544+ intercepted = true;
15431545 }
1544- return false ;
1546+ break ;
15451547 case SLOT_HW_READ_JEDEC :
15461548 if (FIELD_EX32 (intercept_val32 , INTERCEPT_EN , JEDEC )) {
15471549 ot_spi_device_flash_decode_read_jedec (s );
1548- return true;
1550+ intercepted = true;
15491551 }
1550- return false ;
1552+ break ;
15511553 case SLOT_HW_READ_SFDP :
15521554 if (FIELD_EX32 (intercept_val32 , INTERCEPT_EN , SFDP )) {
15531555 ot_spi_device_flash_decode_read_sfdp (s );
1554- return true;
1556+ intercepted = true;
15551557 }
1556- return false ;
1558+ break ;
15571559 case SLOT_HW_READ_NORMAL :
15581560 case SLOT_HW_READ_FAST :
15591561 case SLOT_HW_READ_DUAL :
15601562 case SLOT_HW_READ_QUAD :
15611563 case SLOT_HW_READ_DUAL_IO :
15621564 case SLOT_HW_READ_QUAD_IO :
15631565 /* We try to intercept at every read after an address is given */
1564- return false ;
1566+ break ;
15651567 case SLOT_HW_EN4B :
15661568 case SLOT_HW_EX4B :
15671569 ot_spi_device_flash_decode_addr4_enable (s );
1568- return true;
1570+ intercepted = true;
1571+ break ;
15691572 case SLOT_HW_WREN :
15701573 case SLOT_HW_WRDI :
15711574 /* These HW commands cannot be intercepted */
1572- return false ;
1575+ break ;
15731576 default :
1574- return false ;
1577+ break ;
15751578 }
1579+
1580+ if (intercepted ) {
1581+ trace_ot_spi_device_flash_intercepted_command (s -> ot_id , f -> slot );
1582+ }
1583+
1584+ return intercepted ;
15761585}
15771586
15781587static void
@@ -1613,9 +1622,13 @@ ot_spi_device_flash_passthrough_addr(OtSPIDeviceState *s, uint8_t rx)
16131622 f -> buffer [f -> pos ] = rx ;
16141623 if (f -> cmd_addr_swap_en ) {
16151624 unsigned byte_sel = (f -> len - f -> pos - 1u );
1616- rx = ot_spi_device_swap_byte_data (rx , byte_sel ,
1617- s -> spi_regs [R_ADDR_SWAP_MASK ],
1618- s -> spi_regs [R_ADDR_SWAP_DATA ]);
1625+ uint8_t swapped_rx =
1626+ ot_spi_device_swap_byte_data (rx , byte_sel ,
1627+ s -> spi_regs [R_ADDR_SWAP_MASK ],
1628+ s -> spi_regs [R_ADDR_SWAP_DATA ]);
1629+ trace_ot_spi_device_flash_swap_byte (s -> ot_id , "address" , byte_sel , rx ,
1630+ swapped_rx );
1631+ rx = swapped_rx ;
16191632 }
16201633
16211634 (void )ot_spi_device_flash_spi_transfer (s , rx );
@@ -1660,9 +1673,13 @@ ot_spi_device_flash_passthrough_payload(OtSPIDeviceState *s, uint8_t rx)
16601673
16611674 g_assert (f -> cmd_payload_swap_en );
16621675
1663- rx = ot_spi_device_swap_byte_data (rx , f -> pos ,
1664- s -> spi_regs [R_PAYLOAD_SWAP_MASK ],
1665- s -> spi_regs [R_PAYLOAD_SWAP_DATA ]);
1676+ uint8_t swapped_rx =
1677+ ot_spi_device_swap_byte_data (rx , f -> pos ,
1678+ s -> spi_regs [R_PAYLOAD_SWAP_MASK ],
1679+ s -> spi_regs [R_PAYLOAD_SWAP_DATA ]);
1680+ trace_ot_spi_device_flash_swap_byte (s -> ot_id , "payload" , f -> pos , rx ,
1681+ swapped_rx );
1682+ rx = swapped_rx ;
16661683
16671684 (void )ot_spi_device_flash_spi_transfer (s , rx );
16681685
@@ -1680,6 +1697,8 @@ static uint8_t ot_spi_device_flash_passthrough_read(OtSPIDeviceState *s)
16801697 if (f -> slot >= SLOT_HW_READ_NORMAL && f -> slot <= SLOT_HW_READ_QUAD_IO ) {
16811698 if (ot_spi_device_get_command_address_size (s ) != 0u ) {
16821699 if (ot_spi_device_is_mailbox_match (s , f -> address )) {
1700+ trace_ot_spi_device_flash_intercept_mailbox (s -> ot_id ,
1701+ f -> address );
16831702 uint8_t * mbx = (uint8_t * )& s -> sram [SPI_SRAM_MBX_OFFSET ];
16841703 uint8_t tx = mbx [f -> address & (SPI_SRAM_MBX_SIZE - 1u )];
16851704 f -> address += 1u ;
@@ -1739,6 +1758,7 @@ ot_spi_device_flash_transfer_passthrough(OtSPIDeviceState *s, uint8_t rx)
17391758
17401759 if (ot_spi_device_flash_passthrough_filter (s , rx )) {
17411760 /* command opcode is filtered, discard all bytes untl next CS */
1761+ trace_ot_spi_device_flash_filtered_command (s -> ot_id , rx );
17421762 FLASH_CHANGE_STATE (s , IDLE );
17431763 BUS_CHANGE_STATE (s , DISCARD );
17441764 break ;
0 commit comments