📄 diagdiag.c
字号:
/*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====*
Diagnostics Packet Processing Common Routines
General Description
Core diagnostic packet processing routines that are common to all targets.
Copyright (c) 2000-2005 by QUALCOMM, Incorporated. All Rights Reserved.
*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====*/
/*===========================================================================
Edit History
$Header: //depot/asic/msmshared/services/diag/MSMSHARED_DIAG_1.1/diagdiag.c#3 $
when who what, where, why
-------- --- ----------------------------------------------------------
22/03/05 as Added type cast in memory poke operations
06/11/04 gr Added support for event masks.
05/18/04 as Added security check to diagdiag_get_property and
diagdiag_put_property. Removed support for DIAG_USER_CMD_F
& DIAG_PERM_USER_CMD_F
10/28/03 as Changes to fix errors when compiling with RVCT2.0
04/07/03 jct Added featurization to dissallow certain operations that
can access memory (FEATURE_DIAG_DISALLOW_MEM_OPS):
DIAG_PEEKB_F
DIAG_PEEKW_F
DIAG_PEEKD_F
DIAG_POKEB_F
DIAG_POKEW_F
DIAG_POKED_F
DIAG_OUTP_F
DIAG_OUTPW_F
DIAG_INP_F
DIAG_INPW_F
01/07/03 djm add FEATURE_DIAG_RPC support for WCDMA_PLT use
08/20/02 lad Moved diagpkt_error() to diagpkt.c.
Moved diagpkt_mode_chg() to diagcomm_sio.c as
diagcomm_mode_chg_pkt().
Removed msg_nice[] and log_nice[] references pending a
redesign of the load balancing feature.
Moved diagpkt_dload() to diagdload.c.
Featurized outp/inp routines for off target removal.
06/07/02 lad Added DIAG_PROTOCOL_LOOPBACK_F.
11/01/01 jal Support for DIAG_SERIAL_CHG_F (switch to data mode)
09/18/01 jal Support for DIAG_CONTROL_F (mode reset/offline)
08/20/01 jal Support for Diag packet: DIAG_TS_F (timestamp),
DIAG_SPC_F (service programming code), DIAG_DLOAD_F
(start downloader), DIAG_OUTP_F/DIAG_OUTPW_F (IO
port byte/word output), DIAG_INP_F/DIAG_INPW_F (IO
port byte/word input)
06/27/01 lad Moved diagpkt_err_rsp() to diagpkt.c.
Updated diagpkt_stream_config() for logging service.
diagpkt_stream_config() can now return DIAGBUF_SIZ.
04/17/01 lad Added #include of diagtune.h.
04/06/01 lad Introduced typedefs for command codes, etc.
Updated DIAGPKT_SUBSYS_REQ_DEFINE macros.
Added diagpkt_subsys_alloc().
Removed diagpkt_process_request since it is not part of the
02/23/01 lad Created file.
===========================================================================*/
#if defined __cplusplus
extern "C" {
#endif
#include "comdef.h"
#include "customer.h"
#include "bio.h"
#include "diag.h"
#include "diagcmd.h"
#include "diagi.h"
#include "diagpkt.h"
#include "diagdiag.h"
#include "diagtarget.h"
#include "diagtune.h"
#include "event.h"
#include "feature.h"
#ifdef _SAMSUNG_MP_RTC_TIME
#include "clk.h"
#include "pm.h"
#include "pmapp_rtc.h"
#endif
#ifdef FEATURE_DIAG_HW_ADDR_CHECK
#include "hw.h"
#endif
#include "msg.h"
#include "qw.h"
#include "ts.h"
#ifdef FEATURE_VOC_TASK
#include "voc.h"
#endif
#ifdef _SAMSUNG_HW_TFS4 //sec_system_Erik_051231_1
#include "fs_tfs4.h"
#include "rex.h"
#include "task.h"
#include "rdevmap.h"
#endif /* _SAMSUNG_HW_TFLASH */
/* Tell lint that we are OK with the fact that pkt_len and req are not
** used in some of the packets, as this is dictated by the awesome design */
/*lint -esym(715,pkt_len,req) */
#ifdef DEBUG_DIAG_TEST
#error code not present
#endif /* DEBUG_DIAG_TEST */
/*===========================================================================
FUNCTION DIAGDIAG_PEEKB
DESCRIPTION
This procedure processes a received peek byte request. It performs the peek
operation and formats a peek response message.
===========================================================================*/
PACKED void * diagdiag_peekb (
PACKED void *req_pkt,
uint16 pkt_len
)
{
DIAG_PEEKB_F_req_type *req = (DIAG_PEEKB_F_req_type *) req_pkt;
DIAG_PEEKB_F_rsp_type *rsp;
const int rsp_len = sizeof(DIAG_PEEKB_F_rsp_type);
int i, count;
PACKED byte *src = NULL;
PACKED byte *dest = NULL;
count = req->length;
src = (byte *) req->ptr;
/*-------------------------------------------------------------------------
Check security, since this is a secure funciton
--------------------------------------------------------------------------*/
if (diag_get_security_state() != DIAG_SEC_UNLOCKED) {
return( diagpkt_err_rsp(DIAG_BAD_SEC_MODE_F, req_pkt, pkt_len) );
}
/*-------------------------------------------------------------------------
Check memory peek length against max allowable length.
--------------------------------------------------------------------------*/
if (count > DIAG_MAX_PEEK_B) {
return( diagpkt_err_rsp(DIAG_BAD_PARM_F, req_pkt, pkt_len) );
}
#ifdef FEATURE_DIAG_HW_ADDR_CHECK
/*-------------------------------------------------------------------------
Check to see if block requested is within a valid range
--------------------------------------------------------------------------*/
if (!hw_valid_addr ((void *) src, count) ) {
return( diagpkt_err_rsp(DIAG_BAD_PARM_F, req_pkt, pkt_len) );
}
#endif
/* Allocate space for response packet */
rsp = (DIAG_PEEKB_F_rsp_type *)diagpkt_alloc(DIAG_PEEKB_F, rsp_len);
if (rsp) {
dest = &rsp->data[0];
/*--------------------------------------------------------------------------
Fill in the boilerplate for the response.
--------------------------------------------------------------------------*/
rsp->ptr = (byte *) src;
rsp->length = count;
#ifdef FEATURE_VOC_TASK
/*---------------------------------------------------------------------------
The vocoder memory space is a special case since the DSP's clocks are
turned off during sleep, making the address invalid. Let voc handle it.
----------------------------------------------------------------------------*/
if (voc_valid_addr ((void *) src, count))
{
voc_status_type eVocStatus;
/* Since the data is byte ordered, no need to hanlde endian-ness here. */
eVocStatus = voc_peek_cmd((void *) src, (void *) dest,
count * sizeof(byte));
if (eVocStatus != VOC_DONE_S) {
return (diagpkt_err_rsp (DIAG_BAD_PARM_F, req_pkt, pkt_len));
}
}
else /* do it ourselves. */
#endif /* FEATURE_VOC_TASK */
{
/*----------------------------------------------------------------------
Lock out interrupts to preserve consistency of the memory block.
----------------------------------------------------------------------*/
INTLOCK ();
for (i = 0; i < count; i++) {
*dest = *src;
src++;
dest++;
}
INTFREE ();
}
}
return (rsp);
} /* diagdiag_peekb */
/*===========================================================================
FUNCTION DIAGDIAG_PEEKW
DESCRIPTION
This procedure processes a received peek word request. It performs the peek
operation and formats a peek response message.
===========================================================================*/
PACKED void * diagdiag_peekw (
PACKED void *req_pkt,
uint16 pkt_len
)
{
DIAG_PEEKW_F_req_type *req =(DIAG_PEEKW_F_req_type *)req_pkt;
DIAG_PEEKW_F_rsp_type *rsp;
const int rsp_len = sizeof(DIAG_PEEKW_F_rsp_type);
int i, count;
PACKED word *src = NULL;
PACKED word *dest = NULL;
count = req->length;
src = (word *) req->ptr;
/*-------------------------------------------------------------------------
Check security, since this is a secure funciton
--------------------------------------------------------------------------*/
if (diag_get_security_state() != DIAG_SEC_UNLOCKED) {
return( diagpkt_err_rsp(DIAG_BAD_SEC_MODE_F, req_pkt, pkt_len) );
}
/*-------------------------------------------------------------------------
Check block length against max allowed length.
-------------------------------------------------------------------------*/
if (count > DIAG_MAX_PEEK_W) {
return( diagpkt_err_rsp(DIAG_BAD_PARM_F, req_pkt, pkt_len) );
}
#ifdef FEATURE_DIAG_HW_ADDR_CHECK
/*-------------------------------------------------------------------------
Check to see that the block requested is within a valid range.
--------------------------------------------------------------------------*/
if (!hw_valid_addr ((void *) src, count * sizeof (word))) {
return( diagpkt_err_rsp(DIAG_BAD_PARM_F, req_pkt, pkt_len) );
}
#endif
/* Allocate space for response packet */
rsp = (DIAG_PEEKW_F_rsp_type *)diagpkt_alloc(DIAG_PEEKW_F, rsp_len);
if (rsp) {
dest = &rsp->data[0];
/*--------------------------------------------------------------------------
Fill in the boilerplate for the response.
--------------------------------------------------------------------------*/
rsp->ptr = (word *) src;
rsp->length = count;
#ifdef FEATURE_VOC_TASK
/*---------------------------------------------------------------------------
The vocoder memory space is a special case since the DSP's clocks are
turned off during sleep, making the address invalid. Let voc handle it.
----------------------------------------------------------------------------*/
if (voc_valid_addr ((void *) src, count * sizeof(word)))
{
voc_status_type eVocStatus;
/* Since the data is byte ordered, no need to hanlde endian-ness here. */
eVocStatus = voc_peek_cmd ((void *) src, (void *) dest,
count * sizeof(word));
if (eVocStatus != VOC_DONE_S)
{
return( diagpkt_err_rsp(DIAG_BAD_PARM_F, req_pkt, pkt_len) );
}
}
else /* do it ourselves. */
#endif /* FEATURE_VOC_TASK */
{
/*----------------------------------------------------------------------
Lock out interrupts to preserve consistency of the memory block.
----------------------------------------------------------------------*/
INTLOCK ();
for (i = 0; i < count; i++) {
*dest = *src;
src++;
dest++;
}
INTFREE ();
}
}
return (rsp);
} /* diagdiag_peekw */
/*===========================================================================
FUNCTION DIAGDIAG_PEEKD
DESCRIPTION
This procedure processes a received peek dword request. It performs the peek
operation and formats a peek response message.
===========================================================================*/
PACKED void * diagdiag_peekd (
PACKED void *req_pkt,
uint16 pkt_len
)
{
DIAG_PEEKD_F_req_type *req = (DIAG_PEEKD_F_req_type *)req_pkt;
DIAG_PEEKD_F_rsp_type *rsp;
const int rsp_len = sizeof(DIAG_PEEKD_F_rsp_type);
int i, count;
PACKED dword *src = NULL;
PACKED dword *dest = NULL;
count = req->length;
src = (dword *) req->ptr;
/*--------------------------------------------------------------------------
Check security, since this is a secure funciton
--------------------------------------------------------------------------*/
if (diag_get_security_state() != DIAG_SEC_UNLOCKED) {
return( diagpkt_err_rsp(DIAG_BAD_SEC_MODE_F, req_pkt, pkt_len) );
}
/*--------------------------------------------------------------------------
Check requested length against max allowable length.
--------------------------------------------------------------------------*/
if (count > DIAG_MAX_PEEK_D) {
return( diagpkt_err_rsp(DIAG_BAD_PARM_F, req_pkt, pkt_len) );
}
#ifdef FEATURE_DIAG_HW_ADDR_CHECK
/*-------------------------------------------------------------------------
Check to see that the block requested is within a valid range.
--------------------------------------------------------------------------*/
if (!hw_valid_addr ((void *) src, count * sizeof(dword))) {
return( diagpkt_err_rsp(DIAG_BAD_PARM_F, req_pkt, pkt_len) );
}
#endif
/* Allocate space for response packet */
rsp = (DIAG_PEEKD_F_rsp_type *)diagpkt_alloc(DIAG_PEEKD_F, rsp_len);
if (rsp) {
dest = &rsp->data[0];
/*--------------------------------------------------------------------------
Fill in the boilerplate for the response.
--------------------------------------------------------------------------*/
rsp->ptr = (dword *) src;
rsp->length = count;
#ifdef FEATURE_VOC_TASK
/*---------------------------------------------------------------------------
The vocoder memory space is a special case since the DSP's clocks are
turned off during sleep, making the address invalid. Let voc handle it.
----------------------------------------------------------------------------*/
if (voc_valid_addr ((void *) src, count * sizeof(dword)))
{
voc_status_type eVocStatus;
/* Since the data is byte ordered, no need to hanlde endian-ness here. */
eVocStatus = voc_peek_cmd ((void *) src, (void *) dest,
count * sizeof(dword));
if (eVocStatus != VOC_DONE_S)
{
return( diagpkt_err_rsp(DIAG_BAD_PARM_F, req_pkt, pkt_len) );
}
}
else /* do it ourselves. */
#endif /* FEATURE_VOC_TASK */
{
/*----------------------------------------------------------------------
Lock out interrupts to preserve consistency of the memory block.
----------------------------------------------------------------------*/
INTLOCK ();
for (i = 0; i < count; i++) {
*dest = *src;
dest++;
src++;
}
INTFREE ();
}
}
return (rsp);
} /* diagdiag_peekd */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -