/*! * @brief Setup SysLinkMemUtils module. * * @sa _SysLinkMemUtils_exit */ static Void _SysLinkMemUtils_init (Void) { List_Params listParams; GT_0trace (curTrace, GT_ENTER, "_SysLinkMemUtils_init"); List_Params_init (&listParams); SysLinkMemUtils_module->addrTable = List_create (&listParams); #if !defined(SYSLINK_BUILD_OPTIMIZE) if (!SysLinkMemUtils_module->addrTable) { GT_setFailureReason (curTrace, GT_4CLASS, (Char *)__func__, PROCMGR_E_MEMORY, "Translation list could not be created!"); } #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */ SysLinkMemUtils_module->semList = OsalSemaphore_create ( OsalSemaphore_Type_Counting, 1); #if !defined(SYSLINK_BUILD_OPTIMIZE) if (!SysLinkMemUtils_module->semList) { GT_setFailureReason (curTrace, GT_4CLASS, (Char *)__func__, PROCMGR_E_MEMORY, "List semaphore could not be created!"); } #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */ GT_0trace (curTrace, GT_LEAVE, "_SysLinkMemUtils_init"); }
/*! * @brief Function to initialize the parameters for this PwrMgr instance. * * @param params Configuration parameters. * * @sa DM8168DUCATIPWR_create */ Void DM8168DUCATIPWR_Params_init (DM8168DUCATIPWR_Params * params) { GT_1trace (curTrace, GT_ENTER, "DM8168DUCATIPWR_Params_init", params); GT_assert (curTrace, (params != NULL)); GT_assert (curTrace, (DM8168DUCATIPWR_state.refCount != 0)); #if !defined(SYSLINK_BUILD_OPTIMIZE) && defined (SYSLINK_BUILD_HLOS) if (DM8168DUCATIPWR_state.refCount == 0) { GT_setFailureReason (curTrace, GT_4CLASS, "DM8168DUCATIPWR_Params_initv", DM8168DUCATIPWR_E_INVALIDSTATE, "Module was not initialized!"); } else if (params == NULL) { GT_setFailureReason (curTrace, GT_4CLASS, "DM8168DUCATIPWR_Params_init", PWRMGR_E_INVALIDARG, "Argument of type (DM8168DUCATIPWR_Params *) " "passed is null!"); } else { #endif /* #if !defined(SYSLINK_BUILD_OPTIMIZE) && defined (SYSLINK_BUILD_HLOS) */ params->reserved = 0; #if !defined(SYSLINK_BUILD_OPTIMIZE) && defined (SYSLINK_BUILD_HLOS) } #endif /* #if !defined(SYSLINK_BUILD_OPTIMIZE) && defined (SYSLINK_BUILD_HLOS) */ GT_0trace (curTrace, GT_LEAVE, "DM8168DUCATIPWR_Params_init"); }
/* Function to allocate the specified number of bytes and memory is set to * the specified value. */ Ptr Memory_valloc (IHeap_Handle heap, SizeT size, SizeT align, Char value, Ptr eb) { Ptr buffer = NULL; GT_4trace (curTrace, GT_ENTER, "Memory_valloc", heap, size, align, eb); /* Check whether the right paramaters are passed or not.*/ GT_assert (curTrace, (size > 0)); (Void) eb; /* Not used. */ if (heap == NULL) { buffer = MemoryOS_alloc (size, align, 0); #if !defined(SYSLINK_BUILD_OPTIMIZE) if (buffer == NULL) { /*! @retval NULL Failed to allocate memory */ GT_setFailureReason (curTrace, GT_4CLASS, "Memory_valloc", Memory_E_MEMORY, "Failed to allocate memory!"); } #endif /* #if !defined(SYSLINK_BUILD_OPTIMIZE) */ } else { buffer = IHeap_alloc (heap, size, align); #if !defined(SYSLINK_BUILD_OPTIMIZE) if (buffer == NULL) { /*! @retval NULL Heap_alloc failed */ GT_setFailureReason (curTrace, GT_4CLASS, "Memory_valloc", Memory_E_MEMORY, "IHeap_alloc failed!"); } #endif /* #if !defined(SYSLINK_BUILD_OPTIMIZE) */ } #if !defined(SYSLINK_BUILD_OPTIMIZE) if (buffer != NULL) { #endif /* #if !defined(SYSLINK_BUILD_OPTIMIZE) */ buffer = Memory_set (buffer, value, size); #if !defined(SYSLINK_BUILD_OPTIMIZE) if (buffer == NULL) { /*! @retval NULL Memory_set to 0 failed */ GT_setFailureReason (curTrace, GT_4CLASS, "Memory_valloc", Memory_E_MEMORY, "Memory_set to 0 failed!"); } } #endif /* #if !defined(SYSLINK_BUILD_OPTIMIZE) */ GT_0trace (curTrace, GT_LEAVE, "Memory_valloc"); /*! @retval Pointer Success: Pointer to allocated buffer */ return buffer; }
/*! * @brief Function to open the NameServer driver. * * @sa NameServerDrv_close */ Int NameServerDrv_open(Void) { Int status = NameServer_S_SUCCESS; GT_0trace(curTrace, GT_ENTER, "NameServerDrv_open"); /* TBD: Protection for refCount. */ if (NameServerDrv_refCount == 0) { /* open the drive */ NameServerDrv_handle = Dev_pollOpen(NAMESERVER_DRVIER_NAME, O_SYNC | O_RDWR); if (NameServerDrv_handle < 0) { status = NameServer_E_OSFAILURE; GT_setFailureReason(curTrace, GT_4CLASS, "NameServerDrv_open", status, "Failed to open NameServer driver with OS"); } /* set flag to close file descriptor on exec */ if (status == NameServer_S_SUCCESS) { status = fcntl(NameServerDrv_handle, F_SETFD, FD_CLOEXEC); if (status != 0) { status = NameServer_E_OSFAILURE; GT_setFailureReason(curTrace, GT_4CLASS, "NameServerDrv_open", status, "Failed to set file descriptor flags"); } } /* set pid on file descriptor for resource tracking */ if (status == NameServer_S_SUCCESS) { status = fcntl(NameServerDrv_handle, F_SETOWN, getpid()); if (status != 0) { status = NameServer_E_OSFAILURE; GT_setFailureReason(curTrace, GT_4CLASS, "NameServerDrv_open", status, "Failed to set process id"); } } } if (status == NameServer_S_SUCCESS) { NameServerDrv_refCount++; } /* failure case */ if (status < 0) { if (NameServerDrv_handle > 0) { close(NameServerDrv_handle); NameServerDrv_handle = 0; } } GT_1trace(curTrace, GT_LEAVE, "NameServerDrv_open", status); return(status); }
/*! * @brief Function to open the HeapMultiBuf driver. * * @sa HeapMultiBufDrv_close */ Int HeapMultiBufDrv_open (Void) { //Int status = HEAPMULTIBUF_SUCCESS; Int status = 0; int osStatus = 0; GT_0trace (curTrace, GT_ENTER, "HeapMultiBufDrv_open"); #if 0 if (HeapMultiBufDrv_refCount == 0) { HeapMultiBufDrv_handle = open (HEAPMULTIBUF_DRIVER_NAME, O_SYNC | O_RDWR); if (HeapMultiBufDrv_handle < 0) { perror (HEAPMULTIBUF_DRIVER_NAME); /*! @retval HEAPMULTIBUF_E_OSFAILURE Failed to open * HeapMultiBuf driver with OS */ status = HEAPMULTIBUF_E_OSFAILURE; GT_setFailureReason (curTrace, GT_4CLASS, "HeapMultiBufDrv_open", status, "Failed to open HeapMultiBuf driver with OS!"); } else { osStatus = fcntl (HeapMultiBufDrv_handle, F_SETFD, FD_CLOEXEC); if (osStatus != 0) { /*! @retval HEAPMULTIBUF_E_OSFAILURE * Failed to set file descriptor flags */ status = HEAPMULTIBUF_E_OSFAILURE; GT_setFailureReason (curTrace, GT_4CLASS, "HeapMultiBufDrv_open", status, "Failed to set file descriptor flags!"); } else { /* TBD: Protection for refCount. */ HeapMultiBufDrv_refCount++; } } } else { HeapMultiBufDrv_refCount++; } #endif GT_1trace (curTrace, GT_LEAVE, "HeapMultiBufDrv_open", status); /*! @retval HEAPMULTIBUF_SUCCESS Operation successfully completed. */ return status; }
/*! * @brief Function to open the ListMP driver. * * @sa ListMPDrv_close */ Int ListMPDrv_open (Void) { Int status = ListMP_S_SUCCESS; int osStatus = 0; GT_0trace (curTrace, GT_ENTER, "ListMPDrv_open"); if (ListMPDrv_refCount == 0) { ListMPDrv_handle = open (LISTMP_DRIVER_NAME, O_SYNC | O_RDWR); if (ListMPDrv_handle < 0) { perror (LISTMP_DRIVER_NAME); /*! @retval ListMP_E_OSFAILURE * Failed to open ListMP driver with OS */ status = ListMP_E_OSFAILURE; GT_setFailureReason (curTrace, GT_4CLASS, "ListMPDrv_open", status, "Failed to open ListMP driver" " with OS!"); } else { osStatus = fcntl (ListMPDrv_handle, F_SETFD, FD_CLOEXEC); if (osStatus != 0) { /*! @retval ListMP_E_OSFAILURE * Failed to set file descriptor flags */ status = ListMP_E_OSFAILURE; GT_setFailureReason (curTrace, GT_4CLASS, "ListMPDrv_open", status, "Failed to set file descriptor flags!"); } else{ /* TBD: Protection for refCount. */ ListMPDrv_refCount++; } } } else { ListMPDrv_refCount++; } GT_1trace (curTrace, GT_LEAVE, "ListMPDrv_open", status); /*! @retval ListMP_S_SUCCESS Operation successfully completed. */ return status; }
/*! * @brief Function to open the Notify driver. * * @param createThread Flag to indicate whether to create thread or not. * * @sa NotifyDrvUsr_close */ Int NotifyDrvUsr_open (Bool createThread) { Int status = Notify_S_SUCCESS; GT_1trace (curTrace, GT_ENTER, "NotifyDrvUsr_open", createThread); if (NotifyDrvUsr_refCount == 0) { /* TBD: Protection for refCount. */ NotifyDrvUsr_refCount++; if (createThread == TRUE) { Notify_CmdArgsThreadAttach attachParams; attachParams.pid = getpid (); status = NotifyDrvUsr_ioctl (CMD_NOTIFY_THREADATTACH, &attachParams); if (status < 0) { GT_setFailureReason (curTrace, GT_4CLASS, "NotifyDrvUsr_close", status, "Notify attach failed on kernel " "side!"); } else { /* Create the pthread */ pthread_create (&NotifyDrv_workerThread, NULL, (Ptr) _NotifyDrvUsr_eventWorker, NULL); if (NotifyDrv_workerThread == (UInt32) NULL) { /*! @retval Notify_E_OSFAILURE Failed to create Notify thread */ status = Notify_E_OSFAILURE; GT_setFailureReason (curTrace, GT_4CLASS, "NotifyDrvUsr_open", status, "Failed to create Notify " "thread!"); } } } } else { /* TBD: Protection for refCount. */ NotifyDrvUsr_refCount++; } GT_1trace (curTrace, GT_LEAVE, "NotifyDrvUsr_open", status); /*! @retval Notify_S_SUCCESS Operation successfully completed. */ return status; }
/*! * @brief Function to close the Notify driver. * * @param deleteThread Flag to indicate whether to delete thread or not. * * @sa NotifyDrvUsr_open */ Int NotifyDrvUsr_close (Bool deleteThread) { Int status = Notify_S_SUCCESS; int osStatus = 0; UInt32 pid; Notify_CmdArgsThreadDetach cmdArgs; GT_1trace (curTrace, GT_ENTER, "NotifyDrvUsr_close", deleteThread); /* TBD: Protection for refCount. */ if (NotifyDrvUsr_refCount == 1) { if (deleteThread == TRUE) { pid = getpid (); cmdArgs.pid = pid; status = NotifyDrvUsr_ioctl (CMD_NOTIFY_THREADDETACH, &cmdArgs); if (status < 0) { GT_setFailureReason (curTrace, GT_4CLASS, "NotifyDrvUsr_close", status, "Notify detach failed on kernel side!"); } #ifndef LINUX_THREAD pthread_join (NotifyDrv_workerThread, NULL); #endif } NotifyDrvUsr_refCount--; osStatus = close (NotifyDrvUsr_handle); if (osStatus != 0) { perror ("Notify driver close: " NOTIFY_DRIVER_NAME); /*! @retval Notify_E_OSFAILURE Failed to open Notify driver with OS */ status = Notify_E_OSFAILURE; GT_setFailureReason (curTrace, GT_4CLASS, "NotifyDrvUsr_close", status, "Failed to close Notify driver with OS!"); } else { NotifyDrvUsr_handle = -1; } } else { NotifyDrvUsr_refCount--; } GT_1trace (curTrace, GT_LEAVE, "NotifyDrvUsr_close", status); return status; }
/*! * @brief Function to close a handle to an instance of this PwrMgr. * * @param handlePtr Pointer to Handle to the PwrMgr instance * * @sa DM8168DUCATIPWR_open */ Int DM8168DUCATIPWR_close (DM8168DUCATIPWR_Handle * handlePtr) { Int status = PWRMGR_SUCCESS; GT_1trace (curTrace, GT_ENTER, "DM8168DUCATIPWR_close", handlePtr); GT_assert (curTrace, (handlePtr != NULL)); GT_assert (curTrace, ((handlePtr != NULL) && (*handlePtr != NULL))); GT_assert (curTrace, (DM8168DUCATIPWR_state.refCount != 0)); #if !defined(SYSLINK_BUILD_OPTIMIZE) && defined (SYSLINK_BUILD_HLOS) if (DM8168DUCATIPWR_state.refCount == 0) { GT_setFailureReason (curTrace, GT_4CLASS, "DM8168DUCATIPWR_close", DM8168DUCATIPWR_E_INVALIDSTATE, "Module was not initialized!"); } else if (handlePtr == NULL) { /*! @retval PWRMGR_E_INVALIDARG Invalid NULL handlePtr pointer specified*/ status = PWRMGR_E_INVALIDARG; GT_setFailureReason (curTrace, GT_4CLASS, "DM8168DUCATIPWR_close", status, "Invalid NULL handlePtr pointer specified"); } else if (*handlePtr == NULL) { /*! @retval PWRMGR_E_HANDLE Invalid NULL *handlePtr specified */ status = PWRMGR_E_HANDLE; GT_setFailureReason (curTrace, GT_4CLASS, "DM8168DUCATIPWR_close", status, "Invalid NULL *handlePtr specified"); } else { #endif /* #if !defined(SYSLINK_BUILD_OPTIMIZE) && defined(SYSLINK_BUILD_HLOS) */ /* Nothing to be done for close. */ *handlePtr = NULL; #if !defined(SYSLINK_BUILD_OPTIMIZE) && defined (SYSLINK_BUILD_HLOS) } #endif /* #if !defined(SYSLINK_BUILD_OPTIMIZE) && defined(SYSLINK_BUILD_HLOS) */ GT_1trace (curTrace, GT_LEAVE, "DM8168DUCATIPWR_close", status); /*! @retval PWRMGR_SUCCESS Operation successful */ return status; }
/* * ======== OsalKfile_close ======== */ Int OsalKfile_close (OsalKfile_Handle * fileHandle) { Int status = OSALKFILE_SUCCESS; OsalKfile_Object * fileObject = NULL; mm_segment_t fs; GT_1trace (curTrace, GT_ENTER, "OsalKfile_close", fileHandle); GT_assert (curTrace, (fileHandle != NULL)); #if !defined(SYSLINK_BUILD_OPTIMIZE) if (fileHandle == NULL) { /*! @retval OSALKFILE_E_INVALIDARG NULL provided for argument fileHandle. */ status = OSALKFILE_E_INVALIDARG; GT_setFailureReason (curTrace, GT_4CLASS, "OsalKfile_close", status, "NULL provided for argument fileHandle"); } else if (*fileHandle == NULL) { /*! @retval OSALKFILE_E_HANDLE NULL file handle provided. */ status = OSALKFILE_E_HANDLE; GT_setFailureReason (curTrace, GT_4CLASS, "OsalKfile_close", status, "NULL file handle provided."); } else { #endif /* #if !defined(SYSLINK_BUILD_OPTIMIZE) */ fileObject = (OsalKfile_Object *) *fileHandle; fs = get_fs(); set_fs (KERNEL_DS); filp_close (fileObject->fileDesc, NULL); set_fs (fs); Memory_free (NULL, fileObject, sizeof(OsalKfile_Object)); /* Reset user's file handle pointer. */ *fileHandle = NULL; #if !defined(SYSLINK_BUILD_OPTIMIZE) } #endif /* #if !defined(SYSLINK_BUILD_OPTIMIZE) */ GT_1trace (curTrace, GT_LEAVE, "OsalKfile_close", status); /*! @retval OSALKFILE_SUCCESS Operation successfully completed. */ return status; }
/*! * @brief Function to open the ClientNotifyMgr driver. * * @sa GatePetersonDrv_close */ Int ClientNotifyMgrDrv_open (Void) { Int status = ClientNotifyMgr_S_SUCCESS; int osStatus = 0; GT_0trace (curTrace, GT_ENTER, "ClientNotifyMgrDrv_open"); if (ClientNotifyMgrDrv_refCount == 0) { /* TBD: Protection for refCount. */ ClientNotifyMgrDrv_refCount++; ClientNotifyMgrDrv_handle = Dev_pollOpen (CLIENTNOTIFYMGR_DRVIER_NAME, O_SYNC | O_RDWR); if (ClientNotifyMgrDrv_handle < 0) { perror (CLIENTNOTIFYMGR_DRVIER_NAME); /*! @retval ClientNotifyMgr_E_OSFAILURE Failed to open ClientNotifyMgr driver with OS */ status = ClientNotifyMgr_E_OSFAILURE; GT_setFailureReason (curTrace, GT_4CLASS, "ClientNotifyMgrDrv_open", status, "Failed to open ClientNotifyMgr driver with OS!"); } else { osStatus = fcntl (ClientNotifyMgrDrv_handle, F_SETFD, FD_CLOEXEC); if (osStatus != 0) { /*! @retval ClientNotifyMgr_E_OSFAILURE Failed to set file * descriptor flags */ status = ClientNotifyMgr_E_OSFAILURE; GT_setFailureReason (curTrace, GT_4CLASS, "ClientNotifyMgrDrv_open", status, "Failed to set file descriptor flags!"); } } } else { ClientNotifyMgrDrv_refCount++; } GT_1trace (curTrace, GT_LEAVE, "ClientNotifyMgrDrv_open", status); /*! @retval ClientNotifyMgr_SUCCESS Operation successfully completed. */ return (status); }
/*! * @brief Deletes an instance of Semaphore object. * * @param mutexHandle Semaphore object handle which needs to be deleted. * * @sa OsalSemaphore_create */ Int OsalSemaphore_delete(OsalSemaphore_Handle *semHandle) { Int status = OSALSEMAPHORE_SUCCESS; OsalSemaphore_Object **semObj = (OsalSemaphore_Object **)semHandle; int osStatus = 0; GT_1trace (curTrace, GT_ENTER, "OsalSemaphore_delete", semHandle); GT_assert (curTrace, (semHandle != NULL)); #if !defined(SYSLINK_BUILD_OPTIMIZE) if (semHandle == NULL) { status = OSALSEMAPHORE_E_INVALIDARG; GT_setFailureReason (curTrace, GT_4CLASS, "OsalSemaphore_delete", status, "NULL provided for argument semHandle"); } else if (*semHandle == NULL) { status = OSALSEMAPHORE_E_HANDLE; GT_setFailureReason (curTrace, GT_4CLASS, "OsalSemaphore_delete", status, "NULL Semaphore handle provided."); } else { #endif /* #if !defined(SYSLINK_BUILD_OPTIMIZE) */ osStatus = sem_destroy(&((*semObj)->lock)); #if !defined(SYSLINK_BUILD_OPTIMIZE) if (osStatus < 0) { status = OSALSEMAPHORE_E_HANDLE; GT_setFailureReason (curTrace, GT_4CLASS, "OsalSemaphore_delete", status, "Failed to destroy semaphore"); } #endif /* #if !defined(SYSLINK_BUILD_OPTIMIZE) */ Memory_free(NULL, *semHandle, sizeof (OsalSemaphore_Object)); *semHandle = NULL; #if !defined(SYSLINK_BUILD_OPTIMIZE) } #endif /* #if !defined(SYSLINK_BUILD_OPTIMIZE) */ GT_1trace (curTrace, GT_LEAVE, "OsalSemaphore_delete", status); return status; }
/*! * @brief Function to open the Ipc driver. * * @sa IpcDrv_close */ Int IpcDrv_open (Void) { Int status = Ipc_S_SUCCESS; int osStatus = 0; GT_0trace (curTrace, GT_ENTER, "IpcDrv_open"); if (IpcDrv_refCount == 0) { IpcDrv_handle = open (IPC_DRIVER_NAME, O_SYNC | O_RDWR); if (IpcDrv_handle < 0) { perror (IPC_DRIVER_NAME); /*! @retval Ipc_E_OSFAILURE Failed to open Ipc driver with OS */ status = Ipc_E_OSFAILURE; GT_setFailureReason (curTrace, GT_4CLASS, "IpcDrv_open", status, "Failed to open Ipc driver with OS!"); } else { osStatus = fcntl (IpcDrv_handle, F_SETFD, FD_CLOEXEC); if (osStatus != 0) { /*! @retval Ipc_E_OSFAILURE Failed to set file descriptor flags */ status = Ipc_E_OSFAILURE; GT_setFailureReason (curTrace, GT_4CLASS, "IpcDrv_open", status, "Failed to set file descriptor flags!"); } else { /* TBD: Protection for refCount. */ IpcDrv_refCount++; } } } else { IpcDrv_refCount++; } GT_1trace (curTrace, GT_LEAVE, "IpcDrv_open", status); return status; }
/*! * @brief Function to initialize the HAL object * * @param halObj Return parameter: Pointer to the HAL object * @param initParams Optional initialization parameters * * @sa OMAPL1XX_halExit * OMAPL1XX_phyShmemInit */ Int OMAPL1XX_halInit (Ptr * halObj, Ptr params) { Int status = PROCESSOR_SUCCESS; OMAPL1XX_HalObject * halObject = NULL; GT_2trace (curTrace, GT_ENTER, "OMAPL1XX_halInit", halObj, params); GT_assert (curTrace, (halObj != NULL)); (Void) params ; /* Not used. */ *halObj = Memory_calloc (NULL, sizeof (OMAPL1XX_HalObject), 0, NULL); #if !defined(SYSLINK_BUILD_OPTIMIZE) if (*halObj == NULL) { /*! @retval PROCESSOR_E_MEMORY Memory allocation failed */ status = PROCESSOR_E_MEMORY; GT_setFailureReason (curTrace, GT_4CLASS, "OMAPL1XX_halInit", status, "Memory allocation failed for HAL object!"); } else { #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */ halObject = (OMAPL1XX_HalObject *) *halObj; halObject->offsetPsc0 = OFFSET_PSC0; halObject->offsetSysModule = OFFSET_SYSTEM_MODULE; status = OMAPL1XX_phyShmemInit (*halObj); #if !defined(SYSLINK_BUILD_OPTIMIZE) if (status < 0) { GT_setFailureReason (curTrace, GT_4CLASS, "OMAPL1XX_halInit", status, "OMAPL1XX_phyShmemInit failed!"); Memory_free (NULL, *halObj, sizeof (OMAPL1XX_HalObject)); *halObj = NULL; } } #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */ GT_1trace (curTrace, GT_LEAVE, "OMAPL1XX_halInit", status); /*! @retval PROCESSOR_SUCCESS Operation successful */ return status; }
/*! * @brief Leave/unlock the Mutex object. * * This function releases the critical section identified by this * mutex handle. The completion of this function shall make the * critical section available to any other threads that may be * waiting to acquire it. * * @param mutexHandle Mutex object handle to be released. * @param key Key received from the corresponding enter call. * * @sa OsalMutex_enter */ Void OsalMutex_leave(OsalMutex_Handle mutexHandle, IArg key) { OsalMutex_Object * mutexObj = (OsalMutex_Object*) mutexHandle; Int ret = 0; GT_2trace (curTrace, GT_ENTER, "OsalMutex_leave", mutexHandle, key); GT_assert (curTrace, (mutexHandle != NULL)); /* key can be 0, so not checked. */ #if !defined(SYSLINK_BUILD_OPTIMIZE) if (mutexHandle == NULL) { /* Void function, so not setting status. */ GT_setFailureReason (curTrace, GT_4CLASS, "OsalMutex_leave", OSALMUTEX_E_HANDLE, "NULL Mutex handle provided."); } else { #endif /* #if !defined(SYSLINK_BUILD_OPTIMIZE) */ ret = pthread_mutex_unlock (&(mutexObj->lock)); GT_assert (curTrace, (ret == 0)); #if !defined(SYSLINK_BUILD_OPTIMIZE) } #endif /* #if !defined(SYSLINK_BUILD_OPTIMIZE) */ GT_0trace (curTrace, GT_LEAVE, "OsalMutex_leave"); }
/*! * @brief Creates and initializes an event object for thread * synchronization. The event is initialized to a * non-signaled state.. * * @param Un-allocated event object. * @sa EventClose */ OsalEvent_Handle OsalEvent_create (Void) { #if (!defined(SYSLINK_BUILD_OPTIMIZE)|| defined(SYSLINK_TRACE_ENABLE)) Int status = OSALEVENT_SUCCESS ; #endif /*(!defined(SYSLINK_BUILD_OPTIMIZE)|| defined(SYSLINK_TRACE_ENABLE)) */ OsalEvent_Object* event = NULL; GT_0trace (curTrace, GT_ENTER, "OsalEvent_create"); event = Memory_alloc (NULL, sizeof (OsalEvent_Object), 0, NULL); #if !defined(SYSLINK_BUILD_OPTIMIZE) if (event == NULL) { status = OSALEVENT_E_MEMORY; GT_setFailureReason (curTrace, GT_4CLASS, "OsalEvent_create", OSALEVENT_E_MEMORY, "Memory allocation failed"); } else { #endif /* #if !defined(SYSLINK_BUILD_OPTIMIZE) */ event->value = 0; event->lock = OsalSpinlock_create (OsalSpinlock_Type_Normal); init_waitqueue_head (&event->list) ; #if !defined(SYSLINK_BUILD_OPTIMIZE) } #endif /* #if !defined(SYSLINK_BUILD_OPTIMIZE) */ GT_1trace (curTrace, GT_LEAVE, "OsalEvent_create", status); /*!@status The object created */ return (OsalEvent_Handle) event; }
/*! * @brief Closes the handle corresponding to an event. It also frees the * resources allocated, if any, during call to OpenEvent () * * @param allocated event object handle. * @sa OsalEvent_delete */ Int OsalEvent_delete (OsalEvent_Handle handle) { Int status = OSALEVENT_SUCCESS ; OsalEvent_Object* event = (OsalEvent_Object*) handle; GT_1trace (curTrace, GT_ENTER,"OsalEvent_close",event ); GT_assert (curTrace, (NULL != event) ); status = OsalSpinlock_delete (&(event->lock)); if (status >= 0) { event->signature = 0; } #if !defined(SYSLINK_BUILD_OPTIMIZE) else { status = OSALEVENT_E_SPINLOCK; GT_setFailureReason(curTrace, GT_4CLASS, "OsalEvent_close",OSALEVENT_E_SPINLOCK, "SpinLock Delete failed"); } #endif /* #if !defined(SYSLINK_BUILD_OPTIMIZE) */ GT_1trace (curTrace, GT_LEAVE,"Event_Close",status ); /*!@status OSALEVENT_SUCCESS if call succeeded.*/ /*!@status OSALEVENT_E_SPINLOCK when SpinLock operation fails.*/ return status; }
/*! * @brief Function to close the Notify driver. * * @param deleteThread Flag to indicate whether to delete thread or not. * * @sa NotifyDrvUsr_open */ Int NotifyDrvUsr_close (Bool deleteThread) { Int status = Notify_S_SUCCESS; GT_1trace (curTrace, GT_ENTER, "NotifyDrvUsr_close", deleteThread); /* TBD: Protection for refCount. */ if (NotifyDrvUsr_refCount == 1) { if (deleteThread == TRUE) { Notify_CmdArgsThreadDetach detachParams; detachParams.pid = getpid (); status = NotifyDrvUsr_ioctl (CMD_NOTIFY_THREADDETACH, &detachParams); if (status < 0) { GT_setFailureReason (curTrace, GT_4CLASS, "NotifyDrvUsr_close", status, "Notify detach failed on kernel side!"); } pthread_join (NotifyDrv_workerThread, NULL); } NotifyDrvUsr_refCount--; } else { NotifyDrvUsr_refCount--; } GT_1trace (curTrace, GT_LEAVE, "NotifyDrvUsr_close", status); return status; }
/*! * @brief Function to close the ClientNotifyMgr driver. * * @sa ClientNotifyMgrDrv_open */ Int ClientNotifyMgrDrv_close (Void) { Int status = ClientNotifyMgr_S_SUCCESS; int osStatus = 0; GT_0trace (curTrace, GT_ENTER, "ClientNotifyMgrDrv_close"); /* TBD: Protection for refCount. */ ClientNotifyMgrDrv_refCount--; if (ClientNotifyMgrDrv_refCount == 0) { osStatus = close (ClientNotifyMgrDrv_handle); if (osStatus != 0) { perror ("ClientNotifyMgr driver close: "); /*! @retval ClientNotifyMgr_E_OSFAILURE Failed to open ClientNotifyMgr * driver with OS */ status = ClientNotifyMgr_E_OSFAILURE; GT_setFailureReason (curTrace, GT_4CLASS, "ClientNotifyMgrDrv_close", status, "Failed to close ClientNotifyMgr driver with OS!"); } else { ClientNotifyMgrDrv_handle = 0; } } GT_1trace (curTrace, GT_LEAVE, "ClientNotifyMgrDrv_close", status); /*! @retval ClientNotifyMgr_S_SUCCESS Operation successfully completed. */ return (status); }
/*! * @brief Function to invoke the APIs through ioctl. * * @param cmd Command for driver ioctl * @param args Arguments for the ioctl command * * @sa */ Int SyslinkMemMgrDrv_ioctl (UInt32 cmd, Ptr args) { Int status = MEMMGR_SUCCESS; int osStatus = 0; GT_2trace (curTrace, GT_ENTER, "SyslinkMemMgrDrv_ioctl", cmd, args); GT_assert (curTrace, (SyslinkMemMgrDrv_refCount > 0)); osStatus = ioctl (SyslinkMemMgrDrv_handle, cmd, args); if (osStatus < 0) { /*! @retval MEMMGR_E_OSFAILURE Driver ioctl failed */ status = MEMMGR_E_OSFAILURE; GT_setFailureReason (curTrace, GT_4CLASS, "SyslinkMemMgrDrv_ioctl", status, "Driver ioctl failed!"); } else { /* First field in the structure is the API status. */ status = ((SyslinkMemMgrDrv_CmdArgs *) args)->apiStatus; } GT_1trace (curTrace, GT_LEAVE, "SyslinkMemMgrDrv_ioctl", status); /*! @retval MEMMGR_SUCCESS Operation successfully completed. */ return status; }
/*! * @brief Function to close the SyslinkMemMgr driver. * * @sa SyslinkMemMgrDrv_open */ Int SyslinkMemMgrDrv_close (Void) { Int status = MEMMGR_SUCCESS; int osStatus = 0; GT_0trace (curTrace, GT_ENTER, "SyslinkMemMgrDrv_close"); /* TBD: Protection for refCount. */ SyslinkMemMgrDrv_refCount--; if (SyslinkMemMgrDrv_refCount == 0) { osStatus = close (SyslinkMemMgrDrv_handle); if (osStatus != 0) { perror ("SyslinkMemMgr driver close: "); /*! @retval MEMMGR_E_OSFAILURE Failed to open SyslinkMemMgr driver with OS */ status = MEMMGR_E_OSFAILURE; GT_setFailureReason (curTrace, GT_4CLASS, "SyslinkMemMgrDrv_close", status, "Failed to close SyslinkMemMgr driver with OS!"); } else { SyslinkMemMgrDrv_handle = 0; } } GT_1trace (curTrace, GT_LEAVE, "SyslinkMemMgrDrv_close", status); /*! @retval MEMMGR_SUCCESS Operation successfully completed. */ return status; }
/*! * @brief Function to invoke the APIs through ioctl. * * @param cmd Command for driver ioctl * @param args Arguments for the ioctl command * * @sa */ Int OsalDrv_ioctl (UInt32 cmd, Ptr args) { Int status = OSALDRV_SUCCESS; int osStatus = 0; TraceDrv_CmdArgs * cmdArgs = (TraceDrv_CmdArgs *) args; GT_2trace (curTrace, GT_ENTER, "OsalDrv_ioctl", cmd, args); GT_assert (curTrace, (OsalDrv_refCount > 0)); // osStatus = ioctl (OsalDrv_handle, cmd, args); osStatus = devctl( OsalDrv_handle, DCMD_TRACEDRV_SETTRACE, cmdArgs, sizeof(TraceDrv_CmdArgs), NULL); if (osStatus < 0) { /*! @retval OSALDRV_E_OSFAILURE Driver ioctl failed */ status = OSALDRV_E_OSFAILURE; GT_setFailureReason (curTrace, GT_4CLASS, "OsalDrv_ioctl", status, "Driver ioctl failed!"); } else { /* First field in the structure is the API status. */ status = ((TraceDrv_CmdArgs *) args)->apiStatus; } GT_1trace (curTrace, GT_LEAVE, "OsalDrv_ioctl", status); /*! @retval OSALDRV_SUCCESS Operation successfully completed. */ return status; }
/*! * @brief Function to map a memory region specific to the driver. * * @sa OsalDrv_close,OsalDrv_open */ UInt32 OsalDrv_map (UInt32 addr, UInt32 size, Bool isCached) { UInt32 userAddr = (UInt32) NULL; OsalMemMap_CmdArgs args; GT_0trace (curTrace, GT_ENTER, "OsalDrv_map"); if (OsalDrv_refCount == 1) { args.len = size; args.paddr = (off_t)addr; args.isCached = isCached; devctl(OsalDrv_handle, DCMD_OSALMEM_MMAP, &args, sizeof(args), NULL); userAddr = (UInt32)(args.vaddr); #if !defined(SYSLINK_BUILD_OPTIMIZE) if (userAddr == (UInt32) MAP_FAILED) { userAddr = (UInt32)NULL; GT_setFailureReason (curTrace, GT_4CLASS, "OsalDrv_map", OSALDRV_E_MAP, "Failed to map memory to user space!"); } #endif /* #if !defined(SYSLINK_BUILD_OPTIMIZE) */ } GT_1trace (curTrace, GT_LEAVE, "OsalDrv_map", userAddr); /*! @retval NULL Operation was successful. */ /*! @retval valid-address Operation successfully completed. */ return userAddr; }
/*! * @brief Function to close the OsalDrv driver. * * @sa OsalDrv_open */ Int OsalDrv_close (Void) { Int status = OSALDRV_SUCCESS; int osStatus = 0; GT_0trace (curTrace, GT_ENTER, "OsalDrv_close"); /* TBD: Protection for refCount. */ OsalDrv_refCount--; if (OsalDrv_refCount == 0) { osStatus = close (OsalDrv_handle); if (osStatus != 0) { perror ("OsalDrv driver close: " OSALDRV_DRIVER_NAME); /*! @retval OSALDRV_E_OSFAILURE Failed to open OsalDrv driver with OS */ status = OSALDRV_E_OSFAILURE; GT_setFailureReason (curTrace, GT_4CLASS, "OsalDrv_close", status, "Failed to close OsalDrv driver with OS!"); } else { OsalDrv_handle = 0; } } GT_1trace (curTrace, GT_LEAVE, "OsalDrv_close", status); /*! @retval OSALDRV_SUCCESS Operation successfully completed. */ return status; }
/*! * @brief Function to invoke the APIs through ioctl. * * @param cmd Command for driver ioctl * @param args Arguments for the ioctl command * * @sa */ Int ClientNotifyMgrDrv_ioctl (UInt32 cmd, Ptr args) { Int status = ClientNotifyMgr_S_SUCCESS; int osStatus = 0; GT_2trace (curTrace, GT_ENTER, "ClientNotifyMgrDrv_ioctl", cmd, args); GT_assert (curTrace, (ClientNotifyMgrDrv_refCount > 0)); osStatus = ioctl (ClientNotifyMgrDrv_handle, cmd, args); if (osStatus < 0) { /*! @retval ClientNotifyMgr_E_OSFAILURE Driver ioctl failed */ status = ClientNotifyMgr_E_OSFAILURE; GT_setFailureReason (curTrace, GT_4CLASS, "ClientNotifyMgrDrv_ioctl", status, "Driver ioctl failed"); } else { /* First field in the structure is the API status. */ status = ((ClientNotifyMgrDrv_CmdArgs *) args)->apiStatus; } GT_1trace (curTrace, GT_LEAVE, "ClientNotifyMgrDrv_ioctl", status); return (status); }
/*! * @brief Acquire/lock the Mutex object. * * This function acquires the critical section identified by this * mutex handle. Once this function is successfully entered, * further calls to OsalMutex_enter shall block till the critical * section has been released by the caller. * * @param mutexHandle Mutex object handle to be acquired. * * @sa OsalMutex_leave */ IArg OsalMutex_enter (OsalMutex_Handle mutexHandle) { IArg retVal = 0; OsalMutex_Object * mutexObj = (OsalMutex_Object*) mutexHandle; Int ret = 0; GT_1trace (curTrace, GT_ENTER, "OsalMutex_enter", mutexHandle); GT_assert (curTrace, (mutexHandle != NULL)); #if !defined(SYSLINK_BUILD_OPTIMIZE) if (mutexHandle == NULL) { /* Function does not return status. */ GT_setFailureReason (curTrace, GT_4CLASS, "OsalMutex_enter", OSALMUTEX_E_HANDLE, "NULL Mutex handle provided."); } else { #endif /* #if !defined(SYSLINK_BUILD_OPTIMIZE) */ ret = pthread_mutex_lock (&(mutexObj->lock)); GT_assert (curTrace, (ret == 0)); #if !defined(SYSLINK_BUILD_OPTIMIZE) } #endif /* #if !defined(SYSLINK_BUILD_OPTIMIZE) */ GT_1trace (curTrace, GT_LEAVE, "OsalMutex_enter", retVal); /*! @retval 0 Operation successfully completed. */ return retVal; }
/*! * @brief Function to finalize the HAL object * * @param halObj Pointer to the HAL object * * @sa OMAPL1XX_halInit * OMAPL1XX_phyShmemExit */ Int OMAPL1XX_halExit (Ptr halObj) { Int status = PROCESSOR_SUCCESS; OMAPL1XX_HalObject * halObject = NULL; GT_1trace (curTrace, GT_ENTER, "OMAPL1XX_halExit", halObj); GT_assert (curTrace, (halObj != NULL)); halObject = (OMAPL1XX_HalObject *) halObj ; status = OMAPL1XX_phyShmemExit (halObj); #if !defined(SYSLINK_BUILD_OPTIMIZE) if (status < 0) { GT_setFailureReason (curTrace, GT_4CLASS, "OMAPL1XX_halExit", status, "OMAPL1XX_phyShmemExit failed!"); } #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */ if (halObj != NULL) { /* Free the memory for the HAL object. */ Memory_free (NULL, halObj, sizeof (OMAPL1XX_HalObject)); } GT_1trace (curTrace, GT_LEAVE, "OMAPL1XX_halExit", status); /*! @retval PROCESSOR_SUCCESS Operation successful */ return status; }
/*! * @brief Function to close the Ipc driver. * * @sa IpcDrv_open */ Int IpcDrv_close (Void) { Int status = Ipc_S_SUCCESS; int osStatus = 0; GT_0trace (curTrace, GT_ENTER, "IpcDrv_close"); /* TBD: Protection for refCount. */ IpcDrv_refCount--; if (IpcDrv_refCount == 0) { osStatus = close (IpcDrv_handle); if (osStatus != 0) { perror ("Ipc driver close: "); /*! @retval Ipc_E_OSFAILURE Failed to open Ipc driver with OS */ status = Ipc_E_OSFAILURE; GT_setFailureReason (curTrace, GT_4CLASS, "IpcDrv_close", status, "Failed to close Ipc driver with OS!"); } else { IpcDrv_handle = 0; } } GT_1trace (curTrace, GT_LEAVE, "IpcDrv_close", status); return status; }
/*! * @brief Function to control reset operations * * @param halObj Pointer to the HAL object * @param cmd Reset control command * @param arg Arguments specific to the reset control command * * @sa */ Int DM8168VIDEOM3_halResetCtrl(Ptr halObj, Processor_ResetCtrlCmd cmd, Ptr args) { Int status = PROCESSOR_SUCCESS; DM8168VIDEOM3_HalObject * halObject = NULL; GT_3trace(curTrace, GT_ENTER, "DM8168VIDEOM3_halResetCtrl", halObj, cmd, args); GT_assert(curTrace, (halObj != NULL)); GT_assert(curTrace, (cmd < Processor_ResetCtrlCmd_EndValue)); halObject = (DM8168VIDEOM3_HalObject *) halObj ; switch (cmd) { case Processor_ResetCtrlCmd_Reset: { /*Put ONLY Ducati M3_0 to Reset*/ SET_BIT (REG((halObject->prcmBase) + RM_DEFAULT_RSTCTRL), 0x2); /* clear the status bit only if it is set*/ if(TEST_BIT(REG((halObject->prcmBase) + RM_DEFAULT_RSTST) , 0x2)) { REG((halObject->prcmBase) + RM_DEFAULT_RSTST) = 0x4; } } break; case Processor_ResetCtrlCmd_Release: { /*Bring ONLY Ducati M3_0 out of Reset*/ CLEAR_BIT (REG((halObject->prcmBase) + RM_DEFAULT_RSTCTRL), 0x2); /*Check for Ducati M3_0 out of Reset*/ while((((REG(halObject->prcmBase + RM_DEFAULT_RSTST)&0x04))!=0x04) && (((REG(halObject->prcmBase + RM_DEFAULT_RSTST)&0x14))!=0x14) && (((REG(halObject->prcmBase + RM_DEFAULT_RSTST)&0x1C))!=0x1C)) ; /*Check Module is in Functional Mode */ while(((REG(halObject->prcmBase + CM_DEFAULT_DUCATI_CLKCTRL)&0x30000)>>16)!=0) ; } break; case Processor_ResetCtrlCmd_PeripheralUp: { /* Nothing to be done to bringup the peripherals for this device. */ } break; default: { /*! @retval PROCESSOR_E_INVALIDARG Invalid argument */ status = PROCESSOR_E_INVALIDARG; GT_setFailureReason (curTrace, GT_4CLASS, "DM8168VIDEOM3_halResetCtrl", status, "Unsupported reset ctrl cmd specified"); } break; } GT_1trace(curTrace, GT_LEAVE, "DM8168VIDEOM3_halResetCtrl",status); /*! @retval PROCESSOR_SUCCESS Operation successful */ return status; }
/*! * @brief Function to invoke the APIs through ioctl. * * @param cmd Command for driver ioctl * @param args Arguments for the ioctl command * * @sa */ Int HeapMultiBufDrv_ioctl (UInt32 cmd, Ptr args) { //Int status = HEAPMULTIBUF_SUCCESS; Int status = 0; int osStatus = 0; #if 0 GT_2trace (curTrace, GT_ENTER, "HeapMultiBufDrv_ioctl", cmd, args); GT_assert (curTrace, (HeapMultiBufDrv_refCount > 0)); osStatus = ioctl (HeapMultiBufDrv_handle, cmd, args); if (osStatus < 0) { /*! @retval HEAPMULTIBUF_E_OSFAILURE Driver ioctl failed */ status = HEAPMULTIBUF_E_OSFAILURE; GT_setFailureReason (curTrace, GT_4CLASS, "HeapMultiBufDrv_ioctl", status, "Driver ioctl failed!"); } else { /* First field in the structure is the API status. */ status = ((HeapMultiBufDrv_CmdArgs *) args)->apiStatus; } #endif GT_1trace (curTrace, GT_LEAVE, "HeapMultiBufDrv_ioctl", status); /*! @retval HEAPMULTIBUF_SUCCESS Operation successfully completed. */ return status; }