1 #ifndef MSOS_TYPE_LINUX_KERNEL 2 #include "stdlib.h" 3 #endif 4 #include "MsTypes.h" 5 6 #ifndef _UTOPIA_H_ 7 #define _UTOPIA_H_ 8 9 #ifdef __cplusplus 10 extern "C" 11 { 12 #endif 13 14 #include "utopia_driver_id.h" 15 16 /******************************************************************************* 17 Status define rule: 18 0xMMRRRRSS //M:Module, R:Reserve(please keep 0), S:Status code 19 MM = 0 for common status. 20 MM = 1 for Utopia Framwork and Utopia module 21 22 Will support GetErrorStr(Status, *str); 23 *******************************************************************************/ 24 /*! \defgroup UTPA UTOPIA CORE Interface 25 26 <b> Features </b> 27 -# Move driver gloable variable to Instant / Module / Resource layer. 28 -# Unify call entry to ioctl() 29 -# trace support 30 -# debug support 31 -# multi-process with Share memory method (SHM) 32 -# multi-process interrupt handle 33 -# Polimorphism 34 -# Version control 35 -# STR/STD solution 36 37 \image html utopia2_pic1.png 38 \image html utopia2_pic2.png 39 40 We allow each driver to put their private data struce into each layer, like following: 41 -# pInstant->private 42 -# pModule->private 43 -# pModuleShm private as resource been put into Resource 44 Ex: treat device interrupt status a resource, please see multi-process interrupt for detail 45 -# pResource->private 46 47 \image html utopia2_pic3.png 48 49 <b>Operation Flow</b> 50 -# UtopiaInit(); 51 -# UtopiaOpen(MS_U32 u32ModuleID, void** pInstant, MS_U32 u32ModuleVersion, void* pvAttribute); 52 -# UtopiaIoctl(void* pInstant, MS_U32 u32Cmd, MS_U32* pu32Args); 53 -# UtopiaClose(void* pInstant); 54 55 * */ 56 57 58 #define UTOPIA_STATUS_SUCCESS 0x00000000 59 #define UTOPIA_STATUS_FAIL 0x00000001 60 #define UTOPIA_STATUS_NOT_SUPPORTED 0x00000002 61 #define UTOPIA_STATUS_PARAMETER_ERROR 0x00000003 62 #define UTOPIA_STATUS_DONT_CARE 0x00000004 63 #define UTOPIA_STATUS_ERR_SYS 0x00000005 ///< operating system call failure 64 #define UTOPIA_STATUS_ERR_INV 0x00000006 ///< invalid argument passed 65 #define UTOPIA_STATUS_ERR_TIMEDOUT 0x00000007 ///< timeout occured 66 #define UTOPIA_STATUS_ERR_DEFERRED 0x00000008 ///< action has been deferred 67 #define UTOPIA_STATUS_ERR_UNIMPLEM 0x00000009 ///< Unimplemented service 68 #define UTOPIA_STATUS_ERR_LOCKED 0x00000010 ///< object locked 69 #define UTOPIA_STATUS_ERR_DELETED 0x00000011 ///< Object has been deleted 70 #define UTOPIA_STATUS_ERR_HEAP 0x00000012 ///< Heap full 71 #define UTOPIA_STATUS_ERR_UNINIT 0x00000013 ///< module is not initialised 72 #define UTOPIA_STATUS_ERR_UNIQUE 0x00000014 ///< unique id needed 73 #define UTOPIA_STATUS_ERR_STATE 0x00000015 ///< invalid state to invoke function 74 #define UTOPIA_STATUS_ERR_DEV 0x00000016 ///< no valid device exists 75 #define UTOPIA_STATUS_ERR_NOT_FOUND 0x00000017 ///< Not found 76 #define UTOPIA_STATUS_ERR_EOL 0x00000018 ///< a list traversal has ended 77 #define UTOPIA_STATUS_ERR_TERM 0x00000019 ///< module has terminated 78 #define UTOPIA_STATUS_ERR_LIMIT 0x00000020 ///< System limit was reached. 79 #define UTOPIA_STATUS_ERR_RESOURCE 0x00000021 ///< insufficient resources for request 80 #define UTOPIA_STATUS_ERR_NOT_AVAIL 0x00000022 ///< resources not available 81 #define UTOPIA_STATUS_ERR_BAD_DATA 0x00000023 ///< Bad data in transport stream 82 #define UTOPIA_STATUS_ERR_INLINE_SUCCESS 0x00000024 83 #define UTOPIA_STATUS_ERR_DEFERRED_SUCCESS 0x00000025 84 #define UTOPIA_STATUS_ERR_IN_USE 0x00000026 ///< Object is in use. 85 #define UTOPIA_STATUS_ERR_INTERMEDIATE 0x00000027 ///< Intermediate return 0x0000000 successful but not complete 86 #define UTOPIA_STATUS_ERR_OVERRUN 0x00000028 ///< Buffer overrun occured (e.g. in filters). 87 #define UTOPIA_STATUS_ERR_ABORT 0x00000029 ///< Request not supported. 88 #define UTOPIA_STATUS_ERR_NOTIMPLEMENTED 0x00000030 ///< Request not implemented. 89 #define UTOPIA_STATUS_ERR_INVALID_HANDLE 0x00000031 90 #define UTOPIA_STATUS_ERR_NOMEM 0x00000032 ///< No Memory 91 #define UTOPIA_STATUS_SHM_EXIST 0x00000033 ///< target share memory already exists 92 #define UTOPIA_STATUS_RPOOL_ESTABLISHED 0x00000034 ///< target resource pool is already established 93 #define UTOPIA_STATUS_NO_RESOURCE 0x00000035 ///< try to obtain resource but fail 94 #define UTOPIA_STATUS_SIGNAL_OK 0x00000036 95 #define UTOPIA_STATUS_ERR_USER 0x00000099 ///< start of subsystem specific errors 96 97 #define MS_MODULE_NULL 0 98 //#define MS_MODULE_UTOPIA 0xFFFF0000 99 #define MS_UTOPIA_DB_LEVEL_TRACE 0x80000000 100 101 #define utopia_malloc malloc 102 #define utopia_free free 103 104 #if defined(MSOS_TYPE_LINUX_KERNEL) 105 #define free kfree 106 #define malloc(size) kmalloc((size), GFP_KERNEL) 107 #endif 108 109 #ifdef CONFIG_UTOPIA_PROC_DBG_SUPPORT 110 MS_U32 MdbPrint(MS_U64* u64ReqHdl, const char* fmt, ...); 111 #endif 112 113 #define KERNEL_MODE 0x80000000 114 115 #define UTOPIA_IOC_MAGIC 'U' 116 #define UTOPIA_IOCTL_SetMODULE _IOWR(UTOPIA_IOC_MAGIC, 1, UTOPIA_DDI_OPEN_ARG) 117 #define UTOPIA_IOCTL_OpenMODULE _IOWR(UTOPIA_IOC_MAGIC, 2, int) 118 #define UTOPIA_IOCTL_IoctlMODULE _IOWR(UTOPIA_IOC_MAGIC, 3, UTOPIA_DDI_IOCTL_ARG) 119 #define UTOPIA_IOCTL_CloseMODULE _IOWR(UTOPIA_IOC_MAGIC, 4, int) 120 121 #define UTOPIA_IOCTL_MODULE_DYNAMIC_MAPPING _IOWR(UTOPIA_IOC_MAGIC, 5,KDrvMPool_Info_t) 122 #define UTOPIA_IOCTL_AUTH_SetIPCheck _IOWR(UTOPIA_IOC_MAGIC, 6, UTOPIA_AUTH_IPCHECK_ARG) 123 #define UTOPIA_IOCTL_AUTH_SetHashInfo _IOWR(UTOPIA_IOC_MAGIC, 7, UTOPIA_AUTH_HASHINFO_ARG) 124 125 #if defined(CONFIG_COMPAT) 126 #define UTOPIA_IOCTL_SetMODULE_COMPAT _IOWR(UTOPIA_IOC_MAGIC, 1, UTOPIA_DDI_OPEN_ARG_32) 127 #define UTOPIA_IOCTL_IoctlMODULE_COMPAT _IOWR(UTOPIA_IOC_MAGIC, 3, UTOPIA_DDI_IOCTL_ARG_32) 128 #define UTOPIA_IOCTL_MODULE_DYNAMIC_MAPPING_COMPAT _IOWR(UTOPIA_IOC_MAGIC, 5,KDrvMPool_Info_t) 129 130 #endif 131 132 //------------------------------------------------------------------------------------------------- 133 /// UTOPIA core driver initialize 134 /// @ingroup UTPA 135 /// @return UTOPIA_STATUS_SUCCESS - Success 136 /// @return UTOPIA_STATUS_FAIL - Failure 137 //------------------------------------------------------------------------------------------------- 138 MS_U32 UtopiaInit(void); 139 140 #ifdef CONFIG_MBOOT 141 MS_U32 UtopiaInit_str(void); 142 #endif 143 144 //------------------------------------------------------------------------------------------------- 145 /// UTOPIA core driver open by Module ID 146 /// @ingroup UTPA 147 /// @param u32ModuleID \b IN: Module ID 148 /// @param pInstant \b IN: Instant from Open 149 /// @param u32ModuleVersion \b IN: The Module Version if needed 150 /// @param pAttribte \b IN: Module Attrubite 151 /// @return UTOPIA_STATUS_SUCCESS - Success 152 /// @return UTOPIA_STATUS_FAIL - Failure 153 //------------------------------------------------------------------------------------------------- 154 MS_U32 UtopiaOpen(MS_U32 u32ModuleID, void** pInstant, MS_U32 u32ModuleVersion, 155 const void* const pAttribte); 156 157 //------------------------------------------------------------------------------------------------- 158 /// UTOPIA core driver all operation control by Ioctl 159 /// @ingroup UTPA 160 /// @param pInstant \b IN: Instant that refer to a Module 161 /// @param u32Cmd \b IN: The module command 162 /// @param pArgs \b IN: Command arguments 163 /// @return UTOPIA_STATUS_SUCCESS - Success 164 /// @return UTOPIA_STATUS_FAIL - Failure 165 //------------------------------------------------------------------------------------------------- 166 MS_U32 UtopiaIoctl(void* pInstant, MS_U32 u32Cmd, void* const pArgs); 167 168 //------------------------------------------------------------------------------------------------- 169 /// UTOPIA core driver close 170 /// @ingroup UTPA 171 /// @param pInstant \b IN: Instant for close 172 /// @return UTOPIA_STATUS_SUCCESS - Success 173 /// @return UTOPIA_STATUS_FAIL - Failure 174 //------------------------------------------------------------------------------------------------- 175 MS_U32 UtopiaClose(void* pInstant); 176 177 #ifdef __cplusplus 178 } 179 #endif 180 181 #endif 182