NVIDIA DriveOS Linux NSR SDK API Reference

7.0.3.0 Release
Operating System Abstraction (NvOS)

Detailed Description

This provides a basic set of interfaces to unify code across all supported operating systems. This layer does not handle any hardware specific functions, such as interrupts. "Platform" setup and GPU access are done by other layers.

Warning
Drivers and applications should not make any operating system calls outside of this layer, including stdlib functions. Doing so will result in non-portable code.

For APIs that take key parameters, keys may be of NVOS_KEY_MAX length. Any characters beyond this maximum is ignored.

All strings passed to or from NvOS functions are encoded in UTF-8. For character values below 128, this is the same as simple ASCII.

Important:

At interrupt time there are only a handful of NvOS functions that are safe to call:

NvOs Configuration Data Storage Support

NvOs supports named configuration variables that may have string values or unsigned integer values.

The storage of the configuration data is highly platform dependent. The platform may provide the means to set the initial data for the storage in the platform build phase. Also it may be possible to set and retrieve the values in a running system via OS provided mechanisms.

Information about the configuration data storages for various operating systems follows.

Linux / Win32 x86 Host

On x86 host systems and Linux the configuration data storage is the environment inherited from the shell that launches the application. To set configuration variable values export the appropriate environment variables from the launching shell.

Windows CE / Window Mobile

On target Windows systems the configuration data is stored in the Windows registry, under the registry path:

    HKEY_LOCAL_MACHINE\Software\NVIDIA Corporation\NvOs

The configuration data can be set by .reg files in the image build.

Android

On Android the configuration store is the Android property mechanism. NvOs config variables are stored in the "persist.tegra" namespace. Values can be set via the "setprop" tool and values queried via the "getprop" tool.

As with other Linux systems, the environment acts as a read-only configuration data store. Values read from the environment override those read from Android properties.

Other Target Systems

The default for target systems is to use a file on the file system as the data storage. The path to the file on the target file system is:

   /etc/tegra_config.txt

Data Structures

struct  NvOsOsInfoRec
 
struct  NvOsStatTypeRec
 
struct  NvOsSystemTimeRec
 Defines the system time structure. More...
 
struct  NvOsAllocatorRec
 

Macros

#define NVOS_KEY_MAX   128
 The maximum length of a shared resource identifier string. More...
 
#define NVOS_PATH_MAX   256
 The maximum length for a file system path. More...
 
#define NVOS_HAS_MTIME   1
 Indicates that NvOsStatType structure has mtime. More...
 
#define NVOS_HAS_MKDIR   1
 Indicates that NvOs has NvOsMkdir(). More...
 
#define NVOS_HAS_FTRUNCATE   1
 Indicates that NvOs has NvOsFtruncate(). More...
 
#define NVOS_HAS_CONDITION   1
 Indicates that NvOs has condition variables. More...
 

Typedefs

typedef NvU32 NvOsPhysAddr
 A physical address. More...
 

Variables

NvOsOs NvOsOsInfoRec::OsType
 
NvOsSku NvOsOsInfoRec::Sku
 
NvU64 NvOsStatTypeRec::size
 
NvOsFileType NvOsStatTypeRec::type
 
NvU64 NvOsStatTypeRec::mtime
 last modified time of the file More...
 
NvU32 NvOsSystemTimeRec::Seconds
 
NvU32 NvOsSystemTimeRec::Milliseconds
 
NvOsAllocFunc NvOsAllocatorRec::Alloc
 
NvOsAllocAlignFunc NvOsAllocatorRec::AllocAlign
 
NvOsReallocFunc NvOsAllocatorRec::Realloc
 
NvOsFreeFunc NvOsAllocatorRec::Free
 

Print Operations

enum  {
  NVOS_VERB_LVL_0 = 0,
  NVOS_VERB_LVL_1 = 1,
  NVOS_VERB_LVL_2 = 2,
  NVOS_VERB_LVL_3 = 3,
  NVOS_VERB_LVL_4 = 4
}
 
typedef struct NvOsFileRec * NvOsFileHandle
 Printf family. More...
 
NvError NvOsFprintf (NvOsFileHandle stream, const char *format,...)
 Prints a string to a file stream. More...
 
NvS32 NvOsSnprintf (char *str, size_t size, const char *format,...)
 Expands a string into a given string buffer. More...
 
NvError NvOsVfprintf (NvOsFileHandle stream, const char *format, va_list ap)
 Prints a string to a file stream using a va_list. More...
 
NvS32 NvOsVsnprintf (char *str, size_t size, const char *format, va_list ap)
 Expands a string into a string buffer using a va_list. More...
 
void NvOsDebugPrintf (const char *format,...)
 Outputs a message to the debugging console, if present. More...
 
void NvOsLogPrintf (int prio, const char *tag, const char *format,...)
 Same as NvOsDebugPrintf, except takes priority and tag fields. More...
 
void NvOsDebugVprintf (const char *format, va_list ap)
 Same as NvOsDebugPrintf, except takes a va_list. More...
 
NvS32 NvOsDebugNprintf (const char *format,...)
 Same as NvOsDebugPrintf, except returns the number of chars written. More...
 
void NvOsDebugString (const char *str)
 
int NvOsSetVerboseLevel (NvS32 VerbLevel)
 
int NvOsGetVerboseLevel (NvS32 *VerbLevel)
 
void NvOsVerbosePrintf (NvS32 VerbLevel, const char *Fmt,...)
 
NvError NvOsShowError (NvError err, const char *file, int line)
 Prints an error and the line it appeared on. More...
 
#define NV_SHOW_ERRORS   NV_DEBUG
 Prints err if it is an error (does nothing if err==NvSuccess). More...
 
#define NV_SHOW_ERROR(err)   (err)
 
#define NV_ENABLE_DEBUG_PRINTS   0
 Helper macro to go along with NvOsDebugPrintf. More...
 
#define NV_DEBUG_PRINTF(x)   do {} while (NV_FALSE)
 

OS Version

enum  NvOsOs {
  NvOsOs_Unknown = 0x0UL,
  NvOsOs_Windows = 0x1UL,
  NvOsOs_Linux = 0x2UL,
  NvOsOs_Qnx = 0x4UL,
  NvOsOs_Integrity = 0x5UL,
  NvOsOs_Force32 = 0x7fffffffUL
}
 
enum  NvOsSku {
  NvOsSku_Unknown = 0x0UL,
  NvOsSku_Android = 0x1UL,
  NvOsSku_Force32 = 0x7fffffffUL
}
 
typedef struct NvOsOsInfoRec NvOsOsInfo
 
NvError NvOsGetOsInformation (NvOsOsInfo *pOsInfo)
 Gets the current OS version. More...
 

String Operations

enum  NvOsCodePage {
  NvOsCodePage_Unknown = 0x0UL,
  NvOsCodePage_Utf8 = 0x1UL,
  NvOsCodePage_Utf16 = 0x2UL,
  NvOsCodePage_Windows1252 = 0x3UL,
  NvOsCodePage_Force32 = 0x7fffffffUL
}
 Defines straight-forward mappings to international language encodings. More...
 
void NvOsStrcpy (char *dest, const char *src)
 Copies a string. More...
 
void NvOsStrncpy (char *dest, const char *src, size_t size)
 Copies a string, length-limited. More...
 
size_t NvOsStrlen (const char *s)
 Gets the length of a string. More...
 
size_t NvOsStrnlen (const char *s, size_t size)
 Gets the length of a string. More...
 

Memory Operations (Basic)

void NvOsMemcpy (void *dest, const void *src, size_t size)
 Copies memory. More...
 
int NvOsMemcmp (const void *s1, const void *s2, size_t size)
 Compares two memory regions. More...
 
void NvOsMemset (void *s, NvU8 c, size_t size)
 Sets a region of memory to a value. More...
 

File Input/Output

enum  NvOsSeekEnum {
  NvOsSeek_Set = 0,
  NvOsSeek_Cur = 1,
  NvOsSeek_End = 2,
  NvOsSeek_Force32 = 0x7FFFFFFF
}
 Defines wrappers over stdlib's file stream functions, with some changes to the API. More...
 
enum  NvOsFileType {
  NvOsFileType_Unknown = 0,
  NvOsFileType_File = 1,
  NvOsFileType_Directory = 2,
  NvOsFileType_Fifo = 3,
  NvOsFileType_CharacterDevice = 4,
  NvOsFileType_BlockDevice = 5,
  NvOsFileType_Force32 = 0x7FFFFFFF
}
 
typedef struct NvOsStatTypeRec NvOsStatType
 
NvError NvOsFopen (const char *path, NvU32 flags, NvOsFileHandle *file)
 Opens a file stream. More...
 
NvError NvOsFcloseEx (NvOsFileHandle stream)
 Closes a file stream. More...
 
void NvOsFclose (NvOsFileHandle stream)
 Closes a file stream. More...
 
NvError NvOsFwrite (NvOsFileHandle stream, const void *ptr, size_t size)
 Writes to a file stream. More...
 
NvError NvOsFread (NvOsFileHandle stream, void *ptr, size_t size, size_t *bytes)
 Reads a file stream. More...
 
NvError NvOsFgetc (NvOsFileHandle stream, NvU8 *c)
 Gets a character from a file stream. More...
 
NvError NvOsFseek (NvOsFileHandle file, NvS64 offset, NvOsSeekEnum whence)
 Changes the file position pointer. More...
 
NvError NvOsFtell (NvOsFileHandle file, NvU64 *position)
 Gets the current file position pointer. More...
 
NvError NvOsStat (const char *filename, NvOsStatType *stat)
 Gets file information. More...
 
NvError NvOsFstat (NvOsFileHandle file, NvOsStatType *stat)
 Gets file information from an already open file. More...
 
NvError NvOsFflush (NvOsFileHandle stream)
 Flushes any pending writes to the file stream. More...
 
NvError NvOsFsync (NvOsFileHandle stream)
 Commits any pending writes to storage media. More...
 
NvError NvOsFremove (const char *filename)
 Removes a file from the storage media. More...
 
NvError NvOsFtruncate (NvOsFileHandle stream, NvU64 length)
 Causes the file to have a size of length bytes. More...
 
#define NVOS_OPEN_READ   0x1
 Opens a file with read permissions. More...
 
#define NVOS_OPEN_WRITE   0x2
 Opens a file with write persmissions. More...
 
#define NVOS_OPEN_CREATE   0x4
 Creates a file if is not present on the file system. More...
 
#define NVOS_OPEN_APPEND   0x8
 Open file in append mode. More...
 

Directories

typedef struct NvOsDirRec * NvOsDirHandle
 A handle to a directory. More...
 
NvError NvOsOpendir (const char *path, NvOsDirHandle *dir)
 Opens a directory. More...
 
NvError NvOsReaddir (NvOsDirHandle dir, char *name, size_t size)
 Gets the next entry in the directory. More...
 
void NvOsClosedir (NvOsDirHandle dir)
 Closes the directory. More...
 
NvError NvOsMkdir (char *dirname)
 Creates the directory. More...
 
NvError NvOsGetConfigU32 (const char *name, NvU32 *value)
 Retrieves an unsigned integer variable from the config store. More...
 
NvError NvOsGetConfigString (const char *name, char *value, NvU32 size)
 Retrieves a string variable from the config store. More...
 
NvError NvOsGetSysConfigString (const char *name, char *value, NvU32 size)
 Retrieves a string variable from the config store, with a persist.sys prefix. More...
 

Memory Allocation

