Home | History | Annotate | Download | only in inc
      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 COMMON_H
     52 typedef unsigned char   u8;
     53 typedef unsigned short u16;
     54 typedef unsigned long   u32;
     55 typedef unsigned long long u64;
     56 
     57 #ifndef BIT
     58 #define BIT(x) (1 << (x))
     59 #endif
     60 #endif
     61 
     62 #ifndef NULL
     63 #define NULL    (0)
     64 #endif
     65 
     66 typedef enum
     67 {
     68     OS_FOPEN_READ = 0,
     69 	OS_FOPEN_READ_BINARY,
     70 	OS_FOPEN_WRITE,
     71 	OS_FOPEN_WRITE_BINARY
     72 } os_fopen_mode_e;
     73 
     74 enum { CU_MSG_DEBUG, CU_MSG_INFO1, CU_MSG_WARNING, CU_MSG_ERROR, CU_MSG_INFO2};
     75 
     76 /****************************************************************************************
     77  *                      OS Memory API                                                   *
     78  ****************************************************************************************/
     79 PVOID os_MemoryCAlloc(U32 Number, U32 Size);
     80 PVOID os_MemoryAlloc(U32 Size);
     81 VOID os_MemoryFree(PVOID pMemPtr);
     82 PVOID os_memset(PVOID s, U8 c, U32 n);
     83 PVOID os_memcpy(PVOID dest, const PVOID src, U32 n);
     84 S32 os_memcmp(const PVOID s1, const PVOID s2, S32 n);
     85 
     86 /****************************************************************************************
     87  *                      OS File API                                                    *
     88  ****************************************************************************************/
     89 PVOID os_fopen (const PS8 path, os_fopen_mode_e mode);
     90 S32 os_fclose (PVOID stream);
     91 S32 os_getFileSize (PVOID file);
     92 PS8 os_fgets (PS8 s, S32 size, PVOID stream);
     93 S32 os_fread (PVOID ptr, S32 size, S32 nmemb, PVOID stream);
     94 S32 os_fwrite (PVOID ptr, S32 size, S32 nmemb, PVOID stream);
     95 
     96 /****************************************************************************************
     97  *                      OS String API                                                   *
     98  ****************************************************************************************/
     99 PS8 os_strcpy(PS8 dest, const PS8 src);
    100 PS8 os_strncpy(PS8 dest, const PS8 src, S32 n);
    101 S32 os_strcmp(const PS8 s1, const PS8 s2);
    102 S32 os_strncmp(const PS8 s1, const PS8 s2, U32 n);
    103 S32 os_sscanf(const PS8 str, const PS8 format, ...);
    104 S32 os_sprintf(PS8 str, const PS8 format, ...);
    105 PS8 os_strcat(PS8 dest, const PS8 src);
    106 U32 os_strlen(const PS8 s);
    107 PS8 os_strchr(const PS8 s, S32 c);
    108 S32 os_strtol(const PS8 nptr, PPS8 endptr, S32 base);
    109 U32 os_strtoul(const PS8 nptr, PPS8 endptr, S32 base);
    110 S32 os_tolower(S32 c);
    111 S32 os_isupper(S32 c);
    112 S32 os_toupper(S32 c);
    113 S32 os_atoi(const PS8 str);
    114 
    115 /****************************************************************************************
    116  *                      OS Output API                                                   *
    117  ****************************************************************************************/
    118 S32 os_Printf(const PS8 buffer);
    119 VOID os_error_printf(S32 debug_level, const PS8 arg_list ,...);
    120 
    121 /****************************************************************************************
    122  *                      Miscelanous OS API                                              *
    123  ****************************************************************************************/
    124 S32 os_getInputString(PS8 inbuf, S32 len);
    125 VOID os_Catch_CtrlC_Signal(PVOID SignalCB);
    126 
    127 VOID os_OsSpecificCmdParams(S32 argc, PS8* argv);
    128 VOID os_InitOsSpecificModules(VOID);
    129 VOID os_DeInitOsSpecificModules(VOID);
    130 TI_SIZE_T os_get_last_error(VOID);
    131 
    132 #endif  /* _CUOSAPI_H_ */
    133 
    134