NVIDIA DriveOS Linux SDK API Reference

7.2.5.0 Early Access Release
nvos_s3_tegra_safety.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: Copyright (c) 2019-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3  * SPDX-License-Identifier: LicenseRef-NvidiaProprietary
4  *
5  * NVIDIA CORPORATION and its licensors retain all intellectual property
6  * and proprietary rights in and to this software, related documentation
7  * and any modifications thereto. Any use, reproduction, disclosure or
8  * distribution of this software and related documentation without an express
9  * license agreement from NVIDIA CORPORATION is strictly prohibited
10  */
11 
12 #ifndef INCLUDED_NVOS_S3_TEGRA_SAFETY_H
13 #define INCLUDED_NVOS_S3_TEGRA_SAFETY_H
14 
15 #if defined(__QNX__) || defined(__linux__)
16 
17 #include <stdarg.h>
18 #include <unistd.h>
19 
20 #include "nverror.h"
21 #include "nvtypes.h"
22 
24 #include "nvos_s3_tegra_log.h"
25 
26 #if defined(__cplusplus)
27 extern "C"
28 {
29 #endif
30 
39 typedef struct NvOsConditionRec *NvOsConditionHandle;
40 
83 void *NvOsAllocAlign(size_t align, size_t size);
84 
91 typedef enum
92 {
94  NvOsOs_Unknown = 0x0UL,
96  NvOsOs_Windows = 0x1UL,
98  NvOsOs_Linux = 0x2UL,
100  NvOsOs_Qnx = 0x4UL,
104  NvOsOs_Force32 = 0x7FFFFFFFUL,
105 } NvOsOs;
106 
108 typedef enum
109 {
115  NvOsSku_Force32 = 0x7FFFFFFFUL,
116 } NvOsSku;
117 
120 typedef struct
121 {
126 } NvOsOsInfo;
127 
157 
193 void NvOsGetProcessInfo(char* buf, NvU32 len);
194 
225 
264 
304 
340 
344 typedef struct NvOsMutexRec *NvOsMutexHandle;
345 
381 
424  NvOsConditionHandle cond,
425  NvOsMutexHandle mutex,
426  NvU32 microsecs);
427 
436 typedef void *NvOsLibraryHandle;
437 
469 void* NvOsLibraryGetSymbol(NvOsLibraryHandle library, const char *symbol);
470 
508 NvError NvOsLibraryLoad(const char *name, NvOsLibraryHandle *library);
509 
547 
588 void *NvOsAlloc(size_t size);
589 
624 void NvOsFree(void *ptr);
625 
656 void NvOsMemset(void *s, NvU8 c, size_t size);
657 
698 void *NvOsRealloc(void *ptr, size_t size);
699 
737 int32_t NvOsTypeMemInit(const char *typ_mem_name, int32_t *handle);
738 
777 int32_t NvOsTypeMemDeinit(int32_t handle);
778 
819 void *NvOsAllocTypeMemCached(int32_t handle, size_t size, uint32_t flags,
820  int64_t *paddr);
821 
862 void *NvOsAllocTypeMemUncached(int32_t handle, size_t size, uint32_t flags,
863  int64_t *paddr);
864 
908 int32_t NvOsTypeMemFree(size_t size, void *ptr);
909 
956 
995 
1037 
1071 
1122 NvError NvOsMapRegSpace(NvU64 *reg, NvU32 base, NvU32 size);
1123 
1158 NvU32 NvOsReadReg(NvU64 reg, NvU32 off);
1159 
1202 NvError NvOsUnMapRegSpace(NvU64 *reg, NvU32 base, NvU32 size);
1203 
1235 void NvOsWriteReg(NvU64 reg, NvU32 off, NvU32 val);
1236 
1245 typedef struct NvOsSemaphoreRec *NvOsSemaphoreHandle;
1246 
1287  NvOsSemaphoreHandle orig,
1288  NvOsSemaphoreHandle *semaphore);
1289 
1338 NvError NvOsSemaphoreCreate(NvOsSemaphoreHandle *semaphore, NvU32 value);
1339 
1385 
1420 
1459 
1507 
1541 void NvOsSleepMS(NvU32 msec);
1542 
1579 NvError NvOsSleepUS(NvU32 usec);
1580 
1618 NvError NvOsSleepNS(NvU32 nsec);
1619 
1620 NVOS_COV_WHITELIST(deviate, NVOS_MISRA(Rule, 3_1), "<QNXBSP>:<nvidia>:<1>:<TID-320>")
1655 NvError NvOsBusyWaitUS(NvU32 usec);
1656 
1657 NVOS_COV_WHITELIST(deviate, NVOS_MISRA(Rule, 3_1), "<QNXBSP>:<nvidia>:<1>:<TID-320>")
1692 NvError NvOsBusyWaitNS(NvU32 nsec);
1693 
1699 #if defined(__QNX__)
1700 
1703 #define NVOS_INVALID_TLS_INDEX (-1)
1704 #elif defined(__linux__)
1705 #define NVOS_INVALID_TLS_INDEX 0xFFFFFFFFU
1706 #endif
1707 
1711 typedef void (*NvOsThreadFunction)(void *args);
1712 
1716 typedef struct NvOsThreadRec *NvOsThreadHandle;
1717 
1763  NvOsThreadFunction function,
1764  void *args,
1765  NvOsThreadHandle *thread);
1766 
1812 
1856 NvError NvOsThreadSetName(NvOsThreadHandle t, const char *name);
1857 
1866 typedef struct
1867 {
1868  NvU32 Seconds;
1870 } NvOsSystemTime;
1871 
1903 NvError NvOsGetSystemTime(NvOsSystemTime *hNvOsSystemtime);
1904 
1930 NvU32 NvOsGetTimeMS(void);
1931 
1968 NvU64 NvOsGetTimeNS(void);
1969 
1996 NvU64 NvOsGetTimeUS(void);
1997 
2041 NvS32 NvOsAtomicExchange32(NvS32 *pTarget, NvS32 value);
2042 
2083 NvS32 NvOsAtomicExchangeAdd32(NvS32 *pTarget, NvS32 value);
2084 
2120 NvError NvOsGetConfigString(const char *name, char *value, NvU32 size);
2121 
2154 NvError NvOsGetConfigU32(const char *name, NvU32 *value);
2155 
2192 NvError NvOsGetSysConfigString(const char *name, char *value, NvU32 size);
2193 
2237 #if defined(__QNX__)
2239  void **pTarget,
2240  const void *OldValue,
2241  const void *NewValue);
2242 #else
2244  void **pTarget,
2245  void *OldValue,
2246  void *NewValue);
2247 #endif
2248 
2291  NvS32 *pTarget,
2292  NvS32 OldValue,
2293  NvS32 NewValue);
2294 
2295 #if defined(__linux__)
2296 
2324 int NvOsDebugExternalLogInit(void);
2325 #endif
2326 
2327 typedef enum
2328 {
2333 
2334 struct NvOsAllocatorRec;
2335 typedef void* (*NvOsAllocFunc)(struct NvOsAllocatorRec *rec, size_t size);
2336 typedef void* (*NvOsAllocAlignFunc)(struct NvOsAllocatorRec *rec,
2337  size_t align,
2338  size_t size);
2339 typedef void* (*NvOsReallocFunc)(struct NvOsAllocatorRec *rec,
2340  void *ptr,
2341  size_t size);
2342 typedef void (*NvOsFreeFunc)(struct NvOsAllocatorRec *rec, void *ptr);
2343 
2344 typedef struct NvOsAllocatorRec {
2349 } NvOsAllocator;
2350 
2352 
2353 #if defined(__linux__) && NV_DEBUG
2354 
2355 void *NvOsAllocLeak(NvOsAllocator *a, size_t size, const char *f, int l);
2356 
2357 void *NvOsAllocAlignLeak(NvOsAllocator *a, size_t align, size_t size, const char *f, int l);
2358 
2359 void *NvOsReallocLeak(NvOsAllocator *a, void *ptr, size_t size, const char *f, int l);
2360 
2361 void NvOsFreeLeak(NvOsAllocator *a, void *ptr, const char *f, int l);
2362 
2363 #define NvOsAlloc(size) NvOsAllocLeak(NvOsGetCurrentAllocator(), size, __FILE__, __LINE__)
2364 #define NvOsAllocAlign(align, size) NvOsAllocAlignLeak(NvOsGetCurrentAllocator(), align, size, __FILE__, __LINE__)
2365 #define NvOsRealloc(ptr, size) NvOsReallocLeak(NvOsGetCurrentAllocator(), ptr, size, __FILE__, __LINE__)
2366 #define NvOsFree(ptr) NvOsFreeLeak(NvOsGetCurrentAllocator(), ptr, __FILE__, __LINE__)
2367 
2368 #endif
2369 
2370 typedef NvBool (*NvOsAllocSimCB)(NvOsAllocHookType AllocType, void *UserContext);
2371 
2372 void NvOsSetAllocHook(NvOsAllocSimCB Hook, void* UserContext);
2373 
2374 #if defined(__cplusplus)
2375 }
2376 #endif
2377 
2378 #else /* defined(__QNX__) */
2379 #include "nvos_tegra_nonsafety.h"
2380 #endif /* defined(__QNX__) */
2381 
2382 #endif // INCLUDED_NVOS_S3_TEGRA_SAFETY_H
NvOsAllocator
struct NvOsAllocatorRec NvOsAllocator
NvOsAllocFunc
void *(* NvOsAllocFunc)(struct NvOsAllocatorRec *rec, size_t size)
Definition: nvos_s3_tegra_safety.h:2335
NvOsWriteReg
void NvOsWriteReg(NvU64 reg, NvU32 off, NvU32 val)
This function writes the val parameter to the sum of two parameters (Reg and Off) and the sum is pass...
NvOsSemaphoreCreate
NvError NvOsSemaphoreCreate(NvOsSemaphoreHandle *semaphore, NvU32 value)
This function creates a semaphore, and the number of wait operations, is initialized to the value par...
NvOsConditionCreate
NvError NvOsConditionCreate(NvOsConditionHandle *cond)
This function creates a condition.
NvOsFree
void NvOsFree(void *ptr)
This function free the allocated memory.
NvOsGetSysConfigString
NvError NvOsGetSysConfigString(const char *name, char *value, NvU32 size)
This function gets an environment variable as string pointer. And copy it to value parameter by strnc...
NvError
NvError
The NvError enumeration contains ALL return / error codes.
Definition: nverror.h:43
NvOsConditionDestroy
NvError NvOsConditionDestroy(NvOsConditionHandle cond)
This function destroys a condition.
NvOsAllocatorRec::AllocAlign
NvOsAllocAlignFunc AllocAlign
Definition: nvos_s3_tegra_safety.h:2346
NvOsSemaphoreWaitEx
NvError NvOsSemaphoreWaitEx(NvOsSemaphoreHandle semaphore)
This function waits a semaphore, and decrease the number of wait operations. Thread is blocked infini...
NvOsConditionBroadcast
NvError NvOsConditionBroadcast(NvOsConditionHandle cond)
This function resumes multiple threads which wait the condition.
NvOsMutexCreate
NvError NvOsMutexCreate(NvOsMutexHandle *mutex)
This function creates a mutex.
NvOsThreadJoinEx
NvError NvOsThreadJoinEx(NvOsThreadHandle t)
This function blocks until while the thread is running, after the thread is terminated,...
NvOsThreadSetName
NvError NvOsThreadSetName(NvOsThreadHandle t, const char *name)
This function set thread name.
NvOsSemaphoreWaitTimeout
NvError NvOsSemaphoreWaitTimeout(NvOsSemaphoreHandle semaphore, NvU32 msec)
This function waits a semaphore and decreases the number of wait operation.
nvos_s3_tegra_log.h
NvOsAllocHookType_Realloc
@ NvOsAllocHookType_Realloc
Definition: nvos_s3_tegra_safety.h:2331
NvOsOs_Integrity
@ NvOsOs_Integrity
Integrity OS.
Definition: nvos_s3_tegra_safety.h:102
NvOsSku_Unknown
@ NvOsSku_Unknown
Unknown SKU.
Definition: nvos_s3_tegra_safety.h:111
NvOsLibraryHandle
void * NvOsLibraryHandle
Definition: nvos_s3_tegra_safety.h:436
NVOS_MISRA
#define NVOS_MISRA(type, num)
These macros are used for whitelisting coverity violations.
Definition: nvos_static_analysis.h:196
nverror.h
NvOsMutexHandle
struct NvOsMutexRec * NvOsMutexHandle
Definition: nvos_s3_tegra_safety.h:344
NvOsAllocTypeMemCached
void * NvOsAllocTypeMemCached(int32_t handle, size_t size, uint32_t flags, int64_t *paddr)
Allocate cached typed memory.
NvOsGetConfigString
NvError NvOsGetConfigString(const char *name, char *value, NvU32 size)
This function gets an environment variable as string pointer. And copy it to value parameter by strnc...
NvOsOsInfo::Sku
NvOsSku Sku
OS SKU.
Definition: nvos_s3_tegra_safety.h:125
NvOsSleepUS
NvError NvOsSleepUS(NvU32 usec)
This function sleep during the given microsecond.
NvOsOsInfo
Info about OS type and the chip SKU.
Definition: nvos_s3_tegra_safety.h:120
NvOsBusyWaitUS
NvError NvOsBusyWaitUS(NvU32 usec)
This function busy-wait without blocking for a period of time. This function is designed for use with...
NvOsSku_Android
@ NvOsSku_Android
Android.
Definition: nvos_s3_tegra_safety.h:113
NvOsAllocAlign
void * NvOsAllocAlign(size_t align, size_t size)
This function allocates aligned memory.
NvOsOs_Force32
@ NvOsOs_Force32
Max value for NvOsOs.
Definition: nvos_s3_tegra_safety.h:104
NvOsReallocFunc
void *(* NvOsReallocFunc)(struct NvOsAllocatorRec *rec, void *ptr, size_t size)
Definition: nvos_s3_tegra_safety.h:2339
NvOsFreeFunc
void(* NvOsFreeFunc)(struct NvOsAllocatorRec *rec, void *ptr)
Definition: nvos_s3_tegra_safety.h:2342
NvOsSemaphoreHandle
struct NvOsSemaphoreRec * NvOsSemaphoreHandle
Definition: nvos_s3_tegra_safety.h:1245
NvOsLibraryGetSymbol
void * NvOsLibraryGetSymbol(NvOsLibraryHandle library, const char *symbol)
This function get symbol from the loaded dynamic library.
NvOsMemset
void NvOsMemset(void *s, NvU8 c, size_t size)
This function initializes the memory with the c parameter, And the length of initializing memory,...
NvOsAllocAlignFunc
void *(* NvOsAllocAlignFunc)(struct NvOsAllocatorRec *rec, size_t align, size_t size)
Definition: nvos_s3_tegra_safety.h:2336
NvOsAllocHookType_Free
@ NvOsAllocHookType_Free
Definition: nvos_s3_tegra_safety.h:2330
NvOsSku
NvOsSku
Definition: nvos_s3_tegra_safety.h:108
NvOsSemaphoreDestroyEx
NvError NvOsSemaphoreDestroyEx(NvOsSemaphoreHandle semaphore)
This function destroys a semaphore.
NvOsTypeMemDeinit
int32_t NvOsTypeMemDeinit(int32_t handle)
Close typed memory handle.
NvOsSku_Force32
@ NvOsSku_Force32
Max value for NvOsSku.
Definition: nvos_s3_tegra_safety.h:115
nvos_common_tegra_safety.h
NvOsConditionWaitTimeout
NvError NvOsConditionWaitTimeout(NvOsConditionHandle cond, NvOsMutexHandle mutex, NvU32 microsecs)
This function waits for a condition till timeout.
NvOsAtomicCompareExchange32
NvS32 NvOsAtomicCompareExchange32(NvS32 *pTarget, NvS32 OldValue, NvS32 NewValue)
This function assigns new value to pointer if the value of pointer is same with the value specified b...
NvOsRealloc
void * NvOsRealloc(void *ptr, size_t size)
This function resizes the allocated memory as the size parameter.
NvOsOsInfo::OsType
NvOsOs OsType
OS type - qnx, linux, etc.
Definition: nvos_s3_tegra_safety.h:123
NvOsOs_Qnx
@ NvOsOs_Qnx
QNX OS.
Definition: nvos_s3_tegra_safety.h:100
NvOsDebugExternalLogInit
int NvOsDebugExternalLogInit(void)
This function initializes the connection with syslog. And if a shared memory for log level control ex...
NvOsGetCurrentAllocator
struct NvOsAllocatorRec * NvOsGetCurrentAllocator(void)
NvOsLibraryLoad
NvError NvOsLibraryLoad(const char *name, NvOsLibraryHandle *library)
This function loads the dynamic library.
NvOsConditionHandle
struct NvOsConditionRec * NvOsConditionHandle
Definition: nvos_s3_tegra_safety.h:39
NvOsThreadFunction
void(* NvOsThreadFunction)(void *args)
Definition: nvos_s3_tegra_safety.h:1711
NvOsAtomicExchange32
NvS32 NvOsAtomicExchange32(NvS32 *pTarget, NvS32 value)
This function atomically swaps the contents of a 32-bit memory location with a value....
NvOsSetAllocHook
void NvOsSetAllocHook(NvOsAllocSimCB Hook, void *UserContext)
NvOsAtomicExchangeAdd32
NvS32 NvOsAtomicExchangeAdd32(NvS32 *pTarget, NvS32 value)
This function atomically increments the contents of a 32-bit memory location by a specified amount....
NvOsAllocHookType
NvOsAllocHookType
Definition: nvos_s3_tegra_safety.h:2327
NvOsAllocSimCB
NvBool(* NvOsAllocSimCB)(NvOsAllocHookType AllocType, void *UserContext)
Definition: nvos_s3_tegra_safety.h:2370
NvOsAllocatorRec::Free
NvOsFreeFunc Free
Definition: nvos_s3_tegra_safety.h:2348
NvOsSleepNS
NvError NvOsSleepNS(NvU32 nsec)
This function sleep during the given nanosecond.
NvOsSystemTime
System Time Structure.
Definition: nvos_s3_tegra_safety.h:1866
NvOsGetTimeNS
NvU64 NvOsGetTimeNS(void)
This function gets the current time as nanosecond.
void
typedef void(WFD_APIENTRY PFNWFDBINDSOURCETOPIPELINEWITHTIMESTAMPNV)(const WFDDevice device
NvOsOs_Linux
@ NvOsOs_Linux
Linux OS.
Definition: nvos_s3_tegra_safety.h:98
NvOsSemaphoreSignalEx
NvError NvOsSemaphoreSignalEx(NvOsSemaphoreHandle semaphore)
This function increases the number of wait operation, to given semaphore.
NvOsGetTimeMS
NvU32 NvOsGetTimeMS(void)
This function returns the current time as millisecond.
NvOsLibraryUnloadEx
NvError NvOsLibraryUnloadEx(NvOsLibraryHandle library)
This function unloads the loaded dynamic lib.
NvOsUnMapRegSpace
NvError NvOsUnMapRegSpace(NvU64 *reg, NvU32 base, NvU32 size)
This function unmap device's physical address from process's address space.
NvOsAlloc
void * NvOsAlloc(size_t size)
This function returns the allocated memory dynamically, and allocated memory is not initialized.
NvOsThreadHandle
struct NvOsThreadRec * NvOsThreadHandle
Definition: nvos_s3_tegra_safety.h:1716
NvOsMutexLockEx
NvError NvOsMutexLockEx(NvOsMutexHandle mutex)
This function locks a mutex.
NvOsTypeMemInit
int32_t NvOsTypeMemInit(const char *typ_mem_name, int32_t *handle)
Open type memory specified by typ_mem_name and return the handle to the typed memory.
NvOsMutexUnlockEx
NvError NvOsMutexUnlockEx(NvOsMutexHandle mutex)
This function unlocks a mutex.
NvOsAllocatorRec::Realloc
NvOsReallocFunc Realloc
Definition: nvos_s3_tegra_safety.h:2347
NvOsMutexDestroyEx
NvError NvOsMutexDestroyEx(NvOsMutexHandle mutex)
This function destroys a mutex.
NvOsSleepMS
void NvOsSleepMS(NvU32 msec)
This function sleep during the given millisecond.
NvOsAtomicCompareExchangePtr
void * NvOsAtomicCompareExchangePtr(void **pTarget, void *OldValue, void *NewValue)
This function atomically compares the contents of a pointer-sized memory location with a value,...
NvOsGetSystemTime
NvError NvOsGetSystemTime(NvOsSystemTime *hNvOsSystemtime)
This function gets the current time as seconds and milliseconds.
NvOsOs_Unknown
@ NvOsOs_Unknown
Unsupported OS.
Definition: nvos_s3_tegra_safety.h:94
NvOsGetOsInformation
NvError NvOsGetOsInformation(NvOsOsInfo *pOsInfo)
This function gets the OS information.
handle
const WFDCommitType const WFDHandle handle
Definition: wfdext.h:532
NvOsAllocTypeMemUncached
void * NvOsAllocTypeMemUncached(int32_t handle, size_t size, uint32_t flags, int64_t *paddr)
Allocate non-cached typed memory.
NvOsAllocatorRec::Alloc
NvOsAllocFunc Alloc
Definition: nvos_s3_tegra_safety.h:2345
NvOsTypeMemFree
int32_t NvOsTypeMemFree(size_t size, void *ptr)
Frees the previously allocated memory. This function removes any mappings for pages in the address ra...
NvOsConditionWait
NvError NvOsConditionWait(NvOsConditionHandle cond, NvOsMutexHandle mutex)
This function waits a condition.
NvOsAllocatorRec
Definition: nvos_s3_tegra_safety.h:2344
NvOsThreadCreate
NvError NvOsThreadCreate(NvOsThreadFunction function, void *args, NvOsThreadHandle *thread)
This function creates a thread with entry point and parameter of entry point. All signals are blocked...
NvOsSemaphoreClone
NvError NvOsSemaphoreClone(NvOsSemaphoreHandle orig, NvOsSemaphoreHandle *semaphore)
This function clones the semaphore.
NVOS_COV_WHITELIST
#define NVOS_COV_WHITELIST(type, checker, comment_str)
Definition: nvos_static_analysis.h:199
NvOsGetConfigU32
NvError NvOsGetConfigU32(const char *name, NvU32 *value)
This function get an environment variable as integer.
NvOsMapRegSpace
NvError NvOsMapRegSpace(NvU64 *reg, NvU32 base, NvU32 size)
This function map device's physical address to process's address space. And mapped address is stored ...
NvOsAllocHookType_Alloc
@ NvOsAllocHookType_Alloc
Definition: nvos_s3_tegra_safety.h:2329
NvOsOs_Windows
@ NvOsOs_Windows
Windows OS.
Definition: nvos_s3_tegra_safety.h:96
NvOsOs
NvOsOs
Definition: nvos_s3_tegra_safety.h:91
NvOsGetTimeUS
NvU64 NvOsGetTimeUS(void)
This function returns the current time as microsecond.
NvOsReadReg
NvU32 NvOsReadReg(NvU64 reg, NvU32 off)
This function reads the value of device's physical address from mapped pointer. And mapped address is...
NvOsGetProcessInfo
void NvOsGetProcessInfo(char *buf, NvU32 len)
This function gets process information. The buf parameter is printed as 's - (pid d)' which followed ...
NvOsSystemTime::Seconds
NvU32 Seconds
Time in seconds.
Definition: nvos_s3_tegra_safety.h:1868
NvOsSystemTime::Milliseconds
NvU32 Milliseconds
Time in milliseconds.
Definition: nvos_s3_tegra_safety.h:1869
NvOsBusyWaitNS
NvError NvOsBusyWaitNS(NvU32 nsec)
This function busy-wait without blocking for a period of time. This function is designed for use with...
NvOsConditionSignal
NvError NvOsConditionSignal(NvOsConditionHandle cond)
This function resumes a thread which wait the condition.