mirror of
https://gitea.osmocom.org/sim-card/simtrace2.git
synced 2026-08-14 07:17:11 +03:00
firmware: Implement debug command via USB control vendor class
Allows to collect talloc reports and other debug information from a script while the remsim-client is still running. Change-Id: I1f4d29335eb0d2feef376b8ecdfe57a0162914d6
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
|
||||
#include "board.h"
|
||||
#include "simtrace.h"
|
||||
#include "talloc.h"
|
||||
#include "utils.h"
|
||||
#include "main_common.h"
|
||||
#include <osmocom/core/timer.h>
|
||||
@@ -39,6 +40,8 @@ typedef struct {
|
||||
void (*usart0_irq) (void);
|
||||
/* Interrupt handler for USART1 */
|
||||
void (*usart1_irq) (void);
|
||||
/* ctrl vendor request handler */
|
||||
void (*ctrl_vendor_req) (const USBGenericRequest *request);
|
||||
} conf_func;
|
||||
|
||||
static const conf_func config_func_ptrs[] = {
|
||||
@@ -74,6 +77,7 @@ static const conf_func config_func_ptrs[] = {
|
||||
.usart0_irq = mode_cardemu_usart0_irq,
|
||||
.usart1_irq = mode_cardemu_usart1_irq,
|
||||
#endif
|
||||
.ctrl_vendor_req = mode_cardemu_ctrl_vendor_req,
|
||||
},
|
||||
#endif
|
||||
#ifdef HAVE_MITM
|
||||
@@ -137,6 +141,26 @@ static void check_exec_dbg_cmd(void)
|
||||
board_exec_dbg_cmd(ch);
|
||||
}
|
||||
|
||||
void USBDCallbacks_RequestReceived(const USBGenericRequest *request)
|
||||
{
|
||||
if (USBGenericRequest_GetType(request) != USBGenericRequest_VENDOR)
|
||||
return USBDDriver_RequestHandler(USBD_GetDriver(), request);
|
||||
|
||||
|
||||
if (config_func_ptrs[simtrace_config].ctrl_vendor_req)
|
||||
config_func_ptrs[simtrace_config].ctrl_vendor_req(request);
|
||||
else {
|
||||
/* only ctrl in is supported */
|
||||
if (USBGenericRequest_GetDirection(request) == USBGenericRequest_IN)
|
||||
/* Return ZLP */
|
||||
USBD_Write(0, NULL, 0, NULL, NULL);
|
||||
else /* stall Ctrl out vendor requests */
|
||||
USBD_Stall(0);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Main
|
||||
*------------------------------------------------------------------------------*/
|
||||
|
||||
Reference in New Issue
Block a user