zte's code,first commit

Change-Id: I9a04da59e459a9bc0d67f101f700d9d7dc8d681b
diff --git a/cp/ps/driver/inc/pub/drv_stub.h b/cp/ps/driver/inc/pub/drv_stub.h
new file mode 100644
index 0000000..77c2110
--- /dev/null
+++ b/cp/ps/driver/inc/pub/drv_stub.h
@@ -0,0 +1,301 @@
+/*******************************************************************************

+ * Copyright (C) 2007, ZTE Corporation.

+ *

+ * File Name:    drv_stub.h

+ * File Mark:    

+ * Description:  

+ * Others:        

+ * Version:       1.0

+ * Author:        wangxia

+ * Date:          2008-2-22

+ * History 1:      

+ *     Date: 

+ *     Version:

+ *     Author: 

+ *     Modification:  

+ * History 2: 

+  ********************************************************************************/

+

+#ifndef _DRV_STUB_H

+#define _DRV_STUB_H

+

+

+/****************************************************************************

+* 	                                        Include files

+****************************************************************************/

+

+

+/****************************************************************************

+* 	                                        Macros

+****************************************************************************/

+

+

+/****************************************************************************

+* 	                                        Types

+****************************************************************************/

+

+/****************************************************************************************

+ ****************************************************************************************

+ * PCL configuration 

+ ****************************************************************************************

+ ****************************************************************************************/

+

+/* Table of symbolic names for the pcl registers 

+   keep in sync with PAD_pcl_registers.

+   ONLY APPEND TO THIS LIST NEVER REMOVE OR PUT ENTRIES INBETWEEN*/

+enum PAD_symbolic_names

+{

+  /*0*/

+  PAD_HS_DET,

+  PAD_ACC_DET,

+  PAD_ACC_PWR_EN,

+  PAD_PERF_MON,

+  PAD_HS_SENDEND,

+

+  /*5*/

+  PAD_FLIP_SENSE,

+  PAD_AP_RESET,

+  PAD_AP_CLK_REQ,

+  PAD_VCXO_EN,

+  PAD_MAIN_SUB,

+

+  /*10*/

+  PAD_LCD_RESET,

+  PAD_LCD_COMPIC_RESET,

+  PCD_LCD_COMPIC,

+  PAD_SMC_VZ_N,

+  PAD_SMC_RST,

+

+  /*15*/

+  PAD_USB_ID,

+  PAD_VBOOST_SEL,

+  PAD_VBOOST_EN,

+  GPS_GPIO_ASIC_STDBY,

+  GPS_GPIO_ASIC_RESET,

+

+  /*20*/

+  GPS_GPIO_ASIC_RFON,

+  PAD_CHK_EXT_32KHZ,

+  PAD_HS_AMP_SD,  

+  PAD_HS_AMP_UD,  

+  PAD_HS_AMP_CLK,

+

+ /*25*/

+  PAD_GDC_INT,

+  PAD_LED_RED,

+  PAD_LED_GREEN,

+  PAD_LED_BLUE,

+  PAD_IRDA_SD,

+

+  /*30*/

+  PAD_MMC_CMD,

+  PAD_MMC_DAT,

+  PAD_MMC_ROD_EN,

+  PAD_MMC_VDD_EN,          /* VDD for MMC Interface */

+  PAD_SD_MMC_DAT1,         /* DAT1 for extended SD/MMC  */

+

+  /*35*/

+  PAD_SD_MMC_DAT2,         /* DAT2 for extended SD/MMC  */

+  PAD_SD_MMC_DAT3,         /* DAT3 for extended SD/MMC  */

+  PAD_CS_SD_MMC,           /* RDE: CS for SD/MMC when using SPI Interface */ 

+  PAD_MTSR_SD_MMC,         /* RDE: CS for SD/MMC when using SPI Interface */   

+  PAD_MRST_SD_MMC,         /* RDE: CS for SD/MMC when using SPI Interface */

+

+  /*40*/

+  PAD_CLK_SD_MMC,          /* RDE: CS for SD/MMC when using SPI Interface */

+  PAD_USART1_RTS,

+  PAD_DIF_CD,

+  PAD_DIF_CS,

+  PAD_HS_MONO_STEREO,

+

+  /*45*/

+  PAD_CIF_RESET,           /*reset for camera on MPE*/

+  PAD_CIF_PD,              /*PowerDown of camera on MPE*/

+  PAD_SIM_VCC,

+  PAD_LEDPWM2,   /* SUB LCD Backlight enable for NBG_HW_MPE: name corresponds to schematic name but PWM is not supported by HW */

+  PAD_I2S1_CLK0,

+

+  /*50*/

+  PAD_I2S1_RX,

+  PAD_I2S1_TX,

+  PAD_I2S1_WA0,

+  PAD_MMC_DETECT,            /*MMC/SD card detection on MPE*/

+  PAD_CHG_VAL,

+

+  /*55*/

+  PAD_I2C_SCL,

+  PAD_I2C_SDA,

+  PAD_RST_FM,

+  PAD_FLASH,

+  PAD_VIBRATOR,

+

+  /*60*/

+  PAD_FM_AMP_SHDN, 

+  PAD_CIF_RESET2,           /* Reset for the second camera */

+  PAD_DIF_VD,               /* Intensity setting via boost converter for both Displays on  MPEU Userboard */

+  PAD_I2S2_CLK0,

+  PAD_I2S2_RX,

+

+  /*65*/

+  PAD_I2S2_TX,

+  PAD_I2S2_WA0,

+  PAD_BT_RST,

+  PAD_IRDA_TX,

+  PAD_IRDA_RX,

+

+ /*70*/

+  PAD_BB_TEST,              /* Setting bb into test mode */

+  PAD_RESET_DET,            /* Set on traps              */

+  PAD_PP_PMU_EXT_ON,        /* Wakeup ap pmu             */

+  PAD_IPC_ACK,

+  PAD_USIF1_RTS,

+

+ /*75*/

+  PAD_USIF1_CTS,

+  PAD_USIF2_RTS,

+  PAD_USIF2_CTS,

+  PAD_USIF3_RTS,

+  PAD_USIF3_CTS,

+

+  /*80*/

+  PAD_MIC_INT,

+  PAD_AUD_AMP,

+  PAD_SP_AMP_SD,

+  PAD_SPK_RCV_SEL,

+  PAD_FM_BBP_SEL,

+

+  /*85*/

+  PAD_BT_TX,			/* serial (USIF) port pins used for BT communication */

+  PAD_BT_RX,

+  PAD_BT_RTS,

+  PAD_BT_CTS,

+  PAD_UART0_RTS,

+

+  /*90*/

+  PAD_UART0_CTS,

+  PAD_UART1_RTS,

+  PAD_UART1_CTS,

+  PAD_UART1_RX,

+  PAD_UART1_TX,

+

+  /*95*/

+  PAD_I2S1_CLK1,

+  PAD_I2S1_WA1,

+  PAD_I2S2_CLK1,

+  PAD_I2S2_WA1,

+  PAD_USIF1_TXD,

+  

+  /*100*/

+  PAD_USIF1_RXD,

+  PAD_WLAN_1V8_EN,

+  PAD_MMC2_VDD_EN, 

+  PAD_MMC2_ROD_EN, 

+  PAD_MMC2_CLK,

+

+ /*105*/

+  PAD_MMC2_CMD,

+  PAD_MMC2_DAT0,

+  PAD_MMC2_DAT1,

+  PAD_MMC2_DAT2,

+  PAD_MMC2_DAT3,

+

+  /*110*/

+  PAD_MMCI_IO_RESET,

+  PAD_AUD_SPK_AMP,		/*Used for SPK_AMP for NX1*/

+  PAD_AUDIO_SELECT,		/*Used for AUDIO_SELECT for NX1*/

+  PAD_EE_WP,

+  PAD_USIF1_CLK,		

+

+  /*115*/

+  PAD_USIF1_HWAKE, 

+  PAD_USIF1_MWAKE,	

+  PAD_USIF1_RX,    

+  PAD_USIF1_TX,

+  PAD_USIF2_CLK,		

+

+  /*120*/ 

+  PAD_USIF2_HWAKE, 

+  PAD_USIF2_MWAKE,

+  PAD_USIF2_RX,    

+  PAD_USIF2_TX,    

+  PAD_USIF3_CLK,		

+

+  /*125*/

+  PAD_USIF3_HWAKE, 

+  PAD_USIF3_MWAKE,	

+  PAD_USIF3_RX,    

+  PAD_USIF3_TX,    

+  PAD_CAM_STBY_2,

+

+  /*130*/

+  PAD_CAM_RESET_2,

+  PAD_CAM_STBY_1,

+  PAD_CAM_RESET_1,

+  PAD_CHG_DET,

+  PAD_BAT_DET,

+

+  /*135*/

+  PAD_CHG_ON,  

+  PAD_USB_ON,

+  BL_LED_DIM,

+  PAD_USB_DET,

+  PAD_USB_CHR_EN,

+

+  /*140*/

+  PAD_CIF_DATA0,

+  PAD_CIF_DATA1,

+  PAD_CIF_DATA2,

+  PAD_CIF_DATA3,

+  PAD_CIF_DATA4,

+

+  /*145*/

+  PAD_CIF_DATA5,

+  PAD_CIF_DATA6,

+  PAD_CIF_DATA7,

+  PAD_CIF_PCLK,

+  PAD_CIF_HSYNC,

+

+  /*150*/

+  PAD_CIF_VSYNC,

+  PAD_MODEM_READY,

+  

+  PAD_LAST_ELEMENT         	/* always last element, used to verify PCL setup */ 

+  };

+

+/*IFX BB version*/

+typedef enum

+{

+  SYS_BB_VER_INVALID,

+  SYS_BB_VER_SGOLD,    

+  SYS_BB_VER_SGOLDLITE,

+  SYS_BB_VER_SGOLD2,

+  SYS_BB_VER_SGOLD3,

+  SYS_BB_VER_SGOLDRADIO

+} bb_ver_enum;

+

+typedef enum 

+{

+  SYS_BB_REV_INVALID,

+  SYS_BB_REV_10,    

+  SYS_BB_REV_11,

+  SYS_BB_REV_11A,

+  SYS_BB_REV_11B,

+  SYS_BB_REV_12,

+  SYS_BB_REV_20

+} bb_rev_enum;

+/****************************************************************************

+* 	                                        Constants

+****************************************************************************/

+

+/****************************************************************************

+* 	                                        Global  Variables

+****************************************************************************/

+

+/****************************************************************************

+* 	                                        Function Prototypes

+****************************************************************************/

+

+

+

+#endif/*_DRV_STUB_H*/

+

diff --git a/cp/ps/driver/inc/pub/drvs_assert.h b/cp/ps/driver/inc/pub/drvs_assert.h
new file mode 100644
index 0000000..f19e464
--- /dev/null
+++ b/cp/ps/driver/inc/pub/drvs_assert.h
@@ -0,0 +1,61 @@
+/*******************************************************************************

+ * Copyright (C) 2007, ZTE Corporation.

+ *

+ * File Name:    drvs_assert.h

+ * File Mark:    

+ * Description:  

+ * Others:        

+ * Version:       v0.1

+ * Author:        weizhigang

+ * Date:          2009-7-3

+ * History 1:      

+ *     Date: 

+ *     Version:

+ *     Author: 

+ *     Modification:  

+ * History 2: 

+  ********************************************************************************/

+

+#ifndef _DRVS_ASSERT_H

+#define _DRVS_ASSERT_H

+

+

+/****************************************************************************

+* 	                                        Include files

+****************************************************************************/

+

+

+

+/****************************************************************************

+* 	                                        Function Prototypes

+****************************************************************************/

+#if 0

+VOID zDrvExcep_Handler(CHAR *pExp, 

+							const CHAR * pcFileName, 

+							const CHAR * pcFuncName, 

+							UINT32 dwLineNum);

+

+

+

+/****************************************************************************

+* 	                                        Macros

+****************************************************************************/

+#ifdef _DEBUG

+#ifdef _OS_WIN

+#define zDrv_ASSERT(_EXP)

+#else

