📄 os_sem.txt
字号:
000228 e1a06002 MOV r6,r2
;;;245 #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
;;;246 OS_CPU_SR cpu_sr;
;;;247 #endif
;;;248
;;;249
;;;250 if (OSIntNesting > 0) { /* See if called from ISR ... */
00022c e59f01f0 LDR r0,|L1.1060|
000230 e5d00000 LDRB r0,[r0,#0] ; OSIntNesting
000234 e3500000 CMP r0,#0
000238 da000002 BLE |L1.584|
;;;251 *err = OS_ERR_PEND_ISR; /* ... can't PEND from an ISR */
00023c e3a00002 MOV r0,#2
000240 e5c60000 STRB r0,[r6,#0]
;;;252 return;
;;;253 }
;;;254 #if OS_ARG_CHK_EN > 0
;;;255 if (pevent == (OS_EVENT *)0) { /* Validate 'pevent' */
;;;256 *err = OS_ERR_PEVENT_NULL;
;;;257 return;
;;;258 }
;;;259 if (pevent->OSEventType != OS_EVENT_TYPE_SEM) { /* Validate event block type */
;;;260 *err = OS_ERR_EVENT_TYPE;
;;;261 return;
;;;262 }
;;;263 #endif
;;;264 OS_ENTER_CRITICAL();
;;;265 if (pevent->OSEventCnt > 0) { /* If sem. is positive, resource available ... */
;;;266 pevent->OSEventCnt--; /* ... decrement semaphore only if positive. */
;;;267 OS_EXIT_CRITICAL();
;;;268 *err = OS_NO_ERR;
;;;269 return;
;;;270 }
;;;271 /* Otherwise, must wait until event occurs */
;;;272 OSTCBCur->OSTCBStat |= OS_STAT_SEM; /* Resource not available, pend on semaphore */
;;;273 OSTCBCur->OSTCBDly = timeout; /* Store pend timeout in TCB */
;;;274 OS_EventTaskWait(pevent); /* Suspend task until event or timeout occurs */
;;;275 OS_EXIT_CRITICAL();
;;;276 OS_Sched(); /* Find next highest priority task ready */
;;;277 OS_ENTER_CRITICAL();
;;;278 if (OSTCBCur->OSTCBStat & OS_STAT_SEM) { /* Must have timed out if still waiting for event*/
;;;279 OS_EventTO(pevent);
;;;280 OS_EXIT_CRITICAL();
;;;281 *err = OS_TIMEOUT; /* Indicate that didn't get event within TO */
;;;282 return;
;;;283 }
;;;284 OSTCBCur->OSTCBEventPtr = (OS_EVENT *)0;
;;;285 OS_EXIT_CRITICAL();
;;;286 *err = OS_NO_ERR;
;;;287 }
|L1.580|
000244 e8bd8070 POP {r4-r6,pc}
|L1.584|
000248 e3540000 CMP r4,#0 ;255
00024c 1a000002 BNE |L1.604| ;255
000250 e3a00004 MOV r0,#4 ;256
000254 e5c60000 STRB r0,[r6,#0] ;256
000258 eafffff9 B |L1.580| ;257
|L1.604|
00025c e5d40000 LDRB r0,[r4,#0] ;259
000260 e3500003 CMP r0,#3 ;259
000264 0a000002 BEQ |L1.628| ;259
000268 e3a00001 MOV r0,#1 ;260
00026c e5c60000 STRB r0,[r6,#0] ;260
000270 eafffff3 B |L1.580| ;261
|L1.628|
000274 ef000002 SVC 0x2 ; formerly SWI ;264
000278 e1d400b2 LDRH r0,[r4,#2] ;265
00027c e3500000 CMP r0,#0 ;265
000280 da000006 BLE |L1.672| ;265
000284 e1d400b2 LDRH r0,[r4,#2] ;266
000288 e2400001 SUB r0,r0,#1 ;266
00028c e1c400b2 STRH r0,[r4,#2] ;266
000290 ef000003 SVC 0x3 ; formerly SWI ;267
000294 e3a00000 MOV r0,#0 ;268
000298 e5c60000 STRB r0,[r6,#0] ;268
00029c eaffffe8 B |L1.580| ;269
|L1.672|
0002a0 e59f0184 LDR r0,|L1.1068| ;272
0002a4 e5900000 LDR r0,[r0,#0] ;272 ; OSTCBCur
0002a8 e5d0001c LDRB r0,[r0,#0x1c] ;272
0002ac e3800001 ORR r0,r0,#1 ;272
0002b0 e59f1174 LDR r1,|L1.1068| ;272
0002b4 e5911000 LDR r1,[r1,#0] ;272 ; OSTCBCur
0002b8 e5c1001c STRB r0,[r1,#0x1c] ;272
0002bc e59f0168 LDR r0,|L1.1068| ;273
0002c0 e5900000 LDR r0,[r0,#0] ;273 ; OSTCBCur
0002c4 e1c051ba STRH r5,[r0,#0x1a] ;273
0002c8 e1a00004 MOV r0,r4 ;274
0002cc ebfffffe BL OS_EventTaskWait ;274
0002d0 ef000003 SVC 0x3 ; formerly SWI ;275
0002d4 ebfffffe BL OS_Sched ;276
0002d8 ef000002 SVC 0x2 ; formerly SWI ;277
0002dc e59f0148 LDR r0,|L1.1068| ;278
0002e0 e5900000 LDR r0,[r0,#0] ;278 ; OSTCBCur
0002e4 e5d0001c LDRB r0,[r0,#0x1c] ;278
0002e8 e3100001 TST r0,#1 ;278
0002ec 0a000005 BEQ |L1.776| ;278
0002f0 e1a00004 MOV r0,r4 ;279
0002f4 ebfffffe BL OS_EventTO ;279
0002f8 ef000003 SVC 0x3 ; formerly SWI ;280
0002fc e3a0000a MOV r0,#0xa ;281
000300 e5c60000 STRB r0,[r6,#0] ;281
000304 eaffffce B |L1.580| ;282
|L1.776|
000308 e3a00000 MOV r0,#0 ;284
00030c e59f1118 LDR r1,|L1.1068| ;284
000310 e5911000 LDR r1,[r1,#0] ;284 ; OSTCBCur
000314 e581000c STR r0,[r1,#0xc] ;284
000318 ef000003 SVC 0x3 ; formerly SWI ;285
00031c e3a00000 MOV r0,#0 ;286
000320 e5c60000 STRB r0,[r6,#0] ;286
000324 eaffffc6 B |L1.580|
ENDP
OSSemPost PROC
;;;307 INT8U OSSemPost (OS_EVENT *pevent)
;;;308 {
000328 e92d4010 PUSH {r4,lr}
00032c e1a04000 MOV r4,r0
;;;309 #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
;;;310 OS_CPU_SR cpu_sr;
;;;311 #endif
;;;312
;;;313
;;;314 #if OS_ARG_CHK_EN > 0
;;;315 if (pevent == (OS_EVENT *)0) { /* Validate 'pevent' */
000330 e3540000 CMP r4,#0
000334 1a000001 BNE |L1.832|
;;;316 return (OS_ERR_PEVENT_NULL);
000338 e3a00004 MOV r0,#4
;;;317 }
;;;318 if (pevent->OSEventType != OS_EVENT_TYPE_SEM) { /* Validate event block type */
;;;319 return (OS_ERR_EVENT_TYPE);
;;;320 }
;;;321 #endif
;;;322 OS_ENTER_CRITICAL();
;;;323 if (pevent->OSEventGrp != 0x00) { /* See if any task waiting for semaphore */
;;;324 OS_EventTaskRdy(pevent, (void *)0, OS_STAT_SEM); /* Ready highest prio task waiting on event */
;;;325 OS_EXIT_CRITICAL();
;;;326 OS_Sched(); /* Find highest priority task ready to run */
;;;327 return (OS_NO_ERR);
;;;328 }
;;;329 if (pevent->OSEventCnt < 65535) { /* Make sure semaphore will not overflow */
;;;330 pevent->OSEventCnt++; /* Increment semaphore count to register event */
;;;331 OS_EXIT_CRITICAL();
;;;332 return (OS_NO_ERR);
;;;333 }
;;;334 OS_EXIT_CRITICAL(); /* Semaphore value has reached its maximum */
;;;335 return (OS_SEM_OVF);
;;;336 }
|L1.828|
00033c e8bd8010 POP {r4,pc}
|L1.832|
000340 e5d40000 LDRB r0,[r4,#0] ;318
000344 e3500003 CMP r0,#3 ;318
000348 0a000001 BEQ |L1.852| ;318
00034c e3a00001 MOV r0,#1 ;319
000350 eafffff9 B |L1.828| ;319
|L1.852|
000354 ef000002 SVC 0x2 ; formerly SWI ;322
000358 e5d40001 LDRB r0,[r4,#1] ;323
00035c e3500000 CMP r0,#0 ;323
000360 0a000007 BEQ |L1.900| ;323
000364 e3a02001 MOV r2,#1 ;324
000368 e3a01000 MOV r1,#0 ;324
00036c e1a00004 MOV r0,r4 ;324
000370 ebfffffe BL OS_EventTaskRdy ;324
000374 ef000003 SVC 0x3 ; formerly SWI ;325
000378 ebfffffe BL OS_Sched ;326
00037c e3a00000 MOV r0,#0 ;327
000380 eaffffed B |L1.828| ;327
|L1.900|
000384 e1d400b2 LDRH r0,[r4,#2] ;329
000388 e59f10a0 LDR r1,|L1.1072| ;329
00038c e1500001 CMP r0,r1 ;329
000390 aa000006 BGE |L1.944| ;329
000394 e1d400b2 LDRH r0,[r4,#2] ;330
000398 e2800001 ADD r0,r0,#1 ;330
00039c e3c00801 BIC r0,r0,#0x10000 ;330
0003a0 e1c400b2 STRH r0,[r4,#2] ;330
0003a4 ef000003 SVC 0x3 ; formerly SWI ;331
0003a8 e3a00000 MOV r0,#0 ;332
0003ac eaffffe2 B |L1.828| ;332
|L1.944|
0003b0 ef000003 SVC 0x3 ; formerly SWI ;334
0003b4 e3a00032 MOV r0,#0x32 ;335
0003b8 eaffffdf B |L1.828| ;335
ENDP
OSSemQuery PROC
;;;356 INT8U OSSemQuery (OS_EVENT *pevent, OS_SEM_DATA *pdata)
;;;357 {
0003bc e92d41f0 PUSH {r4-r8,lr}
0003c0 e1a04000 MOV r4,r0
0003c4 e1a05001 MOV r5,r1
;;;358 #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
;;;359 OS_CPU_SR cpu_sr;
;;;360 #endif
;;;361 INT8U *psrc;
;;;362 INT8U *pdest;
;;;363
;;;364
;;;365 #if OS_ARG_CHK_EN > 0
;;;366 if (pevent == (OS_EVENT *)0) { /* Validate 'pevent' */
0003c8 e3540000 CMP r4,#0
0003cc 1a000001 BNE |L1.984|
;;;367 return (OS_ERR_PEVENT_NULL);
0003d0 e3a00004 MOV r0,#4
;;;368 }
;;;369 if (pevent->OSEventType != OS_EVENT_TYPE_SEM) { /* Validate event block type */
;;;370 return (OS_ERR_EVENT_TYPE);
;;;371 }
;;;372 #endif
;;;373 OS_ENTER_CRITICAL();
;;;374 pdata->OSEventGrp = pevent->OSEventGrp; /* Copy message mailbox wait list */
;;;375 psrc = &pevent->OSEventTbl[0];
;;;376 pdest = &pdata->OSEventTbl[0];
;;;377 #if OS_EVENT_TBL_SIZE > 0
;;;378 *pdest++ = *psrc++;
;;;379 #endif
;;;380
;;;381 #if OS_EVENT_TBL_SIZE > 1
;;;382 *pdest++ = *psrc++;
;;;383 #endif
;;;384
;;;385 #if OS_EVENT_TBL_SIZE > 2
;;;386 *pdest++ = *psrc++;
;;;387 #endif
;;;388
;;;389 #if OS_EVENT_TBL_SIZE > 3
;;;390 *pdest++ = *psrc++;
;;;391 #endif
;;;392
;;;393 #if OS_EVENT_TBL_SIZE > 4
;;;394 *pdest++ = *psrc++;
;;;395 #endif
;;;396
;;;397 #if OS_EVENT_TBL_SIZE > 5
;;;398 *pdest++ = *psrc++;
;;;399 #endif
;;;400
;;;401 #if OS_EVENT_TBL_SIZE > 6
;;;402 *pdest++ = *psrc++;
;;;403 #endif
;;;404
;;;405 #if OS_EVENT_TBL_SIZE > 7
;;;406 *pdest = *psrc;
;;;407 #endif
;;;408 pdata->OSCnt = pevent->OSEventCnt; /* Get semaphore count */
;;;409 OS_EXIT_CRITICAL();
;;;410 return (OS_NO_ERR);
;;;411 }
|L1.980|
0003d4 e8bd81f0 POP {r4-r8,pc}
|L1.984|
0003d8 e5d40000 LDRB r0,[r4,#0] ;369
0003dc e3500003 CMP r0,#3 ;369
0003e0 0a000001 BEQ |L1.1004| ;369
0003e4 e3a00001 MOV r0,#1 ;370
0003e8 eafffff9 B |L1.980| ;370
|L1.1004|
0003ec ef000002 SVC 0x2 ; formerly SWI ;373
0003f0 e5d40001 LDRB r0,[r4,#1] ;374
0003f4 e5c50004 STRB r0,[r5,#4] ;374
0003f8 e2846008 ADD r6,r4,#8 ;375
0003fc e2857002 ADD r7,r5,#2 ;376
000400 e4d60001 LDRB r0,[r6],#1 ;378
000404 e4c70001 STRB r0,[r7],#1 ;378
000408 e4d60001 LDRB r0,[r6],#1 ;382
00040c e4c70001 STRB r0,[r7],#1 ;382
000410 e1d400b2 LDRH r0,[r4,#2] ;408
000414 e1c500b0 STRH r0,[r5,#0] ;408
000418 ef000003 SVC 0x3 ; formerly SWI ;409
00041c e3a00000 MOV r0,#0 ;410
000420 eaffffeb B |L1.980| ;410
|L1.1060|
000424 00000000 DCD OSIntNesting ;410
|L1.1064|
000428 00000000 DCD OSEventFreeList ;410
|L1.1068|
00042c 00000000 DCD OSTCBCur ;410
|L1.1072|
000430 0000ffff DCD 0x0000ffff ;410
ENDP
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -