|
|
NVIDIA DriveOS Linux SDK API Reference
|
7.2.5.0 Early Access Release
|
Go to the documentation of this file.
13 #ifndef INCLUDED_NVOS_COMMON_TEGRA_SAFETY_H
14 #define INCLUDED_NVOS_COMMON_TEGRA_SAFETY_H
39 #elif defined(__linux__)
47 #if defined(__cplusplus)
55 #define NVOS_OPEN_READ (0x1U)
60 #define NVOS_OPEN_WRITE (0x2U)
65 #define NVOS_OPEN_CREATE (0x4U)
70 #define NVOS_OPEN_APPEND (0x8U)
94 #define NVOS_MAGIC_NUM_COMMON (0xF0250000U)
95 #define NVOS_MAGIC_NUM_COND_HANDLE (NVOS_MAGIC_NUM_COMMON | 0x0000A001U)
96 #define NVOS_MAGIC_NUM_FILE_HANDLE (NVOS_MAGIC_NUM_COMMON | 0x0000B001U)
97 #define NVOS_MAGIC_NUM_LIB_HANDLE (NVOS_MAGIC_NUM_COMMON | 0x0000C001U)
98 #define NVOS_MAGIC_NUM_MUTEX_HANDLE (NVOS_MAGIC_NUM_COMMON | 0x0000D001U)
99 #define NVOS_MAGIC_NUM_SEMA_HANDLE (NVOS_MAGIC_NUM_COMMON | 0x0000E001U)
100 #define NVOS_MAGIC_NUM_THREAD_HANDLE (NVOS_MAGIC_NUM_COMMON | 0x0000F001U)
101 #define NVOS_MAGIC_NUM_INVALID (0xFFFFFFFFU)
132 static inline void NvOsQnxErrnoToNvError(
NvError *e)
139 *e = NvError_ReadOnlyAttribute;
142 *e = NvError_FileNotFound;
145 *e = NvError_AccessDenied;
148 *e = NvError_DirOperationFailed;
151 *e = NvError_InvalidAddress;
154 *e = NvError_NotSupported;
157 *e = NvError_NotSupported;
160 *e = NvError_ResourceError;
163 *e = NvError_AlreadyAllocated;
166 *e = NvError_FileOperationFailed;
173 *e = NvError_InvalidAddress;
176 *e = NvError_InvalidSize;
179 *e = NvError_InterruptedBySignal;
182 *e = NvError_AlreadyAllocated;
185 *e = NvError_NotSupported;
188 *e = NvError_InvalidSize;
191 *e = NvError_AccessDenied;
194 *e = NvError_Timeout;
197 *e = NvError_Timeout;
200 *e = NvError_InvalidState;
203 *e = NvError_ModuleNotPresent;
206 *e = NvError_BadParameter;
209 *e = NvError_NotSupported;
212 *e = NvError_InsufficientMemory;
215 *e = NvError_ProcessDoesNotExist;
218 *e = NvError_InvalidSize;
221 *e = NvError_InvalidState;
226 #elif defined(__linux__)
232 case EROFS: *e = NvError_ReadOnlyAttribute;
break;
233 case ENOENT: *e = NvError_FileNotFound;
break;
234 case EACCES: *e = NvError_AccessDenied;
break;
235 case ENOTDIR: *e = NvError_DirOperationFailed;
break;
236 case EEXIST: *e = NvError_PathAlreadyExists;
break;
237 case EFAULT: *e = NvError_InvalidAddress;
break;
238 case ENFILE: *e = NvError_FileOperationFailed;
break;
239 case EMFILE: *e = NvError_FileOperationFailed;
break;
240 case EIO: *e = NvError_ResourceError;
break;
241 case EADDRINUSE: *e = NvError_AlreadyAllocated;
break;
242 case EBADF: *e = NvError_FileOperationFailed;
break;
243 case EAGAIN: *e = NvError_Busy;
break;
244 case EADDRNOTAVAIL: *e = NvError_InvalidAddress;
break;
245 case EFBIG: *e = NvError_InvalidSize;
break;
246 case EINTR: *e = NvError_Timeout;
break;
247 case EALREADY: *e = NvError_AlreadyAllocated;
break;
248 case EOPNOTSUPP: *e = NvError_NotSupported;
break;
249 case ENOSPC: *e = NvError_InvalidSize;
break;
250 case EPERM: *e = NvError_AccessDenied;
break;
251 case ETIME: *e = NvError_Timeout;
break;
252 case ETIMEDOUT: *e = NvError_Timeout;
break;
253 case ELOOP: *e = NvError_InvalidState;
break;
254 case ENXIO: *e = NvError_ModuleNotPresent;
break;
255 case ENOMEM: *e = NvError_InsufficientMemory;
break;
256 case EINVAL: *e = NvError_BadValue;
break;
257 case ENODEV: *e = NvError_DeviceNotFound;
break;
258 case ERANGE: *e = NvError_InvalidSize;
break;
282 #ifdef INCLUDED_NVOS_H
283 NvOsMemAttribute_Reserved = 0,
298 #ifdef INCLUDED_NVOS_H
299 #if defined(__LP64__) && !defined(__DEPRECATE_NVOS_MEM_ATTR_UNCACHED__) && (!NVOS_IS_QNX)
300 #if defined(__GNUC__) && (__GNUC__ >= 4) && (__GNUC_MINOR__ >= 6)
301 #pragma GCC diagnostic warning "-Wdeprecated-declarations"
302 #define DEPRECATE_NVOS_MEM_ATTR_UNCACHED __attribute__ ((deprecated(\
303 "Use NvOsMemAttribute_WriteCombined instead!!\n"\
304 "Use proper barrier protection when moved to writecombined\n"\
305 "VPR is treated as strongly ordered in kernel even if you use\n"\
306 "writecombined. So, no need for barrier protection for VPR allocations")))
309 #define NvOsMemAttribute_Uncached NvOsMemAttribute_Reserved
312 #define NvOsMemAttribute_Uncached NvOsMemAttribute_Reserved
317 #define NVOS_MEM_NONE 0x0U
320 #define NVOS_MEM_READ 0x1U
323 #define NVOS_MEM_WRITE 0x2U
326 #define NVOS_MEM_EXECUTE 0x4U
329 #define NVOS_MEM_READ_WRITE (NVOS_MEM_READ | NVOS_MEM_WRITE)
332 #define NVOS_MEM_MMAP_FIXED 0x40U
335 #define NVOS_MEM_MMAP_LAZY 0x80U
338 #define NVOS_MEM_MMAP_POPULATE 0x100U
359 #if !defined(NV_ENABLE_DEBUG_PRINTS)
360 #define NV_ENABLE_DEBUG_PRINTS 0
362 #if NV_ENABLE_DEBUG_PRINTS && NV_DEBUG
363 #define NV_DEBUG_PRINTF(x) do { NvOsDebugPrintf x; } while (NV_FALSE)
365 #define NV_DEBUG_PRINTF(x) do {} while (NV_FALSE)
370 #define NVOS_PATH_MAX 256
406 size_t size,
void **ptr);
1163 long int NvUStrtol(
const char *s,
char **endptr,
int base);
1197 uint32_t
NvUStrtoui(
const char *s,
char **endptr, int32_t base);
1231 unsigned long int NvUStrtoul(
const char *s,
char **endptr,
int base);
1266 unsigned long long int NvUStrtoull(
const char *s,
char **endptr,
int base);
1332 void NvOsStrncpy(
char *dest,
const char *src,
size_t size);
1336 #define NV_SHOW_ERRORS NV_DEBUG
1340 #define NV_SHOW_ERROR(err) NvOsShowError(err,__FILE__,__LINE__)
1344 #define NV_SHOW_ERROR(err) (err)
1408 void NvOsMemcpy(
void *dest,
const void *src,
size_t size);
1796 #if defined(__QNX__)
1831 #if defined(__QNX__)
2352 const char *src,
size_t count);
2391 const char *src,
size_t count);
2427 #if defined(__cplusplus)
2431 #endif // INCLUDED_NVOS_COMMON_TEGRA_SAFETY_H
int32_t NvOsSnprintfStrWith2U32(char *dst, size_t max_count, const char *src, NvU32 val0, NvU32 val1)
This function generates a formatted string with a string and two unsigned integers and copy it into t...
void * NvUAlloc0(size_t size)
This function dynamically allocates zeroed memory.
@ NvOsCodePage_Windows1252
void * NvOsTlsGet(NvOsTlsKeyHandle TlsIndex)
This function gets the thread specific data, which is pointed by TlsIndex parameter.
int32_t NvOsSnprintfStrHexU64(char *dst, size_t max_count, const char *src, NvU64 val)
This function generates a formatted string with a string and an unsigned 64bit integer(in hex format)...
int32_t NvOsSnprintfStrU64(char *dst, size_t max_count, const char *src, NvU64 val)
This function generates a formatted string with a string and unsigned 64-bit integer and copy it into...
struct NvOsPageAllocRec * NvOsPageAllocHandle
@ NvOsSeek_End
NvOS equivalent of SEEK_END.
void NvOsMemcpy(void *dest, const void *src, size_t size)
This function copy to destination pointer from source pointer, and copying length is given as size pa...
NvError
The NvError enumeration contains ALL return / error codes.
void NvOsClosedir(NvOsDirHandle dir)
This function closes a directory.
void NvOsThreadYield(void)
This function yields the caller thread and let other thread run.
NvError NvOsFcloseEx(NvOsFileHandle hFile)
This function closes a file stream.
int32_t NvOsSnprintfStrHexRawBytes(char *dst, size_t max_count, const char *src, NvU32 val)
This function generates a formatted string with a string and an unsigned integer(in hex format) and c...
@ NvOsThreadPriorityType_Last
NvError NvOsStrncpySafe(char *dest, size_t destsz, const char *src, size_t count)
This function copies the source string to the destination string up to the maximum length specified b...
@ NvOsThreadPriorityType_Native
NvOsThreadPriorityType_Native is ONLY valid when used with NvOsThreadCreateWithAttr using this value ...
NvError NvOsOpendir(const char *path, NvOsDirHandle *dir)
This function opens a directory.
@ NvOsSeek_Set
NvOS equivalent of SEEK_SET.
NvOsCodePage
Defines straight-forward mappings to international language encodings.
int32_t NvOsSnprintfStrS32(char *dst, size_t max_count, const char *src, NvS32 val)
This function generates a formatted string with a string and a signed integer and copy it into the ou...
void NvOsStrncpy(char *dest, const char *src, size_t size)
This function copy to dest string parameter from src string parameter, And the maximum copying length...
int32_t NvOsSnprintfStrHexU32(char *dst, size_t max_count, const char *src, NvU32 val)
This function generates a formatted string with a string and an unsigned integer(in hex format) and c...
int32_t NvOsSnprintfStrU32(char *dst, size_t max_count, const char *src, NvU32 val)
This function generates a formatted string with a string and unsigned integer and copy it into the ou...
int32_t NvOsSnprintfU32(char *dst, size_t max_count, NvU32 val)
This function generates a formatted string with a unsigned integer and copy it into the output array,...
struct NvOsInterruptRec * NvOsInterruptHandle
@ NvOsFileType_CharacterDevice
@ NvOsPageFlags_Contiguous
NvError NvOsFread(NvOsFileHandle hFile, void *ptr, size_t size, size_t *bytes)
This function read from a file stream and store to ptr parameter.
NvError NvOsShowError(NvError err, const char *file, int line)
This function prints an error and the line it appeared on. Does nothing if err is NvSuccess.
struct NvOsStatTypeRec NvOsStatType
int32_t NvOsSnprintfStrPtr(char *dst, size_t max_count, const char *src, const void *ptr)
This function generates a formatted string with a string and a pointer and copy it into the output ar...
NvError NvOsTlsAddTerminator(void(*func)(void *args), void *context)
This function registers a function which will be called when thread terminates successfully.
NvError NvOsSharedMemMap(NvOsSharedMemHandle descriptor, size_t offset, size_t size, void **ptr)
NvError NvOsStrErrorSafe(int errnum, char *buf, size_t buflen)
The function converts an error number to an error string and stores the string inside the buffer spec...
struct NvOsSharedMemRec * NvOsSharedMemHandle
uint32_t NvUStrtoui(const char *s, char **endptr, int32_t base)
This function convert to unsigned int from string pointer.
static NvBool NvOsLinuxErrnoToNvError(NvError *e)
struct NvOsFileRec NvOsFile
NvError NvOsFstat(NvOsFileHandle hFile, NvOsStatType *filestat)
This function gets a type of file stream, as file, directory, fifo, character device and unknown.
NvError NvOsFopen(const char *path, NvU32 flags, NvOsFileHandle *file)
This function opens a file stream from path parameter.
long int NvUStrtol(const char *s, char **endptr, int base)
This function converts a string to integer.
size_t NvOsStrnlen(const char *s, size_t size)
This function counts the length of given string, and its length is counted up to given size parameter...
unsigned long long int NvUStrtoull(const char *s, char **endptr, int base)
This function convert to unsigned long long int from string pointer.
int32_t NvOsSnprintfS32(char *dst, size_t max_count, NvS32 val)
This function generates a formatted string with a signed integer and copy it into the output array,...
NvError NvOsFseek(NvOsFileHandle hFile, NvS64 offset, NvOsSeekEnum whence)
This function changes the current position of file stream as it is specified by offset and whence par...
struct NvOsFileRec * NvOsFileHandle
@ NvOsThreadPriorityType_Force32
@ NvOsSeek_Cur
NvOS equivalent of SEEK_CUR.
int32_t NvOsSnprintfU64(char *dst, size_t max_count, NvU64 val)
This function generates a formatted string with an unsigned 64-bit integer and copy it into the outpu...
NvError NvOsStrncatSafe(char *dest, size_t destsz, const char *src, size_t count)
This function appends the source string to the destination string up to the maximum length specified ...
NvOsTlsKeyHandle NvOsTlsAlloc(void)
This function creates a thread specific data.
unsigned long int NvUStrtoul(const char *s, char **endptr, int base)
This function convert to unsigned long int from string pointer.
NvError NvOsSharedMemAlloc(const char *key, size_t size, NvOsSharedMemHandle *descriptor)
NvError NvOsStat(const char *filename, NvOsStatType *filestat)
This function gets a type of path.
NvBool NvOsTlsRemoveTerminator(void(*func)(void *args), void *context)
This function unregisters a function from the list of functions will be called when thread terminates...
@ NvOsMemAttribute_InnerWriteBack
void NvOsTlsFree(NvOsTlsKeyHandle TlsIndex)
This function free the thread specific data, which is pointed by TlsIndex parameter.
void NvOsSharedMemFree(NvOsSharedMemHandle descriptor)
NvOsMemAttribute
Defines memory attributes.
void NvOsTlsSet(NvOsTlsKeyHandle TlsIndex, void *value)
This function set a thread specific data, which is pointed by TlsIndex parameter.
@ NvOsPageFlags_NonContiguous
NvError NvOsSharedMemHandleFromFd(int fd, NvOsSharedMemHandle *descriptor)
NvError NvOsSharedMemGetFd(NvOsSharedMemHandle descriptor, int *fd)
@ NvOsSeek_Force32
Max value of NvOsSeekEnum.
int32_t NvOsSnprintfStrWith2S32(char *dst, size_t max_count, const char *src, NvS32 val0, NvS32 val1)
This function generates a formatted string with a string and two signed integers and copy it into the...
@ NvOsMemAttribute_Uncached
int32_t NvOsSnprintfStr(char *dst, size_t max_count, const char *src)
This function generates a formatted string with a string and copy it into the output array,...
@ NvOsMemAttribute_Secured
NvError NvOsFflush(NvOsFileHandle hFile)
This function flush a file stream, if there is any buffered/unwritten memory regarding the file strea...
@ NvOsMemAttribute_Force32
@ NvOsMemAttribute_DeviceMemory
@ NvOsThreadPriorityType_NearInterrupt
NvU64 NvOsGetCurrentThreadId(void)
This function returns the thread id.
NvOsTlsKeyHandle NvOsTlsAllocWithDestructor(void(*destructor)(void *args))
This function creates a thread specific data, and store function pointer into it, and the function po...
NvError NvOsFtell(NvOsFileHandle hFile, NvU64 *position)
This function gets the current position of file stream, and it is stored to position parameter as byt...
@ NvOsMemAttribute_SO_DeviceMemory
@ NvOsFileType_BlockDevice
NvError NvOsFwrite(NvOsFileHandle hFile, const void *ptr, size_t size)
This function writes the buffer to a file stream, and the length or writing is up to size parameter.
void NvOsSharedMemUnmap(void *ptr, size_t size)
@ NvOsMemAttribute_WriteBack
int32_t NvOsSnprintfStrFloat(char *dst, size_t max_count, const char *src, NvF32 val)
This function generates a formatted string with a string and a float and copy it into the output arra...
@ NvOsMemAttribute_WriteCombined
@ NvOsThreadPriorityType_Normal
NvError NvOsFgetc(NvOsFileHandle hFile, NvU8 *c)
This function read a character from the current position of a file stream,and the read character is s...