enum  NvOsMemAttribute {
  NvOsMemAttribute_Uncached = 0,
  NvOsMemAttribute_WriteBack = 1,
  NvOsMemAttribute_WriteCombined = 2,
  NvOsMemAttribute_InnerWriteBack = 3,
  NvOsMemAttribute_Secured = 4,
  NvOsMemAttribute_DeviceMemory = 5,
  NvOsMemAttribute_SO_DeviceMemory = 6,
  NvOsMemAttribute_End = 7,
  NvOsMemAttribute_Force32 = 0x7FFFFFFF
}
 Defines memory attributes. More...
 
typedef struct NvOsSharedMemRec * NvOsSharedMemHandle
 An opaque handle returned by shared memory allocations. More...
 
voidNvOsAlloc (size_t size)
 Dynamically allocates memory. More...
 
voidNvOsAllocAlign (size_t align, size_t size)
 Dynamically allocates memory with specific alignment. More...
 
voidNvOsRealloc (void *ptr, size_t size)
 Re-sizes a previous dynamic allocation. More...
 
void NvOsFree (void *ptr)
 Frees a dynamic memory allocation. More...
 
NvError NvOsSharedMemAlloc (const char *key, size_t size, NvOsSharedMemHandle *descriptor)
 Dynamically allocates multiprocess shared memory. More...
 
NvError NvOsSharedMemHandleFromFd (int fd, NvOsSharedMemHandle *descriptor)
 Enables sharing NvOsSharedMemHandle memory that was created by a call to NvOsSharedMemAlloc(). More...
 
NvError NvOsSharedMemGetFd (NvOsSharedMemHandle descriptor, int *fd)
 Extracts the file descriptor from a handle. More...
 
NvError NvOsSharedMemMap (NvOsSharedMemHandle descriptor, size_t offset, size_t size, void **ptr)
 Maps a shared memory region into the process virtual memory. More...
 
void NvOsSharedMemUnmap (void *ptr, size_t size)
 Unmaps a mapped region of shared memory. More...
 
void NvOsSharedMemFree (NvOsSharedMemHandle descriptor)
 Frees shared memory from NvOsSharedMemAlloc(). More...
 
NvError NvOsPhysicalMemMap (NvOsPhysAddr phys, size_t size, NvOsMemAttribute attrib, NvU32 flags, void **ptr)
 Maps computer resources into user space. More...
 
void NvOsPhysicalMemUnmap (void *ptr, size_t size)
 Releases resources previously allocated by NvOsPhysicalMemMap(). More...
 
#define NVOS_MEM_NONE   0x0U
 Specifies no memory flags. More...
 
#define NVOS_MEM_READ   0x1U
 Specifies the memory may be read. More...
 
#define NVOS_MEM_WRITE   0x2U
 Specifies the memory may be written to. More...
 
#define NVOS_MEM_EXECUTE   0x4U
 Specifies the memory may be executed. More...
 
#define NVOS_MEM_GLOBAL_ADDR   0x8U
 The memory must be visible by all processes, this is only valid for WinCE 5.0. More...
 
#define NVOS_MEM_READ_WRITE   (NVOS_MEM_READ | NVOS_MEM_WRITE)
 The memory may be both read and writen. More...
 
#define NVOS_MEM_MMAP_FIXED   0x40U
 Specifies the memory must be mapped as fixed for mmap. More...
 
#define NVOS_MEM_MMAP_LAZY   0x80U
 Support MAP_LAZY for mmap in QNX. More...
 
#define NVOS_MEM_MMAP_POPULATE   0x100U
 Support MAP_POPULATE for mmap. More...
 

Page Allocator

enum  NvOsPageFlags {
  NvOsPageFlags_Contiguous = 0,
  NvOsPageFlags_NonContiguous = 1,
  NvOsMemFlags_Forceword = 0x7ffffff
}
 Low-level memory allocation of the external system memory. More...
 
typedef struct NvOsPageAllocRec * NvOsPageAllocHandle
 
NvError NvOsPageAlloc (size_t size, NvOsMemAttribute attrib, NvOsPageFlags flags, NvU32 protect, NvOsPageAllocHandle *descriptor)
 Allocates memory via the page allocator. More...
 
void NvOsPageFree (NvOsPageAllocHandle descriptor)
 Frees pages from NvOsPageAlloc(). More...
 
NvError NvOsPageMap (NvOsPageAllocHandle descriptor, size_t offset, size_t size, void **ptr)
 Maps pages into the virtual address space. More...
 
void NvOsPageUnmap (NvOsPageAllocHandle descriptor, void *ptr, size_t size)
 Unmaps the virtual address from NvOsPageMap(). More...
 
NvOsPhysAddr NvOsPageAddress (NvOsPageAllocHandle descriptor, size_t offset)
 Returns the physical address given an offset. More...
 

Dynamic Library Handling

typedef struct NvOsLibraryRec * NvOsLibraryHandle
 A handle to a dynamic library. More...
 
NvError NvOsLibraryLoad (const char *name, NvOsLibraryHandle *library)
 Load a dynamic library. More...
 
voidNvOsLibraryGetSymbol (NvOsLibraryHandle library, const char *symbol)
 Gets an address of a symbol in a dynamic library. More...
 
void NvOsLibraryUnload (NvOsLibraryHandle library)
 Unloads a dynamic library. More...
 
NvError NvOsLibraryUnloadEx (NvOsLibraryHandle library)
 Unloads a dynamic library. More...
 

Syncronization Objects and Thread Management

enum  NvOsThreadPriorityType {
  NvOsThreadPriorityType_Normal = 1,
  NvOsThreadPriorityType_NearInterrupt = 2,
  NvOsThreadPriorityType_Native = 3,
  NvOsThreadPriorityType_Last = 4,
  NvOsThreadPriorityType_Force32 = 0x7FFFFFFF
}
 
typedef struct NvOsMutexRec * NvOsMutexHandle
 
typedef struct NvOsIntrMutexRec * NvOsIntrMutexHandle
 
typedef struct NvOsConditionRec * NvOsConditionHandle
 
typedef struct NvOsSemaphoreRec * NvOsSemaphoreHandle
 
typedef struct NvOsThreadRec * NvOsThreadHandle
 
typedef void(* NvOsThreadFunction) (void *args)
 Entry point for a thread. More...
 
typedef NvU32 NvOsTlsKeyHandle
 A NvOsTlsKey Handle. More...
 
void NvOsSleepMS (NvU32 msec)
 Unschedules the calling thread for at least the given number of milliseconds. More...
 
void NvOsWaitUS (NvU32 usec)
 Stalls the calling thread for at least the given number of microseconds. More...
 
NvError NvOsSleepUS (NvU32 usec)
 
NvError NvOsSleepNS (NvU32 nsec)
 
NvError NvOsBusyWaitUS (NvU32 usec)
 Stalls the calling thread for at least the given number of microseconds. More...
 
NvError NvOsBusyWaitNS (NvU32 nsec)
 
NvError NvOsMutexCreate (NvOsMutexHandle *mutex)
 Allocates a new process-local mutex. More...
 
void NvOsMutexLock (NvOsMutexHandle mutex)
 Locks the given unlocked mutex. More...
 
NvError NvOsMutexLockEx (NvOsMutexHandle mutex)
 Locks the given unlocked mutex. More...
 
void NvOsMutexUnlock (NvOsMutexHandle mutex)
 Unlocks a locked mutex. More...
 
NvError NvOsMutexUnlockEx (NvOsMutexHandle mutex)
 Unlocks a locked mutex. More...
 
void NvOsMutexDestroy (NvOsMutexHandle mutex)
 Frees the resources held by a mutex. More...
 
NvError NvOsMutexDestroyEx (NvOsMutexHandle mutex)
 Frees the resources held by a mutex. More...
 
NvError NvOsIntrMutexCreate (NvOsIntrMutexHandle *mutex)
 Creates a mutex that is safe to aquire in an ISR. More...
 
void NvOsIntrMutexLock (NvOsIntrMutexHandle mutex)
 Aquire an ISR-safe mutex. More...
 
void NvOsIntrMutexUnlock (NvOsIntrMutexHandle mutex)
 Releases an ISR-safe mutex. More...
 
void NvOsIntrMutexDestroy (NvOsIntrMutexHandle mutex)
 Destroys an ISR-safe mutex. More...
 
NvError NvOsConditionCreate (NvOsConditionHandle *cond)
 Creates a condition variable. More...
 
NvError NvOsConditionDestroy (NvOsConditionHandle cond)
 Frees resources held by the condition variable. More...
 
NvError NvOsConditionBroadcast (NvOsConditionHandle cond)
 Unblocks all threads currently blocked on the specified condition variable. More...
 
NvError NvOsConditionSignal (NvOsConditionHandle cond)
 Unblocks atleast one of the threads that are blocked on the specified condition variable. More...
 
NvError NvOsConditionWait (NvOsConditionHandle cond, NvOsMutexHandle mutex)
 Atomically releases the mutex and causes the calling thread to block on the condition variable. More...
 
NvError NvOsConditionWaitTimeout (NvOsConditionHandle cond, NvOsMutexHandle mutex, NvU32 microsecs)
 Atomically releases the mutex and causes the calling thread to block on the condition variable with a timeout. More...
 
NvError NvOsSemaphoreCreate (NvOsSemaphoreHandle *semaphore, NvU32 value)
 Creates a counting semaphore. More...
 
NvError NvOsSemaphoreClone (NvOsSemaphoreHandle orig, NvOsSemaphoreHandle *semaphore)
 Creates a duplicate semaphore from the given semaphore. More...
 
void NvOsSemaphoreWait (NvOsSemaphoreHandle semaphore)
 Waits until the semaphore value becomes non-zero, then decrements the value and returns. More...
 
NvError NvOsSemaphoreWaitEx (NvOsSemaphoreHandle semaphore)
 Waits until the semaphore value becomes non-zero, then decrements the value and returns. More...
 
NvError NvOsSemaphoreWaitTimeout (NvOsSemaphoreHandle semaphore, NvU32 msec)
 Waits for the given semaphore value to become non-zero with timeout. More...
 
void NvOsSemaphoreSignal (NvOsSemaphoreHandle semaphore)
 Increments the semaphore value. More...
 
NvError NvOsSemaphoreSignalEx (NvOsSemaphoreHandle semaphore)
 Increments the semaphore value. More...
 
void NvOsSemaphoreDestroy (NvOsSemaphoreHandle semaphore)
 Frees resources held by the semaphore. More...
 
NvError NvOsSemaphoreDestroyEx (NvOsSemaphoreHandle semaphore)
 Frees resources held by the semaphore. More...
 
NvError NvOsThreadCreate (NvOsThreadFunction function, void *args, NvOsThreadHandle *thread)
 Creates a thread. More...
 
NvError NvOsInterruptPriorityThreadCreate (NvOsThreadFunction function, void *args, NvOsThreadHandle *thread)
 Creates a near interrupt priority thread. More...
 
const char * NvOsThreadGetName (NvOsThreadHandle thread)
 Returns the name of the given thread. More...
 
NvError NvOsThreadSetName (NvOsThreadHandle thread, const char *name)
 Assigns the given name to the given thread. More...
 
void NvOsThreadJoin (NvOsThreadHandle thread)
 Waits for the given thread to exit. More...
 
NvError NvOsThreadJoinEx (NvOsThreadHandle thread)
 Waits for the given thread to exit. More...
 
void NvOsThreadYield (void)
 Yields to another runnable thread. More...
 
NvU64 NvOsGetCurrentThreadId (void)
 Returns current thread ID. More...
 
voidNvOsAtomicCompareExchangePtr (void **pTarget, void *OldValue, void *NewValue)
 Atomically compares the contents of a pointer-sized memory location with a value, and if they match, updates it to a new value. More...
 
