• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 ASR Microelectronics (Shanghai) Co., Ltd. All rights reserved.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "cmsis_os2.h"
17 #include "kal.h"
18 #include "los_event.h"
19 #include "los_membox.h"
20 #include "los_memory.h"
21 #include "los_interrupt.h"
22 #include "los_mux.h"
23 #include "los_queue.h"
24 #include "los_sem.h"
25 #include "los_swtmr.h"
26 #include "los_task.h"
27 #include "los_timer.h"
28 #include "los_debug.h"
29 #include "liteos_patch.h"
30 
LOS_SemPendingNoTask(UINT32 semHandle)31 UINT32 LOS_SemPendingNoTask(UINT32 semHandle)
32 {
33     UINT32 intSave, retVal;
34     LosSemCB *semOnCheck = GET_SEM(semHandle);
35 
36     if (semHandle >= LOSCFG_BASE_IPC_SEM_LIMIT) {
37         return LOS_ERRNO_SEM_INVALID;
38     }
39     intSave = LOS_IntLock();
40     if (LOS_ListEmpty(&semOnCheck->semList)) {
41         retVal = LOS_OK;
42     } else {
43         retVal = LOS_NOK;
44     }
45     LOS_IntRestore(intSave);
46     return retVal;
47 }
48 
osSemaphorePendingNoTask(osSemaphoreId_t semaphore_id)49 osStatus_t osSemaphorePendingNoTask(osSemaphoreId_t semaphore_id)
50 {
51     UINT32 uwRet;
52 
53     if (OS_INT_ACTIVE) {
54         return osErrorISR;
55     }
56 
57     if (semaphore_id == NULL) {
58         return osErrorParameter;
59     }
60 
61     uwRet = LOS_SemPendingNoTask(((LosSemCB *)semaphore_id)->semID);
62     if (uwRet == LOS_OK) {
63         return osOK;
64     } else {
65         return osError;
66     }
67 }