| lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 1 | /*******************************************************************************
 | 
 | 2 |  * Copyright (C) 2007, ZTE Corporation.
 | 
 | 3 |  *
 | 
 | 4 |  * File Name:
 | 
 | 5 |  * File Mark:
 | 
 | 6 |  * Description:
 | 
 | 7 |  * Others:
 | 
 | 8 |  * Version:       1.0
 | 
 | 9 |  * Author:        geanfeng
 | 
 | 10 |  * Date:          2013-09-25
 | 
 | 11 |  * History 1:
 | 
 | 12 |  *     Date:
 | 
 | 13 |  *     Version:
 | 
 | 14 |  *     Author:
 | 
 | 15 |  *     Modification:
 | 
 | 16 |  * History 2:
 | 
 | 17 |   ********************************************************************************/
 | 
 | 18 | 
 | 
 | 19 | #ifndef _DRVS_IO_H_
 | 
 | 20 | #define _DRVS_IO_H_
 | 
 | 21 | 
 | 
 | 22 | /****************************************************************************
 | 
 | 23 | * 	                                        Include files
 | 
 | 24 | ****************************************************************************/
 | 
 | 25 | #include "drvs_io_keys.h"
 | 
 | 26 | #include "drvs_io_names.h"
 | 
 | 27 | 
 | 
 | 28 | /****************************************************************************
 | 
 | 29 | * 	                                        Macros
 | 
 | 30 | ****************************************************************************/
 | 
 | 31 | #define ZDRVIO_INVALID_HANDLE  NULL
 | 
 | 32 | 
 | 
 | 33 | 
 | 
 | 34 | /****************************************************************************
 | 
 | 35 | * 	                                        Types
 | 
 | 36 | ****************************************************************************/
 | 
 | 37 | /*IO handle*/
 | 
 | 38 | typedef void * T_ZDrvIO_Handle;
 | 
 | 39 | 
 | 
 | 40 | /*Open Flags*/
 | 
 | 41 | typedef struct  _T_ZDRVIO_FLAGS
 | 
 | 42 | {
 | 
 | 43 | 	UINT32 READ:1;
 | 
 | 44 | 	UINT32 WRITE:1;
 | 
 | 45 | 	UINT32 MULTI_READ:1;
 | 
 | 46 | 	UINT32 MULTI_WRITE:1;
 | 
 | 47 | 	UINT32 SHARED:1;
 | 
 | 48 | 	UINT32 RESERVE:27;
 | 
 | 49 | }
 | 
 | 50 | T_ZDRVIO_FLAGS;
 | 
 | 51 | 
 | 
 | 52 | 
 | 
 | 53 | /*Global Notify Handle*/
 | 
 | 54 | typedef VOID * T_ZDrvIO_GNotifyHandle;
 | 
 | 55 | 
 | 
 | 56 | 
 | 
 | 57 | /*Global Notify Callback Function*/
 | 
 | 58 | typedef VOID (*T_ZDrvIO_GNotifyCallBack)(const char* devName, T_DRVIO_EVENT event);
 | 
 | 59 | 
 | 
 | 60 | /****************************************************************************
 | 
 | 61 | * 	                                        Constants
 | 
 | 62 | ****************************************************************************/
 | 
 | 63 | 
 | 
 | 64 | /****************************************************************************
 | 
 | 65 | * 	                                        Global  Variables
 | 
 | 66 | ****************************************************************************/
 | 
 | 67 | 
 | 
 | 68 | /****************************************************************************
 | 
 | 69 | * 	                                        Function Prototypes
 | 
 | 70 | ****************************************************************************/
 | 
 | 71 | /*******************************************************************************
 | 
 | 72 |  * Function: zDrvIO_Open
 | 
 | 73 |  * Description:search device by device name, open it, and set the action flags.
 | 
 | 74 |  * Input:
 | 
 | 75 |     name: device name.
 | 
 | 76 |     flags: open flags, control the device action.
 | 
 | 77 |  * Output:None
 | 
 | 78 |  *
 | 
 | 79 |  * Returns:
 | 
 | 80 |               T_ZDrvIO_Handle: the opened device handle. if error happened, return NULL.
 | 
 | 81 |  * Others:
 | 
 | 82 |  ********************************************************************************/
 | 
 | 83 | T_ZDrvIO_Handle zDrvIO_Open(const char *name, T_ZDRVIO_FLAGS flags);
 | 
 | 84 | /*******************************************************************************
 | 
 | 85 |  * Function: zDrvIO_Read
 | 
 | 86 |  * Description:read data from device.
 | 
 | 87 |  * Input:
 | 
 | 88 |  	handle:the device handle for read.
 | 
 | 89 |  	buffer: the read data buffer. the buffer space supplied by high layer.
 | 
 | 90 |  	length:the data length need to read.
 | 
 | 91 |  * Output:None
 | 
 | 92 |  *
 | 
 | 93 |  * Returns:
 | 
 | 94 |               ret >= 0: return the actual read length.
 | 
 | 95 |               DRV_ERROR_NOCONNECT: the device disconnect event happend, need return error to inform higher user.
 | 
 | 96 |               other: other error maked by device.
 | 
 | 97 |  * Others:
 | 
 | 98 |  ********************************************************************************/
 | 
 | 99 | SINT32 zDrvIO_Read(T_ZDrvIO_Handle handle, UINT8* buffer, UINT32 length);
 | 
 | 100 | /*******************************************************************************
 | 
 | 101 |  * Function: zDrvIO_Write
 | 
 | 102 |  * Description:write data to IO handle
 | 
 | 103 |  * Input:
 | 
 | 104 |   	handle:the device handle for write.
 | 
 | 105 |  	buffer: the write data buffer. the buffer space supplied by high layer.
 | 
 | 106 |  	length:the write data length.
 | 
 | 107 | * Output:None
 | 
 | 108 |  *
 | 
 | 109 |  * Returns:
 | 
 | 110 |               ret >= 0: return the actual write length.
 | 
 | 111 |               DRV_ERROR_NOCONNECT: the device disconnect event happend, need return error to inform higher user.
 | 
 | 112 |               other: other error maked by device.
 | 
 | 113 |  * Others:
 | 
 | 114 |  ********************************************************************************/
 | 
 | 115 | SINT32 zDrvIO_Write(T_ZDrvIO_Handle handle, UINT8* buffer, UINT32 length);
 | 
 | 116 | /*******************************************************************************
 | 
 | 117 |  * Function: zDrvIO_BRead
 | 
 | 118 |  * Description:read data from device.
 | 
 | 119 |  * Input:
 | 
 | 120 |  	handle:the device handle for read.
 | 
 | 121 |  	buffer: the read data buffer. the buffer space supplied by high layer.
 | 
 | 122 |  	length:the data length need to read.
 | 
 | 123 |  	pos:the read data position in device storage space.
 | 
 | 124 |  * Output:None
 | 
 | 125 |  *
 | 
 | 126 |  * Returns:
 | 
 | 127 |               ret >= 0: return the actual read length.
 | 
 | 128 |               DRV_ERROR_NOCONNECT: the device disconnect event happend, need return error to inform higher user.
 | 
 | 129 |               other: other error maked by device.
 | 
 | 130 |  * Others:
 | 
 | 131 |  ********************************************************************************/
 | 
 | 132 | SINT32 zDrvIO_BRead(T_ZDrvIO_Handle handle, UINT8* buffer, UINT32 blkCnt, UINT32 pos);
 | 
 | 133 | /*******************************************************************************
 | 
 | 134 |  * Function: zDrvIO_BWrite
 | 
 | 135 |  * Description:write data to IO handle
 | 
 | 136 |  * Input:
 | 
 | 137 |   	handle:the device handle for write.
 | 
 | 138 |  	buffer: the write data buffer. the buffer space supplied by high layer.
 | 
 | 139 |  	length:the write data length.
 | 
 | 140 |  	pos:the write data position in device storage space.
 | 
 | 141 | * Output:None
 | 
 | 142 |  *
 | 
 | 143 |  * Returns:
 | 
 | 144 |               ret >= 0: return the actual write length.
 | 
 | 145 |               DRV_ERROR_NOCONNECT: the device disconnect event happend, need return error to inform higher user.
 | 
 | 146 |               other: other error maked by device.
 | 
 | 147 |  * Others:
 | 
 | 148 |  ********************************************************************************/
 | 
 | 149 | SINT32 zDrvIO_BWrite(T_ZDrvIO_Handle handle, UINT8* buffer, UINT32 blkCnt, UINT32 pos);
 | 
 | 150 | /*******************************************************************************
 | 
 | 151 |  * Function: zDrvIO_Ctrl
 | 
 | 152 |  * Description:control device.
 | 
 | 153 |  * Input:
 | 
 | 154 |   	handle:the device handle for control.
 | 
 | 155 |    	function:the control function.
 | 
 | 156 |   	handle:the control function arguments.
 | 
 | 157 | * Output:None
 | 
 | 158 |  *
 | 
 | 159 |  * Returns:
 | 
 | 160 |               DRV_SUCCESS: success.
 | 
 | 161 |               DRV_ERROR: error.
 | 
 | 162 |  * Others:
 | 
 | 163 |  ********************************************************************************/
 | 
 | 164 | SINT32 zDrvIO_Ctrl(T_ZDrvIO_Handle handle, T_DRVIO_CTRL_KEY  function, VOID *arg);
 | 
 | 165 | /*******************************************************************************
 | 
 | 166 |  * Function: zDrvIO_Close
 | 
 | 167 |  * Description:close the device
 | 
 | 168 |  * Input:
 | 
 | 169 |  	handle:the device handle to be closed.
 | 
 | 170 |  * Output:None
 | 
 | 171 |  *
 | 
 | 172 |  * Returns:
 | 
 | 173 |               DRV_SUCCESS: success.
 | 
 | 174 |               DRV_ERROR: error.
 | 
 | 175 |  * Others:
 | 
 | 176 |  ********************************************************************************/
 | 
 | 177 | SINT32 zDrvIO_Close(T_ZDrvIO_Handle handle);
 | 
 | 178 | 
 | 
 | 179 | /*******************************************************************************
 | 
 | 180 |  * Function: zDrvIO_RegisterGlobalNotify
 | 
 | 181 |  * Description: register global notifier.
 | 
 | 182 |  * Input:
 | 
 | 183 |  *        globalNotifyFn: global noitifier callback function
 | 
 | 184 |  * Output:None
 | 
 | 185 |  *
 | 
 | 186 |  * Returns:
 | 
 | 187 |  *       T_ZDrvIO_GNotifyHandle : the global notifier handler.
 | 
 | 188 |  * Others:
 | 
 | 189 |  ********************************************************************************/
 | 
 | 190 | T_ZDrvIO_GNotifyHandle zDrvIO_RegisterGlobalNotify(T_ZDrvIO_GNotifyCallBack globalNotifyFn);
 | 
 | 191 | /*******************************************************************************
 | 
 | 192 |  * Function: zDrvIO_UnregisterGlobalNotify
 | 
 | 193 |  * Description: unregister global notifier.
 | 
 | 194 |  * Input:
 | 
 | 195 |  *        gNotifyHandle: the global notifier handler
 | 
 | 196 |  * Output:None
 | 
 | 197 |  *
 | 
 | 198 |  * Returns:
 | 
 | 199 |  *
 | 
 | 200 |  * Others:
 | 
 | 201 |  ********************************************************************************/
 | 
 | 202 | VOID zDrvIO_UnregisterGlobalNotify(T_ZDrvIO_GNotifyHandle gNotifyHandle);
 | 
 | 203 | 
 | 
 | 204 | 
 | 
 | 205 | #endif/*_DRVS_IO_H_*/
 | 
 | 206 | 
 |