NvS32 NvOsAtomicCompareExchange32 (NvS32 *pTarget, NvS32 OldValue, NvS32 NewValue)
 Atomically compares the contents of a 32-bit memory location with a value, and if they match, updates it to a new value. More...
 
NvS32 NvOsAtomicExchange32 (NvS32 *pTarget, NvS32 Value)
 Atomically swaps the contents of a 32-bit memory location with a value. More...
 
NvS32 NvOsAtomicExchangeAdd32 (NvS32 *pTarget, NvS32 Value)
 Atomically increments the contents of a 32-bit memory location by a specified amount. More...
 
NvOsTlsKeyHandle NvOsTlsAlloc (void)
 Allocates a thread-local storage variable. More...
 
NvOsTlsKeyHandle NvOsTlsAllocWithDestructor (void(*destructor)(void *))
 Allocates a thread-local storage variable, with destructor when thread exits. More...
 
void NvOsTlsFree (NvOsTlsKeyHandle TlsIndex)
 Frees a thread-local storage variable. More...
 
voidNvOsTlsGet (NvOsTlsKeyHandle TlsIndex)
 Gets the value of a thread-local storage variable. More...
 
void NvOsTlsSet (NvOsTlsKeyHandle TlsIndex, void *Value)
 Sets the value of a thread-local storage variable. More...
 
NvError NvOsTlsAddTerminator (void(*func)(void *), void *context)
 Registers a function that should be called when the thread terminates to clean up any structures stored in thread-local storage. More...
 
NvBool NvOsTlsRemoveTerminator (void(*func)(void *), void *context)
 Checks the list of existing terminator functions for one that matches both the function and the data, and then removes that function from the list. More...
 
#define NVOS_INVALID_TLS_INDEX   0xFFFFFFFF
 A TLS index that is guaranteed to be invalid. More...
 
#define NVOS_TLS_CNT   4
 

Time Functions

typedef struct NvOsSystemTimeRec NvOsSystemTime
 Defines the system time structure. More...
 
NvError NvOsGetSystemTime (NvOsSystemTime *hNvOsSystemtime)
 Gets system realtime clock. More...
 
NvU32 NvOsGetTimeMS (void)
 
NvU64 NvOsGetTimeUS (void)
 
NvU64 NvOsGetTimeNS (void)
 

CPU Cache

Cache operations for both instruction and data cache, implemented per processor.

enum  NvOsCallstackType {
  NvOsCallstackType_NoStack = 1,
  NvOsCallstackType_HexStack = 2,
  NvOsCallstackType_SymbolStack = 3,
  NvOsCallstackType_Last = 4,
  NvOsCallstackType_Force32 = 0x7FFFFFFF
}
 
typedef void(* NvOsInterruptHandler) (void *args)
 Interrupt handler function. More...
 
typedef struct NvOsInterruptRec * NvOsInterruptHandle
 Interrupt handler type. More...
 
typedef void *(* NvOsAllocFunc) (struct NvOsAllocatorRec *, size_t size)
 
typedef void *(* NvOsAllocAlignFunc) (struct NvOsAllocatorRec *, size_t align, size_t size)
 
typedef void *(* NvOsReallocFunc) (struct NvOsAllocatorRec *, void *ptr, size_t size)
 
typedef void(* NvOsFreeFunc) (struct NvOsAllocatorRec *, void *ptr)
 
typedef struct NvOsAllocatorRec NvOsAllocator
 
typedef struct NvCallstackRec NvCallstack
 
typedef void(* NvOsDumpCallback) (void *context, const char *line)
 
void NvOsDataCacheWriteback (void)
 Writes back the entire data cache. More...
 
void NvOsDataCacheWritebackInvalidate (void)
 Writes back and invalidates the entire data cache. More...
 
void NvOsDataCacheWritebackRange (void *start, NvU32 length)
 Writes back a range of the data cache. More...
 
void NvOsDataCacheWritebackInvalidateRange (void *start, NvU32 length)
 Writes back and invlidates a range of the data cache. More...
 
void NvOsInstrCacheInvalidate (void)
 Invalidates the entire instruction cache. More...
 
void NvOsInstrCacheInvalidateRange (void *start, NvU32 length)
 Invalidates a range of the instruction cache. More...
 
NvBool NvOsIsMemoryOfGivenType (NvOsMemAttribute Attrib, NvU32 Addr)
 Checks and returns whether the given memory address is within memory of given attribute. More...
 
void NvOsFlushWriteCombineBuffer (void)
 Flushes the CPU's write combine buffer. More...
 
NvError NvOsInterruptRegister (NvU32 IrqListSize, const NvU32 *pIrqList, const NvOsInterruptHandler *pIrqHandlerList, void *context, NvOsInterruptHandle *handle, NvBool InterruptEnable)
 Registers the interrupt handler with the IRQ number. More...
 
void NvOsInterruptUnregister (NvOsInterruptHandle handle)
 Unregisters the interrupt handler from the associated IRQ number. More...
 
NvError NvOsInterruptEnable (NvOsInterruptHandle handle)
 Enables the interrupt handler with the IRQ number. More...
 
void NvOsInterruptDone (NvOsInterruptHandle handle)
 Called when the ISR/IST is done handling the interrupt. More...
 
void NvOsInterruptMask (NvOsInterruptHandle handle, NvBool mask)
 Mask/unmask an interrupt. More...
 
struct NvOsAllocatorRecNvOsGetCurrentAllocator (void)
 
void NvOsDumpToDebugPrintf (void *context, const char *line)
 
NvCallstackNvOsCallstackCreate (NvOsCallstackType stackType)
 
void NvOsCallstackDestroy (NvCallstack *callstack)
 
NvU32 NvOsCallstackGetHeight (NvCallstack *stack)
 
void NvOsCallstackGetFrame (char *buf, NvU32 len, NvCallstack *stack, NvU32 level)
 
void NvOsCallstackDump (NvCallstack *stack, NvU32 skip, NvOsDumpCallback callBack, void *context)
 
NvU32 NvOsCallstackHash (NvCallstack *stack)
 
NvBool NvOsCallstackContainsPid (NvCallstack *stack, NvU32 pid)
 
void NvOsGetProcessInfo (char *buf, NvU32 len)
 
static NV_INLINE void NvOsDebugCallstack (NvU32 skip)
 
int NvOsSetFpsTarget (int target)
 To be deprecated. More...
 
int NvOsModifyFpsTarget (int fd, int target)
 To be deprecated. More...
 
void NvOsCancelFpsTarget (int fd)
 To be deprecated. More...
 
NvU32 NvOsReadReg (NvU64 Reg, NvU32 Off)
 
void NvOsWriteReg (NvU64 reg, NvU32 off, NvU32 val)
 
NvError NvOsMapRegSpace (NvU64 *VirtReg, NvU32 Base, NvU32 Size)
 
NvError NvOsUnMapRegSpace (NvU64 *VirtReg, NvU32 Base, NvU32 Size)
 
int NvOsDebugExternalLogInit (void)
 This function does slog initialization for current executing context. More...
 

Macro Definition Documentation

◆ NV_DEBUG_PRINTF

#define NV_DEBUG_PRINTF (   x)    do {} while (NV_FALSE)

Definition at line 309 of file nvos_tegra_nonsafety.h.

◆ NV_ENABLE_DEBUG_PRINTS

#define NV_ENABLE_DEBUG_PRINTS   0

Helper macro to go along with NvOsDebugPrintf.

Usage:

    NV_DEBUG_PRINTF(("foo: %s\n", bar));

The debug print will be disabled by default in all builds, debug and release.

Note
Usage requires double parentheses.

To enable debug prints in a particular .c file, add the following to the top of the .c file and rebuild:

    #define NV_ENABLE_DEBUG_PRINTS 1

To enable debug prints in a particular module, add the following to the makefile and rebuild:

    LCDEFS += -DNV_ENABLE_DEBUG_PRINTS=1

Definition at line 304 of file nvos_tegra_nonsafety.h.

◆ NV_SHOW_ERROR

#define NV_SHOW_ERROR (   err)    (err)

Definition at line 276 of file nvos_tegra_nonsafety.h.

◆ NV_SHOW_ERRORS

#define NV_SHOW_ERRORS   NV_DEBUG

Prints err if it is an error (does nothing if err==NvSuccess).

Always returns err unchanged never prints anything if err==NvSuccess)

NOTE: Do not use this with errors that are expected to occur under normal situations.

Parameters
err- the error to return
Returns
err

Definition at line 272 of file nvos_tegra_nonsafety.h.

◆ NVOS_HAS_CONDITION

#define NVOS_HAS_CONDITION   1

Indicates that NvOs has condition variables.

Definition at line 144 of file nvos_tegra_nonsafety.h.

◆ NVOS_HAS_FTRUNCATE

#define NVOS_HAS_FTRUNCATE   1

Indicates that NvOs has NvOsFtruncate().

Definition at line 140 of file nvos_tegra_nonsafety.h.

◆ NVOS_HAS_MKDIR

#define NVOS_HAS_MKDIR   1

Indicates that NvOs has NvOsMkdir().

Definition at line 136 of file nvos_tegra_nonsafety.h.

◆ NVOS_HAS_MTIME

#define NVOS_HAS_MTIME   1

Indicates that NvOsStatType structure has mtime.

Definition at line 132 of file nvos_tegra_nonsafety.h.

◆ NVOS_INVALID_TLS_INDEX

#define NVOS_INVALID_TLS_INDEX   0xFFFFFFFF

A TLS index that is guaranteed to be invalid.

Definition at line 1582 of file nvos_tegra_nonsafety.h.

◆ NVOS_KEY_MAX

#define NVOS_KEY_MAX   128

The maximum length of a shared resource identifier string.

Definition at line 124 of file nvos_tegra_nonsafety.h.

◆ NVOS_MEM_EXECUTE

#define NVOS_MEM_EXECUTE   0x4U

Specifies the memory may be executed.

Definition at line 921 of file nvos_tegra_nonsafety.h.

◆ NVOS_MEM_GLOBAL_ADDR

#define NVOS_MEM_GLOBAL_ADDR   0x8U

The memory must be visible by all processes, this is only valid for WinCE 5.0.

Definition at line 927 of file nvos_tegra_nonsafety.h.

◆ NVOS_MEM_MMAP_FIXED

#define NVOS_MEM_MMAP_FIXED   0x40U

Specifies the memory must be mapped as fixed for mmap.

Definition at line 933 of file nvos_tegra_nonsafety.h.

◆ NVOS_MEM_MMAP_LAZY

#define NVOS_MEM_MMAP_LAZY   0x80U

Support MAP_LAZY for mmap in QNX.

Definition at line 936 of file nvos_tegra_nonsafety.h.

◆ NVOS_MEM_MMAP_POPULATE

#define NVOS_MEM_MMAP_POPULATE   0x100U

Support MAP_POPULATE for mmap.

Definition at line 939 of file nvos_tegra_nonsafety.h.

◆ NVOS_MEM_NONE

#define NVOS_MEM_NONE   0x0U

Specifies no memory flags.

Definition at line 912 of file nvos_tegra_nonsafety.h.

◆ NVOS_MEM_READ

#define NVOS_MEM_READ   0x1U

Specifies the memory may be read.

Definition at line 915 of file nvos_tegra_nonsafety.h.

◆ NVOS_MEM_READ_WRITE

#define NVOS_MEM_READ_WRITE   (NVOS_MEM_READ | NVOS_MEM_WRITE)

The memory may be both read and writen.

Definition at line 930 of file nvos_tegra_nonsafety.h.