+#define zDrv_ASSERT(_EXP)  do{if(!(_EXP))  zDrvExcep_Handler(#_EXP,(CHAR *)__FILE__,(CHAR *)__FUNCTION__,__LINE__);}while(0)

+#endif

+#else

+#define zDrv_ASSERT(_EXP)

+#endif

+#endif

+

+#define zDrv_ASSERT(_EXP)	zOss_ASSERT(_EXP)

+#define zDrv_AssertEx(FalseCondition, code)    {if (FalseCondition) { zDrv_ASSERT(0); return code; }}

+

+

+

+

+#endif/*_DRVS_ASSERT_H*/

+

diff --git a/cp/ps/driver/inc/pub/drvs_bitops.h b/cp/ps/driver/inc/pub/drvs_bitops.h
new file mode 100644
index 0000000..b277274
--- /dev/null
+++ b/cp/ps/driver/inc/pub/drvs_bitops.h
@@ -0,0 +1,299 @@
+/*******************************************************************************

+ * Copyright (C) 2007, ZTE Corporation.

+ *

+ * File Name:

+ * File Mark:

+ * Description:

+ * Others:

+ * Version:       1.0

+ * Author:        geanfeng

+ * Date:          2013-09-25

+ * History 1:

+ *     Date:

+ *     Version:

+ *     Author:

+ *     Modification:

+ * History 2:

+  ********************************************************************************/

+

+#ifndef _DRVS_BITOPS_H_

+#define _DRVS_BITOPS_H_

+

+#ifdef __cplusplus 

+extern "C" 

+    {

+#endif

+

+/****************************************************************************

+* 	                                        Include files

+****************************************************************************/

+

+/****************************************************************************

+* 	                                        Macros

+****************************************************************************/

+

+

+/****************************************************************************

+* 	                                        Types

+****************************************************************************/

+

+/****************************************************************************

+* 	                                        Constants

+****************************************************************************/

+

+/****************************************************************************

+* 	                                        Global  Variables

+****************************************************************************/

+

+/****************************************************************************

+* 	                                        Function Prototypes

+****************************************************************************/

+#ifndef set_bit 

+/*

+ * These functions are the basis of our bit ops.

+ *

+ * First, the atomic bitops. These use native endian.

+ */

+static inline void ____atomic_set_bit(unsigned int bitnum, volatile unsigned long *p)

+{

+	unsigned long flags;

+	unsigned long mask = 1UL << (bitnum & 31);

+

+	p += bitnum >> 5;

+

+	LOCK_SAVE(flags);

+	*p |= mask;

+	LOCK_RESTORE(flags);

+}

+

+static inline void ____atomic_clear_bit(unsigned int bitnum, volatile unsigned long *p)

+{

+	unsigned long flags;

+	unsigned long mask = 1UL << (bitnum & 31);

+

+	p += bitnum >> 5;

+

+	LOCK_SAVE(flags);

+	*p &= ~mask;

+	LOCK_RESTORE(flags);

+}

+

+static inline void ____atomic_change_bit(unsigned int bitnum, volatile unsigned long *p)

+{

+	unsigned long flags;

+	unsigned long mask = 1UL << (bitnum & 31);

+

+	p += bitnum >> 5;

+

+	LOCK_SAVE(flags);

+	*p ^= mask;

+	LOCK_RESTORE(flags);

+}

+

+static inline int

+____atomic_test_and_set_bit(unsigned int bitnum, volatile unsigned long *p)

+{

+	unsigned long flags;

+	unsigned int res;

+	unsigned long mask = 1UL << (bitnum & 31);

+

+	p += bitnum >> 5;

+

+	LOCK_SAVE(flags);

+	res = *p;

+	*p = res | mask;

+	LOCK_RESTORE(flags);

+

+	return (res & mask) != 0;

+}

+

+static inline int

+____atomic_test_and_clear_bit(unsigned int bitnum, volatile unsigned long *p)

+{

+	unsigned long flags;

+	unsigned int res;

+	unsigned long mask = 1UL << (bitnum & 31);

+

+	p += bitnum >> 5;

+

+	LOCK_SAVE(flags);

+	res = *p;

+	*p = res & ~mask;

+	LOCK_RESTORE(flags);

+

+	return (res & mask) != 0;

+}

+

+static inline int

+____atomic_test_and_change_bit(unsigned int bitnum, volatile unsigned long *p)

+{

+	unsigned long flags;

+	unsigned int res;

+	unsigned long mask = 1UL << (bitnum & 31);

+

+	p += bitnum >> 5;

+

+	LOCK_SAVE(flags);

+	res = *p;

+	*p = res ^ mask;

+	LOCK_RESTORE(flags);

+

+	return (res & mask) != 0;

+}

+

+

+#define ATOMIC_BITOP(name,nr,p)	____atomic_##name(nr, p)

+

+/*

+ * Native endian atomic definitions.

+ */

+#define set_bit(nr,p)			ATOMIC_BITOP(set_bit,nr,p)

+#define clear_bit(nr,p)			ATOMIC_BITOP(clear_bit,nr,p)

+#define change_bit(nr,p)		ATOMIC_BITOP(change_bit,nr,p)

+#define test_and_set_bit(nr,p)		ATOMIC_BITOP(test_and_set_bit,nr,p)

+#define test_and_clear_bit(nr,p)	ATOMIC_BITOP(test_and_clear_bit,nr,p)

+#define test_and_change_bit(nr,p)	ATOMIC_BITOP(test_and_change_bit,nr,p)

+

+static inline void ____relax_set_bit(unsigned int bitnum, volatile unsigned long *p)

+{

+	unsigned long mask = 1UL << (bitnum & 31);

+

+	p += bitnum >> 5;

+	*p |= mask;

+}

+

+static inline void ____relax_clear_bit(unsigned int bitnum, volatile unsigned long *p)

+{

+	unsigned long mask = 1UL << (bitnum & 31);

+

+	p += bitnum >> 5;

+	*p &= ~mask;

+}

+

+static inline void ____relax_change_bit(unsigned int bitnum, volatile unsigned long *p)

+{

+	unsigned long mask = 1UL << (bitnum & 31);

+

+	p += bitnum >> 5;

+	*p ^= mask;

+}

+

+static inline int

+____relax_test_and_set_bit(unsigned int bitnum, volatile unsigned long *p)

+{

+	unsigned int res;

+	unsigned long mask = 1UL << (bitnum & 31);

+

+	p += bitnum >> 5;

+

+	res = *p;

+	*p = res | mask;

+

+	return (res & mask) != 0;

+}

+

+static inline int

+____relax_test_and_clear_bit(unsigned int bitnum, volatile unsigned long *p)

+{

+	unsigned int res;

+	unsigned long mask = 1UL << (bitnum & 31);

+

+	p += bitnum >> 5;

+

+	res = *p;

+	*p = res & ~mask;

+

+	return (res & mask) != 0;

+}

+

+static inline int

+____relax_test_and_change_bit(unsigned int bitnum, volatile unsigned long *p)

+{

+	unsigned int res;

+	unsigned long mask = 1UL << (bitnum & 31);

+

+	p += bitnum >> 5;

+

+	res = *p;

+	*p = res ^ mask;

+

+	return (res & mask) != 0;

+}

+

+#define RELAX_BITOP(name,nr,p)	____relax_##name(nr, p)

+

+/*

+ * Native endian relax definitions.

+ */

+#define __set_bit(nr,p)			RELAX_BITOP(set_bit,nr,p)

+#define __clear_bit(nr,p)			RELAX_BITOP(clear_bit,nr,p)

+#define __change_bit(nr,p)		RELAX_BITOP(change_bit,nr,p)

+#define __test_and_set_bit(nr,p)		RELAX_BITOP(test_and_set_bit,nr,p)

+#define __test_and_clear_bit(nr,p)	RELAX_BITOP(test_and_clear_bit,nr,p)

+#define __test_and_change_bit(nr,p)	RELAX_BITOP(test_and_change_bit,nr,p)

+

+

+/*

+ * This routine doesn't need to be atomic.

+ */

+static inline int test_bit(int nr, const void * addr)

+{

+    return ((unsigned char *) addr)[nr >> 3] & (1U << (nr & 7));

+}

+

+#endif

+

+static inline void ____atomic_set_bits_u32(unsigned int start, unsigned int nr,

+												unsigned int val, volatile unsigned long *p)

+{

+	unsigned long flags;

+	unsigned long start_u32;

+	unsigned long nr_u32;

+	unsigned long val_u32;

+	unsigned long mask;

+	unsigned long tmp;

+	

+	start_u32 = start & 31;

+	nr_u32 = nr & 31;

+	mask = ~(((1<<nr_u32) - 1) << start_u32);

+	val_u32 = (val & ((1<<nr_u32) - 1)) << start_u32;

+	

+	LOCK_SAVE(flags);

+	tmp = *p;

+	tmp &= mask;

+	tmp |= val_u32;

+	*p = tmp;

+	LOCK_RESTORE(flags);

+}

+

+static inline void ____relax_set_bits_u32(unsigned int start, unsigned int nr,

+												unsigned int val, volatile unsigned long *p)

+{

+	unsigned long start_u32;

+	unsigned long nr_u32;

+	unsigned long val_u32;

+	unsigned long mask;

+	unsigned long tmp;

+	

+	start_u32 = start & 31;

+	nr_u32 = nr & 31;

+	mask = ~(((1<<nr_u32) - 1) << start_u32);

+	val_u32 = (val & ((1<<nr_u32) - 1)) << start_u32;

+	

+	tmp = *p;

+	tmp &= mask;

+	tmp |= val_u32;

+	*p = tmp;

+}

+#define ATOMIC_BITSOP(name,start,nr,val,p)	____atomic_##name(start,nr,val,p)

+#define RELAX_BITSOP(name,start,nr,val,p)	____atomic_##name(start,nr,val,p)

+

+#define set_bits_u32(start,nr,val,p) ATOMIC_BITSOP(set_bits_u32,start,nr,val,p)

+#define __set_bits_u32(start,nr,val,p) RELAX_BITSOP(set_bits_u32,start,nr,val,p)

+

+

+#ifdef   __cplusplus

+    }

+#endif

+

+#endif

diff --git a/cp/ps/driver/inc/pub/drvs_bits.h b/cp/ps/driver/inc/pub/drvs_bits.h
new file mode 100644
index 0000000..4fb269e
--- /dev/null
+++ b/cp/ps/driver/inc/pub/drvs_bits.h
@@ -0,0 +1,65 @@
+/*********************************************************************

+* °æÈ¨ËùÓÐ (C)2003, ÉîÛÚÊÐÖÐÐËͨѶ¹É·ÝÓÐÏÞ¹«Ë¾¡£

+* 

+* ÎļþÃû³Æ£º drvs_bits.h

+* ÄÚÈÝÕªÒª£º ΪÑÚÂ붨Òå

+* ×÷    Õߣº ÖÐÐËͨѶ £º¹Ù»ª²®

+* Íê³ÉÈÕÆÚ£º 2006Äê04ÔÂ18ÈÕ

+**********************************************************************/

+

+/*ÐÞ¸ÄÀúÊ·£º

+2006-04-18: hbguan,´´½¨

+*/

+

+#ifndef _BITS_H

+#define _BITS_H

+

+#ifdef __cplusplus 

+extern "C" 

