[T106][ZXW-22]7520V3SCV2.01.01.02P42U09_VEC_V0.8_AP_VEC origin source commit
Change-Id: Ic6e05d89ecd62fc34f82b23dcf306c93764aec4b
diff --git a/cp/ps/driver/src/public/inc/io_request.h b/cp/ps/driver/src/public/inc/io_request.h
new file mode 100644
index 0000000..1d143ce
--- /dev/null
+++ b/cp/ps/driver/src/public/inc/io_request.h
@@ -0,0 +1,335 @@
+/*******************************************************************************
+ * Copyright (C) 2007, ZTE Corporation.
+ *
+ * File Name:io_request.h
+ * File Mark:
+ * Description:
+ * Others:
+ * Version: 1.0
+ * Author: geanfeng
+ * Date: 2013-09-25
+ * History 1:
+ * Date:
+ * Version:
+ * Author:
+ * Modification:
+ * History 2:
+ ********************************************************************************/
+
+#ifndef _IO_REQUEST_H
+#define _IO_REQUEST_H
+
+/****************************************************************************
+* Include files
+****************************************************************************/
+#include "drvs_list.h"
+#include "ring_queue.h"
+#include "request_queue.h"
+/****************************************************************************
+* Macros
+****************************************************************************/
+/****************************************************************************
+* Types
+****************************************************************************/
+typedef enum _T_DONE_STATE {
+ REQUEST_SUCCESS = 0,
+ REQUEST_NODEV,
+ REQUEST_ERROR,
+}T_DONE_STATE;
+
+typedef enum _T_IO_HND_STATE
+{
+ IO_REQUEST_UNCREATED = 0,
+ IO_REQUEST_CREATED,
+ IO_REQUEST_FORCE_EXIT,
+}
+T_IO_HND_STATE;
+
+typedef enum _T_IO_REQUEST_STATE
+{
+ IO_REQUEST_STOP = 0,
+ IO_REQUEST_START,
+ IO_REQUEST_START_TO_SUSPEND,
+ IO_REQUEST_STOP_TO_SUSPEND,
+}
+T_IO_REQUEST_STATE;
+
+
+typedef enum _T_IO_REQUEST_DIRECTION
+{
+ IO_REQUEST_READ = 0,
+ IO_REQUEST_WRITE,
+ IO_REQUEST_READ_WRITE,
+}
+T_IO_REQUEST_DIRECTION;
+
+
+typedef enum _T_IO_REQUEST_BLOCK_TYPE
+{
+ IO_REQUEST_NO_WAIT = 0,
+ IO_REQUEST_WAIT_FOREVER,
+}
+T_IO_REQUEST_BLOCK_TYPE;
+
+typedef struct _T_IO_RequestOps
+{
+ SINT32 (*hal_enable)(VOID *reqHndData);
+ SINT32 (*hal_disable)(VOID *reqHndData);
+ SINT32 (*start_request)(VOID *reqHndData, T_IO_REQUEST_DIRECTION reqDirection);
+ VOID (*free_request) (VOID *reqHndData, T_IO_REQUEST_DIRECTION reqDirection, T_Request *req);
+ SINT32 (*request_done)(VOID *reqHndData, T_Request *req, T_DONE_STATE doneState);
+}
+T_IO_RequestOps;
+
+typedef struct _T_Request_SgList
+{
+ UINT8 *reqBuffer;
+ UINT32 reqCount;
+}
+T_Request_SgList;
+
+
+typedef struct _T_IO_RequestHnd T_IO_RequestHnd;
+
+typedef SINT32 (*RequestDoneHnd)(T_IO_RequestHnd *, T_Request_SgList *, T_DONE_STATE);
+
+
+typedef struct _T_IO_RequestHnd
+{
+ struct list_head node; /* node*/
+ UINT8 *name;
+ T_IO_REQUEST_DIRECTION reqDirection;
+ UINT32 reqSize;
+ volatile T_IO_HND_STATE hndState;
+ UINT32 isSuspend;
+ UINT32 halEnabled;
+ T_IO_RequestOps *ops;
+ VOID *reqHndData;
+
+ /*read*/
+ UINT32 readReqCount;
+ T_Request_Queue *readQ;
+ T_Ring_Queue *readDoneBuffer;
+ T_IO_REQUEST_STATE readReqState;
+ ZOSS_SEMAPHORE_ID readReqSem;
+ RequestDoneHnd readDoneFn;
+ T_Request_SgList readSgList;
+ UINT32 readSgListMaxCount;
+ UINT32 readFreeCnt;
+
+ /*write*/
+ UINT32 writeReqCount;
+ T_Request_Queue *writeQ;
+ T_IO_REQUEST_STATE writeReqState;
+ ZOSS_SEMAPHORE_ID writeReqSem;
+ RequestDoneHnd writeDoneFn;
+ T_Request_SgList writeSgList;
+ UINT32 writeSgListMaxCount;
+ UINT32 writeFreeCnt;
+
+}
+T_IO_RequestHnd;
+
+
+/****************************************************************************
+* Constants
+****************************************************************************/
+
+/****************************************************************************
+* Global Variables
+****************************************************************************/
+
+/****************************************************************************
+* Function Prototypes
+****************************************************************************/
+
+/*******************************************************************************
+ * Function: IORequest_Create
+ * Description:create the IO request handle, configure the params.
+ * Input:
+ * Output:None
+ *
+ * Returns:
+ DRV_SUCCESS: success.
+ DRV_ERROR: error.
+ * Others:.
+ ********************************************************************************/
+T_IO_RequestHnd * IORequest_Create(UINT8* name,
+ T_IO_REQUEST_DIRECTION reqDirection, UINT32 reqSize,
+ VOID *reqHndData, T_IO_RequestOps *ops,
+ UINT32 readReqCount, UINT32 readSgListMaxCount,
+ UINT32 writeReqCount, UINT32 writeSgListMaxCount);
+
+/*******************************************************************************
+ * Function: IORequest_SubmitReadRequest
+ * Description:submit the read request.
+ * Input:
+ * reqHnd: the handle of request.
+ * req: the submit request.
+ * Output:None
+ *
+ * Returns:
+ * DRV_SUCCESS: success
+ ********************************************************************************/
+SINT32 IORequest_SubmitReadRequest(T_IO_RequestHnd *reqHnd, T_Request *req);
+
+/*******************************************************************************
+ * Function: IORequest_FetchDoneRequest
+ * Description:fetch the completed read request.
+ * Input:
+ * reqHnd: the handle of request.
+ * blockType: the block type of this operation. no wait or wait forever.
+ * Output:None
+ * req: the complete read request.
+ * Returns:
+ * DRV_SUCCESS: success
+ * DRV_ERROR_AGAIN: no wait, need fetch again.
+ * DRV_ERROR_ABORT: force exit.
+ * Others:
+ ********************************************************************************/
+SINT32 IORequest_FetchDoneRequest(T_IO_RequestHnd *reqHnd, T_Request *req, T_IO_REQUEST_BLOCK_TYPE blockType);
+
+/*******************************************************************************
+ * Function: IORequest_SubmitWriteRequest
+ * Description:submit the write request.
+ * Input:
+ * reqHnd: the handle of request.
+ * req: the submit request.
+ * blockType: the block type of this operation. no wait or wait forever.
+ * Output:None
+ *
+ * Returns:
+ * DRV_SUCCESS: success
+ * DRV_ERROR_AGAIN: no wait, submit again.
+ * DRV_ERROR_ABORT: force exit.
+ * Others:
+ ********************************************************************************/
+SINT32 IORequest_SubmitWriteRequest(T_IO_RequestHnd *reqHnd, T_Request *req, T_IO_REQUEST_BLOCK_TYPE blockType);
+
+/*******************************************************************************
+ * Function: IORequest_WaitRequestDone
+ * Description:wait the write request done.
+ * Input:
+ * reqHnd: the handle of request.
+ * Output:None
+ *
+ * Returns:
+ * DRV_SUCCESS: success
+ * DRV_ERROR_ABORT: force exit.
+ * Others:
+ ********************************************************************************/
+SINT32 IORequest_WaitRequestDone(T_IO_RequestHnd *reqHnd);
+
+/*******************************************************************************
+ * Function: IORequest_GetSgList
+ * Description:get the current requests scatter list.
+ * Input:
+ * Output:None
+ *
+ * Returns:
+ T_Request_SgList* : success.
+ NULL: error
+ * Others:
+ ********************************************************************************/
+T_Request_SgList* IORequest_GetSgList(T_IO_RequestHnd *reqHnd, T_IO_REQUEST_DIRECTION reqDirection);
+
+/*******************************************************************************
+ * Function: IORequest_Done
+ * Description:has complete the request, take next proccess .
+ * Input:
+ * Output:None
+ *
+ * Returns:
+ DRV_SUCCESS: success.
+ DRV_ERROR: error.
+ * Others:×¢Òâ:µ÷Óô˽ӿڵÄÓÅÏȼ¶Ò»¶¨¸ßÓÚÄ£¿éÄ򵀮äËû½Ó¿Ú£¬²»¿É±»´ò¶Ï¡£
+ ********************************************************************************/
+SINT32 IORequest_Done(T_IO_RequestHnd *reqHnd, T_IO_REQUEST_DIRECTION reqDirection);
+
+/*******************************************************************************
+ * Function: IORequest_Suspend
+ * Description:suspend the request process, stop the hal operation.
+ * Input:
+ * Output:None
+ *
+ * Returns:
+ DRV_SUCCESS: success.
+ DRV_ERROR: error.
+ * Others:
+ ********************************************************************************/
+SINT32 IORequest_Suspend(T_IO_RequestHnd *reqHnd);
+
+/*******************************************************************************
+ * Function: IORequest_Resume
+ * Description:resume the request process, and restart the stopped hal operation.
+ * Input:
+ * Output:None
+ *
+ * Returns:
+ DRV_SUCCESS: success.
+ DRV_ERROR: error.
+ * Others:
+ ********************************************************************************/
+VOID IORequest_Resume(T_IO_RequestHnd *reqHnd);
+
+/*******************************************************************************
+ * Function: IORequest_ForceExit
+ * Description: force the higher process exit.
+ * Input:
+ * Output:None
+ *
+ * Returns:
+ DRV_SUCCESS: success.
+ DRV_ERROR: error.
+ * Others:
+ ********************************************************************************/
+VOID IORequest_ForceExit(T_IO_RequestHnd *reqHnd);
+/*******************************************************************************
+ * Function: IORequest_CancelExit
+ * Description: cancel exit mode, alloc higher process enter iorequest module.
+ * Input:
+ * Output:None
+ *
+ * Returns:
+ * Others:
+ ********************************************************************************/
+VOID IORequest_CancelExit(T_IO_RequestHnd *reqHnd);
+/*******************************************************************************
+ * Function: IORequest_Destroy
+ * Description:release the IO Request Handle, and inform the higher layer.
+ * Input:
+ * Output:None
+ *
+ * Returns:
+
+ * Others:×¢Òâ:º¯Êý²»¸ºÔðÊÍ·ÅreqHnd¿Õ¼ä£¬½öÉèÖúÏÊÊ״̬.
+ ÔÚÉϲãÈ·±£Ê±»ú°²È«ºó£¬²Å¿ÉÊͷŸÿռ䡣
+ ********************************************************************************/
+VOID IORequest_Destroy(T_IO_RequestHnd *reqHnd);
+
+/*******************************************************************************
+ * Function: IORequest_Print
+ * Description:print the debug info.
+ * Input:
+ * Output:None
+ *
+ * Returns:
+
+ * Others:
+ ********************************************************************************/
+VOID IORequest_Print(T_IO_RequestHnd *reqHnd);
+
+/*******************************************************************************
+ * Function: IORequest_PrintAll
+ * Description:print the debug info.
+ * Input:
+ * Output:None
+ *
+ * Returns:
+
+ * Others:
+ ********************************************************************************/
+VOID IORequest_PrintAll(VOID);
+
+#endif/*_IO_REQUEST_H*/
+
diff --git a/cp/ps/driver/src/public/inc/qalloc.h b/cp/ps/driver/src/public/inc/qalloc.h
new file mode 100644
index 0000000..98ab2b4
--- /dev/null
+++ b/cp/ps/driver/src/public/inc/qalloc.h
@@ -0,0 +1,137 @@
+/*******************************************************************************
+ * Copyright (C) 2007, ZTE Corporation.
+ *
+ * File Name:hal_qalloc.h
+ * File Mark:
+ * Description:
+ * Others:
+ * Version: 1.0
+ * Author: geanfeng
+ * Date: 2013-09-25
+ * History 1:
+ * Date:
+ * Version:
+ * Author:
+ * Modification:
+ * History 2:
+ ********************************************************************************/
+
+#ifndef _HAL_QALLOC_H
+#define _HAL_QALLOC_H
+
+
+/****************************************************************************
+* Include files
+****************************************************************************/
+#include "drvs_general.h"
+#include "drvs_list.h"
+/****************************************************************************
+* Macros
+****************************************************************************/
+
+/****************************************************************************
+* Types
+****************************************************************************/
+/*
+ * General purpose special memory pool descriptor.
+ */
+typedef struct _T_Quick_Pool {
+ struct list_head node; /* node*/
+ struct list_head chunks; /* list of chunks in this pool */
+ UINT32 count;
+ UINT8* name;
+}T_Quick_Pool;
+
+/****************************************************************************
+* Constants
+****************************************************************************/
+
+/****************************************************************************
+* Global Variables
+****************************************************************************/
+
+/****************************************************************************
+* Function Prototypes
+****************************************************************************/
+
+/**
+ * QPool_Create - create a new special memory pool
+*
+ * Create a new special memory pool that can be used to manage special purpose
+ * memory not managed by the regular kmalloc/kfree interface.
+ */
+T_Quick_Pool *QPool_Create(UINT8* name);
+
+/**
+ * QPool_AddVirt - add a new chunk of special memory to the pool
+ * @pool: pool to add new memory chunk to
+ * @virt: virtual starting address of memory chunk to add to pool
+ * @phys: physical starting address of memory chunk to add to pool
+ * @size: size in bytes of the memory chunk to add to pool
+ *
+ * Add a new chunk of special memory to the specified pool.
+ *
+ * Returns 0 on success or a -ve errno on failure.
+ */
+SINT32 QPool_AddVirt(T_Quick_Pool *pool,UINT32 virt, UINT32 size,
+ UINT32 page_size, UINT32 max_alloc_order);
+
+/**
+ * QPool_Alloc - allocate special memory from the pool
+ * @pool: pool to allocate from
+ * @size: number of bytes to allocate from the pool
+ * @debug_info: some debug info
+ *
+ * Allocate the requested number of bytes from the specified pool.
+ * Uses a first-fit algorithm.
+ */
+UINT32 QPool_Alloc(T_Quick_Pool *pool, UINT32 size, VOID *debug_info);
+
+/**
+ * QPool_Free - free allocated special memory back to the pool
+ * @pool: pool to free to
+ * @addr: starting address of memory to free back to pool
+ * @size: size in bytes of memory to free
+ *
+ */
+VOID QPool_Free(T_Quick_Pool *pool, UINT32 addr, VOID *debug_info);
+
+/**
+ * QPool_Destroy - destroy a special memory pool
+ *
+ * Destroy the specified special memory pool. Verifies that there are no
+ * outstanding allocations.
+ */
+VOID QPool_Destroy(T_Quick_Pool *pool);
+
+/**
+ * gen_pool_avail - get available free space of the pool
+ * @pool: pool to get available free space
+ *
+ * Return available free space of the specified pool.
+ */
+UINT32 QPool_Avail(T_Quick_Pool *pool);
+
+/**
+ * QPool_Size - get size in bytes of memory managed by the pool
+ * @pool: pool to get size
+ *
+ * Return size in bytes of memory managed by the pool.
+ */
+UINT32 QPool_Size(T_Quick_Pool *pool);
+
+/**
+ * QPool_Print - print the pool debug info.
+ * @pool: pool to print
+ *
+ */
+VOID QPool_Print(T_Quick_Pool *pool);
+
+/**
+ * QPool_PrintAll - print the all pool debug info.
+ *
+ */
+VOID QPool_PrintAll(VOID);
+
+#endif/*_HAL_TCLK_REG_H*/
+
diff --git a/cp/ps/driver/src/public/inc/random.h b/cp/ps/driver/src/public/inc/random.h
new file mode 100644
index 0000000..4c5de4d
--- /dev/null
+++ b/cp/ps/driver/src/public/inc/random.h
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * Copyright (C) 2007, ZTE Corporation.
+ *
+ * File Name:random.h
+ * File Mark:
+ * Description:
+ * Others:
+ * Version: 1.0
+ * Author: geanfeng
+ * Date: 2013-09-25
+ * History 1:
+ * Date:
+ * Version:
+ * Author:
+ * Modification:
+ * History 2:
+ ********************************************************************************/
+
+#ifndef _RANDOM_H
+#define _RANDOM_H
+
+/****************************************************************************
+* Include files
+****************************************************************************/
+#include "drvs_general.h"
+/****************************************************************************
+* Macros
+****************************************************************************/
+
+/****************************************************************************
+* Types
+****************************************************************************/
+
+
+/****************************************************************************
+* Constants
+****************************************************************************/
+
+/****************************************************************************
+* Global Variables
+****************************************************************************/
+
+/****************************************************************************
+* Function Prototypes
+****************************************************************************/
+/*******************************************************************************
+ * Function: random32
+ * Description:
+ * Input:
+ * Output:None
+ *
+ * Returns:
+ UINT32: value
+ * Others:
+ ********************************************************************************/
+UINT32 random32(VOID);
+
+
+
+#endif/*_RING_QUEUE_H*/
+
diff --git a/cp/ps/driver/src/public/inc/request_queue.h b/cp/ps/driver/src/public/inc/request_queue.h
new file mode 100644
index 0000000..357694a
--- /dev/null
+++ b/cp/ps/driver/src/public/inc/request_queue.h
@@ -0,0 +1,94 @@
+/*******************************************************************************
+ * Copyright (C) 2007, ZTE Corporation.
+ *
+ * File Name:request_queue.h
+ * File Mark:
+ * Description:
+ * Others:
+ * Version: 1.0
+ * Author: geanfeng
+ * Date: 2013-09-25
+ * History 1:
+ * Date:
+ * Version:
+ * Author:
+ * Modification:
+ * History 2:
+ ********************************************************************************/
+
+#ifndef _REQUEST_QUEUE_H
+#define _REQUEST_QUEUE_H
+
+/****************************************************************************
+* Include files
+****************************************************************************/
+#include "drvs_general.h"
+#include "ring_queue.h"
+/****************************************************************************
+* Macros
+****************************************************************************/
+
+/****************************************************************************
+* Types
+****************************************************************************/
+typedef enum _T_QUEUE_STATE{
+ QUEUE_IDLE,
+ QUEUE_SUBMITING,
+ QUEUE_SUSPEND,
+ QUEUE_WORKING,
+}T_QUEUE_STATE;
+
+
+typedef struct _T_Request_Queue T_Request_Queue;
+typedef struct _T_Request T_Request;
+
+typedef SINT32 (*queue_notify)(T_Request_Queue *);
+
+
+/*
+ * request state
+ */
+typedef struct _T_Request_Queue {
+ T_Ring_Queue *queue;
+
+ T_QUEUE_STATE work_state;
+ T_QUEUE_STATE process_state;
+
+ queue_notify notify_fn;
+ VOID *queue_data;
+}T_Request_Queue;
+
+/*
+ * request
+ */
+typedef struct _T_Request {
+ VOID *data;
+}T_Request;
+
+
+
+/****************************************************************************
+* Constants
+****************************************************************************/
+
+/****************************************************************************
+* Global Variables
+****************************************************************************/
+
+/****************************************************************************
+* Function Prototypes
+****************************************************************************/
+T_Request_Queue *requestQueue_Create(unsigned long req_count, unsigned long req_size, queue_notify notify_fn, VOID* queue_data);
+
+SINT32 requestQueue_SubmitRequest(T_Request_Queue *q, T_Request *req);
+
+SINT32 requestQueue_FetchRequest(T_Request_Queue *q, T_Request *req);
+
+SINT32 requestQueue_Suspend(T_Request_Queue *q);
+
+SINT32 requestQueue_Resume(T_Request_Queue *q);
+
+VOID requestQueue_Destroy(T_Request_Queue *q);
+
+#endif/*_REQUEST_QUEUE_H*/
+
diff --git a/cp/ps/driver/src/public/inc/ring_queue.h b/cp/ps/driver/src/public/inc/ring_queue.h
new file mode 100644
index 0000000..1da1af3
--- /dev/null
+++ b/cp/ps/driver/src/public/inc/ring_queue.h
@@ -0,0 +1,81 @@
+/*******************************************************************************
+ * Copyright (C) 2007, ZTE Corporation.
+ *
+ * File Name:ring_queue.h
+ * File Mark:
+ * Description:
+ * Others:
+ * Version: 1.0
+ * Author: geanfeng
+ * Date: 2013-09-25
+ * History 1:
+ * Date:
+ * Version:
+ * Author:
+ * Modification:
+ * History 2:
+ ********************************************************************************/
+
+#ifndef _RING_QUEUE_H
+#define _RING_QUEUE_H
+
+/****************************************************************************
+* Include files
+****************************************************************************/
+#include "drvs_general.h"
+/****************************************************************************
+* Macros
+****************************************************************************/
+
+/****************************************************************************
+* Types
+****************************************************************************/
+typedef enum _T_USER_PROTECT_POLICY {
+ QUEUE_PROTECT_RAW = 0,
+ QUEUE_PROTECT_MUTEX,
+ QUEUE_PROTECT_IRQ,
+}T_USER_PROTECT_POLICY;
+
+typedef struct _T_Ring_Queue {
+ UINT8 *unit_buffer;
+ UINT32 unit_buffer_size;
+ UINT32 unit_size;
+ UINT32 unit_count;
+ UINT32 write_pos;
+ UINT32 read_pos;
+
+ T_USER_PROTECT_POLICY multi_user_protect;
+ ZOSS_SEMAPHORE_ID lock;
+}T_Ring_Queue;
+
+/****************************************************************************
+* Constants
+****************************************************************************/
+
+/****************************************************************************
+* Global Variables
+****************************************************************************/
+
+/****************************************************************************
+* Function Prototypes
+****************************************************************************/
+T_Ring_Queue *ringQueue_Create(UINT32 unit_count, UINT32 unit_size, T_USER_PROTECT_POLICY multi_user_protect);
+
+SINT32 ringQueue_Init(T_Ring_Queue *queue, UINT8 *unit_buffer,
+ UINT32 unit_count, UINT32 unit_size, T_USER_PROTECT_POLICY protect_policy);
+
+SINT32 ringQueue_Enqueue(T_Ring_Queue *queue, VOID *unit);
+
+SINT32 ringQueue_Dequeue(T_Ring_Queue *queue, VOID *unit);
+
+SINT32 ringQueue_Empty(T_Ring_Queue *queue);
+
+SINT32 ringQueue_Full(T_Ring_Queue *queue);
+
+VOID ringQueue_Fush(T_Ring_Queue *queue);
+
+VOID ringQueue_Destroy(T_Ring_Queue *queue);
+
+
+#endif/*_RING_QUEUE_H*/
+