◆ NVOS_MEM_WRITE

#define NVOS_MEM_WRITE   0x2U

Specifies the memory may be written to.

Definition at line 918 of file nvos_tegra_nonsafety.h.

◆ NVOS_OPEN_APPEND

#define NVOS_OPEN_APPEND   0x8

Open file in append mode.

Implies WRITE.

Definition at line 509 of file nvos_tegra_nonsafety.h.

◆ NVOS_OPEN_CREATE

#define NVOS_OPEN_CREATE   0x4

Creates a file if is not present on the file system.

Definition at line 506 of file nvos_tegra_nonsafety.h.

◆ NVOS_OPEN_READ

#define NVOS_OPEN_READ   0x1

Opens a file with read permissions.

Definition at line 500 of file nvos_tegra_nonsafety.h.

◆ NVOS_OPEN_WRITE

#define NVOS_OPEN_WRITE   0x2

Opens a file with write persmissions.

Definition at line 503 of file nvos_tegra_nonsafety.h.

◆ NVOS_PATH_MAX

#define NVOS_PATH_MAX   256

The maximum length for a file system path.

Definition at line 128 of file nvos_tegra_nonsafety.h.

◆ NVOS_TLS_CNT

#define NVOS_TLS_CNT   4

Definition at line 1583 of file nvos_tegra_nonsafety.h.

Typedef Documentation

◆ NvCallstack

typedef struct NvCallstackRec NvCallstack

Definition at line 2045 of file nvos_tegra_nonsafety.h.

◆ NvOsAllocAlignFunc

typedef void*(* NvOsAllocAlignFunc) (struct NvOsAllocatorRec *, size_t align, size_t size)

Definition at line 1858 of file nvos_tegra_nonsafety.h.

◆ NvOsAllocator

◆ NvOsAllocFunc

typedef void*(* NvOsAllocFunc) (struct NvOsAllocatorRec *, size_t size)

Definition at line 1857 of file nvos_tegra_nonsafety.h.

◆ NvOsConditionHandle

typedef struct NvOsConditionRec* NvOsConditionHandle

Definition at line 1107 of file nvos_tegra_nonsafety.h.

◆ NvOsDirHandle

typedef struct NvOsDirRec* NvOsDirHandle

A handle to a directory.

Definition at line 674 of file nvos_tegra_nonsafety.h.

◆ NvOsDumpCallback

typedef void(* NvOsDumpCallback) (void *context, const char *line)

Definition at line 2057 of file nvos_tegra_nonsafety.h.

◆ NvOsFileHandle

typedef struct NvOsFileRec* NvOsFileHandle

Printf family.

Definition at line 151 of file nvos_tegra_nonsafety.h.

◆ NvOsFreeFunc

typedef void(* NvOsFreeFunc) (struct NvOsAllocatorRec *, void *ptr)

Definition at line 1860 of file nvos_tegra_nonsafety.h.

◆ NvOsInterruptHandle

typedef struct NvOsInterruptRec* NvOsInterruptHandle

Interrupt handler type.

Definition at line 1778 of file nvos_tegra_nonsafety.h.

◆ NvOsInterruptHandler

typedef void(* NvOsInterruptHandler) (void *args)

Interrupt handler function.

Definition at line 1774 of file nvos_tegra_nonsafety.h.

◆ NvOsIntrMutexHandle

typedef struct NvOsIntrMutexRec* NvOsIntrMutexHandle

Definition at line 1106 of file nvos_tegra_nonsafety.h.

◆ NvOsLibraryHandle

typedef struct NvOsLibraryRec* NvOsLibraryHandle

A handle to a dynamic library.

Definition at line 1048 of file nvos_tegra_nonsafety.h.

◆ NvOsMutexHandle

typedef struct NvOsMutexRec* NvOsMutexHandle

Definition at line 1105 of file nvos_tegra_nonsafety.h.

◆ NvOsOsInfo

typedef struct NvOsOsInfoRec NvOsOsInfo

◆ NvOsPageAllocHandle

typedef struct NvOsPageAllocRec* NvOsPageAllocHandle

Definition at line 978 of file nvos_tegra_nonsafety.h.

◆ NvOsPhysAddr

typedef NvU32 NvOsPhysAddr

A physical address.

Must be 64 bits for OSs that support more than 64 bits of physical addressing, not necessarily correlated to the size of a virtual address.

Currently, 64-bit physical addressing is supported by NvOS on WinNT only.

XXX 64-bit phys addressing really should be supported on Linux/x86, since all modern x86 CPUs have 36-bit (or more) physical addressing. We might need to control a PCI card that the SBIOS has placed at an address above 4 GB.

Definition at line 119 of file nvos_tegra_nonsafety.h.

◆ NvOsReallocFunc

typedef void*(* NvOsReallocFunc) (struct NvOsAllocatorRec *, void *ptr, size_t size)

Definition at line 1859 of file nvos_tegra_nonsafety.h.

◆ NvOsSemaphoreHandle

typedef struct NvOsSemaphoreRec* NvOsSemaphoreHandle

Definition at line 1108 of file nvos_tegra_nonsafety.h.

◆ NvOsSharedMemHandle

typedef struct NvOsSharedMemRec* NvOsSharedMemHandle

An opaque handle returned by shared memory allocations.

Definition at line 804 of file nvos_tegra_nonsafety.h.

◆ NvOsStatType

typedef struct NvOsStatTypeRec NvOsStatType

◆ NvOsSystemTime

Defines the system time structure.

◆ NvOsThreadFunction

typedef void(* NvOsThreadFunction) (void *args)

Entry point for a thread.

Definition at line 1434 of file nvos_tegra_nonsafety.h.

◆ NvOsThreadHandle

typedef struct NvOsThreadRec* NvOsThreadHandle

Definition at line 1109 of file nvos_tegra_nonsafety.h.

◆ NvOsTlsKeyHandle

typedef NvU32 NvOsTlsKeyHandle

A NvOsTlsKey Handle.

On Integrity pthread_key_t is a pointer type, whereas it is an unsigned int on other platforms.

For Integrity case, NvOsTlsKeyHandle will be typedef'ed to NvUPtr later in a subsequent change.

Definition at line 1579 of file nvos_tegra_nonsafety.h.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
NVOS_VERB_LVL_0 
NVOS_VERB_LVL_1 
NVOS_VERB_LVL_2 
NVOS_VERB_LVL_3 
NVOS_VERB_LVL_4 

Definition at line 232 of file nvos_tegra_nonsafety.h.

◆ NvOsCallstackType

Enumerator
NvOsCallstackType_NoStack 
NvOsCallstackType_HexStack 
NvOsCallstackType_SymbolStack 
NvOsCallstackType_Last 
NvOsCallstackType_Force32 

Definition at line 2047 of file nvos_tegra_nonsafety.h.

◆ NvOsCodePage

Defines straight-forward mappings to international language encodings.

Commonly-used encodings on supported operating systems are provided.

Note
NvOS string (and file/directory name) processing functions expect UTF-8 encodings. If the system-default encoding is not UTF-8, conversion may be required.
See also
NvUStrConvertCodePage.
Enumerator
NvOsCodePage_Unknown 
NvOsCodePage_Utf8 
NvOsCodePage_Utf16 
NvOsCodePage_Windows1252 
NvOsCodePage_Force32 

Definition at line 384 of file nvos_tegra_nonsafety.h.

◆ NvOsFileType

Enumerator
NvOsFileType_Unknown 
NvOsFileType_File 
NvOsFileType_Directory 
NvOsFileType_Fifo 
NvOsFileType_CharacterDevice 
NvOsFileType_BlockDevice 
NvOsFileType_Force32 

Definition at line 471 of file nvos_tegra_nonsafety.h.

◆ NvOsMemAttribute

Defines memory attributes.

Enumerator
NvOsMemAttribute_Uncached 
NvOsMemAttribute_WriteBack 
NvOsMemAttribute_WriteCombined 
NvOsMemAttribute_InnerWriteBack 
NvOsMemAttribute_Secured 
NvOsMemAttribute_DeviceMemory 
NvOsMemAttribute_SO_DeviceMemory 
NvOsMemAttribute_End 
NvOsMemAttribute_Force32 

Definition at line 875 of file nvos_tegra_nonsafety.h.

◆ NvOsOs

enum NvOsOs
Enumerator
NvOsOs_Unknown 
NvOsOs_Windows 
NvOsOs_Linux 
NvOsOs_Qnx 
NvOsOs_Integrity 
NvOsOs_Force32 

Definition at line 317 of file nvos_tegra_nonsafety.h.

◆ NvOsPageFlags

Low-level memory allocation of the external system memory.

Enumerator
NvOsPageFlags_Contiguous 
NvOsPageFlags_NonContiguous 
NvOsMemFlags_Forceword 

Definition at line 970 of file nvos_tegra_nonsafety.h.

◆ NvOsSeekEnum

Defines wrappers over stdlib's file stream functions, with some changes to the API.

Enumerator
NvOsSeek_Set 

NvOS equivalent of SEEK_SET.

NvOsSeek_Cur 

NvOS equivalent of SEEK_CUR.

NvOsSeek_End 

NvOS equivalent of SEEK_END.

NvOsSeek_Force32 

Max value for NvOsSeekEnum.

Definition at line 458 of file nvos_tegra_nonsafety.h.

◆ NvOsSku

enum NvOsSku
Enumerator
NvOsSku_Unknown 
NvOsSku_Android 
NvOsSku_Force32 

Definition at line 327 of file nvos_tegra_nonsafety.h.

◆ NvOsThreadPriorityType

Enumerator
NvOsThreadPriorityType_Normal 
NvOsThreadPriorityType_NearInterrupt 
NvOsThreadPriorityType_Native 
NvOsThreadPriorityType_Last 
NvOsThreadPriorityType_Force32 

Definition at line 1420 of file nvos_tegra_nonsafety.h.

Function Documentation

◆ NvOsAlloc()

void* NvOsAlloc ( size_t  size)

Dynamically allocates memory.

Alignment, if desired, must be done by the caller.

Parameters
sizeThe size of the memory to allocate.

◆ NvOsAllocAlign()

void* NvOsAllocAlign ( size_t  align,
size_t  size 
)

Dynamically allocates memory with specific alignment.

Parameters
alignThe alignment of the memory to allocate. Must be a power of two.
sizeThe size of the memory to allocate, in bytes.

◆ NvOsAtomicCompareExchange32()

NvS32 NvOsAtomicCompareExchange32 ( NvS32 *  pTarget,
NvS32  OldValue,
NvS32  NewValue 
)

Atomically compares the contents of a 32-bit memory location with a value, and if they match, updates it to a new value.

This function is the equivalent of the following code, except that other threads or processors are effectively prevented from reading or writing *pTarget while we are inside the function.

NvS32 OldTarget = *pTarget;
if (OldTarget == OldValue)
*pTarget = NewValue;
return OldTarget;

◆ NvOsAtomicCompareExchangePtr()

void* NvOsAtomicCompareExchangePtr ( void **  pTarget,
void OldValue,
void NewValue 
)

Atomically compares the contents of a pointer-sized memory location with a value, and if they match, updates it to a new value.

This function is the equivalent of the following code, except that other threads or processors are effectively prevented from reading or writing *pTarget while we are inside the function.

void *OldTarget = *pTarget;
if (OldTarget == OldValue)
*pTarget = NewValue;
return OldTarget;

◆ NvOsAtomicExchange32()

NvS32 NvOsAtomicExchange32 ( NvS32 *  pTarget,
NvS32  Value 
)

Atomically swaps the contents of a 32-bit memory location with a value.