+    {

+#endif

+

+typedef unsigned long WORD32;

+

+/* ¶¨ÒåλÑÚÂë*/

+#define bit01               ((WORD32)0x00000001)

+#define bit02               ((WORD32)0x00000003)

+#define bit03               ((WORD32)0x00000007)

+#define bit04               ((WORD32)0x0000000f)

+#define bit05               ((WORD32)0x0000001f)

+#define bit06               ((WORD32)0x0000003f)

+#define bit07               ((WORD32)0x0000007f)

+#define bit08               ((WORD32)0x000000ff)

+#define bit09               ((WORD32)0x000001ff)

+#define bit10               ((WORD32)0x000003ff)

+#define bit11               ((WORD32)0x000007ff)

+#define bit12               ((WORD32)0x00000fff)

+#define bit13               ((WORD32)0x00001fff)

+#define bit14               ((WORD32)0x00003fff)

+#define bit15               ((WORD32)0x00007fff)

+#define bit16               ((WORD32)0x0000ffff)

+#define bit17               ((WORD32)0x0001ffff)

+#define bit18               ((WORD32)0x0003ffff)

+#define bit19               ((WORD32)0x0007ffff)

+#define bit20               ((WORD32)0x000fffff)

+#define bit21               ((WORD32)0x001fffff)

+#define bit22               ((WORD32)0x003fffff)

+#define bit23               ((WORD32)0x007fffff)

+#define bit24               ((WORD32)0x00ffffff)

+#define bit25               ((WORD32)0x01ffffff)

+#define bit26               ((WORD32)0x03ffffff)

+#define bit27               ((WORD32)0x07ffffff)

+#define bit28               ((WORD32)0x0fffffff)

+#define bit29               ((WORD32)0x1fffffff)

+#define bit30               ((WORD32)0x3fffffff)

+#define bit31               ((WORD32)0x7fffffff)

+#define bit32               ((WORD32)0xffffffff)

+

+                                                            

+#ifdef   __cplusplus

+    }

+#endif

+

+#endif /* _BITS_H */

+

+

diff --git a/cp/ps/driver/inc/pub/drvs_config.h b/cp/ps/driver/inc/pub/drvs_config.h
new file mode 100644
index 0000000..46645f5
--- /dev/null
+++ b/cp/ps/driver/inc/pub/drvs_config.h
@@ -0,0 +1,95 @@
+/***********************************************************************

+* Copyright (C) 2013, ZTE Corporation.

+*

+* File Name: 	drvs_config.h

+* File Mark:

+* Description:  drv configurate declaration.

+* Others:

+* Version:  v1.0

+* Author:   geanfeng

+* Date:     2013-04-03

+

+**********************************************************************/

+#ifndef    _DRVS_CONFIG_H_

+#define    _DRVS_CONFIG_H_

+

+

+/*************************************************************************

+*                            Include files                                                                         *

+*************************************************************************/

+

+/****************************************************************************

+* 	                         Base Type

+****************************************************************************/

+#define DRV_CONFIG(x)  DRV_CONFIG_##x

+

+#ifdef DRV_CONFIG_C_DEFINE

+#define DRV_CONFIG_DEFINE(x)  int DRV_CONFIG_##x;

+#else

+#ifdef DRV_CONFIG_WRITE_ENABLE

+#define DRV_CONFIG_DEFINE(x)  extern int DRV_CONFIG_##x;

+#else

+#define DRV_CONFIG_DEFINE(x)  extern const int DRV_CONFIG_##x;

+#endif

+#endif

+/**************************************************************************

+*                            Types                                                                                   *

+**************************************************************************/

+/*

+* INT

+*/

+

+

+/*

+* TIMER

+*/

+

+/*

+* USB

+*/

+DRV_CONFIG_DEFINE(USB_HIGHSPEED)

+DRV_CONFIG_DEFINE(USB_VNIC_HALF_DL_BUFF_CNT)

+DRV_CONFIG_DEFINE(USB_IP_4BYTE_ALIGNMENT)

+DRV_CONFIG_DEFINE(USB_VNIC_ADJUST_MAXPKTNUM)

+

+/*

+* I2C

+*/

+DRV_CONFIG_DEFINE(USE_PMIC_I2C)

+DRV_CONFIG_DEFINE(USE_I2C0)

+DRV_CONFIG_DEFINE(USE_I2C1)

+

+/*

+* FLASH TYPE

+*/

+DRV_CONFIG_DEFINE(USE_NAND)

+DRV_CONFIG_DEFINE(USE_SPI_NAND)

+DRV_CONFIG_DEFINE(USE_MMC)

+DRV_CONFIG_DEFINE(USE_PART)

+

+/*

+* UART 

+*/

+DRV_CONFIG_DEFINE(USE_UART_AUTOBAUD)

+/**************************************************************************

+*                            Global  Variable                                                                             *

+**************************************************************************/

+

+/**************************************************************************

+ *                           Function Prototypes                                                                        *

+ **************************************************************************/

+ /****************************************************************************

+ * Function:   zDrvConfig_Initiate

+ * Description: initialize drv configuration;

+ * Parameters:

+ *   Input:

+ *   Output:

+ *

+ * Returns:

+ *     SINT32

+ *

+ * Others:

+ ***************************************************************************/

+SINT32 zDrvConfig_Initiate(VOID);

+

+#endif    /*_DRVS_CONFIG_H_*/

diff --git a/cp/ps/driver/inc/pub/drvs_debug.h b/cp/ps/driver/inc/pub/drvs_debug.h
new file mode 100644
index 0000000..63d2d38
--- /dev/null
+++ b/cp/ps/driver/inc/pub/drvs_debug.h
@@ -0,0 +1,81 @@
+/*******************************************************************************

+ * Copyright (C) 2007, ZTE Corporation.

+ *

+ * File Name:

+ * File Mark:

+ * Description:

+ * Others:

+ * Version:       1.0

+ * Author:        geanfeng

+ * Date:          2013-09-25

+ * History 1:

+ *     Date:

+ *     Version:

+ *     Author:

+ *     Modification:

+ * History 2:

+  ********************************************************************************/

+

+#ifndef _DRVS_DEBUG_H_

+#define _DRVS_DEBUG_H_

+

+/****************************************************************************

+* 	                                        Include files

+****************************************************************************/

+#include "drvs_general.h"

+

+/****************************************************************************

+* 	                                        Macros

+****************************************************************************/

+

+/****************************************************************************

+* 	                                        Types

+****************************************************************************/

+typedef enum _T_DRV_DEBUG_PRINT_CHANNEL

+{

+    DRV_DEBUG_PRINT_ZOSS,

+    DRV_DEBUG_PRINT_DCC

+}T_DRV_DEBUG_PRINT_CHANNEL;

+

+/****************************************************************************

+* 	                                        Constants

+****************************************************************************/

+

+/****************************************************************************

+* 	                                        Global  Variables

+****************************************************************************/

+extern volatile T_DRV_DEBUG_PRINT_CHANNEL  g_debugPrintChnSel;

+/****************************************************************************

+* 	                                        Function Prototypes

+****************************************************************************/

+SINT32 debug_Print(const VOID *pFormat, ... );

+/*******************************************************************************

+* Function:zDrvDebug_Printf

+* Description:  log´òÓ¡

+* Parameters:

+*       pFormat:¸ñʽ»¯×Ö·û´®

+*	 Output:

+*

+* Returns:

+*

+*

+* Others:

+********************************************************************************/

+#ifdef _OS_WIN

+#define zDrvDebug_Printf

+#else

+#define zDrvDebug_Printf(s...)  \

+{ \

+	if (g_debugPrintChnSel == DRV_DEBUG_PRINT_ZOSS)\

+		{\

+			zOss_Printf(SUBMDL_HAL, PRINT_LEVEL_NORMAL, s);\

+		}\

+	else \

+		{\

+			debug_Print(s);\

+		}\

+}

+#endif

+

+#endif/*_DRVS_IO_H_*/

+

diff --git a/cp/ps/driver/inc/pub/drvs_hisr.h b/cp/ps/driver/inc/pub/drvs_hisr.h
new file mode 100644
index 0000000..b8d8909
--- /dev/null
+++ b/cp/ps/driver/inc/pub/drvs_hisr.h
@@ -0,0 +1,57 @@
+/*******************************************************************************

+ * Copyright (C) 2007, ZTE Corporation.

+ *

+ * File Name:    drvs_hisr.h

+ * File Mark:    

+ * Description:  Provide the declaration of return types  for HAL

+ * Others:        

+ * Version:       V0.5

+ * Author:        xiongquan

+ * Date:          2008-12-01

+ * History 1:      

+ *     Date: 

+ *     Version:

+ *     Author: 

+ *     Modification:  

+ * History 2: 

+  ********************************************************************************/

+#ifndef _DRVS_HISR_H

+#define _DRVS_HISR_H

+

+/****************************************************************************

+* 	                                        Types

+****************************************************************************/

+typedef struct _T_Drv_Hisr

+{

+    UINT8 active;

+    UINT32 event;

+    ZOSS_THREAD_ID   pid;

+    ZOSS_SEMAPHORE_ID semid;

+    VOID * devPtr;

+}

+T_Drv_Hisr;

+

+typedef VOID(*FUNC_HISRENTRY)(SINT32 arg);

+

+/****************************************************************************

+* 	                                        Constants

+****************************************************************************/

+

+/****************************************************************************

+* 	                                        Global  Variables

+****************************************************************************/

+

+/****************************************************************************

+* 	                                        Function Prototypes

+****************************************************************************/

+SINT32  zDrv_HisrCreate(T_Drv_Hisr * hisr, CHAR *name, SINT32 size,  SINT32 priority,  FUNC_HISRENTRY hisr_entry, VOID *hisr_device);

+VOID  zDrv_HisrFree(T_Drv_Hisr * hisr);

+VOID  zDrv_HisrStart(T_Drv_Hisr * hisr, UINT32 event);

+VOID zDrv_HisrActivate(T_Drv_Hisr * hisr);

+VOID zDrv_HisrWaitSem(T_Drv_Hisr * hisr);

+VOID zDrv_HisrResetEvent (T_Drv_Hisr *hisr, UINT32 event);

+SINT32 zDrv_HisrInitSem(T_Drv_Hisr * hisr);

+

+

+#endif

+

