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

📄 diagdiag.c

📁 free sources for gsm
💻 C
📖 第 1 页 / 共 5 页
字号:
} /* diagdiag_get_perm_property */


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

FUNCTION DIAGDIAG_PUT_PERM_PROPERTY

DESCRIPTION
  This procedure processes a put_perm_property request. The structure
  specified by name in the request packet is filled in using the values
  specified in the packet.

DEPENDENCIES
  None.

RETURN VALUE
  The length of the response packet.

SIDE EFFECTS
  None.

===========================================================================*/
PACKED void * diagdiag_put_perm_property
(
  PACKED void *req_pkt, /* pointer to request packet  */
  uint16 pkt_len            /* length of request packet  */
)
{
  void *prop_addr;    /* address of the specified property */
  DIAG_PUT_PERM_PROPERTY_F_req_type *req =
    (DIAG_PUT_PERM_PROPERTY_F_req_type *) req_pkt;
  DIAG_PUT_PERM_PROPERTY_F_rsp_type *rsp;
  const unsigned int rsp_len = sizeof( DIAG_PUT_PERM_PROPERTY_F_rsp_type );

/*----------------------------------------------------------------------------
  Allocate buffer space for response packet.
----------------------------------------------------------------------------*/
  rsp = (DIAG_PUT_PERM_PROPERTY_F_rsp_type *)
    diagpkt_alloc (DIAG_PUT_PERM_PROPERTY_F, rsp_len);

/*----------------------------------------------------------------------------
  Fill in some of the fields in the response packet.
----------------------------------------------------------------------------*/
  memcpy((void *) &rsp->guid[0],
         (const void *) &req->guid[0],
         sizeof(diag_guid_type));

  memcpy((void *) &rsp->name[0],
         (const void *) &req->name[0],
         sizeof(req->name));

/*---------------------------------------------------------------------------
  Check for valid GUID.
----------------------------------------------------------------------------*/
  if ( !diag_guid_is_valid( req->guid ) ) {
    rsp->size    = 0;
    rsp->data[0] = DIAG_EXTN_INVALID_GUID;
    return rsp;
  }

/*---------------------------------------------------------------------------
  Check data size against maximum allowed size.
----------------------------------------------------------------------------*/
  if ( req->size > DIAG_MAX_PROPERTY_SIZE ) {
    rsp->size    = 0;
    rsp->data[0] = DIAG_EXTN_INVALID_SIZE;
    return rsp;
  }

/*---------------------------------------------------------------------------
  Look up the address of the specified property. Return with an error status
  if we do not get a valid address. If we get a valid address, write bytes
  into memory.  Lock out interrupts to preserve consistency of the memory
  block.
----------------------------------------------------------------------------*/
  prop_addr = diag_lookup_prop( (char *) req->name );

  if ( prop_addr == NULL ) {
    rsp->size    = 0;
    rsp->data[0] = DIAG_EXTN_INVALID_NAME;
    return rsp;
  }

  rsp->size = req->size;

  INTLOCK( );
  memcpy(prop_addr,
         (const void *) &rsp->data[0],
         req->size * sizeof(byte));
  INTFREE( );

  return rsp;

} /* diagdiag_put_perm_property */

#ifdef _SAMSUNG_MP_PRECONFIG  
// SEC_UI2_KKW_20050808_1
#include "factory_preconfig.h"
//extern int DIAG_FAC_PRECFG_SET_F_rsp_type;

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

FUNCTION DIAGDIAG_SET_FACTORY_PRECONFIG

DESCRIPTION
  This procedure echos the request in the response.

RETURN VALUE
  Pointer to response packet.

============================================================================*/
PACKED void * diagdiag_set_factory_preconfig (
  PACKED void *req_pkt,
  uint16 pkt_len
)
{
  fac_precfg_status_e_type status;
  nv_item_type nvi;
  DIAG_FAC_PRECFG_SET_F_rsp_type *rsp;
  const int rsp_len = sizeof(DIAG_FAC_PRECFG_SET_F_rsp_type);
  DIAG_FAC_PRECFG_SET_F_req_type *req_ptr = (DIAG_FAC_PRECFG_SET_F_req_type *) req_pkt;

  rsp = (DIAG_FAC_PRECFG_SET_F_rsp_type *) diagpkt_alloc (DIAG_FAC_PRECFG_SET_F, rsp_len);
  if (rsp != NULL)
  {
    //Now, Call Factory Preconfiguration Routine..
    status = samsung_factory_preconfig( req_ptr->country_name, DIAG_CMD );

    if (status != FAC_PRECFG_SUCCESS) 
      rsp->country_name = 0x00FF; //error
    else
    {
      nvi.preconfig.country_name = req_ptr->country_name;
      if (diag_nv_write(NV_PRECONFIG_I, &nvi) == NV_DONE_S)
        rsp->country_name = nvi.preconfig.country_name;
      else
        rsp->country_name = 0x00FF; //error
    }
  }

  return (rsp);
}


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

FUNCTION DIAGDIAG_GET_FACTORY_PRECONFIG