This function is the equivalent of the following code, except that other threads or processors are effectively prevented from reading or writing *pTarget while we are inside the function.

NvS32 OldTarget = *pTarget;
*pTarget = Value;
return OldTarget;

◆ NvOsAtomicExchangeAdd32()

NvS32 NvOsAtomicExchangeAdd32 ( NvS32 *  pTarget,
NvS32  Value 
)

Atomically increments the contents of a 32-bit memory location by a specified amount.

This function is the equivalent of the following code, except that other threads or processors are effectively prevented from reading or writing *pTarget while we are inside the function.

NvS32 OldTarget = *pTarget;
*pTarget = OldTarget + Value;
return OldTarget;

◆ NvOsBusyWaitNS()

NvError NvOsBusyWaitNS ( NvU32  nsec)

◆ NvOsBusyWaitUS()

NvError NvOsBusyWaitUS ( NvU32  usec)

Stalls the calling thread for at least the given number of microseconds.

The actual time waited might be longer; you cannot depend on this function for precise timing.

Note
It is safe to use this function at ISR time.
Parameters
usecThe number of microseconds to wait.
Return values
NvSuccessIf successful, or the appropriate error code.

◆ NvOsCallstackContainsPid()

NvBool NvOsCallstackContainsPid ( NvCallstack stack,
NvU32  pid 
)

◆ NvOsCallstackCreate()

NvCallstack* NvOsCallstackCreate ( NvOsCallstackType  stackType)

Referenced by NvOsDebugCallstack().

◆ NvOsCallstackDestroy()

void NvOsCallstackDestroy ( NvCallstack callstack)

Referenced by NvOsDebugCallstack().

◆ NvOsCallstackDump()

void NvOsCallstackDump ( NvCallstack stack,
NvU32  skip,
NvOsDumpCallback  callBack,
void context 
)

Referenced by NvOsDebugCallstack().

◆ NvOsCallstackGetFrame()

void NvOsCallstackGetFrame ( char *  buf,
NvU32  len,
NvCallstack stack,
NvU32  level 
)

◆ NvOsCallstackGetHeight()

NvU32 NvOsCallstackGetHeight ( NvCallstack stack)

◆ NvOsCallstackHash()

NvU32 NvOsCallstackHash ( NvCallstack stack)

◆ NvOsCancelFpsTarget()

void NvOsCancelFpsTarget ( int  fd)

To be deprecated.

Cancels the fps target previously supplied with the NvOsSetFpsTarget() function.

Parameters
fdThe file descriptor generated by NvOsSetFpsTarget.

◆ NvOsClosedir()

void NvOsClosedir ( NvOsDirHandle  dir)

Closes the directory.

Parameters
dirThe directory to close. Passing in a null handle is okay.

◆ NvOsConditionBroadcast()

NvError NvOsConditionBroadcast ( NvOsConditionHandle  cond)

Unblocks all threads currently blocked on the specified condition variable.

Parameters
condThe condition variable on which other threads may be blocked.
Return values
NvError_BadParameterif the condition variable is not valid.

◆ NvOsConditionCreate()

NvError NvOsConditionCreate ( NvOsConditionHandle cond)

Creates a condition variable.

Parameters
condA pointer to the condition variable to initialize.
Return values
NvSuccessif successful, or the appropriate error code.
NvError_InsufficientMemoryif insufficient memory exists.
NvError_Busyif there are insufficient resources.

◆ NvOsConditionDestroy()

NvError NvOsConditionDestroy ( NvOsConditionHandle  cond)

Frees resources held by the condition variable.

Parameters
condThe condition variable to destroy.
Return values
NvSuccessif successful.
NvError_BadParameterif condition variable is not valid.
NvError_Busyif the condition variable is currently being used in another thread.

◆ NvOsConditionSignal()

NvError NvOsConditionSignal ( NvOsConditionHandle  cond)

Unblocks atleast one of the threads that are blocked on the specified condition variable.

Parameters
condThe condition variable on which other threads may be blocked.
Return values
NvError_BadParameterif condition variable is not valid.

◆ NvOsConditionWait()

NvError NvOsConditionWait ( NvOsConditionHandle  cond,
NvOsMutexHandle  mutex 
)

Atomically releases the mutex and causes the calling thread to block on the condition variable.

This function must be called with mutex locked by the calling thread or undefined behaviour results. Upon successful return, the mutex shall have been locked and be owned by the calling thread.

Parameters
condThe condition variable to wait on.
mutexThe associated mutex that needs to be locked by the calling thread.
Return values
NvSuccessif successful.
NVError_AccessDeniedif the mutex was not owned by the calling thread.
NvError_BadParameterif condition variable or mutex is not valid.

◆ NvOsConditionWaitTimeout()

NvError NvOsConditionWaitTimeout ( NvOsConditionHandle  cond,
NvOsMutexHandle  mutex,
NvU32  microsecs 
)

Atomically releases the mutex and causes the calling thread to block on the condition variable with a timeout.

Must be called with mutex locked by the calling thread or undefined behaviour results. Upon successful return, the mutex shall have been locked and be owned by the calling thread

Parameters
condThe condition variable to wait on.
mutexThe associated mutex that needs to be locked by the calling thread.
microsecsTime specified in microseconds for timeout to occur.
Return values
NvSuccessif successful.
NVError_AccessDeniedif the mutex was not owned by the calling thread.
NVError_Timeoutif the time specified by microsecs has passed before the condition variable is signalled or broadcast.
NvError_BadParameterif condition variable or mutex is not valid.

◆ NvOsDataCacheWriteback()

void NvOsDataCacheWriteback ( void  )

Writes back the entire data cache.

◆ NvOsDataCacheWritebackInvalidate()

void NvOsDataCacheWritebackInvalidate ( void  )

Writes back and invalidates the entire data cache.

◆ NvOsDataCacheWritebackInvalidateRange()

void NvOsDataCacheWritebackInvalidateRange ( void start,
NvU32  length 
)

Writes back and invlidates a range of the data cache.

Parameters
startA pointer to the start address.
lengthThe number of bytes to write back.

◆ NvOsDataCacheWritebackRange()

void NvOsDataCacheWritebackRange ( void start,
NvU32  length 
)

Writes back a range of the data cache.

Parameters
startA pointer to the start address.
lengthThe number of bytes to write back.

◆ NvOsDebugCallstack()

static NV_INLINE void NvOsDebugCallstack ( NvU32  skip)
static

◆ NvOsDebugExternalLogInit()

int NvOsDebugExternalLogInit ( void  )

This function does slog initialization for current executing context.

The Log init operation is performed internally in the NvOs library constructor. So this function call is not required for process where NvOs library loaded. However this function should be called when child process is executed using fork().

SWUD ID:

Returns
int return zero on Success and -1 An error occurred log Init failed.
Note
  • This function should be called when current executing context is forked process. In any other case this function is not expected to be called.
  • Is thread safe: No
  • Required Privileges: N/A
  • API Mode
    • Initialization: Yes
    • Run time: No
    • De-initialization: No

◆ NvOsDebugNprintf()

NvS32 NvOsDebugNprintf ( const char *  format,
  ... 
)

Same as NvOsDebugPrintf, except returns the number of chars written.

Returns
number of chars written or -1 if that number is unavailable.

◆ NvOsDebugPrintf()

void NvOsDebugPrintf ( const char *  format,
  ... 
)

Outputs a message to the debugging console, if present.

All device driver debug printfs should use this. Do not use this for interacting with a user from an application; in that case, use NvTestPrintf() instead.

Parameters
formatA pointer to the format string.

◆ NvOsDebugString()

void NvOsDebugString ( const char *  str)

◆ NvOsDebugVprintf()

void NvOsDebugVprintf ( const char *  format,
va_list  ap 
)

Same as NvOsDebugPrintf, except takes a va_list.

◆ NvOsDumpToDebugPrintf()

void NvOsDumpToDebugPrintf ( void context,
const char *  line 
)

Referenced by NvOsDebugCallstack().

◆ NvOsFclose()

void NvOsFclose ( NvOsFileHandle  stream)

Closes a file stream.

Parameters
streamThe file stream to close. Passing in a null handle is okay.

◆ NvOsFcloseEx()

NvError NvOsFcloseEx ( NvOsFileHandle  stream)

Closes a file stream.

Parameters
streamThe file stream to close. Passing in a null handle is okay.
Returns
NvSuccess if successful.
NvError_BadParamter when stream is NULL.
NvError_FileOperationFailed when closing file is failed.

◆ NvOsFflush()

NvError NvOsFflush ( NvOsFileHandle  stream)

Flushes any pending writes to the file stream.

Parameters
streamThe file stream.

◆ NvOsFgetc()

NvError NvOsFgetc ( NvOsFileHandle  stream,
NvU8 *  c 
)

Gets a character from a file stream.

Parameters
streamThe file stream.
[out]cA pointer to the character from the file stream.
Return values
NvError_EndOfFileWhen the end of file is reached.

◆ NvOsFlushWriteCombineBuffer()

void NvOsFlushWriteCombineBuffer ( void  )

Flushes the CPU's write combine buffer.

◆ NvOsFopen()

NvError NvOsFopen ( const char *  path,
NvU32  flags,
NvOsFileHandle file 
)

Opens a file stream.

If the NVOS_OPEN_CREATE flag is specified, NVOS_OPEN_WRITE must also be specified.

If NVOS_OPEN_WRITE is specified, the file will be opened for write and will be truncated if it was previously existing.

If NVOS_OPEN_WRITE and NVOS_OPEN_READ are specified, the file will not be truncated.

Parameters
pathA pointer to the path to the file.
flagsOr'd flags for the open operation (NVOS_OPEN_*).
[out]fileA pointer to the file that will be opened, if successful.

◆ NvOsFprintf()

NvError NvOsFprintf ( NvOsFileHandle  stream,
const char *  format,
  ... 
)

Prints a string to a file stream.

Parameters
streamThe file stream to which to print.
formatThe format string.

◆ NvOsFread()

NvError NvOsFread ( NvOsFileHandle  stream,
void ptr,
size_t  size,
size_t *  bytes 
)

Reads a file stream.

Buffered read implementation if available for a particular OS may return corrupted data if multiple threads read from the same stream simultaneously.

To detect short reads (less that specified amount), pass in bytes and check its value to the expected value. The bytes parameter may be null.

Parameters
streamThe file stream.
ptrA pointer to the buffer for the read data.
sizeThe length of the read.
[out]bytesA pointer to the number of bytes readd; may be null.
Return values
NvError_FileReadFailedIf the file read encountered any system errors.
NvError_EndOfFileIndicates end of file reached. Bytes must be checked to determine whether data was read into the buffer.

◆ NvOsFree()

void NvOsFree ( void ptr)

Frees a dynamic memory allocation.

Freeing a null value is okay.

Parameters
ptrA pointer to the memory to free, which should be from NvOsAlloc().

◆ NvOsFremove()

NvError NvOsFremove ( const char *  filename)

Removes a file from the storage media.

If the file is open, this function marks the file for deletion upon close.

Parameters
filenameA pointer to the file to remove.
Return values
NvError_FileOperationFailedIf cannot remove file.

◆ NvOsFseek()

NvError NvOsFseek ( NvOsFileHandle  file,
NvS64  offset,
NvOsSeekEnum  whence 
)

Changes the file position pointer.

Parameters
fileThe file.
offsetThe offset from whence to seek.
whenceThe starting point for the seek.
Return values
NvError_FileOperationFailedOn error.

◆ NvOsFstat()

NvError NvOsFstat ( NvOsFileHandle  file,
NvOsStatType stat 
)

