blob: c307d96c4ae70510ba6562600922e23b23eaa461 [file] [log] [blame]
/******************************************************************************
*(C) Copyright 2008 Marvell International Ltd.
* All Rights Reserved
******************************************************************************/
#ifndef UTILITIES_H_
#define UTILITIES_H_
#include <stdlib.h>
#include <stdarg.h>
#include "linux_types.h"
#ifdef __cplusplus
extern "C" {
#endif
#define DIAG_USB_BSPFLAG 1
#define DIAG_UART_BSPFLAG 2
#define DIAG_ATCMD_BSPFLAG 101
enum {
TEL_FILE_OPEN_FAILED = -2,
TEL_FILE_READ_FAILED = -1,
};
enum {
DUAL_SIM_DUAL_STANDBY,
DUAL_SIM_SINGLE_STANDBY,
DUAL_SIM_SGIT,
DUAL_SIM_DUAL_STANDBY_FP,
};
char *strcasestr(const char *s, const char *find);
int vasprintf(char **ret, const char *format, va_list args);
int asprintf(char **ret, const char *format, ...);
int StringToInt(const char *pString, int *pVal, int strLen, int strMinLen, int strMaxLen, int valMin, int valMax);
int HexStringToInt(const char *pString, void *pVal, int strLen, int strMinLen, int strMaxLen, int sizeBytes);
int get_bspflag_from_kernel_cmdline(void);
int InProduction_Mode(void);
int InUARTProduction_Mode(void); //Check if UART port is occupied by ATcmd server
int get_chipid(unsigned long *chipid);
int get_hardwareVersion(char *hardwareVerBuf, int maxHdVerBufSize);
BOOL Is_TD_mode();
int saveProcessName(const char *execPath, char *dest, unsigned int size);
BOOL isDualSimSolution();
BOOL isSim2Master();
void setSim2Master(BOOL option);
int openTtyDevice(const char* deviceName);
int connectUnixSocket(const char* socketName);
int setDualSimType(int type);
int getDualSimType(void);
void initDualSimType(int type);
BOOL check_if_old_eeh_process(char *ind, BOOL is_cp_eeh_old_ver);
BOOL eeh_sd_card_available(int rw);
ssize_t readFile(const char* path, void* buf, size_t len);
#ifdef __GLIBC__
size_t strlcat(char *dst, const char *src, size_t size);
#endif
#define SYS_BASEBAND_PROPERTY "sys.baseband"
#define BASEBAND_TD "TD"
#define BASEBAND_UMTS "UMTS"
#define BASEBAND_UNKNOWN "UNKNOWN"
#define SYS_LTE_MODE "sys.lte.mode"
#define LTE_MODE_DUALLINK "duallink"
#define LTE_MODE_CSFB "csfb"
#define DS_KEY "ds"
/* key word pattern */
/* if there is either PROP_LTG_RF or PROP_LWG_RF property, use it
* it not, use PROP_RAW_RF */
#define PROP_RAW_RF "ro.boot.rfpattern"
#define PROP_LTG_RF "ro.boot.rfpattern.ltg"
#define PROP_LWG_RF "ro.boot.rfpattern.lwg"
/* TMP IMAGE FILE */
#define RF_TMP_FILE "/tmp/CUR_RF_IMAGE.bin"
/* persist.sys.current.cp shows the current cp type:
* 3 -- LTG, 4 -- LWG */
#define SYS_CURRENT_CP "persist.sys.current.cp"
#define LTG_CP "3"
#define LWG_CP "4"
#define BOOT_EXIST_CP "ro.boot.exist.cp"
#define SYS_EXIST_CP "ro.sys.exist.cp"
static inline unsigned int get_LWG_partition(unsigned int property)
{
return property >> 4 & 0xF;
}
static inline unsigned int get_LTG_partition(unsigned int property)
{
return property & 0xF;
}
static inline int partition_to_cp_type(unsigned int partition, unsigned int property)
{
int cp_type = atoi(LTG_CP); /* begin with LTG */
while (property) {
if ((property & 0xF) == partition)
return cp_type;
property >>= 4;
++cp_type;
}
return -1; /* not found this partition */
}
#ifdef __cplusplus
}
#endif
#endif /* UTILITIES_H_ */