⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 diagdiag.c

📁 free sources for gsm
💻 C
📖 第 1 页 / 共 5 页
字号:
  rsp = (DIAG_PASSWORD_F_rsp_type *) diagpkt_alloc (DIAG_PASSWORD_F, rsp_len);

/*------------------------------------------------------------------------*/

  MSG_LOW ("Security Password given", 0, 0, 0);

  /* If the security is already unlocked, then it doesn't matter what
  ** you give as the security code.  Otherwise we need to compare
  ** the given security code with the one in the phone.
  */
  if ((diag_get_security_state() == DIAG_SEC_UNLOCKED) ||
      (diag_check_password((void *) req->password))) {

    rsp->password_ok = TRUE;
    diag_set_security_state(DIAG_SEC_UNLOCKED);
  }
  /* Otherwise, the code was incorrect.  Diag will now powerdown the phone.
  */
  else {
    rsp->password_ok = FALSE;
    diag_set_security_state(DIAG_SEC_LOCKED);

    diagpkt_commit(rsp);
    rsp = NULL;

    /* Flush DIAG's TX buffer */
    diagbuf_flush();

    /* Power down the phone.  This function does not return.
    */
    diag_powerdown();
  }

  return (rsp);

} /* diagdiag_password */



/*===========================================================================
FUNCTION DIAGDIAG_TS

DESCRIPTION
  Return an IS-95/IS-2000 timestamp

DEPENDENCIES
  None.

RETURN VALUE
  Pointer to response packet.

SIDE EFFECTS
  None.
===========================================================================*/
PACKED void * diagdiag_ts (
  PACKED void *req_pkt,
  uint16 pkt_len
)
{
  qword ts_time;                 /* time stamp */
  DIAG_TS_F_rsp_type *rsp;
  const int rsp_len = sizeof( DIAG_TS_F_rsp_type );


/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
  /*------------------------------------------------------------------------
    Get the time, stuff the packet.
  -------------------------------------------------------------------------*/

  ts_get (ts_time);

  rsp = (DIAG_TS_F_rsp_type *) diagpkt_alloc (DIAG_TS_F, rsp_len);

  qw_equ_misaligned (rsp->ts, ts_time);

  return (rsp);

} /* diagdiag_ts */



#if defined (T_MSM3)
#error code not present
#else
#define MSM_MEMMAP_IO_OFFSET 0x00000000
#endif

/*===========================================================================

FUNCTION DIAGDIAG_OUTP

DESCRIPTION
  This procedure processes a received command to write a byte to a port.
  The byte is written to the input port and a response packet is built.

DEPENDENCIES
  None.

RETURN VALUE
  Pointer to response packet.

SIDE EFFECTS
  None.

===========================================================================*/
PACKED void * diagdiag_outp (
  PACKED void *req_pkt,
  uint16 pkt_len
)
{
  DIAG_OUTP_F_rsp_type *rsp;
  const int rsp_len = sizeof( DIAG_OUTP_F_rsp_type );
  DIAG_OUTP_F_req_type *req = (DIAG_OUTP_F_req_type *) req_pkt;

  /*----------------------------------------------------------------------
    Check security, since this is a secure function
  ----------------------------------------------------------------------*/
  if (diag_get_security_state() == DIAG_SEC_LOCKED) {
    rsp = (DIAG_OUTP_F_rsp_type *)diagpkt_err_rsp( DIAG_BAD_SEC_MODE_F, req_pkt, pkt_len );
    return rsp;
  }

  /*----------------------------------------------------------------------
    Write byte to port
  ----------------------------------------------------------------------*/
  (void) outp( req->port + MSM_MEMMAP_IO_OFFSET, req->data );

  /*-----------------------------------------------------------------------
    Prepare the response packet.
  -----------------------------------------------------------------------*/
  /* Allocate space for rsponse packet */
  rsp = (DIAG_OUTP_F_rsp_type *)diagpkt_alloc( DIAG_OUTP_F, rsp_len );

  if (rsp)
  {
    rsp->port = req->port;
    rsp->data = req->data;
  }

  return (rsp);

} /* diagdiag_outp */