Gets file information from an already open file.

Parameters
fileThe open file.
[out]statA pointer to the information structure.

◆ NvOsFsync()

NvError NvOsFsync ( NvOsFileHandle  stream)

Commits any pending writes to storage media.

After this completes, any pending writes are guaranteed to be on the storage media associated with the stream (if any).

Parameters
streamThe file stream.

◆ NvOsFtell()

NvError NvOsFtell ( NvOsFileHandle  file,
NvU64 *  position 
)

Gets the current file position pointer.

Parameters
fileThe file.
[out]positionA pointer to the file position.
Return values
NvError_FileOperationFailedOn error.

◆ NvOsFtruncate()

NvError NvOsFtruncate ( NvOsFileHandle  stream,
NvU64  length 
)

Causes the file to have a size of length bytes.

The file must be opened for writing.

Parameters
streamHolds the file stream.
lengthSpecifies the size of file in bytes to which to truncate.
Return values
NvError_FileOperationFailedIf file is not open for writing.
NvError_ResourceErrorIf I/O error occurred when writing to the file.

◆ NvOsFwrite()

NvError NvOsFwrite ( NvOsFileHandle  stream,
const void ptr,
size_t  size 
)

Writes to a file stream.

Parameters
streamThe file stream.
ptrA pointer to the data to write.
sizeThe length of the write.
Return values
NvError_FileWriteFailedReturned on error.

◆ NvOsGetConfigString()

NvError NvOsGetConfigString ( const char *  name,
char *  value,
NvU32  size 
)

Retrieves a string variable from the config store.

See also: NvOs Configuration Data Storage Support

Parameters
nameA pointer to the name of the variable.
valueA pointer to the value to write into.
sizeThe size of the value buffer.
Return values
NvError_ConfigVarNotFoundIf the name is not found in the config store.

◆ NvOsGetConfigU32()

NvError NvOsGetConfigU32 ( const char *  name,
NvU32 *  value 
)

Retrieves an unsigned integer variable from the config store.

See also: NvOs Configuration Data Storage Support

Parameters
nameA pointer to the name of the variable.
[out]valueA pointer to the value to write.
Return values
NvError_ConfigVarNotFoundIf the name is not found in the config store.
NvError_InvalidConfigVarIf the configuration variable cannot be converted into an unsigned integer.

◆ NvOsGetCurrentAllocator()

struct NvOsAllocatorRec* NvOsGetCurrentAllocator ( void  )

◆ NvOsGetCurrentThreadId()

NvU64 NvOsGetCurrentThreadId ( void  )

Returns current thread ID.

Return values
ThreadId

◆ NvOsGetOsInformation()

NvError NvOsGetOsInformation ( NvOsOsInfo pOsInfo)

Gets the current OS version.

Parameters
pOsInfoA pointer to the operating system information structure.

◆ NvOsGetProcessInfo()

void NvOsGetProcessInfo ( char *  buf,
NvU32  len 
)

◆ NvOsGetSysConfigString()

NvError NvOsGetSysConfigString ( const char *  name,
char *  value,
NvU32  size 
)

Retrieves a string variable from the config store, with a persist.sys prefix.

See also: NvOs Configuration Data Storage Support

Parameters
nameA pointer to the name of the variable.
valueA pointer to the value to write into.
sizeThe size of the value buffer.
Return values
NvError_ConfigVarNotFoundIf the name is not found in the config store.

◆ NvOsGetSystemTime()

NvError NvOsGetSystemTime ( NvOsSystemTime hNvOsSystemtime)

Gets system realtime clock.

Parameters
hNvOsSystemtimeA pointer to the system handle used to set the time.

◆ NvOsGetTimeMS()

NvU32 NvOsGetTimeMS ( void  )
Returns
The system time in milliseconds.

The returned values are guaranteed to be monotonically increasing, but may wrap back to zero (after about 50 days of runtime).

In some systems, this is the number of milliseconds since power-on, or may actually be an accurate date.

◆ NvOsGetTimeNS()

NvU64 NvOsGetTimeNS ( void  )
Returns
The system time in nanoseconds.

The returned values are guaranteed to be monotonically increasing, but may wrap back to zero.

Some systems cannot gauantee a nanosecond resolution timer. Even though the time returned is in nanoseconds, it is not guaranteed to have nano-second resolution.

Please be advised that this API is mainly used for code profiling and meant to be used direclty in driver code.

◆ NvOsGetTimeUS()

NvU64 NvOsGetTimeUS ( void  )
Returns
The system time in microseconds.

The returned values are guaranteed to be monotonically increasing, but may wrap back to zero.

Some systems cannot gauantee a microsecond resolution timer. Even though the time returned is in microseconds, it is not gaurnateed to have micro-second resolution.

Please be advised that this API is mainly used for code profiling and meant to be used direclty in driver code.

◆ NvOsGetVerboseLevel()

int NvOsGetVerboseLevel ( NvS32 *  VerbLevel)

◆ NvOsInstrCacheInvalidate()

void NvOsInstrCacheInvalidate ( void  )

Invalidates the entire instruction cache.

◆ NvOsInstrCacheInvalidateRange()

void NvOsInstrCacheInvalidateRange ( void start,
NvU32  length 
)

Invalidates a range of the instruction cache.

Parameters
startA pointer to the start address.
lengthThe number of bytes.

◆ NvOsInterruptDone()

void NvOsInterruptDone ( NvOsInterruptHandle  handle)

Called when the ISR/IST is done handling the interrupt.

Parameters
handleInterrupt handle returned when a successfull call is made to NvOsInterruptRegister().

◆ NvOsInterruptEnable()

NvError NvOsInterruptEnable ( NvOsInterruptHandle  handle)

Enables the interrupt handler with the IRQ number.

Note
This function is intended to only be called from NvOsInterruptRegister().
Parameters
handleInterrupt handle returned when a successfull call is made to NvOsInterruptRegister.
Return values
NvError_BadParameterIf the handle is not valid.
NvError_InsufficientMemoryIf interrupt enable failed.
NvSuccessIf interrupt enable is successful.

◆ NvOsInterruptMask()

void NvOsInterruptMask ( NvOsInterruptHandle  handle,
NvBool  mask 
)

Mask/unmask an interrupt.

Drivers can use this API to fend off interrupts. Mask means no interrupts are forwarded to the CPU. Unmask means, interrupts are forwarded to the CPU. In case of SMP systems, this API masks the interrutps to all the CPUs, not just the calling CPU.

Parameters
handleInterrupt handle returned by NvOsInterruptRegister().
maskNV_FALSE to forward the interrupt to CPU; NV_TRUE to mask the interrupts to CPU.

◆ NvOsInterruptPriorityThreadCreate()

NvError NvOsInterruptPriorityThreadCreate ( NvOsThreadFunction  function,
void args,
NvOsThreadHandle thread 
)

Creates a near interrupt priority thread.

Parameters
functionThe thread entry point.
argsA pointer to the thread arguments.
[out]threadA pointer to the result thread ID structure.

◆ NvOsInterruptRegister()

NvError NvOsInterruptRegister ( NvU32  IrqListSize,
const NvU32 *  pIrqList,
const NvOsInterruptHandler pIrqHandlerList,
void context,
NvOsInterruptHandle handle,
NvBool  InterruptEnable 
)

Registers the interrupt handler with the IRQ number.

Parameters
IrqListSizeSize of the IrqList passed in for registering the IRQ handlers for each IRQ number.
pIrqListArray of IRQ numbers for which interupt handlers are to be registerd.
pIrqHandlerListA pointer to an array of interrupt routines to be called when an interrupt occurs.
contextA pointer to the register's context handle.
handleA pointer to the interrupt handle.
InterruptEnableIf true, immediately enable interrupt. Otherwise enable interrupt only after calling NvOsInterruptEnable().
Return values
NvError_IrqRegistrationFailedIf the interrupt is already registered.
NvError_BadParameterIf the IRQ number is not valid.

◆ NvOsInterruptUnregister()

void NvOsInterruptUnregister ( NvOsInterruptHandle  handle)

Unregisters the interrupt handler from the associated IRQ number.

Note
This function is intended to only be called from NvOsInterruptUnregister().
Parameters
handleinterrupt Handle returned when a successfull call is made to NvOsInterruptRegister().

◆ NvOsIntrMutexCreate()

NvError NvOsIntrMutexCreate ( NvOsIntrMutexHandle mutex)

Creates a mutex that is safe to aquire in an ISR.

Parameters
mutexA pointer to the mutex is stored here on success.

◆ NvOsIntrMutexDestroy()

void NvOsIntrMutexDestroy ( NvOsIntrMutexHandle  mutex)

Destroys an ISR-safe mutex.

Parameters
mutexThe mutex to destroy. If mutex is NULL, this API has no effect.

◆ NvOsIntrMutexLock()

void NvOsIntrMutexLock ( NvOsIntrMutexHandle  mutex)

Aquire an ISR-safe mutex.

Parameters
mutexThe mutex to lock. For kernel (OAL) implementations, NULL implies the system-wide lock will be used.

◆ NvOsIntrMutexUnlock()

void NvOsIntrMutexUnlock ( NvOsIntrMutexHandle  mutex)

Releases an ISR-safe mutex.

Parameters
mutexThe mutex to unlock. For kernel (OAL) implementations, NULL implies the system-wide lock will be used.

◆ NvOsIsMemoryOfGivenType()

NvBool NvOsIsMemoryOfGivenType ( NvOsMemAttribute  Attrib,
NvU32  Addr 
)

Checks and returns whether the given memory address is within memory of given attribute.

Parameters
AttribMemory attribute to check.
AddrAddress of the memory, which is to be checked.
Return values
NV_TRUEif memory pointed by Addr is of given attribute, NV_FASLE otherwise.

◆ NvOsLibraryGetSymbol()

void* NvOsLibraryGetSymbol ( NvOsLibraryHandle  library,
const char *  symbol 
)

Gets an address of a symbol in a dynamic library.

Parameters
libraryThe dynamic library.
symbolA pointer to the symbol to lookup.
Returns
The address of the symbol, or NULL if the symbol cannot be found.

◆ NvOsLibraryLoad()

NvError NvOsLibraryLoad ( const char *  name,
NvOsLibraryHandle library 
)

Load a dynamic library.

No operating system specific suffixes or paths should be used for the library name. So do not use:

     /usr/lib/libnvos.so
     libnvos.dll
 

Just use:

 libnvos
Parameters
nameA pointer to the library name.
[out]libraryA pointer to the result library.
Return values
NvError_LibraryNotFoundIf the library cannot be opened.

◆ NvOsLibraryUnload()

void NvOsLibraryUnload ( NvOsLibraryHandle  library)

Unloads a dynamic library.

Parameters
libraryThe dynamic library to unload. It is okay to pass a null library value.

◆ NvOsLibraryUnloadEx()

NvError NvOsLibraryUnloadEx ( NvOsLibraryHandle  library)

Unloads a dynamic library.

Parameters
libraryThe dynamic library to unload.
Returns
NvSuccess if successful.
NvError_BadParamter when library is NULL.
NvError_LibraryNotFound when unlaoding library is failed.

◆ NvOsLogPrintf()

void NvOsLogPrintf ( int  prio,
const char *  tag,
const char *  format,
  ... 
)

Same as NvOsDebugPrintf, except takes priority and tag fields.

◆ NvOsMapRegSpace()

NvError NvOsMapRegSpace ( NvU64 *  VirtReg,
NvU32  Base,
NvU32  Size 
)

◆ NvOsMemcmp()

int NvOsMemcmp ( const void s1,
const void s2,
size_t  size 
)

