📄 os_sem.txt
字号:
000204 e1a07001 MOV r7,r1
000208 e1a04002 MOV r4,r2
;;;246 #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
;;;247 OS_CPU_SR cpu_sr;
;;;248 #endif
;;;249
;;;250
;;;251 if (OSIntNesting > 0) { /* See if called from ISR ... */
00020c e59f01cc LDR r0,|L1.992|
000210 e5d00000 LDRB r0,[r0,#0] ; OSIntNesting
000214 e3500000 CMP r0,#0
000218 0a000003 BEQ |L1.556|
;;;252 *err = OS_ERR_PEND_ISR; /* ... can't PEND from an ISR */
00021c e3a00002 MOV r0,#2
000220 e5c40000 STRB r0,[r4,#0]
|L1.548|
;;;253 return;
;;;254 }
;;;255 #if OS_ARG_CHK_EN > 0
;;;256 if (pevent == (OS_EVENT *)0) { /* Validate 'pevent' */
;;;257 *err = OS_ERR_PEVENT_NULL;
;;;258 return;
;;;259 }
;;;260 if (pevent->OSEventType != OS_EVENT_TYPE_SEM) { /* Validate event block type */
;;;261 *err = OS_ERR_EVENT_TYPE;
;;;262 return;
;;;263 }
;;;264 #endif
;;;265 OS_ENTER_CRITICAL();
;;;266 if (pevent->OSEventCnt > 0) { /* If sem. is positive, resource available ... */
;;;267 pevent->OSEventCnt--; /* ... decrement semaphore only if positive. */
;;;268 OS_EXIT_CRITICAL();
;;;269 *err = OS_NO_ERR;
;;;270 return;
;;;271 }
;;;272 /* Otherwise, must wait until event occurs */
;;;273 OSTCBCur->OSTCBStat |= OS_STAT_SEM; /* Resource not available, pend on semaphore */
;;;274 OSTCBCur->OSTCBDly = timeout; /* Store pend timeout in TCB */
;;;275 OS_EventTaskWait(pevent); /* Suspend task until event or timeout occurs */
;;;276 OS_EXIT_CRITICAL();
;;;277 OS_Sched(); /* Find next highest priority task ready */
;;;278 OS_ENTER_CRITICAL();
;;;279 if (OSTCBCur->OSTCBStat & OS_STAT_SEM) { /* Must have timed out if still waiting for event*/
;;;280 OS_EventTO(pevent);
;;;281 OS_EXIT_CRITICAL();
;;;282 *err = OS_TIMEOUT; /* Indicate that didn't get event within TO */
;;;283 return;
;;;284 }
;;;285 OSTCBCur->OSTCBEventPtr = (OS_EVENT *)0;
;;;286 OS_EXIT_CRITICAL();
;;;287 *err = OS_NO_ERR;
;;;288 }
000224 e8bd41f0 POP {r4-r8,lr}
000228 e12fff1e BX lr
|L1.556|
00022c e3550000 CMP r5,#0 ;256
000230 1a000002 BNE |L1.576|
000234 e3a00004 MOV r0,#4 ;257
000238 e5c40000 STRB r0,[r4,#0] ;257
00023c eafffff8 B |L1.548|
|L1.576|
000240 e5d50000 LDRB r0,[r5,#0] ;260
000244 e3500003 CMP r0,#3 ;260
000248 0a000002 BEQ |L1.600|
00024c e3a00001 MOV r0,#1 ;261
000250 e5c40000 STRB r0,[r4,#0] ;261
000254 eafffff2 B |L1.548|
|L1.600|
000258 ef000002 SVC #0x2 ;265
00025c e1d500b2 LDRH r0,[r5,#2] ;266
000260 e3a06000 MOV r6,#0 ;266
000264 e3500000 CMP r0,#0 ;266
000268 0a000004 BEQ |L1.640|
00026c e2400001 SUB r0,r0,#1 ;267
000270 e1c500b2 STRH r0,[r5,#2] ;267
000274 ef000003 SVC #0x3 ;268
000278 e5c46000 STRB r6,[r4,#0] ;269
00027c eaffffe8 B |L1.548|
|L1.640|
000280 e59f8160 LDR r8,|L1.1000|
000284 e5980000 LDR r0,[r8,#0] ;273 ; OSTCBCur
000288 e5d0102c LDRB r1,[r0,#0x2c] ;273
00028c e3811001 ORR r1,r1,#1 ;273
000290 e5c0102c STRB r1,[r0,#0x2c] ;273
000294 e1c072ba STRH r7,[r0,#0x2a] ;274
000298 e1a00005 MOV r0,r5 ;275
00029c ebfffffe BL OS_EventTaskWait
0002a0 ef000003 SVC #0x3 ;276
0002a4 ebfffffe BL OS_Sched
0002a8 ef000002 SVC #0x2 ;278
0002ac e5980000 LDR r0,[r8,#0] ;279 ; OSTCBCur
0002b0 e5d0102c LDRB r1,[r0,#0x2c] ;279
0002b4 e3110001 TST r1,#1 ;279
0002b8 0a000005 BEQ |L1.724|
0002bc e1a00005 MOV r0,r5 ;280
0002c0 ebfffffe BL OS_EventTO
0002c4 ef000003 SVC #0x3 ;281
0002c8 e3a0000a MOV r0,#0xa ;282
0002cc e5c40000 STRB r0,[r4,#0] ;282
0002d0 eaffffd3 B |L1.548|
|L1.724|
0002d4 e580601c STR r6,[r0,#0x1c] ;285
0002d8 ef000003 SVC #0x3 ;286
0002dc e5c46000 STRB r6,[r4,#0] ;287
0002e0 eaffffcf B |L1.548|
;;;289 /*$PAGE*/
ENDP
OSSemPost PROC
;;;308 INT8U OSSemPost (OS_EVENT *pevent)
;;;309 {
0002e4 e92d4010 PUSH {r4,lr}
0002e8 e1a04000 MOV r4,r0
;;;310 #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
;;;311 OS_CPU_SR cpu_sr;
;;;312 #endif
;;;313
;;;314
;;;315 #if OS_ARG_CHK_EN > 0
;;;316 if (pevent == (OS_EVENT *)0) { /* Validate 'pevent' */
0002ec e3540000 CMP r4,#0
0002f0 1a000002 BNE |L1.768|
;;;317 return (OS_ERR_PEVENT_NULL);
0002f4 e3a00004 MOV r0,#4
|L1.760|
0002f8 e8bd4010 POP {r4,lr}
;;;318 }
;;;319 if (pevent->OSEventType != OS_EVENT_TYPE_SEM) { /* Validate event block type */
;;;320 return (OS_ERR_EVENT_TYPE);
;;;321 }
;;;322 #endif
;;;323 OS_ENTER_CRITICAL();
;;;324 if (pevent->OSEventGrp != 0x00) { /* See if any task waiting for semaphore */
;;;325 OS_EventTaskRdy(pevent, (void *)0, OS_STAT_SEM); /* Ready highest prio task waiting on event */
;;;326 OS_EXIT_CRITICAL();
;;;327 OS_Sched(); /* Find highest priority task ready to run */
;;;328 return (OS_NO_ERR);
;;;329 }
;;;330 if (pevent->OSEventCnt < 65535) { /* Make sure semaphore will not overflow */
;;;331 pevent->OSEventCnt++; /* Increment semaphore count to register event */
;;;332 OS_EXIT_CRITICAL();
;;;333 return (OS_NO_ERR);
;;;334 }
;;;335 OS_EXIT_CRITICAL(); /* Semaphore value has reached its maximum */
;;;336 return (OS_SEM_OVF);
;;;337 }
0002fc e12fff1e BX lr
|L1.768|
000300 e5d40000 LDRB r0,[r4,#0] ;319
000304 e3500003 CMP r0,#3 ;319
000308 0a000001 BEQ |L1.788|
00030c e3a00001 MOV r0,#1 ;320
000310 eafffff8 B |L1.760|
|L1.788|
000314 ef000002 SVC #0x2 ;323
000318 e5d40001 LDRB r0,[r4,#1] ;324
00031c e3500000 CMP r0,#0 ;324
000320 0a000007 BEQ |L1.836|
000324 e3a02001 MOV r2,#1 ;325
000328 e3a01000 MOV r1,#0 ;325
00032c e1a00004 MOV r0,r4 ;325
000330 ebfffffe BL OS_EventTaskRdy
000334 ef000003 SVC #0x3 ;326
000338 ebfffffe BL OS_Sched
00033c e3a00000 MOV r0,#0 ;328
000340 eaffffec B |L1.760|
|L1.836|
000344 e1d400b2 LDRH r0,[r4,#2] ;330
000348 e59f109c LDR r1,|L1.1004|
00034c e1500001 CMP r0,r1 ;330
000350 2a000004 BCS |L1.872|
000354 e2800001 ADD r0,r0,#1 ;331
000358 e1c400b2 STRH r0,[r4,#2] ;331
00035c ef000003 SVC #0x3 ;332
000360 e3a00000 MOV r0,#0 ;333
000364 eaffffe3 B |L1.760|
|L1.872|
000368 ef000003 SVC #0x3 ;335
00036c e3a00032 MOV r0,#0x32 ;336
000370 eaffffe0 B |L1.760|
;;;338 /*$PAGE*/
ENDP
OSSemQuery PROC
;;;358 INT8U OSSemQuery (OS_EVENT *pevent, OS_SEM_DATA *pdata)
;;;359 {
000374 e92d4070 PUSH {r4-r6,lr}
000378 e1a04000 MOV r4,r0
00037c e1a05001 MOV r5,r1
;;;360 #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
;;;361 OS_CPU_SR cpu_sr;
;;;362 #endif
;;;363 INT8U *psrc;
;;;364 INT8U *pdest;
;;;365
;;;366
;;;367 #if OS_ARG_CHK_EN > 0
;;;368 if (pevent == (OS_EVENT *)0) { /* Validate 'pevent' */
000380 e3540000 CMP r4,#0
000384 1a000002 BNE |L1.916|
;;;369 return (OS_ERR_PEVENT_NULL);
000388 e3a00004 MOV r0,#4
|L1.908|
00038c e8bd4070 POP {r4-r6,lr}
;;;370 }
;;;371 if (pevent->OSEventType != OS_EVENT_TYPE_SEM) { /* Validate event block type */
;;;372 return (OS_ERR_EVENT_TYPE);
;;;373 }
;;;374 #endif
;;;375 OS_ENTER_CRITICAL();
;;;376 pdata->OSEventGrp = pevent->OSEventGrp; /* Copy message mailbox wait list */
;;;377 psrc = &pevent->OSEventTbl[0];
;;;378 pdest = &pdata->OSEventTbl[0];
;;;379 #if OS_EVENT_TBL_SIZE > 0
;;;380 *pdest++ = *psrc++;
;;;381 #endif
;;;382
;;;383 #if OS_EVENT_TBL_SIZE > 1
;;;384 *pdest++ = *psrc++;
;;;385 #endif
;;;386
;;;387 #if OS_EVENT_TBL_SIZE > 2
;;;388 *pdest++ = *psrc++;
;;;389 #endif
;;;390
;;;391 #if OS_EVENT_TBL_SIZE > 3
;;;392 *pdest++ = *psrc++;
;;;393 #endif
;;;394
;;;395 #if OS_EVENT_TBL_SIZE > 4
;;;396 *pdest++ = *psrc++;
;;;397 #endif
;;;398
;;;399 #if OS_EVENT_TBL_SIZE > 5
;;;400 *pdest++ = *psrc++;
;;;401 #endif
;;;402
;;;403 #if OS_EVENT_TBL_SIZE > 6
;;;404 *pdest++ = *psrc++;
;;;405 #endif
;;;406
;;;407 #if OS_EVENT_TBL_SIZE > 7
;;;408 *pdest = *psrc;
;;;409 #endif
;;;410 pdata->OSCnt = pevent->OSEventCnt; /* Get semaphore count */
;;;411 OS_EXIT_CRITICAL();
;;;412 return (OS_NO_ERR);
;;;413 }
000390 e12fff1e BX lr
|L1.916|
000394 e5d40000 LDRB r0,[r4,#0] ;371
000398 e3500003 CMP r0,#3 ;371
00039c 0a000001 BEQ |L1.936|
0003a0 e3a00001 MOV r0,#1 ;372
0003a4 eafffff8 B |L1.908|
|L1.936|
0003a8 ef000002 SVC #0x2 ;375
0003ac e5d40001 LDRB r0,[r4,#1] ;376
0003b0 e5c50004 STRB r0,[r5,#4] ;376
0003b4 e2841008 ADD r1,r4,#8 ;377
0003b8 e2850002 ADD r0,r5,#2 ;378
0003bc e5d12000 LDRB r2,[r1,#0] ;380
0003c0 e5c02000 STRB r2,[r0,#0] ;380
0003c4 e5d11001 LDRB r1,[r1,#1] ;384
0003c8 e5c01001 STRB r1,[r0,#1] ;384
0003cc e1d400b2 LDRH r0,[r4,#2] ;410
0003d0 e1c500b0 STRH r0,[r5,#0] ;410
0003d4 ef000003 SVC #0x3 ;411
0003d8 e3a00000 MOV r0,#0 ;412
0003dc eaffffea B |L1.908|
;;;414 #endif /* OS_SEM_QUERY_EN */
ENDP
|L1.992|
0003e0 00000000 DCD OSIntNesting
|L1.996|
0003e4 00000000 DCD OSEventFreeList
|L1.1000|
0003e8 00000000 DCD OSTCBCur
|L1.1004|
0003ec 0000ffff DCD 0x0000ffff
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -