# OSAL - [Overview](#section223828672165623) - [Summary](#section1437972704165623) - [Files](#files) - [Data Structures](#nested-classes) - [Macros](#define-members) - [Typedefs](#typedef-members) - [Enumerations](#enum-members) - [Functions](#func-members) - [Details](#section281237531165623) - [Macro Definition](#section1226510658165623) - [OSAL\_READB](#ga3de1529efbdabd4fb2f144c6f48df70b) - [OSAL\_READL](#ga14ce14451b2484b2e268a38757237f41) - [OSAL\_READW](#ga8bd523f234f24415fe733addd113e60b) - [OSAL\_WRITEB](#ga48e1f404639550c229aee3ec35a06d79) - [OSAL\_WRITEL](#gaba47d67efad3ad9d1a33a35d2982bd49) - [OSAL\_WRITEW](#ga3358a86c6bbb6f02ab108964962f441f) - [Enumeration Type](#section1297392036165623) - [OSAL\_IRQ\_TRIGGER\_MODE](#ga78cd126b10424753db6f39f9b72ea124) - [OSAL\_THREAD\_PRIORITY](#gab8c099a9c39fdde73c74b3f7367be5d0) - [Function](#section740670116165623) - [OsalAtomicDec\(\)](#gaa411f380e6b21c8467260030ceee38ff) - [OsalAtomicInc\(\)](#ga11214c11a9b875cb8ba0a67aeccc6ac9) - [OsalAtomicRead\(\)](#gaf7b7a860f5cf11bda3008ce16a5d79d5) - [OsalAtomicSet\(\)](#ga0b82ac10305c7ec5ae46707034b866c3) - [OsalClearBit\(\)](#gae3e5b84f326aa1a2c4b8427509f80cd9) - [OsalDiffTime\(\)](#ga36b0af6646f887175993e78391a5cabc) - [OsalDisableIrq\(\)](#gaf6ae039d209e46d45c683aeda3e7cd28) - [OsalEnableIrq\(\)](#ga7f27c6171678ab8cf925660068ac38ff) - [OsalFileClose\(\)](#ga8786ab2baa8669e79173ab7ab47d67bb) - [OsalFileLseek\(\)](#gaada4d66f4bb789bb4113e4084da6dea2) - [OsalFileOpen\(\)](#ga6707125b6ac5e13912a181877f18f292) - [OsalFileRead\(\)](#gac8ebc8dc4b9ce9725875868f69fd17a8) - [OsalFileWrite\(\)](#ga305f575f875ff26bb907c67c23dfb16a) - [OsalGetSysTimeMs\(\)](#gaf91cb1945b66e324fbb0761aa2f98ea3) - [OsalGetTime\(\)](#ga649d3090dcf9ba0e22649e11ac40831f) - [OsalIoRemap\(\)](#ga281757438906600ef89a13362151d955) - [OsalIoUnmap\(\)](#ga0a845edb56df0a35beeea338dc5121aa) - [OsalMDelay\(\)](#ga82ddd682a2441a22dd6148f634a6cea4) - [OsalMemAlloc\(\)](#ga0a1c85eaad6c1588ed091e0e89b74ed2) - [OsalMemAllocAlign\(\)](#gaf6d1b6e5583d9e1ca5abf5048bb3bad9) - [OsalMemCalloc\(\)](#ga7a6d0f6400e835bcbe9ec655bc9f43ee) - [OsalMemFree\(\)](#ga20dc9c415433effea4d481180a50cfa1) - [OsalMSleep\(\)](#ga2361dc099952df28aaef8968f9f4b9a7) - [OsalMutexDestroy\(\)](#gaa37328265ee97277516f6905f90a41b3) - [OsalMutexInit\(\)](#ga9bbc55785f8a533b0b099956bcbe258e) - [OsalMutexLock\(\)](#ga45d893bf49a8fb8caf76fa5d31822e0e) - [OsalMutexTimedLock\(\)](#ga57162c8f2e812ef3e5ace498bb85a3b6) - [OsalMutexUnlock\(\)](#gae76ffb4db66c988be5209e0dfdc7a35f) - [OsalReadFirmware\(\)](#ga2b721d36c177786841cd05cecdb01034) - [OsalRegisterIrq\(\)](#gade084a1942c1672f2148ccf8f6c06331) - [OsalReleaseFirmware\(\)](#gadfccddc78411a76ae8f4af4282da12f0) - [OsalRequestFirmware\(\)](#ga428b9de7fb95a20ab9e25b47a7d4272c) - [OsalSeekFirmware\(\)](#ga41ae4dade9246f3b30efd276cbd43474) - [OsalSemDestroy\(\)](#ga0b6642005b8a128ac01f69385bd6969f) - [OsalSemInit\(\)](#ga7e4325c951479e93abe072290162da0b) - [OsalSemPost\(\)](#gadc3205b416d3fc8e1fa9c332b82e634a) - [OsalSemWait\(\)](#ga0000b9ee1421950d5b3a04cbc839c6af) - [OsalSleep\(\)](#ga8b9ca3498c54b11dcbe88a2a456f23ab) - [OsalSpinDestroy\(\)](#gacd3824f292ddef395bd1a4a7b5546470) - [OsalSpinInit\(\)](#gae36a2d6e4e0191273c9f86a918befb5c) - [OsalSpinLock\(\)](#gae1c4b9ac8ea2a4820d73c20ae017dbd7) - [OsalSpinLockIrq\(\)](#ga7d409ec573a06078112a8ffae14afce5) - [OsalSpinLockIrqSave\(\)](#gab711d8d56055e78dd85f84bc530a4d3f) - [OsalSpinUnlock\(\)](#gada1f1826b19dc900af370a2bcd9681b9) - [OsalSpinUnlockIrq\(\)](#ga7d7848d572fbda413b3b5770e95a234e) - [OsalSpinUnlockIrqRestore\(\)](#ga3be4dbde6c9ae740b012e49ab90e7a8a) - [OsalTestBit\(\)](#gaf02c15a3593cac4add3f661b63aebf81) - [OsalTestClearBit\(\)](#ga8665e70c704921f443fd2db8193ff7cc) - [OsalTestSetBit\(\)](#gac0ff99812a327a4a595802a23b41b46f) - [OsalThreadCreate\(\)](#gad598b3f4b91f5e6aeeaf7b8a6e507f1e) - [OsalThreadDestroy\(\)](#ga223ce6b94770348a93168525c536e6f9) - [OsalThreadResume\(\)](#ga32f0b5c622518b7453f758d95b137a94) - [OsalThreadStart\(\)](#ga74c93bd48d27cde830451f63b224307a) - [OsalThreadSuspend\(\)](#gad556075f625d01557c0075a2c092a1da) - [OsalTimerCreate\(\)](#ga879d9a437e1423021f95cb9341f0d6af) - [OsalTimerDelete\(\)](#gab754f3522245e6b2f9ee1cdecae62b52) - [OsalTimerSetTimeout\(\)](#ga49c2fe3f54d548fe5ec0d03a79691376) - [OsalTimerStartLoop\(\)](#ga575e4f41359c737ab9690ab28838b99f) - [OsalTimerStartOnce\(\)](#gaf2e49d5b01b49e5f64a7701da8667141) - [OsalUDelay\(\)](#ga7ae78fa3318a82dbd769827d4f373958) - [OsalUnregisterIrq\(\)](#gade4ec4496eb07f1ff0610b53ba419dba) ## **Overview** **Description:** Defines the structures and interfaces for the Operating System Abstraction Layer \(OSAL\) module. The OSAL module harmonizes OS interface differences and provides unified OS interfaces externally, including the memory management, thread, mutex, spinlock, semaphore, timer, file, interrupt, time, atomic, firmware, and I/O operation modules. **Since:** 1.0 **Version:** 1.0 ## **Summary** ## Files
Declares interrupt request (IRQ) interfaces and common IRQ trigger modes. |
|
OSAL_WRITEB(value, address) writeb(value, address) |
|
OSAL_WRITEW(value, address) writew(value, address) |
|
OSAL_WRITEL(value, address) writel(value, address) |
|
OSAL_READB(address) readb(address) |
|
OSAL_READW(address) readw(address) |
|
OSAL_READL(address) readl(address) |
|
OSAL_DECLARE_MUTEX (mutex) struct OsalMutex mutex |
|
OSAL_DECLARE_SEMAPHORE (sem) struct OsalSem sem |
|
OSAL_DECLARE_SPINLOCK (spinlock) OsalSpinlock spinlock |
|
OSAL_DECLARE_THREAD (thread) struct OsalThread thread |
|
OSAL_DECLARE_TIMER (timer) OsalTimer timer |
OsalAtomicRead (const OsalAtomic *v) |
|
OsalAtomicSet (OsalAtomic *v, int32_t counter) |
|
OsalAtomicInc (OsalAtomic *v) |
|
OsalAtomicDec (OsalAtomic *v) |
|
OsalTestBit (unsigned long nr, const volatile unsigned long *addr) |
|
OsalTestSetBit (unsigned long nr, volatile unsigned long *addr) |
Sets the value of a specified bit of the variable and returns the bit value before the setting. |
OsalTestClearBit (unsigned long nr, volatile unsigned long *addr) |
Clears the value of a specified bit of the variable and returns the bit value before clearing. |
OsalClearBit (unsigned long nr, volatile unsigned long *addr) |
|
OsalFileOpen (OsalFile *file, const char *path, int flags, uint32_t rights) |
|
OsalFileWrite (OsalFile *file, const void *string, uint32_t length) |
|
OsalFileClose (OsalFile *file) |
|
OsalFileRead (OsalFile *file, void *buf, uint32_t length) |
|
OsalFileLseek (OsalFile *file, off_t offset, int32_t whence) |
|
OsalRequestFirmware (struct OsalFirmware *fw, const char *fwName, void *device) |
Requests a firmware file based on its name and device information. |
OsalSeekFirmware (struct OsalFirmware *fw, uint32_t offset) |
|
OsalReadFirmware (struct OsalFirmware *fw, struct OsalFwBlock *block) |
|
OsalReleaseFirmware (struct OsalFirmware *fw) |
|
OsalIoRemap (unsigned long phys_addr, unsigned long size) |
|
OsalIoUnmap (void *addr) |
Unmaps an I/O virtual address associated with the physical address. |
OsalRegisterIrq (uint32_t irqId, uint32_t config, OsalIRQHandle handle, const char *name, void *dev) |
|
OsalUnregisterIrq (uint32_t irqId) |
|
OsalEnableIrq (uint32_t irqId) |
|
OsalDisableIrq (uint32_t irqId) |
|
OsalMemAlloc (size_t size) |
|
OsalMemCalloc (size_t size) |
Allocates memory of a specified size, and clears the allocated memory. |
OsalMemAllocAlign (size_t alignment, size_t size) |
Allocates memory of a specified size, and aligns the memory address on a given boundary. |
OsalMemFree (void *mem) |
|
OsalMutexInit (struct OsalMutex *mutex) |
|
OsalMutexDestroy (struct OsalMutex *mutex) |
|
OsalMutexLock (struct OsalMutex *mutex) |
|
OsalMutexTimedLock (struct OsalMutex *mutex, uint32_t ms) |
|
OsalMutexUnlock (struct OsalMutex *mutex) |
|
OsalSemInit (struct OsalSem *sem, uint32_t value) |
|
OsalSemWait (struct OsalSem *sem, uint32_t ms) |
|
OsalSemPost (struct OsalSem *sem) |
|
OsalSemDestroy (struct OsalSem *sem) |
|
OsalSpinInit (OsalSpinlock *spinlock) |
|
OsalSpinDestroy (OsalSpinlock *spinlock) |
|
OsalSpinLock (OsalSpinlock *spinlock) |
|
OsalSpinUnlock (OsalSpinlock *spinlock) |
|
OsalSpinLockIrq (OsalSpinlock *spinlock) |
|
OsalSpinUnlockIrq (OsalSpinlock *spinlock) |
|
OsalSpinLockIrqSave (OsalSpinlock *spinlock, uint32_t *flags) |
|
OsalSpinUnlockIrqRestore (OsalSpinlock *spinlock, uint32_t *flags) |
Releases a spinlock, enables the IRQ, and restores the saved IRQ status. |
OsalThreadCreate (struct OsalThread *thread, OsalThreadEntry threadEntry, void *entryPara) |
|
OsalThreadStart (struct OsalThread *thread, const struct OsalThreadParam *param) |
|
OsalThreadDestroy (struct OsalThread *thread) |
|
OsalThreadSuspend (struct OsalThread *thread) |
|
OsalThreadResume (struct OsalThread *thread) |
|
OsalSleep (uint32_t sec) |
|
OsalMSleep (uint32_t ms) |
|
OsalDiffTime (const OsalTimespec *start, const OsalTimespec *end, OsalTimespec *diff) |
|
OsalGetSysTimeMs (void) |
|
OsalMDelay (uint32_t ms) |
|
OsalUDelay (uint32_t us) |
|
OsalTimerCreate (OsalTimer *timer, uint32_t interval, OsalTimerFunc func, uintptr_t arg) |
|
OsalTimerDelete (OsalTimer *timer) |
|
OsalTimerStartOnce (OsalTimer *timer) |
|
OsalTimerStartLoop (OsalTimer *timer) |
|
OsalTimerSetTimeout (OsalTimer *timer, uint32_t interval) |
| address | Indicates the address to read. |
| address | Indicates the address to read. |
| address | Indicates the address to read. |
| value | Indicates the data to write. |
| address | Indicates the address to write. |
| value | Indicates the data to write. |
| address | Indicates the address to write. |
| value | Indicates the data to write. |
| address | Indicates the address to write. |
| OSAL_IRQF_TRIGGER_NONE | |
| OSAL_IRQF_TRIGGER_RISING | |
| OSAL_IRQF_TRIGGER_FALLING | |
| OSAL_IRQF_TRIGGER_HIGH | |
| OSAL_IRQF_TRIGGER_LOW |
| OSAL_THREAD_PRI_LOW | |
| OSAL_THREAD_PRI_DEFAULT | |
| OSAL_THREAD_PRI_HIGH | |
| OSAL_THREAD_PRI_HIGHEST |
| v | Indicates the pointer to the atomic OsalAtomic. |
| v | Indicates the pointer to the atomic OsalAtomic. |
| v | Indicates the pointer to the atomic OsalAtomic. |
| v | Indicates the pointer to the atomic OsalAtomic. |
| counter | Indicates the counter to set. |
| nr | Indicates the bit of the variable. The value ranges from 0 to 31. |
| addr | Indicates the pointer to the variable. |
| start | Indicates the pointer to the start time OsalTimespec. |
| end | Indicates the pointer to the end time OsalTimespec. |
| diff | Indicates the pointer to the time difference OsalTimespec. |
| irqId | Indicates the IRQ ID. |
| irqId | Indicates the IRQ ID. |
| file | Indicates the pointer to the file type OsalFile. |
| file | Indicates the pointer to the file type OsalFile. |
| offset | Indicates the offset to set. |
| whence | Indicates the position from which the offset is to set. For details, see OSAL_SEEK_SET. |
| file | Indicates the pointer to the file type OsalFile. |
| path | Indicates the pointer to the name of the file to open. |
| flags | Indicates the mode of opening the file. For details, see OSAL_O_RD_ONLY. |
| rights | Indicates the permissions required for opening the file. For details, see OSAL_S_IREAD. |
| file | Indicates the pointer to the file type OsalFile. |
| buf | Indicates the pointer to the buffer for storing the content to read. |
| length | Indicates the length of the content to read. |
HDF_FAILURE HDF_STATUS |
|
HDF_ERR_INVALID_PARAM HDF_STATUS |
| file | Indicates the pointer to the file type OsalFile. |
| string | Indicates the pointer to the content to write. |
| length | Indicates the length of the content to write. |
HDF_FAILURE HDF_STATUS |
|
HDF_ERR_INVALID_PARAM HDF_STATUS |
| time | Indicates the pointer to the time structure OsalTimespec. |
| phys_addr | Indicates the I/O physical address. |
| size | Indicates the size of the physical address to remap. |
| addr | Indicates the pointer to the virtual address to unmap. |
| ms | Indicates the delay time, in milliseconds. |
| size | Indicates the size of memory to allocate. |
| alignment | Indicates the memory boundary alignment. The value must be a power of 2. |
| size | Indicates the size of memory to allocate. |
| size | Indicates the size of memory to allocate. |
| mem | Indicates the pointer to the memory to release. |
| ms | Indicates the sleep time, in milliseconds. |
| mutex | Indicates the pointer to the mutex OsalMutex. |
| mutex | Indicates the pointer to the mutex OsalMutex. |
Failed to invoke the system function to initialize the mutex. |
|
| mutex | Indicates the pointer to the mutex OsalMutex. |
| mutex | Indicates the pointer to the mutex OsalMutex. |
| ms | Indicates the timeout duration, in milliseconds. |
| mutex | Indicates the pointer to the mutex OsalMutex. |
| fw | Indicates the pointer to the firmware file OsalFirmware. |
| irqId | Indicates the IRQ ID. |
| config | Indicates the interrupt trigger mode. For details, see OSAL_IRQ_TRIGGER_MODE. |
| handle | Indicates the interrupt processing function. |
| name | Indicates the pointer to the device name for registering an IRQ. |
| dev | Indicates the pointer to the parameter passed to the interrupt processing function. |
| fw Firmware parameter, see detail in OsalFirmware block Firmware data block, see detail in hdf_FWBlock |
| fw | Indicates the pointer to the firmware file OsalFirmware, which cannot be empty. |
| fwName | Indicates the pointer to the firmware file name, which cannot be empty. |
| device | Indicates the pointer to the information about the device that requests the firmware file. |
| fw | Indicates the pointer to the firmware file OsalFirmware. |
| block | Indicates the pointer to the firmware block to read. For details, see OsalFwBlock. |
| sem | Indicates the pointer to the semaphore OsalSem. |
Failed to invoke the system function to destroy the semaphore. |
|
| sem | Indicates the pointer to the semaphore OsalSem. |
| value | Indicates the initial value of the semaphore. |
Failed to invoke the system function to initialize the semaphore. |
|
| sem | Indicates the pointer to the semaphore OsalSem. |
Failed to invoke the system function to release the semaphore. |
|
| sem | Indicates the pointer to the semaphore OsalSem. |
| ms | Indicates the timeout interval. |
Failed to invoke the system function to wait for the semaphore. |
|
| sec | Indicates the sleep time, in seconds. |
| spinlock | Indicates the pointer to the spinlock OsalSpinlock. |
Failed to invoke the system function to destroy the spinlock. |
|
| spinlock | Indicates the pointer to the spinlock OsalSpinlock. |
Failed to invoke the system function to initialize the spinlock. |
|
| spinlock | Indicates the pointer to the spinlock OsalSpinlock. |
Failed to invoke the system function to obtain the spinlock. |
|
| spinlock | Indicates the pointer to the spinlock OsalSpinlock. |
Failed to invoke the system function to obtain the spinlock. |
|
| spinlock | Indicates the pointer to the spinlock OsalSpinlock. |
| flags | Indicates the pointer to the status of the IRQ register. |
Failed to invoke the system function to obtain the spinlock. |
|
| spinlock | Indicates the pointer to the spinlock OsalSpinlock. |
Failed to invoke the system function to release the spinlock. |
|
| spinlock | Indicates the pointer to the spinlock OsalSpinlock. |
Failed to invoke the system function to release the spinlock. |
|
| spinlock | Indicates the pointer to the spinlock OsalSpinlock. |
| flags | Indicates the pointer to the value used to restore the IRQ register. |
Failed to invoke the system function to release the spinlock. |
|
| nr | Indicates the bit of the variable. The value ranges from 0 to 31. |
| addr | Indicates the pointer to the variable. |
| nr | Indicates the bit of the variable. The value ranges from 0 to 31. |
| addr | Indicates the pointer to the variable. |
| nr | Indicates the bit of the variable. The value ranges from 0 to 31. |
| addr | Indicates the pointer to the variable. |
| thread | Indicates the pointer to the thread OsalThread. |
| threadEntry | Indicates the thread callback function OsalThreadEntry. |
| entryPara | Indicates the pointer to the parameter passed to the thread callback function. |
| thread | Indicates the pointer to the thread OsalThread. |
| thread | Indicates the pointer to the thread OsalThread. |
| thread | Indicates the pointer to the thread OsalThread. |
| param | Indicates the pointer to the parameter used to start a thread. For details, see OsalThreadParam. |
| thread | Indicates the pointer to the thread OsalThread. |
| timer | Indicates the pointer to the timer OsalTimer. |
| interval | Indicates the timer interval. |
| func | Indicates the timer execution function OsalTimerFunc. |
| arg | Indicates the argument passed to the timer execution function. |
| timer | Indicates the pointer to the timer OsalTimer. |
| timer | Indicates the pointer to the timer OsalTimer. |
| interval | Indicates the timer interval, in milliseconds. |
| timer | Indicates the pointer to the timer OsalTimer. |
| interval | Indicates the timer interval, in milliseconds. |
| timer | Indicates the pointer to the timer OsalTimer. |
| us | Indicates the delay time, in microseconds. |
| irqId | Indicates the IRQ ID. |