Compares two memory regions.

Deprecated:
Instead use memcmp().
Parameters
s1A pointer to the first memory region.
s2A pointer to the second memory region.
sizeThe length to compare.

This returns 0 If the memory regions are identical

◆ NvOsMemcpy()

void NvOsMemcpy ( void dest,
const void src,
size_t  size 
)

Copies memory.

Deprecated:
Instead use memcpy().
Parameters
destA pointer to the destination of the copy.
srcA pointer to the source memory.
sizeThe length of the copy.

◆ NvOsMemset()

void NvOsMemset ( void s,
NvU8  c,
size_t  size 
)

Sets a region of memory to a value.

This API is deprecated – use memset() instead in new code!

Parameters
sA pointer to the memory region.
cThe value to set.
sizeThe length of the region.

◆ NvOsMkdir()

NvError NvOsMkdir ( char *  dirname)

Creates the directory.

This is currently only implemented on Linux.

Parameters
dirnameA pointer to the name of the directory to create.
Return values
NvError_PathAlreadyExistsIf directory could not be created because the path already exists.
NvSuccessIf the directory was created.
Returns
Other nonzero error code if the directory could not be created for some other reason.

◆ NvOsModifyFpsTarget()

int NvOsModifyFpsTarget ( int  fd,
int  target 
)

To be deprecated.

Sets the frame rate target with an existing file descriptor (fd).

Parameters
fdAn open fd returned by the NvOsSetFpsTarget() function.
targetThe fps target.

◆ NvOsMutexCreate()

NvError NvOsMutexCreate ( NvOsMutexHandle mutex)

Allocates a new process-local mutex.

Note
Mutexes can be locked recursively; if a thread owns the lock, it can lock it again as long as it unlocks it an equal number of times.
Parameters
mutexThe mutex to initialize.
Returns
NvError_MutexCreateFailed, or one of common error codes on failure.

◆ NvOsMutexDestroy()

void NvOsMutexDestroy ( NvOsMutexHandle  mutex)

Frees the resources held by a mutex.

Mutecies are reference counted and a given mutex will not be destroyed until the last reference has gone away.

Parameters
mutexThe mutex to destroy. Passing in a null mutex is okay.

◆ NvOsMutexDestroyEx()

NvError NvOsMutexDestroyEx ( NvOsMutexHandle  mutex)

Frees the resources held by a mutex.

Mutecies are reference counted and a given mutex will not be destroyed until the last reference has gone away.

Parameters
mutexThe mutex to destroy.
Return values
NvSuccessIf successful, or the appropriate error code.

◆ NvOsMutexLock()

void NvOsMutexLock ( NvOsMutexHandle  mutex)

Locks the given unlocked mutex.

If a process is holding a lock on a multi-process mutex when it terminates, this lock will be automatically released.

Parameters
mutexThe mutex to lock; note that this is a recursive lock.

◆ NvOsMutexLockEx()

NvError NvOsMutexLockEx ( NvOsMutexHandle  mutex)

Locks the given unlocked mutex.

If a process is holding a lock on a multi-process mutex when it terminates, this lock will be automatically released.

Parameters
mutexThe mutex to lock; note that this is a recursive lock.
Return values
NvSuccessIf successful, or the appropriate error code.

◆ NvOsMutexUnlock()

void NvOsMutexUnlock ( NvOsMutexHandle  mutex)

Unlocks a locked mutex.

A mutex must be unlocked exactly as many times as it has been locked.

Parameters
mutexThe mutex to unlock.

◆ NvOsMutexUnlockEx()

NvError NvOsMutexUnlockEx ( NvOsMutexHandle  mutex)

Unlocks a locked mutex.

A mutex must be unlocked exactly as many times as it has been locked.

Parameters
mutexThe mutex to unlock.
Return values
NvSuccessIf successful, or the appropriate error code.

◆ NvOsOpendir()

NvError NvOsOpendir ( const char *  path,
NvOsDirHandle dir 
)

Opens a directory.

Parameters
pathA pointer to the path of the directory to open.
[out]dirA pointer to the directory that will be opened, if successful.
Return values
NvError_DirOperationFailedReturned upon failure.

◆ NvOsPageAddress()

NvOsPhysAddr NvOsPageAddress ( NvOsPageAllocHandle  descriptor,
size_t  offset 
)

Returns the physical address given an offset.

This is useful for non-contiguous page allocations.

Parameters
descriptorThe descriptor from NvOsPageAlloc(), etc.
offsetThe offset in bytes into the page range.

◆ NvOsPageAlloc()

NvError NvOsPageAlloc ( size_t  size,
NvOsMemAttribute  attrib,
NvOsPageFlags  flags,
NvU32  protect,
NvOsPageAllocHandle descriptor 
)

Allocates memory via the page allocator.

Parameters
sizeThe number of bytes to allocate.
attribPage caching attributes.
flagsVarious memory allocation flags.
protectPage protection attributes (NVOS_MEM_*).
[out]descriptorA pointer to the result descriptor.
Returns
A descriptor (not a pointer to virtual memory), which may be passed into other functions.

◆ NvOsPageFree()

void NvOsPageFree ( NvOsPageAllocHandle  descriptor)

Frees pages from NvOsPageAlloc().

It is not valid to call NvOsPageFree() while there are outstanding mappings.

Parameters
descriptorThe descriptor from NvOsPageAlloc.

◆ NvOsPageMap()

NvError NvOsPageMap ( NvOsPageAllocHandle  descriptor,
size_t  offset,
size_t  size,
void **  ptr 
)

Maps pages into the virtual address space.

Upon successful completion, *ptr holds a virtual address that may be accessed.

Parameters
descriptorAllocated pages from NvOsPageAlloc(), etc.
offsetOffset in bytes into the page range.
sizeThe size of the mapping.
[out]ptrA pointer to the result pointer.
Return values
NvSuccessIf successful, or the appropriate error code.

◆ NvOsPageUnmap()

void NvOsPageUnmap ( NvOsPageAllocHandle  descriptor,
void ptr,
size_t  size 
)

Unmaps the virtual address from NvOsPageMap().

Parameters
descriptorAllocated pages from NvOsPageAlloc(), etc.
ptrA pointer to the virtual address to unmap that was returned from NvOsPageMap.
sizeThe size of the mapping, which should match what was passed into NvOsPageMap.

◆ NvOsPhysicalMemMap()

NvError NvOsPhysicalMemMap ( NvOsPhysAddr  phys,
size_t  size,
NvOsMemAttribute  attrib,
NvU32  flags,
void **  ptr 
)

Maps computer resources into user space.

Parameters
physThe physical address start.
sizeThe size of the aperture.
attribMemory attributes (caching).
flagsBitwise OR of NVOS_MEM_*.
[out]ptrA pointer to the result pointer.

◆ NvOsPhysicalMemUnmap()

void NvOsPhysicalMemUnmap ( void ptr,
size_t  size 
)

Releases resources previously allocated by NvOsPhysicalMemMap().

Parameters
ptrThe virtual pointer returned by NvOsPhysicalMemMap. If this pointer is null, this function has no effect.
sizeThe size of the mapped region.

◆ NvOsReaddir()

NvError NvOsReaddir ( NvOsDirHandle  dir,
char *  name,
size_t  size 
)

Gets the next entry in the directory.

Parameters
dirThe directory pointer.
[out]nameA pointer to the name of the next file.
sizeThe size of the name buffer.
Return values
NvError_EndOfDirListWhen there are no more entries in the directory.
NvError_DirOperationFailedIf there is a system error.

◆ NvOsReadReg()

NvU32 NvOsReadReg ( NvU64  Reg,
NvU32  Off 
)

◆ NvOsRealloc()

void* NvOsRealloc ( void ptr,
size_t  size 
)

Re-sizes a previous dynamic allocation.

Parameters
ptrA pointer to the original allocation.
sizeThe new size to allocate.

◆ NvOsSemaphoreClone()

NvError NvOsSemaphoreClone ( NvOsSemaphoreHandle  orig,
NvOsSemaphoreHandle semaphore 
)

Creates a duplicate semaphore from the given semaphore.

Freeing the original semaphore has no effect on the new semaphore.

Parameters
origThe semaphore to duplicate.
semaphoreA pointer to the new semaphore.
Return values
NvSuccessIf successful, or the appropriate error code.

◆ NvOsSemaphoreCreate()

NvError NvOsSemaphoreCreate ( NvOsSemaphoreHandle semaphore,
NvU32  value 
)

Creates a counting semaphore.

Parameters
semaphoreA pointer to the semaphore to initialize.
valueThe initial semaphore value.
Return values
NvSuccessIf successful, or the appropriate error code.

◆ NvOsSemaphoreDestroy()

void NvOsSemaphoreDestroy ( NvOsSemaphoreHandle  semaphore)

Frees resources held by the semaphore.

Semaphores are reference counted across the computer (multiproceses), and a given semaphore will not be destroyed until the last reference has gone away.

Parameters
semaphoreThe semaphore to destroy. Passing in a null semaphore is okay (no op).

◆ NvOsSemaphoreDestroyEx()

NvError NvOsSemaphoreDestroyEx ( NvOsSemaphoreHandle  semaphore)

Frees resources held by the semaphore.

Semaphores are reference counted across the computer (multiproceses), and a given semaphore will not be destroyed until the last reference has gone away.

Parameters
semaphoreThe semaphore to destroy.
Return values
NvSuccessIf successful, or the appropriate error code.

◆ NvOsSemaphoreSignal()

void NvOsSemaphoreSignal ( NvOsSemaphoreHandle  semaphore)

Increments the semaphore value.

Parameters
semaphoreThe semaphore to signal.

◆ NvOsSemaphoreSignalEx()

NvError NvOsSemaphoreSignalEx ( NvOsSemaphoreHandle  semaphore)

Increments the semaphore value.

Parameters
semaphoreThe semaphore to signal.
Return values
NvSuccessIf successful, or the appropriate error code.

◆ NvOsSemaphoreWait()

void NvOsSemaphoreWait ( NvOsSemaphoreHandle  semaphore)

Waits until the semaphore value becomes non-zero, then decrements the value and returns.

Parameters
semaphoreThe semaphore to wait for.

◆ NvOsSemaphoreWaitEx()

NvError NvOsSemaphoreWaitEx ( NvOsSemaphoreHandle  semaphore)

Waits until the semaphore value becomes non-zero, then decrements the value and returns.

Parameters
semaphoreThe semaphore to wait for.
Return values
NvSuccessIf successful, or the appropriate error code.

◆ NvOsSemaphoreWaitTimeout()

NvError NvOsSemaphoreWaitTimeout ( NvOsSemaphoreHandle  semaphore,
NvU32  msec 
)

Waits for the given semaphore value to become non-zero with timeout.

If the semaphore value becomes non-zero before the timeout, then the value is decremented and NvSuccess is returned.

Parameters
semaphoreThe semaphore to wait for.
msecTimeout value in milliseconds. NV_WAIT_INFINITE can be used to wait forever.
Return values
NvError_TimeoutIf the wait expires.

◆ NvOsSetFpsTarget()

int NvOsSetFpsTarget ( int  target)

To be deprecated.

Sets a frame rate target that matches the CPU frequency scaling to the measured performance.

Parameters
targetThe fps target.
Returns
A file descriptor that, on exiting, you pass to the NvOsCancelFpsTarget function.

◆ NvOsSetVerboseLevel()

int NvOsSetVerboseLevel ( NvS32  VerbLevel)

◆ NvOsSharedMemAlloc()