diff --git a/cp/ps/driver/inc/pub/drvs_list.h b/cp/ps/driver/inc/pub/drvs_list.h
new file mode 100644
index 0000000..d0cf02b
--- /dev/null
+++ b/cp/ps/driver/inc/pub/drvs_list.h
@@ -0,0 +1,701 @@
+#ifndef _DRVS_LIST_H
+#define _DRVS_LIST_H
+
+#ifndef _OS_LINUX
+
+#ifdef __ARMCC_VERSION
+#define __INLINE __inline
+#else
+#define __INLINE inline
+#endif
+
+
+typedef unsigned int		size_t;
+
+/**
+ * container_of - cast a member of a structure out to the containing structure
+ * @ptr:	the pointer to the member.
+ * @type:	the type of the container struct this is embedded in.
+ * @member:	the name of the member within the struct.
+ *
+ */
+#if defined(__ARMCC_VERSION) || defined(_OS_WIN)
+#define container_of(ptr, type, member) (		\
+	(type *)( (char *)ptr - offsetof(type,member) ))
+#else
+#define container_of(ptr, type, member) ({			\
+	const typeof( ((type *)0)->member ) *__mptr = (ptr);	\
+	(type *)( (char *)__mptr - offsetof(type,member) );})
+#endif
+/*
+ * used to verify that nobody uses non-initialized list entries.
+ */
+#define LIST_POISON1  ((void *) 0x0)
+#define LIST_POISON2  ((void *) 0x0)
+
+
+/*
+ * Simple doubly linked list implementation.
+ *
+ * Some of the internal functions ("__xxx") are useful when
+ * manipulating whole lists rather than single entries, as
+ * sometimes we already know the next/prev entries and we can
+ * generate better code by using them directly rather than
+ * using the generic single-entry routines.
+ */
+
+struct list_head {
+	struct list_head *next, *prev;
+};
+
+#define LIST_HEAD_INIT(name) { &(name), &(name) }
+
+#define LIST_HEAD(name) \
+	struct list_head name = LIST_HEAD_INIT(name)
+
+static __INLINE void INIT_LIST_HEAD(struct list_head *list_ptr)
+{
+	list_ptr->next = list_ptr;
+	list_ptr->prev = list_ptr;
+}
+
+/*
+ * Insert a new entry between two known consecutive entries.
+ *
+ * This is only for internal list manipulation where we know
+ * the prev/next entries already!
+ */
+static __INLINE void __list_add(struct list_head *new_ptr,
+			      struct list_head *prev,
+			      struct list_head *next)
+{
+	next->prev = new_ptr;
+	new_ptr->next = next;
+	new_ptr->prev = prev;
+	prev->next = new_ptr;
+}
+
+/**
+ * list_add - add a new entry
+ * @new_ptr: new entry to be added
+ * @head: list head to add it after
+ *
+ * Insert a new entry after the specified head.
+ * This is good for implementing stacks.
+ */
+static __INLINE void list_add(struct list_head *new_ptr, struct list_head *head)
+{
+	__list_add(new_ptr, head, head->next);
+}
+
+/**
+ * list_add_tail - add a new entry
+ * @new_ptr: new entry to be added
+ * @head: list head to add it before
+ *
+ * Insert a new entry before the specified head.
+ * This is useful for implementing queues.
+ */
+static __INLINE void list_add_tail(struct list_head *new_ptr, struct list_head *head)
+{
+	__list_add(new_ptr, head->prev, head);
+}
+
+/*
+ * Delete a list entry by making the prev/next entries
+ * point to each other.
+ *
+ * This is only for internal list manipulation where we know
+ * the prev/next entries already!
+ */
+static __INLINE void __list_del(struct list_head *prev, struct list_head *next)
+{
+	next->prev = prev;
+	prev->next = next;
+}
+
+/**
+ * list_del - deletes entry from list.
+ * @entry: the element to delete from the list.
+ * Note: list_empty() on entry does not return true after this, the entry is
+ * in an undefined state.
+ */
+static __INLINE void list_del(struct list_head *entry)
+{
+	__list_del(entry->prev, entry->next);
+	entry->next = (struct list_head *)LIST_POISON1;
+	entry->prev = (struct list_head *)LIST_POISON2;
+}
+
+/**
+ * list_replace - replace old entry by new one
+ * @old : the element to be replaced
+ * @new_ptr : the new element to insert
+ *
+ * If @old was empty, it will be overwritten.
+ */
+static __INLINE void list_replace(struct list_head *old,
+				struct list_head *new_ptr)
+{
+	new_ptr->next = old->next;
+	new_ptr->next->prev = new_ptr;
+	new_ptr->prev = old->prev;
+	new_ptr->prev->next = new_ptr;
+}
+
+static __INLINE void list_replace_init(struct list_head *old,
+					struct list_head *new_ptr)
+{
+	list_replace(old, new_ptr);
+	INIT_LIST_HEAD(old);
+}
+
+/**
+ * list_del_init - deletes entry from list and reinitialize it.
+ * @entry: the element to delete from the list.
+ */
+static __INLINE void list_del_init(struct list_head *entry)
+{
+	__list_del(entry->prev, entry->next);
+	INIT_LIST_HEAD(entry);
+}
+
+/**
+ * list_move - delete from one list and add as another's head
+ * @list: the entry to move
+ * @head: the head that will precede our entry
+ */
+static __INLINE void list_move(struct list_head *list_ptr, struct list_head *head)
+{
+	__list_del(list_ptr->prev, list_ptr->next);
+	list_add(list_ptr, head);
+}
+
+/**
+ * list_move_tail - delete from one list and add as another's tail
+ * @list: the entry to move
+ * @head: the head that will follow our entry
+ */
+static __INLINE void list_move_tail(struct list_head *list_ptr,
+				  struct list_head *head)
+{
+	__list_del(list_ptr->prev, list_ptr->next);
+	list_add_tail(list_ptr, head);
+}
+
+/**
+ * list_is_last - tests whether @list_ptr is the last entry in list @head
+ * @list_ptr: the entry to test
+ * @head: the head of the list
+ */
+static __INLINE int list_is_last(const struct list_head *list_ptr,
+				const struct list_head *head)
+{
+	return list_ptr->next == head;
+}
+
+/**
+ * list_empty - tests whether a list is empty
+ * @head: the list to test.
+ */
+static __INLINE int list_empty(const struct list_head *head)
+{
+	return head->next == head;
+}
+
+/**
+ * list_empty_careful - tests whether a list is empty and not being modified
+ * @head: the list to test
+ *
+ * Description:
+ * tests whether a list is empty _and_ checks that no other CPU might be
+ * in the process of modifying either member (next or prev)
+ *
+ * NOTE: using list_empty_careful() without synchronization
+ * can only be safe if the only activity that can happen
+ * to the list entry is list_del_init(). Eg. it cannot be used
+ * if another CPU could re-list_add() it.
+ */
+static __INLINE int list_empty_careful(const struct list_head *head)
+{
+	struct list_head *next = head->next;
+	return (next == head) && (next == head->prev);
+}
+
+/**
+ * list_is_singular - tests whether a list has just one entry.
+ * @head: the list to test.
+ */
+static __INLINE int list_is_singular(const struct list_head *head)
+{
+	return !list_empty(head) && (head->next == head->prev);
+}
+
+static __INLINE void __list_cut_position(struct list_head *list_ptr,
+		struct list_head *head, struct list_head *entry)
+{
+	struct list_head *new_first = entry->next;
+	list_ptr->next = head->next;
+	list_ptr->next->prev = list_ptr;
+	list_ptr->prev = entry;
+	entry->next = list_ptr;
+	head->next = new_first;
+	new_first->prev = head;
+}
+
+/**
+ * list_cut_position - cut a list into two
+ * @list_ptr: a new list to add all removed entries
+ * @head: a list with entries
+ * @entry: an entry within head, could be the head itself
+ *	and if so we won't cut the list
+ *
+ * This helper moves the initial part of @head, up to and
+ * including @entry, from @head to @list. You should
+ * pass on @entry an element you know is on @head. @list
+ * should be an empty list or a list you do not care about
+ * losing its data.
+ *
+ */
+static __INLINE void list_cut_position(struct list_head *list_ptr,
+		struct list_head *head, struct list_head *entry)
+{
+	if (list_empty(head))
+		return;
+	if (list_is_singular(head) &&
+		(head->next != entry && head != entry))
+		return;
+	if (entry == head)
+		INIT_LIST_HEAD(list_ptr);
+	else
+		__list_cut_position(list_ptr, head, entry);
+}
+
+static __INLINE void __list_splice(const struct list_head *list_ptr,
+				 struct list_head *prev,
+				 struct list_head *next)
+{
+	struct list_head *first = list_ptr->next;
+	struct list_head *last = list_ptr->prev;
+
+	first->prev = prev;
+	prev->next = first;
+
+	last->next = next;
+	next->prev = last;
+}
+
+/**
+ * list_splice - join two lists, this is designed for stacks
+ * @list_ptr: the new list to add.
+ * @head: the place to add it in the first list.
+ */
+static __INLINE void list_splice(const struct list_head *list_ptr,
+				struct list_head *head)
+{
+	if (!list_empty(list_ptr))
+		__list_splice(list_ptr, head, head->next);
+}
+
+/**
+ * list_splice_tail - join two lists, each list being a queue
+ * @list_ptr: the new list to add.
+ * @head: the place to add it in the first list.
+ */
+static __INLINE void list_splice_tail(struct list_head *list_ptr,
+				struct list_head *head)
+{
+	if (!list_empty(list_ptr))
+		__list_splice(list_ptr, head->prev, head);
+}
+
+/**
+ * list_splice_init - join two lists and reinitialise the emptied list.
+ * @list_ptr: the new list to add.
+ * @head: the place to add it in the first list.
+ *
+ * The list at @list is reinitialised
+ */
+static __INLINE void list_splice_init(struct list_head *list_ptr,
+				    struct list_head *head)
+{
+	if (!list_empty(list_ptr)) {
+		__list_splice(list_ptr, head, head->next);
+		INIT_LIST_HEAD(list_ptr);
+	}
+}
+
+/**
+ * list_splice_tail_init - join two lists and reinitialise the emptied list
+ * @list_ptr: the new list to add.
+ * @head: the place to add it in the first list.
+ *
+ * Each of the lists is a queue.
+ * The list at @list is reinitialised
+ */
+static __INLINE void list_splice_tail_init(struct list_head *list_ptr,
+					 struct list_head *head)
+{
+	if (!list_empty(list_ptr)) {
+		__list_splice(list_ptr, head->prev, head);
+		INIT_LIST_HEAD(list_ptr);
+	}
+}
+
+/**
+ * list_entry - get the struct for this entry
+ * @ptr:	the &struct list_head pointer.
+ * @type:	the type of the struct this is embedded in.
+ * @member:	the name of the list_struct within the struct.
+ */
+#define list_entry(ptr, type, member) \
+	container_of(ptr, type, member)
+
+/**
+ * list_first_entry - get the first element from a list
+ * @ptr:	the list head to take the element from.
+ * @type:	the type of the struct this is embedded in.
+ * @member:	the name of the list_struct within the struct.
+ *
+ * Note, that list is expected to be not empty.
+ */
+#define list_first_entry(ptr, type, member) \
+	list_entry((ptr)->next, type, member)
+
+/**
+ * list_for_each	-	iterate over a list
+ * @pos:	the &struct list_head to use as a loop cursor.
+ * @head:	the head for your list.
+ */
+#define list_for_each(pos, head) \
+	for (pos = (head)->next; prefetch(pos->next), pos != (head); \
+		pos = pos->next)
+
+/**
+ * __list_for_each	-	iterate over a list
+ * @pos:	the &struct list_head to use as a loop cursor.
+ * @head:	the head for your list.
+ *
+ * This variant differs from list_for_each() in that it's the
+ * simplest possible list iteration code, no prefetching is done.
+ * Use this for code that knows the list to be very short (empty
+ * or 1 entry) most of the time.
+ */
+#define __list_for_each(pos, head) \
+	for (pos = (head)->next; pos != (head); pos = pos->next)
+
+/**
+ * list_for_each_prev	-	iterate over a list backwards
+ * @pos:	the &struct list_head to use as a loop cursor.
+ * @head:	the head for your list.
+ */
+#define list_for_each_prev(pos, head) \
+	for (pos = (head)->prev; prefetch(pos->prev), pos != (head); \
+		pos = pos->prev)
+
+/**
+ * list_for_each_safe - iterate over a list safe against removal of list entry
+ * @pos:	the &struct list_head to use as a loop cursor.
+ * @n:		another &struct list_head to use as temporary storage
+ * @head:	the head for your list.
+ */
+#define list_for_each_safe(pos, n, head) \
+	for (pos = (head)->next, n = pos->next; pos != (head); \
+		pos = n, n = pos->next)
+
+/**
+ * list_for_each_prev_safe - iterate over a list backwards safe against removal of list entry
+ * @pos:	the &struct list_head to use as a loop cursor.
+ * @n:		another &struct list_head to use as temporary storage
+ * @head:	the head for your list.
+ */
+#define list_for_each_prev_safe(pos, n, head) \
+	for (pos = (head)->prev, n = pos->prev; \
+	     prefetch(pos->prev), pos != (head); \
+	     pos = n, n = pos->prev)
+
+/**
+ * list_for_each_entry	-	iterate over list of given type
+ * @pos:	the type * to use as a loop cursor.
+ * @head:	the head for your list.
+ * @member:	the name of the list_struct within the struct.
+ */
+#define list_for_each_entry(pos, head, member)				\
+	for (pos = list_entry((head)->next, typeof(*pos), member);	\
+	     prefetch(pos->member.next), &pos->member != (head);	\
+	     pos = list_entry(pos->member.next, typeof(*pos), member))
+
+/**
+ * list_for_each_entry_reverse - iterate backwards over list of given type.
+ * @pos:	the type * to use as a loop cursor.
+ * @head:	the head for your list.
+ * @member:	the name of the list_struct within the struct.
+ */
+#define list_for_each_entry_reverse(pos, head, member)			\
+	for (pos = list_entry((head)->prev, typeof(*pos), member);	\
+	     prefetch(pos->member.prev), &pos->member != (head);	\
+	     pos = list_entry(pos->member.prev, typeof(*pos), member))
+
+/**
+ * list_prepare_entry - prepare a pos entry for use in list_for_each_entry_continue()
+ * @pos:	the type * to use as a start point
+ * @head:	the head of the list
+ * @member:	the name of the list_struct within the struct.
+ *
+ * Prepares a pos entry for use as a start point in list_for_each_entry_continue().
+ */
+#define list_prepare_entry(pos, head, member) \
+	((pos) ? : list_entry(head, typeof(*pos), member))
+
+/**
+ * list_for_each_entry_continue - continue iteration over list of given type
+ * @pos:	the type * to use as a loop cursor.
+ * @head:	the head for your list.
+ * @member:	the name of the list_struct within the struct.
+ *
+ * Continue to iterate over list of given type, continuing after
+ * the current position.
+ */
+#define list_for_each_entry_continue(pos, head, member) 		\
+	for (pos = list_entry(pos->member.next, typeof(*pos), member);	\
+	     prefetch(pos->member.next), &pos->member != (head);	\
+	     pos = list_entry(pos->member.next, typeof(*pos), member))
+
+/**
+ * list_for_each_entry_continue_reverse - iterate backwards from the given point
+ * @pos:	the type * to use as a loop cursor.
+ * @head:	the head for your list.
+ * @member:	the name of the list_struct within the struct.
+ *
+ * Start to iterate over list of given type backwards, continuing after
+ * the current position.
+ */
+#define list_for_each_entry_continue_reverse(pos, head, member)		\
+	for (pos = list_entry(pos->member.prev, typeof(*pos), member);	\
+	     prefetch(pos->member.prev), &pos->member != (head);	\
+	     pos = list_entry(pos->member.prev, typeof(*pos), member))
+
+/**
+ * list_for_each_entry_from - iterate over list of given type from the current point
+ * @pos:	the type * to use as a loop cursor.
+ * @head:	the head for your list.
+ * @member:	the name of the list_struct within the struct.
+ *
+ * Iterate over list of given type, continuing from current position.
+ */
+#define list_for_each_entry_from(pos, head, member)			\
+	for (; prefetch(pos->member.next), &pos->member != (head);	\
+	     pos = list_entry(pos->member.next, typeof(*pos), member))
+
+/**
+ * list_for_each_entry_safe - iterate over list of given type safe against removal of list entry
+ * @pos:	the type * to use as a loop cursor.
+ * @n:		another type * to use as temporary storage
+ * @head:	the head for your list.
+ * @member:	the name of the list_struct within the struct.
+ */
+#define list_for_each_entry_safe(pos, n, head, member)			\
+	for (pos = list_entry((head)->next, typeof(*pos), member),	\
+		n = list_entry(pos->member.next, typeof(*pos), member);	\
+	     &pos->member != (head);					\
+	     pos = n, n = list_entry(n->member.next, typeof(*n), member))
+
+/**
+ * list_for_each_entry_safe_continue
+ * @pos:	the type * to use as a loop cursor.
+ * @n:		another type * to use as temporary storage
+ * @head:	the head for your list.
+ * @member:	the name of the list_struct within the struct.
+ *
+ * Iterate over list of given type, continuing after current point,
+ * safe against removal of list entry.
+ */
+#define list_for_each_entry_safe_continue(pos, n, head, member) 		\
+	for (pos = list_entry(pos->member.next, typeof(*pos), member),		\
+		n = list_entry(pos->member.next, typeof(*pos), member);		\
+	     &pos->member != (head);						\
+	     pos = n, n = list_entry(n->member.next, typeof(*n), member))
+
+/**
+ * list_for_each_entry_safe_from
+ * @pos:	the type * to use as a loop cursor.
+ * @n:		another type * to use as temporary storage
+ * @head:	the head for your list.
+ * @member:	the name of the list_struct within the struct.
+ *
+ * Iterate over list of given type from current point, safe against
+ * removal of list entry.
+ */
+#define list_for_each_entry_safe_from(pos, n, head, member)			\
+	for (n = list_entry(pos->member.next, typeof(*pos), member);		\
+	     &pos->member != (head);						\
+	     pos = n, n = list_entry(n->member.next, typeof(*n), member))
+
+/**
+ * list_for_each_entry_safe_reverse
+ * @pos:	the type * to use as a loop cursor.
+ * @n:		another type * to use as temporary storage
+ * @head:	the head for your list.
+ * @member:	the name of the list_struct within the struct.
+ *
+ * Iterate backwards over list of given type, safe against removal
+ * of list entry.
+ */
+#define list_for_each_entry_safe_reverse(pos, n, head, member)		\
+	for (pos = list_entry((head)->prev, typeof(*pos), member),	\
+		n = list_entry(pos->member.prev, typeof(*pos), member);	\
+	     &pos->member != (head);					\
+	     pos = n, n = list_entry(n->member.prev, typeof(*n), member))
+
+/*
+ * Double linked lists with a single pointer list head.
+ * Mostly useful for hash tables where the two pointer list head is
+ * too wasteful.
+ * You lose the ability to access the tail in O(1).
+ */
+
+struct hlist_head {
+	struct hlist_node *first;
+};
+
+struct hlist_node {
+	struct hlist_node *next, **pprev;
+};
+
+#define HLIST_HEAD_INIT { .first = NULL }
+#define HLIST_HEAD(name) struct hlist_head name = {  .first = NULL }
+#define INIT_HLIST_HEAD(ptr) ((ptr)->first = NULL)
+static __INLINE void INIT_HLIST_NODE(struct hlist_node *h)
+{
+	h->next = NULL;
+	h->pprev = NULL;
+}
+
+static __INLINE int hlist_unhashed(const struct hlist_node *h)
+{
+	return !h->pprev;
+}
+
+static __INLINE int hlist_empty(const struct hlist_head *h)
+{
+	return !h->first;
+}
+
+static __INLINE void __hlist_del(struct hlist_node *n)
+{
+	struct hlist_node *next = n->next;
+	struct hlist_node **pprev = n->pprev;
+	*pprev = next;
+	if (next)
+		next->pprev = pprev;
+}
+
+static __INLINE void hlist_del(struct hlist_node *n)
+{
+	__hlist_del(n);
+	n->next = (struct hlist_node *)LIST_POISON1;
+	n->pprev = (struct hlist_node **)LIST_POISON2;
+}
+
+static __INLINE void hlist_del_init(struct hlist_node *n)
+{
+	if (!hlist_unhashed(n)) {
+		__hlist_del(n);
+		INIT_HLIST_NODE(n);
+	}
+}
+
+static __INLINE void hlist_add_head(struct hlist_node *n, struct hlist_head *h)
+{
+	struct hlist_node *first = h->first;
+	n->next = first;
+	if (first)
+		first->pprev = &n->next;
+	h->first = n;
+	n->pprev = &h->first;
+}
+
+/* next must be != NULL */
+static __INLINE void hlist_add_before(struct hlist_node *n,
+					struct hlist_node *next)
+{
+	n->pprev = next->pprev;
+	n->next = next;
+	next->pprev = &n->next;
+	*(n->pprev) = n;
+}
+
+static __INLINE void hlist_add_after(struct hlist_node *n,
+					struct hlist_node *next)
+{
+	next->next = n->next;
+	n->next = next;
+	next->pprev = &n->next;
+
+	if(next->next)
+		next->next->pprev  = &next->next;
+}
+
+#define hlist_entry(ptr, type, member) container_of(ptr,type,member)
+
+#define hlist_for_each(pos, head) \
+	for (pos = (head)->first; pos && ({ prefetch(pos->next); 1; }); \
+	     pos = pos->next)
+
+#define hlist_for_each_safe(pos, n, head) \
+	for (pos = (head)->first; pos && ({ n = pos->next; 1; }); \
+	     pos = n)
+
+/**
+ * hlist_for_each_entry	- iterate over list of given type
+ * @tpos:	the type * to use as a loop cursor.
+ * @pos:	the &struct hlist_node to use as a loop cursor.
+ * @head:	the head for your list.
+ * @member:	the name of the hlist_node within the struct.
+ */
+#define hlist_for_each_entry(tpos, pos, head, member)			 \
+	for (pos = (head)->first;					 \
+	     pos && ({ prefetch(pos->next); 1;}) &&			 \
+		({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
+	     pos = pos->next)
+
+/**
+ * hlist_for_each_entry_continue - iterate over a hlist continuing after current point
+ * @tpos:	the type * to use as a loop cursor.
+ * @pos:	the &struct hlist_node to use as a loop cursor.
+ * @member:	the name of the hlist_node within the struct.
+ */
+#define hlist_for_each_entry_continue(tpos, pos, member)		 \
+	for (pos = (pos)->next;						 \
+	     pos && ({ prefetch(pos->next); 1;}) &&			 \
+		({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
+	     pos = pos->next)
+
+/**
+ * hlist_for_each_entry_from - iterate over a hlist continuing from current point
+ * @tpos:	the type * to use as a loop cursor.
+ * @pos:	the &struct hlist_node to use as a loop cursor.
+ * @member:	the name of the hlist_node within the struct.
+ */
+#define hlist_for_each_entry_from(tpos, pos, member)			 \
+	for (; pos && ({ prefetch(pos->next); 1;}) &&			 \
+		({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
+	     pos = pos->next)
+
+/**
+ * hlist_for_each_entry_safe - iterate over list of given type safe against removal of list entry
+ * @tpos:	the type * to use as a loop cursor.
+ * @pos:	the &struct hlist_node to use as a loop cursor.
+ * @n:		another &struct hlist_node to use as temporary storage
+ * @head:	the head for your list.
+ * @member:	the name of the hlist_node within the struct.
+ */
+#define hlist_for_each_entry_safe(tpos, pos, n, head, member)		 \
+	for (pos = (head)->first;					 \
+	     pos && ({ n = pos->next; 1; }) &&				 \
+		({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
+	     pos = n)
+
+#endif
+
+#endif
diff --git a/cp/ps/driver/inc/pub/drvs_ramlog.h b/cp/ps/driver/inc/pub/drvs_ramlog.h
new file mode 100755
index 0000000..a6ba79c
--- /dev/null
+++ b/cp/ps/driver/inc/pub/drvs_ramlog.h
@@ -0,0 +1,236 @@
+/*******************************************************************************

+ * Copyright (C) 2009, ZTE Corporation.

+ *

+ * File Name:    drvs_ramlog.h

+ * File Mark:

+ * Description:

+ * Others:

+ * Version:       V1.0

+ * Author:        yuxiang

+ * Date:          2009-11-06

+ * History 1:

+ *     Date:

+ *     Version:

+ *     Author:

+ *     Modification:

+  ********************************************************************************/

+#ifndef DRVS_RAMLOG_H

+#define DRVS_RAMLOG_H

+

+#ifdef __cplusplus

+   extern "C"

+   {

+#endif

+

+/****************************************************************************

+* 	                        Include files

+****************************************************************************/

+

+/****************************************************************************

+* 	                         Macros

+****************************************************************************/

+/*LOG»º³åÇø´óС¶¨Òå,ÒÔ×Ö½ÚΪµ¥Î»,Çë¸ù¾ÝÄ£¿éÒª´òÓ¡µÄLOGÊýÉèÖÃ*/

+#define RAMLOG_BUF_SIZE_8K      (8*1024)

+#define RAMLOG_BUF_SIZE_16K     (16*1024)

+#define RAMLOG_BUF_SIZE_32K     (32*1024)

+#define RAMLOG_BUF_SIZE_64K     (64*1024)

+#define RAMLOG_BUF_SIZE_128K    (128*1024)

+#define RAMLOG_BUF_SIZE_256K    (256*1024)

+

+

+/*´òÓ¡Ä£¿éºÅ*/

+#define RAMLOG_MOD_CHIP_BASE    1

+

+#define RAMLOG_MOD_AUDIO        (RAMLOG_MOD_CHIP_BASE + 0)

+#define RAMLOG_MOD_BACKLIGHT    (RAMLOG_MOD_CHIP_BASE + 1)

+#define RAMLOG_MOD_BSP          (RAMLOG_MOD_CHIP_BASE + 2)

+#define RAMLOG_MOD_CAM          (RAMLOG_MOD_CHIP_BASE + 3)

+#define RAMLOG_MOD_CIPHER       (RAMLOG_MOD_CHIP_BASE + 4)

+#define RAMLOG_MOD_DMA          (RAMLOG_MOD_CHIP_BASE + 5)

+#define RAMLOG_MOD_DPRAM        (RAMLOG_MOD_CHIP_BASE + 6)

+#define RAMLOG_MOD_DSP          (RAMLOG_MOD_CHIP_BASE + 7)

+#define RAMLOG_MOD_EARPIECE     (RAMLOG_MOD_CHIP_BASE + 8)

+#define RAMLOG_MOD_GPIO         (RAMLOG_MOD_CHIP_BASE + 9)

+#define RAMLOG_MOD_I2C          (RAMLOG_MOD_CHIP_BASE + 10)

+#define RAMLOG_MOD_I2S          (RAMLOG_MOD_CHIP_BASE + 11)

+#define RAMLOG_MOD_INT          (RAMLOG_MOD_CHIP_BASE + 12)

+#define RAMLOG_MOD_ICP          (RAMLOG_MOD_CHIP_BASE + 13)

+#define RAMLOG_MOD_KPDBL        (RAMLOG_MOD_CHIP_BASE + 14)

+#define RAMLOG_MOD_MIDI         (RAMLOG_MOD_CHIP_BASE + 15)

+#define RAMLOG_MOD_POW          (RAMLOG_MOD_CHIP_BASE + 16)

+#define RAMLOG_MOD_RF           (RAMLOG_MOD_CHIP_BASE + 17)

+#define RAMLOG_MOD_RTC          (RAMLOG_MOD_CHIP_BASE + 18)

+#define RAMLOG_MOD_RTT          (RAMLOG_MOD_CHIP_BASE + 19)

+#define RAMLOG_MOD_SD           (RAMLOG_MOD_CHIP_BASE + 20)

+#define RAMLOG_MOD_SPI          (RAMLOG_MOD_CHIP_BASE + 21)

+#define RAMLOG_MOD_TIMER        (RAMLOG_MOD_CHIP_BASE + 22)

+#define RAMLOG_MOD_TONE         (RAMLOG_MOD_CHIP_BASE + 23)

+#define RAMLOG_MOD_UART         (RAMLOG_MOD_CHIP_BASE + 24)

+#define RAMLOG_MOD_UICC         (RAMLOG_MOD_CHIP_BASE + 25)

+#define RAMLOG_MOD_USB          (RAMLOG_MOD_CHIP_BASE + 26)

+#define RAMLOG_MOD_VIDEO        (RAMLOG_MOD_CHIP_BASE + 27)

+#define RAMLOG_MOD_VOICE        (RAMLOG_MOD_CHIP_BASE + 28)

+#define RAMLOG_MOD_VOU          (RAMLOG_MOD_CHIP_BASE + 29)

+#define RAMLOG_MOD_SPIFC        (RAMLOG_MOD_CHIP_BASE + 30)

+

+#define RAMLOG_MOD_ASSERT       (RAMLOG_MOD_CHIP_BASE + 126)

+

+#define RAMLOG_MOD_PERI_BASE    128

+

+#define RAMLOG_MOD_BATTERY      (RAMLOG_MOD_PERI_BASE + 0)

+#define RAMLOG_MOD_CHARGER      (RAMLOG_MOD_PERI_BASE + 1)

+#define RAMLOG_MOD_FLASH        (RAMLOG_MOD_PERI_BASE + 2)

+#define RAMLOG_MOD_FM           (RAMLOG_MOD_PERI_BASE + 3)

+#define RAMLOG_MOD_LCD          (RAMLOG_MOD_PERI_BASE + 4)

+#define RAMLOG_MOD_NAND         (RAMLOG_MOD_PERI_BASE + 5)

+#define RAMLOG_MOD_PMIC         (RAMLOG_MOD_PERI_BASE + 6)

+#define RAMLOG_MOD_PMMANAGER    (RAMLOG_MOD_PERI_BASE + 7)

+#define RAMLOG_MOD_RTCPERI      (RAMLOG_MOD_PERI_BASE + 8)

+#define RAMLOG_MOD_SENSOR       (RAMLOG_MOD_PERI_BASE + 9)

+#define RAMLOG_MOD_TOUCH        (RAMLOG_MOD_PERI_BASE + 10)

+#define RAMLOG_MOD_VIBRATOR     (RAMLOG_MOD_PERI_BASE + 11)

+#define RAMLOG_MOD_LED          (RAMLOG_MOD_PERI_BASE + 12)

+

+#define RAMLOG_MOD_MAX          255

+

+

+#define RAMLOG_MOD_NO1          RAMLOG_MOD_AUDIO        /*Ä£¿éºÅ*/

+#define RAMLOG_MOD_NO1_SHELL    "audio"                 /*shellÃüÁî²ÎÊý,ÎÞ¿Õ¸ñ,×32Byte*/

+#define RAMLOG_MOD_NO1_BUF_SIZE RAMLOG_BUF_SIZE_32K     /*LOG»º³åÇø´óС*/

+#define RAMLOG_MOD_NO1_LOOP_ON  TRUE                    /*ÊÇ·ñÑ­»·´òÓ¡*/

+#define RAMLOG_MOD_NO1_REG      TRUE                   /*ÊÇ·ñ×¢²á,FALSEʱ´ËÄ£¿é²»»á±»×¢²á*/

+

+#define RAMLOG_MOD_NO2          RAMLOG_MOD_KPDBL

+#define RAMLOG_MOD_NO2_SHELL    "kpd"

+#define RAMLOG_MOD_NO2_BUF_SIZE RAMLOG_BUF_SIZE_32K

+#define RAMLOG_MOD_NO2_LOOP_ON  TRUE

+#define RAMLOG_MOD_NO2_REG      FALSE

+

+#define RAMLOG_MOD_NO3          RAMLOG_MOD_LCD /* YinWenguan 2015-2-4 */

+#define RAMLOG_MOD_NO3_SHELL    "lcd"

+#define RAMLOG_MOD_NO3_BUF_SIZE RAMLOG_BUF_SIZE_32K

+#define RAMLOG_MOD_NO3_LOOP_ON  TRUE

+#define RAMLOG_MOD_NO3_REG      FALSE

+

+#define RAMLOG_MOD_NO4          RAMLOG_MOD_POW//RAMLOG_MOD_TOUCH

+#define RAMLOG_MOD_NO4_SHELL    "pow"//"touch"

+#define RAMLOG_MOD_NO4_BUF_SIZE RAMLOG_BUF_SIZE_32K

+#define RAMLOG_MOD_NO4_LOOP_ON  TRUE

+#define RAMLOG_MOD_NO4_REG      FALSE

+

+#define RAMLOG_MOD_NO5          RAMLOG_MOD_CHARGER

+#define RAMLOG_MOD_NO5_SHELL    "charger"

+#define RAMLOG_MOD_NO5_BUF_SIZE RAMLOG_BUF_SIZE_32K

+#define RAMLOG_MOD_NO5_LOOP_ON  TRUE

+#define RAMLOG_MOD_NO5_REG      FALSE

+

+#define RAMLOG_MOD_NO6          RAMLOG_MOD_DMA

+#define RAMLOG_MOD_NO6_SHELL    "dma"

+#define RAMLOG_MOD_NO6_BUF_SIZE RAMLOG_BUF_SIZE_32K

+#define RAMLOG_MOD_NO6_LOOP_ON  TRUE

+#define RAMLOG_MOD_NO6_REG      FALSE

+

+#define RAMLOG_MOD_NO7          RAMLOG_MOD_ICP

+#define RAMLOG_MOD_NO7_SHELL    "icp"

+#define RAMLOG_MOD_NO7_BUF_SIZE RAMLOG_BUF_SIZE_8K

+#define RAMLOG_MOD_NO7_LOOP_ON  TRUE

+#define RAMLOG_MOD_NO7_REG      TRUE

+

+#define RAMLOG_MOD_NO8 			RAMLOG_MOD_UICC

+#define RAMLOG_MOD_NO8_SHELL    "UICC"

+#define RAMLOG_MOD_NO8_BUF_SIZE RAMLOG_BUF_SIZE_8K

+#define RAMLOG_MOD_NO8_LOOP_ON  TRUE

+#define RAMLOG_MOD_NO8_REG      TRUE

+

+#define RAMLOG_MOD_NO9          RAMLOG_MOD_LED

+#define RAMLOG_MOD_NO9_SHELL    "led"

+#define RAMLOG_MOD_NO9_BUF_SIZE RAMLOG_BUF_SIZE_32K

+#define RAMLOG_MOD_NO9_LOOP_ON  TRUE

+#define RAMLOG_MOD_NO9_REG      FALSE

+

+#define RAMLOG_MOD_NO10          RAMLOG_MOD_ASSERT

+#define RAMLOG_MOD_NO10_SHELL    "assert"

+#define RAMLOG_MOD_NO10_BUF_SIZE RAMLOG_BUF_SIZE_32K

+#define RAMLOG_MOD_NO10_LOOP_ON  TRUE

+#define RAMLOG_MOD_NO10_REG      FALSE

+

+#define RAMLOG_MOD_NO11          RAMLOG_MOD_SD

+#define RAMLOG_MOD_NO11_SHELL    "sd"

+#define RAMLOG_MOD_NO11_BUF_SIZE RAMLOG_BUF_SIZE_256K

+#define RAMLOG_MOD_NO11_LOOP_ON  TRUE

+#define RAMLOG_MOD_NO11_REG      FALSE

+

+#define RAMLOG_MOD_NO12          RAMLOG_MOD_CAM

+#define RAMLOG_MOD_NO12_SHELL    "camera"

+#define RAMLOG_MOD_NO12_BUF_SIZE RAMLOG_BUF_SIZE_32K

+#define RAMLOG_MOD_NO12_LOOP_ON  TRUE

+#define RAMLOG_MOD_NO12_REG      FALSE

+

+#define RAMLOG_MOD_NO13          RAMLOG_MOD_VOU

+#define RAMLOG_MOD_NO13_SHELL    "vou"

+#define RAMLOG_MOD_NO13_BUF_SIZE RAMLOG_BUF_SIZE_32K

+#define RAMLOG_MOD_NO13_LOOP_ON  TRUE

+#define RAMLOG_MOD_NO13_REG      FALSE

+

+#define RAMLOG_MOD_NO14          RAMLOG_MOD_PMIC

+#define RAMLOG_MOD_NO14_SHELL    "pmic"

+#define RAMLOG_MOD_NO14_BUF_SIZE RAMLOG_BUF_SIZE_32K

+#define RAMLOG_MOD_NO14_LOOP_ON  TRUE

+#define RAMLOG_MOD_NO14_REG      FALSE

+

+

+#define RAMLOG_MOD_NO15          RAMLOG_MOD_I2C

+#define RAMLOG_MOD_NO15_SHELL    "i2c"

+#define RAMLOG_MOD_NO15_BUF_SIZE RAMLOG_BUF_SIZE_32K

+#define RAMLOG_MOD_NO15_LOOP_ON  TRUE

+#define RAMLOG_MOD_NO15_REG      FALSE

+

+#define RAMLOG_MOD_NO16          RAMLOG_MOD_SPI

+#define RAMLOG_MOD_NO16_SHELL    "spi"

+#define RAMLOG_MOD_NO16_BUF_SIZE RAMLOG_BUF_SIZE_32K

+#define RAMLOG_MOD_NO16_LOOP_ON  TRUE

+#define RAMLOG_MOD_NO16_REG      FALSE

+

+#define RAMLOG_MOD_NO17          RAMLOG_MOD_SPIFC

+#define RAMLOG_MOD_NO17_SHELL    "spifc"

+#define RAMLOG_MOD_NO17_BUF_SIZE RAMLOG_BUF_SIZE_32K

+#define RAMLOG_MOD_NO17_LOOP_ON  TRUE

+#define RAMLOG_MOD_NO17_REG      FALSE

+/****************************************************************************

+* 	                         Types

+****************************************************************************/

+

+

+/****************************************************************************

+* 	                         Constants

+****************************************************************************/

+

+/****************************************************************************

+* 	                         Global  Variables

+****************************************************************************/

+

+/****************************************************************************

+* 	                         Function Prototypes

+****************************************************************************/

+

+SINT32 zDrvRamLog_Initiate(VOID);

+SINT32 ramlog_Printf(UINT16 nModNo, const VOID *pFormat, ...);

+

+#ifdef _OS_WIN

+#define zDrvRamlog_PRINTF(nModNo, s)

+#else

+

+#ifdef _USE_RAMLOG

+#define zDrvRamlog_PRINTF(nModNo, s...) ramlog_Printf(nModNo, s)

+#else

+#define zDrvRamlog_PRINTF(nModNo, s...)

+#endif

+

+#endif

+

+#ifdef __cplusplus

+}

+#endif

+

+#endif

+

diff --git a/cp/ps/driver/inc/pub/drvs_regio.h b/cp/ps/driver/inc/pub/drvs_regio.h
new file mode 100644
index 0000000..4f3f9b9
--- /dev/null
+++ b/cp/ps/driver/inc/pub/drvs_regio.h
@@ -0,0 +1,86 @@
+/*******************************************************************************

+ * Copyright (C) 2007, ZTE Corporation.

+ *

+ * File Name:

+ * File Mark:

+ * Description:

+ * Others:

+ * Version:       1.0

+ * Author:        geanfeng

+ * Date:          2013-09-25

+ * History 1:

+ *     Date:

+ *     Version:

+ *     Author:

+ *     Modification:

+ * History 2:

+  ********************************************************************************/

+

+#ifndef _DRVS_REGIO_H_

+#define _DRVS_REGIO_H_

+

+/****************************************************************************

+* 	                                        Include files

+****************************************************************************/

+

+/****************************************************************************

+* 	                                        Macros

+****************************************************************************/

+

+

+/****************************************************************************

+* 	                                        Types

+****************************************************************************/

+

+/****************************************************************************

+* 	                                        Constants

+****************************************************************************/

+

+/****************************************************************************

+* 	                                        Global  Variables

+****************************************************************************/

+

+/****************************************************************************

+* 	                                        Function Prototypes

+****************************************************************************/

+#ifdef _OS_TOS

+#define wfi()	__asm__ __volatile__ ("wfi" : : : "memory")

+	

+/*

+*	memory barriers

+*/

+#define isb()   __asm__ __volatile__ ("isb" : : : "memory")

+#define dsb()   __asm__ __volatile__ ("dsb" : : : "memory")

+#define dmb()   __asm__ __volatile__ ("dmb" : : : "memory")

+	

+#define wmb()	do { dsb(); zDrvL2x0_Sync(); } while (0)

+#define rmb()	dsb()

+#endif

+	

+/****************************************************************************

+*  io operation definition

+****************************************************************************/

+/*

+*  io operation without memory barriers

+*/

+#define reg(addr)			(*(volatile unsigned *)(addr))

+#define reg8(addr)			(*(volatile unsigned char *)(addr))

+#define reg16(addr)			(*(volatile unsigned short *)(addr))

+#define reg32(addr)			(*(volatile unsigned long *)(addr))

+

+/*

+* io operation with memory barriers

+* cortex-R7 has out-of-order  instruction execution

+* these macro functions below maybe used in some special case 

+*/

+#define ioread8(p)	({ unsigned char  __v = reg8(p); rmb(); __v; })

+#define ioread16(p)	({ unsigned short __v = reg16(p)); rmb(); __v; })

+#define ioread32(p)	({ unsigned long  __v = reg32(p)); rmb(); __v; })

+	

+#define iowrite8(v,p)	({ wmb(); reg8(p) = v; })

+#define iowrite16(v,p)	({ wmb(); reg16(p) = v; })

+#define iowrite32(v,p)	({ wmb(); reg32(p) = v; })

+

+VOID zDrv_MemcpyToIo32(VOID *dst, VOID *src, UINT32 byteCount);

+

+#endif

diff --git a/cp/ps/driver/inc/pub/drvs_ret.h b/cp/ps/driver/inc/pub/drvs_ret.h
new file mode 100644
index 0000000..3792cf7
--- /dev/null
+++ b/cp/ps/driver/inc/pub/drvs_ret.h
@@ -0,0 +1,160 @@
+/*******************************************************************************

+ * Copyright (C) 2007, ZTE Corporation.

+ *

+ * File Name:    Drvs_ret.h

+ * File Mark:    

+ * Description:  Provide the declaration of return types  for HAL

+ * Others:        

+ * Version:       V0.5

+ * Author:        xiongquan

+ * Date:          2008-12-01

+ * History 1:      

+ *     Date: 

+ *     Version:

+ *     Author: 

+ *     Modification:  

+ * History 2: 

+  ********************************************************************************/

+#ifndef _DRVS_RET_H

+#define _DRVS_RET_H

+

+// the type numbers should be between -100 ~ -254 

+typedef enum

+{

+    /* 0 ~ -29: commom */

+    DRV_SUCCESS                                     = 0,        /* successed */

+    DRV_ERROR                                        = -1,      /* failed */

+    DRV_ERR_INVALID_IOCTL_CMD = -2,      /* no this control command branch */

+    DRV_ERR_NOT_SUPPORTED          = -3,      /* this function hasn't been supported */

+    DRV_ERR_INVALID_PARAM          = -4,      /* the input parameter is invalid */

+    DRV_ERR_MEM_ALLOC                  = -5,      /* failed to malloc memory */

+    DRV_ERR_HISR_CREATE_FAIL     = -6,      /* failed to create hisr */

+    DRV_ERR_TIMEOUT                         = -7,      /* timeout for a block waitting operation */

+    DRV_ERR_BUSY                                 = -8,      /* busy now to do the request operation */

+    DRV_ERR_NOT_OPENED                 = -9,      /* the device to operate hasn't been opened yet */

+    DRV_ERR_OPEN_TIMES                  = -10,    /* try to open a device which has been opened already */

+    DRV_ERR_NOT_STARTED               = -11,    /* the device to operate hasn't been started yet */

+    DRV_ERR_START_TIMES                = -12,    /* try to open a device which has been opened already */

+    /* reserved */

+

+    /* -30 ~ -39: for dal */

+    DRV_ERR_DEV_OVERFLOW     = -30,       /* no free entry to install this device. please change ZDRV_MAX_DEV_NUM in dal_api.h */

+    DRV_ERR_DEV_TABLE               = -31,       /* the device table has been destroyed */

+    DRV_ERR_FD_OVERFLOW        = -32,       /* no free entry to open this device. pleas change ZDRV_MAX_DEV_FILE_NUM in dal_api.h */

+    DRV_ERR_FD_TABLE                  = -33,      /* the file descriptor table has been destroyed */

+    DRV_ERR_INSTALLED_TIMES = -34,      /* try to install a device which hasn been installed yet */

+    DRV_ERR_NO_THIS_DEVICE    = -35,      /* try to open a device which hasn't been installed yet */

+    /* reserved */

+    

+    /*-40 ~ -59: for sio */

+    DRV_ERR_NO_CHANNEL                   = -40,         /*the used sio no channel*/

+    DRV_ERR_CHAN_CREATE_FAIL      = -41,           /*the  sio creat channel fail*/

+    DRV_ERR_DEV_STATE_WRONG      = -42,          /*the  sio state error*/

+    DRV_ERR_CHAN_DELETE_FAIL      = -43,          /*the  sio delete channel fail*/

+    DRV_ERR_DEV_READ                         = -44,      /*the  sio read data error*/

+    DRV_ERR_CHAN_SEM_USED            = -45,         /*the  sio semp has been used r*/

+    DRV_ERR_CHAN_DELETED               = -46,       /*the  sio channel has been deleted */

+    DRV_ERR_DEV_CLOSED                    = -47,        /*the  sio has been closed */

+    DRV_ERR_DEV_OPT_NULL                = -48,       /*the  sio device ptr is null*/

+    DRV_ERR_INSTALL_DRIVER_FAIL = -49,          /*the  sio install  faill*/

+    DRV_ERR_BUFFER_NOT_ENOUGH = -50,            /*the  sio data buffer not enough*/

+    /* reserved */

+

+    

+    /* -60 ~ 69: for mux */

+    DRV_ERR_MUX_INVALID_DLCI          = -60,      /* the dlci is invalid */

+    DRV_ERR_MUX_BUSY                             = -61,      /* busy now, so the required operation has been rejected */

+    DRV_ERR_MUX_NOT_READY               = -62,      /* the mux or dlci is not ready to do this required operation */

+    DRV_ERR_MUX_FLOW_CONTROLED = -63,     /* this dlc is flow-controled by the opposite station, so can't sent data any more */

+    DRV_ERR_MUX_PN_REJECTED            = -64,     /* the parameter for this dlc establishment is rejected by the opposite station */

+    DRV_ERR_MUX_BUF_IS_FULL              = -65,      /* the data buffer of this dlc is full, so can't write any more */

+    DRV_ERR_MUX_BUF_IS_EMPTY          = -66,      /* the data buffer of this dlc is empty, so no data to transfer */

+    DRV_ERR_MUX_FRAME_INVALID      = -67,      /* the frame data is invalid */

+    DRV_ERR_MUX_FRAME_UNCOMPLETE    = -68,      /* the frame data is uncomplete */

+

+    DRV_ERROR_EMPTY = -90,

+    DRV_ERROR_FULL = -91,

+    DRV_ERROR_NODEV = -92,

+    DRV_ERROR_SUSPEND = -93,

+    DRV_ERROR_AGAIN = -94,

+    DRV_ERROR_ABORT = -95,

+    DRV_ERROR_NOCONNECT = -96,

+ 

+    /*-100~-104 for spi*/

+    DRV_ERR_NOCOMPLETE              = -100,

+

+    /*-105~-109 for gpio*/

+    DRV_ERR_NOT_WRITE               = -105,

+

+    /*-110~-119 for pmic */      

+    DRV_ERR_CLIENT_NBOVERFLOW 		= -110,	/*!< The requested operation could not becompleted because there are too many PMIC client requests */

+    DRV_ERR_SPI_READ 				= -111,         

+    DRV_ERR_SPI_WRITE 				= -112,    

+    DRV_ERR_EVENT_NOT_SUBSCRIBED 	= -113,	/*!< Event occur and not subscribed       */

+    DRV_ERR_EVENT_CALL_BACK 		= -114,	/*!< Error - bad call back                */   

+    DRV_ERR_UNSUBSCRIBE				= -115,	/*!< Error in un-subscribe event          */

+

+    /*-120~-129 for sd */ 

+    DRV_ERR_INTR_TIMEOUT			= -120,

+    DRV_ERR_INTR_ERROR				= -121,

+    DRV_ERR_CARDSTATE_ERROR			= -122,

+    DRV_ERR_CARD_DISCONNECT			= -123,

+    DRV_ERR_WRITE_PROTECT			= -124,

+    DRV_ERR_PWD_ERR					= -125,

+    DRV_ERR_LOCKCARD_ERR			= -126,

+    DRV_ERR_FORCEERASE_ERR			= -127,

+    DRV_ERR_RESPONSE_ERR			= -128,

+    DRV_ERR_HLE_ERROR              = -129,

+    DRV_ERR_EIO                     = -130, /*IO Error*/

+    DRV_ERR_ERANGE                  = -131, /* Math result not representable */

+    DRV_ERR_EINPROGRESS             = -132, /* Operation now in progress */

+    DRV_ERR_ENODEV                  = -133, /*no such device*/

+    DRV_ERR_BADMSG                  = -134, /*not a date message*/

+    DRV_ERR_ENOENT                  = -135, /* No such file or directory */ 

+    DRV_ERR_ILSEQ		            = -136,	/* Illegal byte sequence */

+

+    /*-137~-140 for i2c */ 

+    DRV_ERR_ADDR_TRANSFER 			= -137,

+    DRV_ERR_DATA_TRANSFER 			= -138,

+    DRV_ERR_AGAIN 					= -139,

+    DRV_ERR_NOACK 					= -140,

+

+

+

+    /*-141~-156 for usb */ 

+    DRV_ERR_NOT_READY               	= -141,

+    DRV_ERR_STATUS_BUSY             = -142,

+    DRV_ERR_STALL                   	= -143,

+    DRV_ERR_END                     		= -144,

+    DRV_ERR_USB_BUF_STATE   	= -145,

+    DRV_ERR_USB_BUF_FULL            = -146,

+    DRV_ERR_USB_BUF_EMPTY         = -147,

+    DRV_ERR_USB_QMI_UNDERRUN  = -148,

+    DRV_ERR_USB_QMI_OVERRUN     = -149,

+    DRV_ERR_USB_QMI_READ0         = -150,

+    DRV_ERR_USB_UNCONNECTED    = -151,

+    DRV_ERR_QMI_HEADER_ERR       = -152,

+    DRV_ERR_QMI_CTL_ERR       = -153,

+    DRV_ERR_QMI_WDS_ERR       = -154,

+    DRV_ERR_QMI_DMS_ERR       = -155,

+    DRV_ERR_QMI_NAS_ERR       = -156,

+

+    /*-160~-180 for nand */

+    DRV_ERR_LEN_ADDRESS  	        = -160,     /* ²Ù×÷µØÖ·´íÎó */

+    DRV_ERR_COMMAND      	        = -161,     /* ÃüÁîÂë´íÎó */

+    DRV_ERR_PE_ERROR                = -162,     /* ÉÕд´íÎó */

+    DRV_ERR_NAND_BUSY    	        = -163,     /* оƬæ */

+    DRV_ERR_PROTECTED    	        = -164,     /* ±£»¤ÇøÓò */

+    DRV_ERR_BANK_ERROR   	        = -165,     /* BANK´íÎó */

+    DRV_ERR_UNKNOWN      	        = -166,     /* UNKNOWN´íÎó */

+    DRV_ERR_LENGTH		            = -167,

+

+    /*-150~-154 for backlight */

+    DRV_ERR_INTERNAL_PERIOD         = -180,

+    DRV_ERR_INTERNAL_FREQ           = -181

+	

+	

+}T_DRVS_RETURN_TYPE;

+

+#endif

+

diff --git a/cp/ps/driver/inc/pub/drvs_ring.h b/cp/ps/driver/inc/pub/drvs_ring.h
new file mode 100644
index 0000000..4ac0d24
--- /dev/null
+++ b/cp/ps/driver/inc/pub/drvs_ring.h
@@ -0,0 +1,251 @@
+/*******************************************************************************

+ * Copyright (C) 2008, ZTE Corporation.

+ *

+ * File Name:    drvs_ring.h

+ * File Mark:

+ * Description:

+ * Others:

+ * Version:       V1.0

+ * Author:        qinxiao

+ * Date:          2009-09-03

+ * History 1:   created

+ *     Date:

+ *     Version:

+ *     Author:

+ *     Modification:

+  ********************************************************************************/

+#ifndef DRVS_RING_H

+#define DRVS_RING_H

+

+#ifdef __cplusplus

+   extern "C"

+   {

+#endif 

+

+/****************************************************************************

+* 	                        Include files

+****************************************************************************/

+

+/****************************************************************************

+* 	                         Macros

+****************************************************************************/

+

+/****************************************************************************

+* 	                         Types

+****************************************************************************/

+typedef struct _T_Hal_Ring

+{

+	UINT32 writePos;    /* offset from start of buffer where to write next */

+	UINT32 readPos;	    /* offset from start of buffer where to read next */

+	UINT32 bufSize;		/* size of ring in bytes */

+	UINT8 *pBuf;			/* pointer to start of buffer */

+}T_Hal_Ring;

+

+/****************************************************************************

+* 	                         Constants

+****************************************************************************/

+

+/****************************************************************************

+* 	                         Global  Variables

+****************************************************************************/

+

+/****************************************************************************

+* 	                         Function Prototypes

+****************************************************************************/

+/******************************************************************************

+ * Function:	hal_RingIsEmpty

+ * Description:		Åжϻ·Ðλº³åÊÇ·ñΪ¿Õ

+ * Parameters:

+ *   Input:

+ *			pRing - :»·Ðλº³åÖ¸Õë

+ *   Output:

+ *			None

+ * Returns:

+ *			¿Õ:TRUE; ·Ç¿Õ:FALSE

+ *

+ * Others:

+ ******************************************************************************/

+BOOL hal_RingIsEmpty( T_Hal_Ring *pRing);

+

+/******************************************************************************

+ * Function:	hal_RingIsFull

+ * Description:		Åжϻ·Ðλº³åÊÇ·ñÒÑÂú

+ * Parameters:

+ *   Input:

+ *			pRing -- »·Ðλº³åÖ¸Õë

+ *   Output:

+ *			None

+ * Returns:

+ *			Âú:TRUE; ·ÇÂú:FALSE

+ *

+ * Others:

+ ******************************************************************************/

+BOOL hal_RingIsFull(T_Hal_Ring *pRing);

+

+/******************************************************************************

+ * Function:	hal_RingCreate

+ * Description:		´´½¨»·Ðλº³å

+ * Parameters:

+ *   Input:

+ *			nbytes -- »·Ðλº³åµÄ´óС£¬µ¥Î»£º×Ö½Ú

+ *   Output:

+ *			None

+ * Returns:

+ *			³É¹¦£º»·Ðλº³åID; ʧ°Ü:hal_NULL

+ *

+ * Others:

+ ******************************************************************************/

+T_Hal_Ring *hal_RingCreate(UINT32 nBytes);

+

+/******************************************************************************

+ * Function:	hal_RingDelete

+ * Description:		ɾ³ý»·Ðλº³å

+ * Parameters:

+ *   Input:

+ *			pRing -- »·Ðλº³åÖ¸Õë

+ *   Output:

+ *			None

+ * Returns:

+ *			None

+ *

+ * Others:

+ ******************************************************************************/

+VOID hal_RingDelete(T_Hal_Ring * pRing);

+

+/******************************************************************************

+ * Function:	hal_RingRead

+ * Description:		¶ÁÈ¡»·Ðλº³å¶ÓÁеÄÊý¾Ý

+ * Parameters:

+ *   Input:

+ *			pRing -- »·Ðλº³åÖ¸Õë

+ *			pBuffer -- Êä³ö»º³åÖ¸Õë	  

+ *			maxbytes -- ÐèÒª¶ÁÈ¡µÄ×î´ó×Ö½ÚÊý

+ *   Output:

+ *			buffer -- Êä³ö»º³åÖ¸Õë	

+ * Returns:

+ *			ʵ¼Ê¶ÁÈ¡µÄ×Ö½ÚÊý

+ *

+ * Others: ·µ»ØÖµ¿ÉÄÜÓëÐèÒª¶ÁÈ¡µÄ×Ö½ÚÊý²»Ò»Ö¡£Èç¹û»º³åΪ¿Õ£¬Ôò·µ»Ø0.

+ ******************************************************************************/

+UINT32 hal_RingRead(T_Hal_Ring *pRing, UINT8 *pBuffer, UINT32 maxBytes);

+

+/******************************************************************************

+ * Function:	hal_RingWrite

+ * Description:	Ïò»·Ðλº³åдÈëÊý¾Ý

+ * Parameters:

+ *   Input:

+ *			pRing -- »·Ðλº³åÖ¸Õë

+ *			pBuffer -- Êä³ö»º³åÖ¸Õë	  

+ *			nBytes -- ´ýдÈëÊý¾ÝµÄ´óС

+ *   Output:

+ *			None

+ * Returns:

+ *			ʵ¼ÊдÈëµÄ×Ö½ÚÊý

+ *

+ * Others: ·µ»ØÖµ¿ÉÄÜÓëÐèҪдÈëµÄ×Ö½ÚÊý²»Ò»Ö¡£Èç¹û»º³åΪÂú£¬Ôò·µ»Ø0.

+ ******************************************************************************/

+UINT32 hal_RingWrite(T_Hal_Ring * pRing, UINT8 *pBuffer, UINT32 nBytes);

+

+/******************************************************************************

+ * Function:	hal_RingFreeBytes

+ * Description:	»ñÈ¡»·Ðλº³åÊ£Óà¿ÉÀûÓÃ×Ö½ÚÊý

+ * Parameters:

+ *   Input:

+ *			pRing -- »·Ðλº³åÖ¸Õë

+ *   Output:

+ *			None

+ * Returns:

+ *			Ê£Óà¿ÉÀûÓÿռä×Ö½ÚÊý

+ *

+ * Others: 

+ ******************************************************************************/

+UINT32 hal_RingFreeBytes(T_Hal_Ring *pRing);

+ 

+/******************************************************************************

+ * Function:	hal_RingUsedBytes

+ * Description:	»ñÈ¡»·Ðλº³åÒÑʹÓõÄ×Ö½ÚÊý

+ * Parameters:

+ *   Input:

+ *			pRing -- »·Ðλº³åÖ¸Õë

+ *   Output:

+ *			None

+ * Returns:

+ *			ÒÑʹÓõÄ×Ö½ÚÊý

+ *

+ * Others: 

+ ******************************************************************************/

+UINT32 hal_RingUsedBytes(T_Hal_Ring *pRing);

+ 

+/******************************************************************************

+ * Function:	hal_RingFlush

+ * Description:	Çå³ý»·Ðλº³åµÄËùÓÐÊý¾Ý

+ * Parameters:

+ *   Input:

+ *			pRing -- »·Ðλº³åÖ¸Õë

+ *   Output:

+ *			None

+ * Returns:

+ *          None

+ * Others: 

+ ******************************************************************************/

+VOID hal_RingFlush(T_Hal_Ring * pRing);

+#if 0

+/******************************************************************************

+ * Function:	hal_RingMoveAhead

+ * Description:	½«»·Ðλº³åµÄдָÕëÒÆ¶¯¼¸¸ö×Ö½Ú

+ * Parameters:

+ *   Input:

+ *			pRing -- »·Ðλº³åÖ¸Õë

+ *          nBytes -- ÐèÒªÒÆ¶¯µÄ×Ö½ÚÊý,ÕýÊýÏòÇ°ÒÆ¶¯£¬¸ºÊýÏòºóÒÆ¶¯£»

+ *                    ·¶Î§:-»·Ðλº³å×î´ó×Ö½ÚÊý-- +»·Ðλº³å×î´ó×Ö½ÚÊý

+ *   Output:

+ *			None

+ * Returns:

+ *          None

+ * Others: µ±Ð´Ö¸Õ볬³ö¶ÓÁÐ×î´ó³¤¶Èʱ£¬»á×Ô¶¯»·ÐÎ.

+ ******************************************************************************/

+VOID hal_RingMoveWritePos(T_Hal_Ring * pRing, SINT32 nBytes);

+ 

+/******************************************************************************

+ * Function:	hal_RingMoveAhead

+ * Description:	Ïò»·Ðλº³åµ±Ç°Ð´Ö¸ÕëµÄÆ«ÒÆ´¦£¬Ð´ÈëÒ»¸öÊý¾Ý

+ *              ²»Òƶ¯Ð´Ö¸Õë

+ * Parameters:

+ *   Input:

+ *			pRing -- »·Ðλº³åÖ¸Õë

+ *          byte:´ýдÈëµÄÊý¾Ý

+ *          offset -- Æ«ÒÆÁ¿, ÕýÊýÏòÇ°ÒÆ¶¯, ¸ºÊýÏòºóÒÆ¶¯;

+ *                    ·¶Î§:-»·Ðλº³å×î´ó×Ö½ÚÊý-- +»·Ðλº³å×î´ó×Ö½ÚÊý,

+ *   Output:

+ *			None

+ * Returns:

+ *          None

+ * Others: µ±Ð´Ö¸Õ볬³ö¶ÓÁÐ×î´ó³¤¶Èʱ£¬»á×Ô¶¯»·ÐÎ.

+ ******************************************************************************/

+VOID hal_RingPutAhead(T_Hal_Ring * pRing, UINT8 byte, SINT32 offset);

+

+/******************************************************************************

+ * Function:	hal_RingGetPossibleReadBlock

+ * Description:	»ñÈ¡»·Ðλº³å¿É¶ÁÈ¡µÄ×Ö½ÚÊýºÍÖ¸Õë

+ * Parameters:

+ *   Input:

+ *			pRing -- »·Ðλº³åÖ¸Õë

+ *   Output:

+ *			nBytes -- ¿É¶ÁÈ¡×Ö½ÚÊý

+ *          UINT8 * -- bufferÖ¸Õë

+ * Returns:

+ *			ÒÑʹÓõÄ×Ö½ÚÊý

+ *

+ * Others: 

+ ******************************************************************************/

+UINT8 *hal_RingGetPossibleReadBlock(T_Hal_Ring * pRing, UINT32 *nBytes);

+

+VOID hal_RingMoveReadPos(T_Hal_Ring * pRing, SINT32 nBytes);

+#endif

+

+#ifdef __cplusplus

+}

+#endif

+

+#endif

+