os_sem.lis
来自「将本站的UCOSFORAVR128V276版本升级到了280版」· LIS 代码 · 共 1,276 行 · 第 1/5 页
LIS
1,276 行
00AC 8A01 movw R16,R20
00AE .dbline -2
00AE L6:
00AE 0E940000 xcall pop_gset3
00B2 .dbline 0 ; func end
00B2 0895 ret
00B4 .dbsym r cpu_sr 10 c
00B4 .dbsym r pevent 20 pS[os_event]
00B4 .dbsym r cnt 22 i
00B4 .dbend
00B4 .dbfunc e OSSemDel _OSSemDel fpS[os_event]
00B4 ; tasks_waiting -> R14
00B4 ; pevent_return -> R20,R21
00B4 ; cpu_sr -> R12
00B4 ; err -> R10,R11
00B4 ; opt -> R20
00B4 ; pevent -> R22,R23
.even
00B4 _OSSemDel::
00B4 0E940000 xcall push_gset5
00B8 422F mov R20,R18
00BA B801 movw R22,R16
00BC 2197 sbiw R28,1
00BE AB84 ldd R10,y+11
00C0 BC84 ldd R11,y+12
00C2 .dbline -1
00C2 .dbline 156
00C2 ; }
00C2 ;
00C2 ; /*$PAGE*/
00C2 ; /*
00C2 ; *********************************************************************************************************
00C2 ; * DELETE A SEMAPHORE
00C2 ; *
00C2 ; * Description: This function deletes a semaphore and readies all tasks pending on the semaphore.
00C2 ; *
00C2 ; * Arguments : pevent is a pointer to the event control block associated with the desired
00C2 ; * semaphore.
00C2 ; *
00C2 ; * opt determines delete options as follows:
00C2 ; * opt == OS_DEL_NO_PEND Delete semaphore ONLY if no task pending
00C2 ; * opt == OS_DEL_ALWAYS Deletes the semaphore even if tasks are waiting.
00C2 ; * In this case, all the tasks pending will be readied.
00C2 ; *
00C2 ; * err is a pointer to an error code that can contain one of the following values:
00C2 ; * OS_NO_ERR The call was successful and the semaphore was deleted
00C2 ; * OS_ERR_DEL_ISR If you attempted to delete the semaphore from an ISR
00C2 ; * OS_ERR_INVALID_OPT An invalid option was specified
00C2 ; * OS_ERR_TASK_WAITING One or more tasks were waiting on the semaphore
00C2 ; * OS_ERR_EVENT_TYPE If you didn't pass a pointer to a semaphore
00C2 ; * OS_ERR_PEVENT_NULL If 'pevent' is a NULL pointer.
00C2 ; *
00C2 ; * Returns : pevent upon error
00C2 ; * (OS_EVENT *)0 if the semaphore was successfully deleted.
00C2 ; *
00C2 ; * Note(s) : 1) This function must be used with care. Tasks that would normally expect the presence of
00C2 ; * the semaphore MUST check the return code of OSSemPend().
00C2 ; * 2) OSSemAccept() callers will not know that the intended semaphore has been deleted unless
00C2 ; * they check 'pevent' to see that it's a NULL pointer.
00C2 ; * 3) This call can potentially disable interrupts for a long time. The interrupt disable
00C2 ; * time is directly proportional to the number of tasks waiting on the semaphore.
00C2 ; * 4) Because ALL tasks pending on the semaphore will be readied, you MUST be careful in
00C2 ; * applications where the semaphore is used for mutual exclusion because the resource(s)
00C2 ; * will no longer be guarded by the semaphore.
00C2 ; *********************************************************************************************************
00C2 ; */
00C2 ;
00C2 ; #if OS_SEM_DEL_EN > 0
00C2 ; OS_EVENT *OSSemDel (OS_EVENT *pevent, INT8U opt, INT8U *err)
00C2 ; {
00C2 .dbline 160
00C2 ; BOOLEAN tasks_waiting;
00C2 ; OS_EVENT *pevent_return;
00C2 ; #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
00C2 ; OS_CPU_SR cpu_sr = 0;
00C2 CC24 clr R12
00C4 .dbline 174
00C4 ; #endif
00C4 ;
00C4 ;
00C4 ;
00C4 ; #if OS_ARG_CHK_EN > 0
00C4 ; if (err == (INT8U *)0) { /* Validate 'err' */
00C4 ; return (pevent);
00C4 ; }
00C4 ; if (pevent == (OS_EVENT *)0) { /* Validate 'pevent' */
00C4 ; *err = OS_ERR_PEVENT_NULL;
00C4 ; return (pevent);
00C4 ; }
00C4 ; #endif
00C4 ; if (pevent->OSEventType != OS_EVENT_TYPE_SEM) { /* Validate event block type */
00C4 FB01 movw R30,R22
00C6 8081 ldd R24,z+0
00C8 8330 cpi R24,3
00CA 29F0 breq L14
00CC .dbline 174
00CC .dbline 175
00CC ; *err = OS_ERR_EVENT_TYPE;
00CC 81E0 ldi R24,1
00CE F501 movw R30,R10
00D0 8083 std z+0,R24
00D2 .dbline 176
00D2 ; return (pevent);
00D2 8B01 movw R16,R22
00D4 77C0 xjmp L13
00D6 L14:
00D6 .dbline 178
00D6 ; }
00D6 ; if (OSIntNesting > 0) { /* See if called from ISR ... */
00D6 2224 clr R2
00D8 30900000 lds R3,_OSIntNesting
00DC 2314 cp R2,R3
00DE 28F4 brsh L16
00E0 .dbline 178
00E0 .dbline 179
00E0 ; *err = OS_ERR_DEL_ISR; /* ... can't DELETE from an ISR */
00E0 8CE8 ldi R24,140
00E2 F501 movw R30,R10
00E4 8083 std z+0,R24
00E6 .dbline 180
00E6 ; return (pevent);
00E6 8B01 movw R16,R22
00E8 6DC0 xjmp L13
00EA L16:
00EA .dbline 182
00EA ; }
00EA ; OS_ENTER_CRITICAL();
00EA 0E940000 xcall _OS_CPU_SR_Save
00EE C02E mov R12,R16
00F0 .dbline 183
00F0 ; if (pevent->OSEventGrp != 0) { /* See if any tasks waiting on semaphore */
00F0 FB01 movw R30,R22
00F2 2580 ldd R2,z+5
00F4 2220 tst R2
00F6 19F0 breq L18
00F8 .dbline 183
00F8 .dbline 184
00F8 ; tasks_waiting = TRUE; /* Yes */
00F8 EE24 clr R14
00FA E394 inc R14
00FC .dbline 185
00FC 01C0 xjmp L19
00FE L18:
00FE .dbline 185
00FE ; } else {
00FE .dbline 186
00FE ; tasks_waiting = FALSE; /* No */
00FE EE24 clr R14
0100 .dbline 187
0100 ; }
0100 L19:
0100 .dbline 188
0100 5527 clr R21
0102 4030 cpi R20,0
0104 4507 cpc R20,R21
0106 31F0 breq L23
0108 X3:
0108 4130 cpi R20,1
010A E0E0 ldi R30,0
010C 5E07 cpc R21,R30
010E 09F4 brne X5
0110 2DC0 xjmp L28
0112 X5:
0112 50C0 xjmp L20
0114 X4:
0114 .dbline 188
0114 ; switch (opt) {
0114 L23:
0114 .dbline 190
0114 ; case OS_DEL_NO_PEND: /* Delete semaphore only if no task waiting */
0114 ; if (tasks_waiting == FALSE) {
0114 EE20 tst R14
0116 D9F4 brne L24
0118 .dbline 190
0118 .dbline 195
0118 ; #if OS_EVENT_NAME_SIZE > 1
0118 ; pevent->OSEventName[0] = '?'; /* Unknown name */
0118 ; pevent->OSEventName[1] = OS_ASCII_NUL;
0118 ; #endif
0118 ; pevent->OSEventType = OS_EVENT_TYPE_UNUSED;
0118 2224 clr R2
011A FB01 movw R30,R22
011C 2082 std z+0,R2
011E .dbline 196
011E ; pevent->OSEventPtr = OSEventFreeList; /* Return Event Control Block to free list */
011E 20900000 lds R2,_OSEventFreeList
0122 30900100 lds R3,_OSEventFreeList+1
0126 3282 std z+2,R3
0128 2182 std z+1,R2
012A .dbline 197
012A ; pevent->OSEventCnt = 0;
012A 2224 clr R2
012C 3324 clr R3
012E FB01 movw R30,R22
0130 3482 std z+4,R3
0132 2382 std z+3,R2
0134 .dbline 198
0134 ; OSEventFreeList = pevent; /* Get next free event control block */
0134 70930100 sts _OSEventFreeList+1,R23
0138 60930000 sts _OSEventFreeList,R22
013C .dbline 199
013C ; OS_EXIT_CRITICAL();
013C 0C2D mov R16,R12
013E 0E940000 xcall _OS_CPU_SR_Restore
0142 .dbline 200
0142 ; *err = OS_NO_ERR;
0142 2224 clr R2
0144 F501 movw R30,R10
0146 2082 std z+0,R2
0148 .dbline 201
0148 ; pevent_return = (OS_EVENT *)0; /* Semaphore has been deleted */
0148 4427 clr R20
014A 5527 clr R21
014C .dbline 202
014C 3AC0 xjmp L21
014E L24:
014E .dbline 202
014E ; } else {
014E .dbline 203
014E ; OS_EXIT_CRITICAL();
014E 0C2D mov R16,R12
0150 0E940000 xcall _OS_CPU_SR_Restore
0154 .dbline 204
0154 ; *err = OS_ERR_TASK_WAITING;
0154 88E0 ldi R24,8
0156 F501 movw R30,R10
0158 8083 std z+0,R24
015A .dbline 205
015A ; pevent_return = pevent;
015A AB01 movw R20,R22
015C .dbline 206
015C ; }
015C .dbline 207
015C ; break;
015C 32C0 xjmp L21
015E L27:
015E .dbline 210
015E .dbline 211
015E 81E0 ldi R24,1
0160 8883 std y+0,R24
0162 2227 clr R18
0164 3327 clr R19
0166 8B01 movw R16,R22
0168 0E940000 xcall _OS_EventTaskRdy
016C .dbline 212
016C L28:
016C .dbline 210
016C ;
016C ; case OS_DEL_ALWAYS: /* Always delete the semaphore */
016C ; while (pevent->OSEventGrp != 0) { /* Ready ALL tasks waiting for semaphore */
016C FB01 movw R30,R22
016E 2580 ldd R2,z+5
0170 2220 tst R2
0172 A9F7 brne L27
0174 .dbline 217
0174 ; (void)OS_EventTaskRdy(pevent, (void *)0, OS_STAT_SEM);
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?