DESCRIPTION
  This procedure echos the request in the response and response country name.

RETURN VALUE
  Pointer to response packet.

============================================================================*/
PACKED void * diagdiag_get_factory_preconfig (
  PACKED void *req_pkt,
  uint16 pkt_len
)
{
  nv_item_type nvi;

  DIAG_FAC_PRECFG_GET_F_rsp_type *rsp;
  const unsigned int rsp_len = sizeof( DIAG_FAC_PRECFG_GET_F_rsp_type );

/*----------------------------------------------------------------------------
  Allocate buffer space for response packet.
----------------------------------------------------------------------------*/
  rsp = (DIAG_FAC_PRECFG_GET_F_rsp_type *)
    diagpkt_alloc (DIAG_FAC_PRECFG_GET_F, rsp_len);

  if (diag_nv_read(NV_PRECONFIG_I, &nvi) == NV_DONE_S)
    rsp->country_name = nvi.preconfig.country_name;
  else
    rsp->country_name = 0x00FF; //error

  return (rsp);
}

#endif //FEATURE_SAMSUNG_FACTORY_PRECONFIG

#ifdef _SAMSUNG_HW_TFLASH  //sec_system_Erik_051231_1
static rdm_device_enum_type prev_diag_device = RDM_NULL_DEV;
/*===========================================================================

FUNCTION diagdiag_tfs4_enable

DESCRIPTION
  This procedure echos the request in the response.

RETURN VALUE
  Pointer to response packet.

============================================================================*/
PACKED void * diagdiag_tfs4_enable (
  PACKED void *req_pkt,
  uint16 pkt_len
)
{
  fac_precfg_status_e_type status;
  nv_item_type nvi;
  DIAG_TFS4_EXPLORER_ENA_F_rsp_type *rsp;
  const int rsp_len = sizeof(DIAG_TFS4_EXPLORER_ENA_F_rsp_type);
  DIAG_TFS4_EXPLORER_ENA_F_req_type *req_ptr = (DIAG_TFS4_EXPLORER_ENA_F_req_type *) req_pkt;

  rsp = (DIAG_TFS4_EXPLORER_ENA_F_rsp_type *) diagpkt_alloc (DIAG_TFS4_EXPLORER_ENA_F, rsp_len);
  if (rsp != NULL)
  {
  #if 0
    rex_set_sigs(&tfs4_tcb, TFS4_EXPLORER_START_SIG);
  #else
    if(rdm_get_device(RDM_DIAG_SRVC) == RDM_USB_DIAG_DEV)
  {
    prev_diag_device = RDM_USB_DIAG_DEV;
    rdm_close_device(RDM_DIAG_SRVC, RDM_USB_DIAG_DEV, NULL);
  }
    rdm_assign_port(RDM_MMC_SRVC, RDM_USB_MMC_DEV, NULL);
  #endif
    rsp->status = 1;
  }
  return (rsp);
}

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

FUNCTION diagdiag_tfs4_diable

DESCRIPTION
  This procedure echos the request in the response.

RETURN VALUE
  Pointer to response packet.

============================================================================*/
PACKED void * diagdiag_tfs4_diable (
  PACKED void *req_pkt,
  uint16 pkt_len
)
{
  fac_precfg_status_e_type status;
  nv_item_type nvi;
  DIAG_TFS4_EXPLORER_DIS_F_rsp_type *rsp;
//sec_ui1_ksr_050909   porting SvEI1   const int rsp_len = sizeof(DIAG_FAC_PRECFG_SET_F_rsp_type);
  const int rsp_len = sizeof(DIAG_TFS4_EXPLORER_DIS_F_req_type);  
//sec_ui1_ksr_050909   porting SvEI1   DIAG_FAC_PRECFG_SET_F_rsp_type -> DIAG_TFS4_EXPLORER_DIS_F_req_type
  DIAG_TFS4_EXPLORER_DIS_F_req_type *req_ptr = (DIAG_TFS4_EXPLORER_DIS_F_req_type *) req_pkt;

  rsp = (DIAG_TFS4_EXPLORER_DIS_F_rsp_type *) diagpkt_alloc (DIAG_TFS4_EXPLORER_DIS_F, rsp_len);
  if (rsp != NULL)
  {
#if 0  
    rex_set_sigs(&tfs4_tcb, TFS4_EXPLORER_END_SIG); 
#else
  rdm_close_device(RDM_MMC_SRVC, RDM_USB_MMC_DEV, NULL);
  if(prev_diag_device == RDM_USB_DIAG_DEV)
  {
    prev_diag_device = RDM_NULL_DEV;
    rdm_assign_port(RDM_DIAG_SRVC, RDM_USB_DIAG_DEV, NULL); 
  }	
#endif
     rsp->status = TRUE;
  }
   return (rsp);
}
#endif /* _SAMSUNG_HW_TFLASH */

//#ifdef _SAMSUNG_MP_RESET_VERIFY
/*===========================================================================

FUNCTION diagdiag_tfs4_diable

DESCRIPTION
  This procedure echos the request in the response.

RETURN VALUE
  Pointer to response packet.

============================================================================*/
#define CR_FILE "/a/cust_reset_success.txt"