NvError NvOsSharedMemAlloc ( const char *  key,
size_t  size,
NvOsSharedMemHandle descriptor 
)

Dynamically allocates multiprocess shared memory.

The memory will be zero initialized when it is first created.

Parameters
keyA pointer to the global key to identify the shared allocation.
sizeThe size of the allocation.
[out]descriptorA pointer to the result descriptor.
Returns
If the shared memory for key already exists, then this returns the already allocated shared memory; otherwise, it creates it.

◆ NvOsSharedMemFree()

void NvOsSharedMemFree ( NvOsSharedMemHandle  descriptor)

Frees shared memory from NvOsSharedMemAlloc().

It is valid to call NvOsSharedMemFree while mappings are still outstanding.

Parameters
descriptorThe memory descriptor.

◆ NvOsSharedMemGetFd()

NvError NvOsSharedMemGetFd ( NvOsSharedMemHandle  descriptor,
int *  fd 
)

Extracts the file descriptor from a handle.

Parameters
descriptorThe memory descriptor to map.
[out]fdA pointer to the result.
Returns
A file descriptor that can be used to create a new handle.

◆ NvOsSharedMemHandleFromFd()

NvError NvOsSharedMemHandleFromFd ( int  fd,
NvOsSharedMemHandle descriptor 
)

Enables sharing NvOsSharedMemHandle memory that was created by a call to NvOsSharedMemAlloc().

Parameters
fdA pointer to the global key to identify the shared allocation.
[out]descriptorA pointer to the result descriptor.
Return values
NvError_SharedMemMapFailedon failure.

◆ NvOsSharedMemMap()

NvError NvOsSharedMemMap ( NvOsSharedMemHandle  descriptor,
size_t  offset,
size_t  size,
void **  ptr 
)

Maps a shared memory region into the process virtual memory.

Parameters
descriptorThe memory descriptor to map.
offsetThe offset in bytes into the mapped area.
sizeThe size area to map.
[out]ptrA pointer to the result pointer.
Return values
NvError_SharedMemMapFailedon failure.

◆ NvOsSharedMemUnmap()

void NvOsSharedMemUnmap ( void ptr,
size_t  size 
)

Unmaps a mapped region of shared memory.

Parameters
ptrA pointer to the pointer to virtual memory.
sizeThe size of the mapped region.

◆ NvOsShowError()

NvError NvOsShowError ( NvError  err,
const char *  file,
int  line 
)

Prints an error and the line it appeared on.

Does nothing if err is NvSuccess.

Parameters
errThe error to return.
fileA pointer to the file the error occurred in.
lineThe line number the error occurred on.
Returns
The err value, on success.

◆ NvOsSleepMS()

void NvOsSleepMS ( NvU32  msec)

Unschedules the calling thread for at least the given number of milliseconds.

Other threads may run during the sleep time.

Parameters
msecThe number of milliseconds to sleep.

◆ NvOsSleepNS()

NvError NvOsSleepNS ( NvU32  nsec)

◆ NvOsSleepUS()

NvError NvOsSleepUS ( NvU32  usec)

◆ NvOsSnprintf()

NvS32 NvOsSnprintf ( char *  str,
size_t  size,
const char *  format,
  ... 
)

Expands a string into a given string buffer.

Parameters
strA pointer to the target string buffer.
sizeThe size of the string buffer.
formatA pointer to the format string.
Returns
The number of characters printed (not including the \0). The buffer was printed to successfully if the returned value is greater than -1 and less than size.

◆ NvOsStat()

NvError NvOsStat ( const char *  filename,
NvOsStatType stat 
)

Gets file information.

Parameters
filenameA pointer to the file about which to get information.
[out]statA pointer to the information structure.

◆ NvOsStrcpy()

void NvOsStrcpy ( char *  dest,
const char *  src 
)

Copies a string.

The src string must be NUL terminated.

Deprecated:
Instead use strcpy().
Parameters
destA pointer to the destination of the copy.
srcA pointer to the source string.

◆ NvOsStrlen()

size_t NvOsStrlen ( const char *  s)

Gets the length of a string.

Deprecated:
Instead use strlen().
Parameters
sA pointer to the string.

◆ NvOsStrncpy()

void NvOsStrncpy ( char *  dest,
const char *  src,
size_t  size 
)

Copies a string, length-limited.

Deprecated:
Instead use strncpy().
Parameters
destA pointer to the destination of the copy.
srcA pointer to the source string.
sizeThe length of the dest string buffer plus NULL terminator.

◆ NvOsStrnlen()

size_t NvOsStrnlen ( const char *  s,
size_t  size 
)

Gets the length of a string.

length-limited.

Parameters
sA pointer to the string.
sizethe maximum length to check

◆ NvOsThreadCreate()

NvError NvOsThreadCreate ( NvOsThreadFunction  function,
void args,
NvOsThreadHandle thread 
)

Creates a thread.

Parameters
functionThe thread entry point.
argsA pointer to the thread arguments.
[out]threadA pointer to the result thread ID structure.

◆ NvOsThreadGetName()

const char* NvOsThreadGetName ( NvOsThreadHandle  thread)

Returns the name of the given thread.

Parameters
threadThe thread whose name needs to be returned.

◆ NvOsThreadJoin()

void NvOsThreadJoin ( NvOsThreadHandle  thread)

Waits for the given thread to exit.

The joined thread will be destroyed automatically. All OS resources will be reclaimed. There is no method for terminating a thread before it exits naturally.

Parameters
threadThe thread to wait for. Passing in a null thread ID is okay (no op).

◆ NvOsThreadJoinEx()

NvError NvOsThreadJoinEx ( NvOsThreadHandle  thread)

Waits for the given thread to exit.

The joined thread will be destroyed automatically. All OS resources will be reclaimed. There is no method for terminating a thread before it exits naturally.

Parameters
threadThe thread to wait for.
Return values
NvSuccessIf successful, or the appropriate error code.

◆ NvOsThreadSetName()

NvError NvOsThreadSetName ( NvOsThreadHandle  thread,
const char *  name 
)

Assigns the given name to the given thread.

Parameters
threadThe thread to assign the name to.
nameString codifying the thread name.

◆ NvOsThreadYield()

void NvOsThreadYield ( void  )

Yields to another runnable thread.

◆ NvOsTlsAddTerminator()

NvError NvOsTlsAddTerminator ( void(*)(void *)  func,
void context 
)

Registers a function that should be called when the thread terminates to clean up any structures stored in thread-local storage.

Parameters
funcThe callback function called when the thread terminates.
contextA pointer to the data to pass to the callback function.

◆ NvOsTlsAlloc()

NvOsTlsKeyHandle NvOsTlsAlloc ( void  )

Allocates a thread-local storage variable.

All TLS variables have initial value NULL in all threads when first allocated.

Returns
The TLS index of the TLS variable if successful, or NVOS_INVALID_TLS_INDEX if not.

◆ NvOsTlsAllocWithDestructor()

NvOsTlsKeyHandle NvOsTlsAllocWithDestructor ( void(*)(void *)  destructor)

Allocates a thread-local storage variable, with destructor when thread exits.

All TLS variables have initial value NULL in all threads when first allocated.

Parameters
destructorCallback to invoke when thread is destroyed.
Returns
The TLS index of the TLS variable if successful, or NVOS_INVALID_TLS_INDEX if not.

◆ NvOsTlsFree()

void NvOsTlsFree ( NvOsTlsKeyHandle  TlsIndex)

Frees a thread-local storage variable.

Parameters
TlsIndexThe TLS index of the TLS variable. This function is a no-op if TlsIndex equals NVOS_INVALID_TLS_INDEX.

◆ NvOsTlsGet()

void* NvOsTlsGet ( NvOsTlsKeyHandle  TlsIndex)

Gets the value of a thread-local storage variable.

Parameters
TlsIndexThe TLS index of the TLS variable. The current value of the TLS variable is returned.

◆ NvOsTlsRemoveTerminator()

NvBool NvOsTlsRemoveTerminator ( void(*)(void *)  func,
void context 
)

Checks the list of existing terminator functions for one that matches both the function and the data, and then removes that function from the list.

Parameters
funcThe callback function called when the thread terminates.
contextA pointer to the data to pass to the callback function.
Returns
True if the terminator exists and was removed, otherwise false if not.

◆ NvOsTlsSet()

void NvOsTlsSet ( NvOsTlsKeyHandle  TlsIndex,
void Value 
)

Sets the value of a thread-local storage variable.

Parameters
TlsIndexThe TLS index of the TLS variable.
ValueA pointer to the new value of the TLS variable.

◆ NvOsUnMapRegSpace()

NvError NvOsUnMapRegSpace ( NvU64 *  VirtReg,
NvU32  Base,
NvU32  Size 
)

◆ NvOsVerbosePrintf()

void NvOsVerbosePrintf ( NvS32  VerbLevel,
const char *  Fmt,
  ... 
)

◆ NvOsVfprintf()

NvError NvOsVfprintf ( NvOsFileHandle  stream,
const char *  format,
va_list  ap 
)

Prints a string to a file stream using a va_list.

Parameters
streamThe file stream.
formatA pointer to the format string.
apThe va_list structure.

◆ NvOsVsnprintf()

NvS32 NvOsVsnprintf ( char *  str,
size_t  size,
const char *  format,
va_list  ap 
)

Expands a string into a string buffer using a va_list.

Parameters
strA pointer to the target string buffer.
sizeThe size of the string buffer.
formatA pointer to the format string.
apThe va_list structure.
Returns
The number of characters printed (not including the \0). The buffer was printed to successfully if the returned value is greater than -1 and less than size.

◆ NvOsWaitUS()

void NvOsWaitUS ( NvU32  usec)

Stalls the calling thread for at least the given number of microseconds.

The actual time waited might be longer; you cannot depend on this function for precise timing.

Note
It is safe to use this function at ISR time.
Parameters
usecThe number of microseconds to wait.

◆ NvOsWriteReg()

void NvOsWriteReg ( NvU64  reg,
NvU32  off,
NvU32  val 
)

Variable Documentation

◆ Alloc

NvOsAllocFunc NvOsAllocatorRec::Alloc

Definition at line 1863 of file nvos_tegra_nonsafety.h.

◆ AllocAlign

NvOsAllocAlignFunc NvOsAllocatorRec::AllocAlign

Definition at line 1864 of file nvos_tegra_nonsafety.h.

◆ Free

NvOsFreeFunc NvOsAllocatorRec::Free

Definition at line 1866 of file nvos_tegra_nonsafety.h.

◆ Milliseconds

NvU32 NvOsSystemTimeRec::Milliseconds

Definition at line 1659 of file nvos_tegra_nonsafety.h.

◆ mtime

NvU64 NvOsStatTypeRec::mtime

last modified time of the file

Definition at line 496 of file nvos_tegra_nonsafety.h.

◆ OsType

NvOsOs NvOsOsInfoRec::OsType

Definition at line 336 of file nvos_tegra_nonsafety.h.

◆ Realloc

NvOsReallocFunc NvOsAllocatorRec::Realloc

Definition at line 1865 of file nvos_tegra_nonsafety.h.

◆ Seconds

NvU32 NvOsSystemTimeRec::Seconds

Definition at line 1658 of file nvos_tegra_nonsafety.h.

◆ size

NvU64 NvOsStatTypeRec::size

Definition at line 493 of file nvos_tegra_nonsafety.h.

◆ Sku

NvOsSku NvOsOsInfoRec::Sku

Definition at line 337 of file nvos_tegra_nonsafety.h.

◆ type

NvOsFileType NvOsStatTypeRec::type

Definition at line 494 of file nvos_tegra_nonsafety.h.