lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 1 | /**************************************************************************
|
| 2 | *
|
| 3 | * Copyright (c) 2012 ZTE Corporation.
|
| 4 | *
|
| 5 | ***************************************************************************
|
| 6 | * Ä£ ¿é Ãû : P98C_OSS
|
| 7 | * ÎÄ ¼þ Ãû : oss_pub.h
|
| 8 | * Ïà¹ØÎļþ :
|
| 9 | * ʵÏÖ¹¦ÄÜ : »ù±¾ÀàÐÍ¡¢Ä£¿éºÅ¡¢´íÎóºÅ¡¢ÏûÏ¢ºÅ¶¨Òå
|
| 10 | * ×÷ Õß : chenxingfang
|
| 11 | * °æ ±¾ : V1.0
|
| 12 | * Íê³ÉÈÕÆÚ : 2012-08-10
|
| 13 | * ÆäËü˵Ã÷ :
|
| 14 | **************************************************************************/
|
| 15 |
|
| 16 | /**************************************************************************
|
| 17 | * Ð޸ļǼ
|
| 18 | **************************************************************************/
|
| 19 | #ifndef _OSS_PUB_H
|
| 20 | #define _OSS_PUB_H
|
| 21 |
|
| 22 | /**************************************************************************
|
| 23 | * #includeÇø
|
| 24 | **************************************************************************/
|
| 25 | #if defined _OS_TOS
|
| 26 | #include <pkgconf/kernel.h>
|
| 27 | #include <cyg/hal/hal_intr.h>
|
| 28 | #include <cyg/kernel/kapi.h>
|
| 29 | #elif defined _OS_OSE
|
| 30 | #include "ose.h"
|
| 31 | #include "osetypes.h"
|
| 32 | #include "ose_spi/arm/cpu_intlock.h"
|
| 33 | #elif defined (_OS_LINUX)
|
| 34 | #include <linux/types.h>
|
| 35 | #include <linux/kernel.h>
|
| 36 | #include <linux/jiffies.h>
|
| 37 | #include <asm/param.h>
|
| 38 | #ifdef _USE_TCM
|
| 39 | #include <asm/tcm.h>
|
| 40 | #endif
|
| 41 | #elif defined _OS_WIN
|
| 42 | # ifndef _USE_OS_SOCK
|
| 43 | #define _WINSOCK2_H
|
| 44 | #define _WINSOCK_H
|
| 45 | #define _WINSOCK2API_
|
| 46 | #define _WINSOCKAPI_
|
| 47 | # endif
|
| 48 | #include <windows.h>
|
| 49 | #endif
|
| 50 |
|
| 51 | #ifdef __cplusplus
|
| 52 | extern "C"
|
| 53 | {
|
| 54 | #endif
|
| 55 |
|
| 56 | /**************************************************************************
|
| 57 | * ³£Á¿¶¨ÒåÇø
|
| 58 | **************************************************************************/
|
| 59 | /* ²Ù×÷ϵͳ´íÎóºÅ, 0x00001000 --- 0x00001fff */
|
| 60 | #define ZOSS_ERR (0x00001000)
|
| 61 |
|
| 62 |
|
| 63 | /* ƽ̨ÏûÏ¢ */
|
| 64 | #define EV_ZPLAT_BASE (0x00001000)
|
| 65 |
|
| 66 | /* ²Ù×÷ϵͳÏûÏ¢, ¸öÊý0x1000 */
|
| 67 | #define EV_ZOSS_BASE (EV_ZPLAT_BASE)
|
| 68 |
|
| 69 | /* ƽ̨ÏûÏ¢Çø¼ä */
|
| 70 | #define EV_ZOSS_SCHE_BASE (EV_ZOSS_BASE)
|
| 71 | #define EV_ZOSS_SYSM_BASE (EV_ZOSS_BASE + 50)
|
| 72 | #define EV_ZOSS_EXCEP_BASE (EV_ZOSS_BASE + 100)
|
| 73 | #define EV_ZOSS_TRACE_BASE (EV_ZOSS_BASE + 150)
|
| 74 | #define EV_ZOSS_MEM_BASE (EV_ZOSS_BASE + 300)
|
| 75 | #define EV_ZOSS_COMM_BASE (EV_ZOSS_BASE + 350)
|
| 76 |
|
| 77 | /* ϵͳ¹ÜÀíÄ£¿éÏûÏ¢ */
|
| 78 | #define EV_INIT (EV_ZOSS_SYSM_BASE + 0) /* ÈÎÎñ³õʼ»¯ÏûÏ¢ */
|
| 79 | #define EV_POWERON (EV_ZOSS_SYSM_BASE + 1) /* ÈÎÎñÉϵçÏûÏ¢ */
|
| 80 | #define EV_POWEROFF (EV_ZOSS_SYSM_BASE + 2) /* ÈÎÎñϵçÏûÏ¢ */
|
| 81 | #define EV_POWERON_OK (EV_ZOSS_SYSM_BASE + 3) /* ÈÎÎñÉϵçÍê³ÉÏûÏ¢ */
|
| 82 | #define EV_PS_START (EV_ZOSS_SYSM_BASE + 4) /* ÐÒéÕ»Æô¶¯ÏûÏ¢ */
|
| 83 | #define EV_TASKSTOP (EV_ZOSS_SYSM_BASE + 5) /* ÐÒéÕ»ÔÝÍ£ÏûÏ¢ */
|
| 84 | #define EV_TASKRESUM (EV_ZOSS_SYSM_BASE + 6) /* ÐÒéÕ»»Ö¸´ÏûÏ¢ */
|
| 85 | #define EV_SYSM_DOWN (EV_ZOSS_SYSM_BASE + 7) /* ¹Ø»úÏûÏ¢ */
|
| 86 |
|
| 87 | /* GUIÏûÏ¢ */
|
| 88 | #define EV_ZGUI_BASE (0x00002000)
|
| 89 |
|
| 90 | /* ÐÒéÕ»²âÊÔ¹¤¾ßÏûÏ¢ */
|
| 91 | #define EV_ZPTE_BASE (EV_ZPLAT_BASE + 0x00008000)
|
| 92 |
|
| 93 | /* ϵͳ¹«¹²´òÓ¡Ä£¿éºÅ */
|
| 94 | #define SUBMDL_SYSBASE (1)
|
| 95 | #define SUBMDL_PUB (SUBMDL_SYSBASE + 0) /* ϵͳ¹«¹² */
|
| 96 | #define SUBMDL_RAM (SUBMDL_SYSBASE + 1) /* ÍùRAM´òÓ¡ */
|
| 97 | #define SUBMDL_FILE (SUBMDL_SYSBASE + 2) /* ÍùÎļþ´òÓ¡ */
|
| 98 | #define SUBMDL_LCD (SUBMDL_SYSBASE + 3) /* ÍùLCD´òÓ¡ */
|
| 99 |
|
| 100 | /* OSS´òÓ¡Ä£¿éºÅ */
|
| 101 | #define SUBMDL_OSSBASE (10)
|
| 102 | #define SUBMDL_COMMON (SUBMDL_OSSBASE + 0) /* ¹«¹²Ä£¿é */
|
| 103 | #define SUBMDL_OSA (SUBMDL_OSSBASE + 1) /* OSAÄ£¿é */
|
| 104 | #define SUBMDL_SCHE (SUBMDL_OSSBASE + 2) /* µ÷¶ÈͨѶ */
|
| 105 | #define SUBMDL_MEM (SUBMDL_OSSBASE + 3) /* ÄÚ´æ¹ÜÀí */
|
| 106 | #define SUBMDL_SYSM (SUBMDL_OSSBASE + 4) /* SYSMÄ£¿é */
|
| 107 | #define SUBMDL_TIMER (SUBMDL_OSSBASE + 5) /* ¶¨Ê±Æ÷Ä£¿é */
|
| 108 | #define SUBMDL_EXCEP (SUBMDL_OSSBASE + 6) /* Òì³£´¦Àí */
|
| 109 | #define SUBMDL_NET (SUBMDL_OSSBASE + 7) /* NETÄ£¿é */
|
| 110 | #define SUBMDL_FS (SUBMDL_OSSBASE + 8) /* Îļþ´úÀíÄ£¿é */
|
| 111 | #define SUBMDL_TRACE (SUBMDL_OSSBASE + 9) /* traceÄ£¿é */
|
| 112 | #define SUBMDL_TEST (SUBMDL_OSSBASE + 10) /* testÄ£¿é */
|
| 113 | #define SUBMDL_EVENT (SUBMDL_OSSBASE + 11) /* EventÄ£¿é */
|
| 114 | #define SUBMDL_NV (SUBMDL_OSSBASE + 12) /* NV´úÀíÄ£¿é */
|
| 115 | #define SUBMDL_SHELL (SUBMDL_OSSBASE + 13) /* SHELL´úÀíÄ£¿é */
|
| 116 | #define SUBMDL_AMT (SUBMDL_OSSBASE + 14) /* AMT´úÀíÄ£¿é */
|
| 117 |
|
| 118 | /* ÐÒéÕ»²âÊÔ¹¤¾ßÄ£¿éºÅ */
|
| 119 | #define SUBMDL_PTE (SUBMDL_OSSBASE + 15)
|
| 120 |
|
| 121 | /* DRV´òÓ¡Ä£¿éºÅ */
|
| 122 | #define SUBMDL_DRVBASE (25)
|
| 123 | #define SUBMDL_DAL (SUBMDL_DRVBASE + 0) /* DALÄ£¿é */
|
| 124 | #define SUBMDL_DD (SUBMDL_DRVBASE + 1) /* DDÄ£¿é */
|
| 125 | #define SUBMDL_HAL (SUBMDL_DRVBASE + 2) /* HALÄ£¿é */
|
| 126 | #define SUBMDL_MUX (SUBMDL_DRVBASE + 3) /* MUXÄ£¿é */
|
| 127 |
|
| 128 | #define SUBMDL_IMS (31) /* IMSÐÅÁîÄ£¿é */
|
| 129 |
|
| 130 | /* MULTIMEDIA´òÓ¡Ä£¿éºÅ */
|
| 131 | #define SUBMDL_MMBASE (60)
|
| 132 | /* MONITOR¸ú×ÙÄ£¿éºÅ */
|
| 133 | #define SUBMDL_MONAGENT (128)
|
| 134 |
|
| 135 | #define SUBMDL_Z_EXTMOD (BYTE)0xff
|
| 136 | #define SUBMDL_ZPS_EXTMOD SUBMDL_Z_EXTMOD
|
| 137 |
|
| 138 | /* FALSE/TRUE¶¨Òå */
|
| 139 | #ifndef _OS_WIN
|
| 140 | #ifdef TRUE
|
| 141 | #undef TRUE
|
| 142 | #endif
|
| 143 | #define TRUE (BOOL)1
|
| 144 |
|
| 145 | #ifdef FALSE
|
| 146 | #undef FALSE
|
| 147 | #endif
|
| 148 | #define FALSE (BOOL)0
|
| 149 |
|
| 150 | /* ×î´óÖµ/×îСֵ¶¨Òå */
|
| 151 | #ifdef _OS_LINUX
|
| 152 | # define oss_max(a,b) (((a) > (b)) ? (a) : (b))
|
| 153 | # define oss_min(a,b) (((a) < (b)) ? (a) : (b))
|
| 154 | #else
|
| 155 | # define max(a,b) (((a) > (b)) ? (a) : (b))
|
| 156 | # define min(a,b) (((a) < (b)) ? (a) : (b))
|
| 157 | #endif
|
| 158 |
|
| 159 | #endif
|
| 160 |
|
| 161 | #ifdef _DEBUG
|
| 162 | # define ZOSS_FILE __FILE__
|
| 163 | # define ZOSS_LINE __LINE__
|
| 164 | #else
|
| 165 | # define ZOSS_FILE NULL
|
| 166 | # define ZOSS_LINE 0
|
| 167 | #endif
|
| 168 |
|
| 169 | #define ___str(x) #x
|
| 170 | #define __str(x) ___str(x)
|
| 171 |
|
| 172 | #define ZOSS_UNUSED_PARAM(_name_) _name_ = _name_;
|
| 173 | #define ZOSS_UNUSED_PTR(_name_) if (_name_) _name_ = _name_;
|
| 174 | #define ZOSS_MACRO_START do {
|
| 175 | #define ZOSS_MACRO_END } while (0)
|
| 176 |
|
| 177 | #define ALIGN_TO(base, align) ((base + (align - 1)) & ~(align - 1))
|
| 178 | #ifndef _OS_LINUX
|
| 179 | #define ARRAY_SIZE(array) (sizeof(array)/sizeof(array[0]))
|
| 180 | #endif
|
| 181 | #define ARRAY_START(array) (&array[0])
|
| 182 | #define ARRAY_END(array) (&array[sizeof(array)/sizeof(array[0])])
|
| 183 |
|
| 184 | /* 1¸öϵͳµÎ´ðËùÐèµÄºÁÃëÊý */
|
| 185 | #if defined _OS_TOS
|
| 186 | # define ZOSS_MS_PER_TICK (CYGNUM_HAL_RTC_PERIOD / 1000)
|
| 187 | #elif defined _OS_OSE
|
| 188 | # define ZOSS_MS_PER_TICK (system_tick() / 1000)
|
| 189 | #elif defined _OS_WIN
|
| 190 | # define ZOSS_MS_PER_TICK 1
|
| 191 | #elif defined _OS_LINUX
|
| 192 | # define ZOSS_MS_PER_TICK 1
|
| 193 | #endif
|
| 194 |
|
| 195 | /**************************************************************************
|
| 196 | * Êý¾Ý½á¹¹¶¨ÒåÇø
|
| 197 | **************************************************************************/
|
| 198 | /* »ù±¾ÀàÐÍ */
|
| 199 | typedef signed char SINT8;
|
| 200 | typedef unsigned char UINT8;
|
| 201 | typedef short SINT16;
|
| 202 | typedef unsigned short UINT16;
|
| 203 | typedef long SINT32;
|
| 204 | typedef UINT8 BITS;
|
| 205 |
|
| 206 | #ifndef _OS_WIN
|
| 207 | typedef unsigned long UINT32;
|
| 208 | typedef unsigned long long UINT64;
|
| 209 | typedef long long SINT64;
|
| 210 | typedef float FLOAT;
|
| 211 | typedef double DOUBLE;
|
| 212 | typedef int BOOL;
|
| 213 |
|
| 214 | #ifndef VOID
|
| 215 | #define VOID void
|
| 216 | #endif
|
| 217 |
|
| 218 | #ifndef CHAR
|
| 219 | #define CHAR char
|
| 220 | #endif
|
| 221 |
|
| 222 | typedef UINT32 SSIZE_T;
|
| 223 | typedef UINT8 BYTE;
|
| 224 | typedef SINT16 SHORT;
|
| 225 | typedef SINT32 LONG;
|
| 226 | typedef UINT16 WORD;
|
| 227 | typedef UINT32 DWORD;
|
| 228 | typedef UINT32 HANDLE;
|
| 229 | typedef SINT8 *PSTR;
|
| 230 | typedef UINT8 *PBYTE;
|
| 231 | typedef UINT16 *PWORD;
|
| 232 | typedef UINT32 *PDWORD;
|
| 233 | typedef VOID *PVOID;
|
| 234 | typedef UINT32 *PHANDLE;
|
| 235 | #else
|
| 236 | typedef __int64 SINT64;
|
| 237 | typedef unsigned __int64 UINT64;
|
| 238 | typedef int mode_t;
|
| 239 | #endif
|
| 240 |
|
| 241 | #if defined (_OS_TOS) || defined(_OS_LINUX)
|
| 242 | typedef SINT8 S8;
|
| 243 | typedef UINT8 U8;
|
| 244 | typedef SINT16 S16;
|
| 245 | typedef UINT16 U16;
|
| 246 | typedef SINT32 S32;
|
| 247 | typedef UINT32 U32;
|
| 248 |
|
| 249 | typedef UINT32 PROCESS;
|
| 250 | typedef UINT32 OSADDRESS;
|
| 251 | typedef UINT8 OSPRIORITY;
|
| 252 | typedef UINT32 OSTIME;
|
| 253 | typedef UINT32 SIGSELECT;
|
| 254 | typedef UINT16 OSVECTOR;
|
| 255 | typedef UINT32 OSUSER;
|
| 256 |
|
| 257 | typedef VOID (OSENTRYPOINT)(VOID);
|
| 258 |
|
| 259 | enum PROCESS_TYPE
|
| 260 | {
|
| 261 | OS_PRI_PROC = 0,
|
| 262 | OS_BG_PROC = 64,
|
| 263 | OS_INT_PROC = 128,
|
| 264 | OS_TI_PROC = 256,
|
| 265 | OS_PHANTOM = 512,
|
| 266 | OS_BLOCK = 1024,
|
| 267 | OS_ZOOMBIE = 2048,
|
| 268 | OS_ILLEGAL = 4096
|
| 269 | };
|
| 270 |
|
| 271 | struct OS_redir_entry
|
| 272 | {
|
| 273 | SIGSELECT sig;
|
| 274 | PROCESS pid;
|
| 275 | };
|
| 276 | #endif
|
| 277 |
|
| 278 | #ifdef _OS_LINUX
|
| 279 | typedef struct {
|
| 280 | int quot; /* quotient */
|
| 281 | int rem; /* remainder */
|
| 282 | } div_t;
|
| 283 | #endif
|
| 284 |
|
| 285 | /**************************************************************************
|
| 286 | * º¯ÊýÉùÃ÷Çø
|
| 287 | **************************************************************************/
|
| 288 | SINT32 zOss_GetLastError(VOID);
|
| 289 |
|
| 290 | /**************************************************************************
|
| 291 | * È«¾Ö±äÁ¿ÉùÃ÷Çø
|
| 292 | **************************************************************************/
|
| 293 |
|
| 294 | #ifdef __cplusplus
|
| 295 | }
|
| 296 | #endif
|
| 297 |
|
| 298 | #endif /* _OSS_PUB_H */
|
| 299 |
|
| 300 |
|