PACKED void * diagdiag_reset_verify (
  PACKED void *req_pkt,
  uint16 pkt_len
)
{
  nv_item_type nvi;

  diag_reset_verify_rsp_type *rsp;
  const unsigned int rsp_len = sizeof( diag_reset_verify_rsp_type );
  int fd;
  static char buf;

/*----------------------------------------------------------------------------
  Allocate buffer space for response packet.
----------------------------------------------------------------------------*/
  rsp = (diag_reset_verify_rsp_type *)diagpkt_alloc (DIAG_RESET_VERIFY_F, rsp_len);

//  boot_lcd_message("  I'm reading the content of file ",15,Red);
	    fd = tfs4_open(CR_FILE, O_RDONLY);
	    tfs4_read(fd, &buf, 1);
	    buf = buf - '0';
	    tfs4_close(fd);

           if(buf == 1 && fd >= 0) 
			rsp->result = TRUE;

//			fd = tfs4_open(CR_FILE, O_CREAT|O_RDWR|O_TRUNC, S_IWRITE|S_IREAD);
//			tfs4_write(fd, "0", 1);
	else
			rsp->result = FALSE;

  return (rsp);
}
//#endif  // _SAMSUNG_MP_RESET_VERIFY

/*===========================================================================

FUNCTION DIAGDIAG_LOOPBACK

DESCRIPTION
  This procedure echos the request in the response.

RETURN VALUE
  Pointer to response packet.

============================================================================*/
PACKED void * diagdiag_loopback (
  PACKED void *req_pkt,
  uint16 pkt_len
)
{
  PACKED void *rsp = NULL;

  /* Allocate the same length as the request. */
  rsp = diagpkt_alloc (DIAG_PROTOCOL_LOOPBACK_F, pkt_len);

  if (rsp != NULL) {
    memcpy ((void *) rsp, (void *) req_pkt, pkt_len);
  }

  return (rsp);
}

#ifdef DEBUG_DIAG_TEST
#error code not present
#endif /* DEBUG_DIAG_TEST  */

#ifdef _SAMSUNG_BREW_MSL  //sec_ui2_mky_060131

extern byte * msl_encrypt_data (byte *  raw_data_buffer_p);
extern void  hw_reset(void);
boolean msl_rw_permission=FALSE;
PACKED void * diagdiag_set_msl_addr(
  PACKED void *req_pkt,
  uint16 pkt_len
)
{
  int m;
  nv_item_type nvi;
  diag_set_msl_addr_req_type *req_ptr = (diag_set_msl_addr_req_type *) req_pkt;
  diag_set_msl_addr_rsp_type *rsp;
  const unsigned int rsp_len = sizeof( diag_set_msl_addr_rsp_type );
  rsp = (diag_set_msl_addr_rsp_type *) diagpkt_alloc (DIAG_MSL_ADDR_SET_F, rsp_len);
  msl_rw_permission = TRUE;
  if(diag_nv_read(NV_MSL_ADDR_I, &nvi) != NV_DONE_S)
  {
    rsp->msl_addr_ok = FALSE;
    return (rsp);
  };
  for(m=0;m<NV_MSL_ADDR_SIZE;m++){
    nvi.msl_addr.digits[m] = req_ptr->msl_addr.digits[m];
  }
  msl_rw_permission = TRUE;
  if (diag_nv_write(NV_MSL_ADDR_I, &nvi) == NV_DONE_S)
  { 
    rsp->msl_addr_ok = TRUE;
  }
  else
  {  
    rsp->cmd_code = DIAG_NO_AUTHORITY_F;
    rsp->msl_addr_ok = FALSE;
  }
  return (rsp);
}
PACKED void * diagdiag_get_msl_addr(
  PACKED void *req_pkt,
  uint16 pkt_len
)
{
  nv_item_type nvi;
  int m;
  diag_get_msl_addr_rsp_type *rsp;
  const unsigned int rsp_len = sizeof( diag_get_msl_addr_rsp_type );
  rsp = (diag_get_msl_addr_rsp_type *) diagpkt_alloc (DIAG_MSL_ADDR_GET_F, rsp_len);
  msl_rw_permission = TRUE;
  if (diag_nv_read(NV_MSL_ADDR_I, &nvi) == NV_DONE_S)
  {
    for(m=0;m<NV_MSL_ADDR_SIZE;m++){
       rsp->msl_addr.digits[m] = nvi.msl_addr.digits[m];
    	}
  }
  else
  {
    rsp->msl_addr.digits[0] = 0x00FF; //error
  }
  return (rsp);
}
boolean Set_Msl_Code(byte * msl_program_code)
{
  nv_item_type nvi;
  memcpy((byte *)nvi.msl_code.digits, (byte *)msl_encrypt_data(msl_program_code),(NV_MSL_CODE_SIZE*2));
  msl_rw_permission = TRUE;

⌨️ 快捷键说明

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