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