/*===========================================================================

FUNCTION DIAGDIAG_OUTPW

DESCRIPTION
  This procedure processes a received command to write a word to a port.
  The word is written to the input port and a response packet is built.

DEPENDENCIES
  None.

RETURN VALUE
  Pointer to response packet.

SIDE EFFECTS
  None.

===========================================================================*/
PACKED void * diagdiag_outpw (
  PACKED void *req_pkt,
  uint16 pkt_len
)
{
  DIAG_OUTPW_F_rsp_type *rsp;
  const int rsp_len = sizeof( DIAG_OUTPW_F_rsp_type );
  DIAG_OUTPW_F_req_type *req = (DIAG_OUTPW_F_req_type *) req_pkt;

  /*----------------------------------------------------------------------
    Check security, since this is a secure funciton
  ----------------------------------------------------------------------*/
  if (diag_get_security_state() == DIAG_SEC_LOCKED) {
    rsp = (DIAG_OUTPW_F_rsp_type *)diagpkt_err_rsp( DIAG_BAD_SEC_MODE_F, req_pkt, pkt_len );
    return rsp;
  }

  /*----------------------------------------------------------------------
    Write word to port
  ----------------------------------------------------------------------*/
  (void) outpw( req->port+ MSM_MEMMAP_IO_OFFSET, req->data );

  /*-----------------------------------------------------------------------
    Prepare the response packet.
  -----------------------------------------------------------------------*/
  /* Allocate space for rsponse packet */
  rsp = (DIAG_OUTPW_F_rsp_type *)diagpkt_alloc( DIAG_OUTPW_F, rsp_len );

  if (rsp)
  {
    rsp->port = req->port;
    rsp->data = req->data;
  }

  return (rsp);

} /* diagdiag_outpw */



/*===========================================================================

FUNCTION DIAGDIAG_INP

DESCRIPTION
  This procedure processes a received command to read a byte from a port.
  The byte is read from the port and a response packet is built.

DEPENDENCIES
  None.

RETURN VALUE
  Pointer to response packet.

SIDE EFFECTS
  None.

===========================================================================*/
PACKED void * diagdiag_inp (
  PACKED void *req_pkt,
  uint16 pkt_len
)
{
  DIAG_INP_F_rsp_type *rsp;
  const int rsp_len = sizeof( DIAG_INP_F_rsp_type );
  DIAG_INP_F_req_type *req = (DIAG_INP_F_req_type *) req_pkt;

  /*----------------------------------------------------------------------
    Check security, since this is a secure funciton
  ----------------------------------------------------------------------*/
  if (diag_get_security_state() == DIAG_SEC_LOCKED) {
    rsp = ( DIAG_INP_F_rsp_type *)diagpkt_err_rsp( DIAG_BAD_SEC_MODE_F, req_pkt, pkt_len );
    return rsp;
  }

  /* Allocate space for rsponse packet */
  rsp = (DIAG_INP_F_rsp_type *)diagpkt_alloc( DIAG_INP_F, rsp_len );

  /*------------------------------------------------------------------------
    Fill in the boilerplate for the response packet, then read the byte in
    from the port.
  ------------------------------------------------------------------------*/
  rsp->port = req->port;

  rsp->data = (byte) inp( req->port + MSM_MEMMAP_IO_OFFSET );

  return (rsp);

} /* diagdiag_inp */



/*===========================================================================

FUNCTION DIAGDIAG_INPW

DESCRIPTION
  This procedure processes a received command to read a word from a port.
  The word is read from the port and a response packet is built.

DEPENDENCIES
  None.

RETURN VALUE
  Pointer to response packet.

SIDE EFFECTS
  None.

===========================================================================*/
PACKED void * diagdiag_inpw (
  PACKED void *req_pkt,
  uint16 pkt_len
)
{
  DIAG_INPW_F_rsp_type *rsp;
  const int rsp_len = sizeof( DIAG_INPW_F_rsp_type );
  DIAG_INPW_F_req_type *req = (DIAG_INPW_F_req_type *) req_pkt;

  /*----------------------------------------------------------------------
    Check security, since this is a secure funciton
  ----------------------------------------------------------------------*/
  if (diag_get_security_state() == DIAG_SEC_LOCKED) {
    rsp = (DIAG_INPW_F_rsp_type *)diagpkt_err_rsp( DIAG_BAD_SEC_MODE_F, req_pkt, pkt_len );
    return rsp;
  }

  /* Allocate space for rsponse packet */
  rsp = (DIAG_INPW_F_rsp_type *)diagpkt_alloc( DIAG_INPW_F, rsp_len );

  /*------------------------------------------------------------------------
    Fill in the boilerplate for the response, then input the word directly
    into the response packet.
  -------------------------------------------------------------------------*/
  rsp->port = req->port;

  rsp->data = inpw( req->port + MSM_MEMMAP_IO_OFFSET );

  return (rsp);

} /* diagdiag_inpw */



