OSDN Git Service

original
[gb-231r1-is01/Gingerbread_2.3.3_r1_IS01.git] / system / wlan / ti / wilink_6_1 / CUDK / os / common / inc / cu_osapi.h
1 /*
2  * cu_osapi.h
3  *
4  * Copyright 2001-2009 Texas Instruments, Inc. - http://www.ti.com/
5  * 
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  * 
10  *     http://www.apache.org/licenses/LICENSE-2.0
11  * 
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and  
16  * limitations under the License.
17  */
18
19 /****************************************************************************/
20 /*                                                                          */
21 /*    MODULE:   cu_osapi.h                                                     */
22 /*    PURPOSE:                                                              */
23 /*                                                                          */
24 /****************************************************************************/
25 #ifndef _CUOSAPI_H_
26 #define _CUOSAPI_H_
27
28 #include "cu_ostypes.h"
29
30 /* defines */
31 /***********/
32 #define OK                      0
33 #define FALSE                   0
34 #define TRUE                    1
35 #define OSAL_ERROR                              -1
36 #define OSAL_SUCCESS                            0
37 #define OSAL_FAILURE                            1
38 #define OS_GETINPUTSTRING_CONTINUE  TRUE+1
39
40 #if !defined(max)
41 #define max(a,b) ((a>b)?a:b)
42 #endif
43 /* replaces IFNAMSIZ in Linux */
44 #define IF_NAME_SIZE    16
45
46 /* 
47  * TODO : supp declares its OS abstarction with primitive types, so these must
48  * be specifically declared here, and only if they weren't defined before by someone
49  * including common.h
50  */
51 #ifndef ANDROID
52 typedef unsigned char   u8;
53 typedef unsigned short u16;
54 typedef unsigned long   u32;
55 typedef unsigned long long u64;
56 #endif
57
58 #ifndef NULL
59 #define NULL    (0)
60 #endif
61
62 typedef enum
63 {
64     OS_FOPEN_READ = 0,
65         OS_FOPEN_READ_BINARY, 
66         OS_FOPEN_WRITE,
67         OS_FOPEN_WRITE_BINARY
68 } os_fopen_mode_e;
69
70 enum { CU_MSG_DEBUG, CU_MSG_INFO1, CU_MSG_WARNING, CU_MSG_ERROR, CU_MSG_INFO2};
71
72 /****************************************************************************************
73  *                      OS Memory API                                                   *
74  ****************************************************************************************/
75 PVOID os_MemoryCAlloc(U32 Number, U32 Size);
76 PVOID os_MemoryAlloc(U32 Size);
77 VOID os_MemoryFree(PVOID pMemPtr);
78 PVOID os_memset(PVOID s, U8 c, U32 n);
79 PVOID os_memcpy(PVOID dest, const PVOID src, U32 n);
80 S32 os_memcmp(const PVOID s1, const PVOID s2, S32 n);
81
82 /****************************************************************************************
83  *                      OS File API                                                    *
84  ****************************************************************************************/
85 PVOID os_fopen (const PS8 path, os_fopen_mode_e mode);
86 S32 os_fclose (PVOID stream);
87 S32 os_getFileSize (PVOID file);
88 PS8 os_fgets (PS8 s, S32 size, PVOID stream);
89 S32 os_fread (PVOID ptr, S32 size, S32 nmemb, PVOID stream);
90 S32 os_fwrite (PVOID ptr, S32 size, S32 nmemb, PVOID stream);
91
92 /****************************************************************************************
93  *                      OS String API                                                   *
94  ****************************************************************************************/
95 PS8 os_strcpy(PS8 dest, const PS8 src);
96 PS8 os_strncpy(PS8 dest, const PS8 src, S32 n);
97 S32 os_strcmp(const PS8 s1, const PS8 s2);
98 S32 os_strncmp(const PS8 s1, const PS8 s2, U32 n);
99 S32 os_sscanf(const PS8 str, const PS8 format, ...);
100 S32 os_sprintf(PS8 str, const PS8 format, ...);
101 PS8 os_strcat(PS8 dest, const PS8 src);
102 U32 os_strlen(const PS8 s);
103 PS8 os_strchr(const PS8 s, S32 c);
104 S32 os_strtol(const PS8 nptr, PPS8 endptr, S32 base);
105 U32 os_strtoul(const PS8 nptr, PPS8 endptr, S32 base);
106 S32 os_tolower(S32 c);
107 S32 os_isupper(S32 c);
108 S32 os_toupper(S32 c);
109 S32 os_atoi(const PS8 str);
110
111 /****************************************************************************************
112  *                      OS Output API                                                   *
113  ****************************************************************************************/
114 S32 os_Printf(const PS8 buffer);
115 VOID os_error_printf(S32 debug_level, const PS8 arg_list ,...);
116
117 /****************************************************************************************
118  *                      Miscelanous OS API                                              *
119  ****************************************************************************************/
120 S32 os_getInputString(PS8 inbuf, S32 len);
121 VOID os_Catch_CtrlC_Signal(PVOID SignalCB);
122
123 VOID os_OsSpecificCmdParams(S32 argc, PS8* argv);
124 VOID os_InitOsSpecificModules(VOID);
125 VOID os_DeInitOsSpecificModules(VOID);
126 TI_SIZE_T os_get_last_error(VOID);
127
128 #endif  /* _CUOSAPI_H_ */
129