/*===========================================================================

FUNCTION DIAGDIAG_GET_DIPSW

DESCRIPTION
  Processes a request to retrieve current dip switch settings.

DEPENDENCIES
  None.

RETURN VALUE
  Pointer to response packet.

SIDE EFFECTS
  None.
===========================================================================*/
PACKED void * diagdiag_get_dipsw (
  PACKED void *req_ptr,      /* pointer to request packet  */
  word pkt_len                 /* length of request packet   */
)
{
  diag_dipsw_rsp_type *rsp_ptr;
  const int rsp_len = sizeof(diag_dipsw_rsp_type);

  rsp_ptr = (diag_dipsw_rsp_type *)diagpkt_alloc(DIAG_GET_DIPSW_F, rsp_len);

  rsp_ptr->switches =
      BIO_GET_SW ( BIO_SW1_M | BIO_SW2_M | BIO_SW3_M | BIO_SW4_M |
                   BIO_SW5_M | BIO_SW6_M | BIO_SW7_M | BIO_SW8_M |
                   BIO_SW9_M | BIO_SW10_M | BIO_SW11_M | BIO_SW12_M |
                   BIO_SW13_M | BIO_SW14_M | BIO_SW15_M | BIO_SW16_M );

  return (rsp_ptr);
} /* diagdiag_get_dipsw */



/*===========================================================================

FUNCTION DIAGDIAG_SET_DIPSW

DESCRIPTION
  Processes a request to set dip switch settings.

DEPENDENCIES
  None.

RETURN VALUE
  Pointer to response packet.

SIDE EFFECTS
  None.
===========================================================================*/
PACKED void * diagdiag_set_dipsw (
  PACKED void *req_pkt,   /* pointer to request packet  */
  word pkt_len               /* length of request packet   */
)
{
  diag_dipsw_req_type *req = (diag_dipsw_req_type *) req_pkt;
  diag_dipsw_rsp_type *rsp;
  const int rsp_len = sizeof(diag_dipsw_rsp_type);

  bio_set_sw ( ( bio_sw_type ) req->switches );

  rsp = (diag_dipsw_rsp_type *)diagpkt_alloc(DIAG_SET_DIPSW_F, rsp_len);

  rsp->switches =
      BIO_GET_SW ( BIO_SW1_M | BIO_SW2_M | BIO_SW3_M | BIO_SW4_M |
                   BIO_SW5_M | BIO_SW6_M | BIO_SW7_M | BIO_SW8_M |
                   BIO_SW9_M | BIO_SW10_M | BIO_SW11_M | BIO_SW12_M |
                   BIO_SW13_M | BIO_SW14_M | BIO_SW15_M | BIO_SW16_M );

  return (rsp);
} /* diagdiag_set_dipsw */


#if 1 //For now, use a fake GUID. -LD
/* Default GUID (since it was unspecified) */
static const diag_guid_type diag_guid =
{
   0xDEADD00D,
   0xDEADD00D,
   0xDEADD00D,
   0x06101975
};
#endif

LOCAL diag_cb_struct_type diag_cb_table[ ] =
{
    { 0, 0 }
};

LOCAL diag_prop_struct_type diag_prop_table[ ] =
{
    { 0, 0 }
};


/*===========================================================================

FUNCTION DIAG_LOOKUP_PROP

DESCRIPTION
  Looks up the address of a callback function given its name.

DEPENDENCIES

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -