⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 os_sem.lst

📁 称植到lpc2124上的UCOS2.85版 是本人初学移植和ARM的成果 可能已有人上传类似的了
💻 LST
📖 第 1 页 / 共 5 页
字号:
 127:../OSsrc/os_sem.c **** ***************************************************************************************************
 128:../OSsrc/os_sem.c **** *                                         DELETE A SEMAPHORE
 129:../OSsrc/os_sem.c **** *
 130:../OSsrc/os_sem.c **** * Description: This function deletes a semaphore and readies all tasks pending on the semaphore.
 131:../OSsrc/os_sem.c **** *
 132:../OSsrc/os_sem.c **** * Arguments  : pevent        is a pointer to the event control block associated with the desired
 133:../OSsrc/os_sem.c **** *                            semaphore.
 134:../OSsrc/os_sem.c **** *
 135:../OSsrc/os_sem.c **** *              opt           determines delete options as follows:
 136:../OSsrc/os_sem.c **** *                            opt == OS_DEL_NO_PEND   Delete semaphore ONLY if no task pending
 137:../OSsrc/os_sem.c **** *                            opt == OS_DEL_ALWAYS    Deletes the semaphore even if tasks are waitin
 138:../OSsrc/os_sem.c **** *                                                    In this case, all the tasks pending will be re
 139:../OSsrc/os_sem.c **** *
 140:../OSsrc/os_sem.c **** *              perr          is a pointer to an error code that can contain one of the following va
 141:../OSsrc/os_sem.c **** *                            OS_ERR_NONE             The call was successful and the semaphore was 
 142:../OSsrc/os_sem.c **** *                            OS_ERR_DEL_ISR          If you attempted to delete the semaphore from 
 143:../OSsrc/os_sem.c **** *                            OS_ERR_INVALID_OPT      An invalid option was specified
 144:../OSsrc/os_sem.c **** *                            OS_ERR_TASK_WAITING     One or more tasks were waiting on the semaphor
 145:../OSsrc/os_sem.c **** *                            OS_ERR_EVENT_TYPE       If you didn't pass a pointer to a semaphore
 146:../OSsrc/os_sem.c **** *                            OS_ERR_PEVENT_NULL      If 'pevent' is a NULL pointer.
 147:../OSsrc/os_sem.c **** *
 148:../OSsrc/os_sem.c **** * Returns    : pevent        upon error
 149:../OSsrc/os_sem.c **** *              (OS_EVENT *)0 if the semaphore was successfully deleted.
 150:../OSsrc/os_sem.c **** *
 151:../OSsrc/os_sem.c **** * Note(s)    : 1) This function must be used with care.  Tasks that would normally expect the prese
 152:../OSsrc/os_sem.c **** *                 the semaphore MUST check the return code of OSSemPend().
 153:../OSsrc/os_sem.c **** *              2) OSSemAccept() callers will not know that the intended semaphore has been deleted 
 154:../OSsrc/os_sem.c **** *                 they check 'pevent' to see that it's a NULL pointer.
 155:../OSsrc/os_sem.c **** *              3) This call can potentially disable interrupts for a long time.  The interrupt disa
 156:../OSsrc/os_sem.c **** *                 time is directly proportional to the number of tasks waiting on the semaphore.
 157:../OSsrc/os_sem.c **** *              4) Because ALL tasks pending on the semaphore will be readied, you MUST be careful i
 158:../OSsrc/os_sem.c **** *                 applications where the semaphore is used for mutual exclusion because the resourc
 159:../OSsrc/os_sem.c **** *                 will no longer be guarded by the semaphore.
 160:../OSsrc/os_sem.c **** ***************************************************************************************************
 161:../OSsrc/os_sem.c **** */
 162:../OSsrc/os_sem.c **** 
 163:../OSsrc/os_sem.c **** #if OS_SEM_DEL_EN > 0
 164:../OSsrc/os_sem.c **** OS_EVENT  *OSSemDel (OS_EVENT *pevent, INT8U opt, INT8U *perr)
 165:../OSsrc/os_sem.c **** {
 271               	.LM28:
 272               	/* prologue: frame size=0 */
 273 007e FF92      		push r15
 274 0080 0F93      		push r16
 275 0082 1F93      		push r17
 276 0084 CF93      		push r28
 277 0086 DF93      		push r29
 278               	/* prologue end (size=5) */
 279 0088 EC01      		movw r28,r24
 280 008a 8A01      		movw r16,r20
 166:../OSsrc/os_sem.c ****     BOOLEAN    tasks_waiting;
 167:../OSsrc/os_sem.c ****     OS_EVENT  *pevent_return;
 168:../OSsrc/os_sem.c **** #if OS_CRITICAL_METHOD == 3                                /* Allocate storage for CPU status regis
 169:../OSsrc/os_sem.c ****     OS_CPU_SR  cpu_sr = 0;
 170:../OSsrc/os_sem.c **** #endif
 171:../OSsrc/os_sem.c **** 
 172:../OSsrc/os_sem.c **** 
 173:../OSsrc/os_sem.c **** 
 174:../OSsrc/os_sem.c **** #if OS_ARG_CHK_EN > 0
 175:../OSsrc/os_sem.c ****     if (perr == (INT8U *)0) {                              /* Validate 'perr'                      
 282               	.LM29:
 283 008c 452B      		or r20,r21
 284 008e 09F4      		brne .+2
 285 0090 60C0      		rjmp .L29
 176:../OSsrc/os_sem.c ****         return (pevent);
 177:../OSsrc/os_sem.c ****     }
 178:../OSsrc/os_sem.c ****     if (pevent == (OS_EVENT *)0) {                         /* Validate 'pevent'                    
 287               	.LM30:
 288 0092 892B      		or r24,r25
 289 0094 11F4      		brne .L11
 179:../OSsrc/os_sem.c ****         *perr = OS_ERR_PEVENT_NULL;
 291               	.LM31:
 292 0096 84E0      		ldi r24,lo8(4)
 293 0098 5AC0      		rjmp .L28
 294               	.L11:
 180:../OSsrc/os_sem.c ****         return (pevent);
 181:../OSsrc/os_sem.c ****     }
 182:../OSsrc/os_sem.c **** #endif
 183:../OSsrc/os_sem.c ****     if (pevent->OSEventType != OS_EVENT_TYPE_SEM) {        /* Validate event block type            
 296               	.LM32:
 297 009a 8881      		ld r24,Y
 298 009c 8330      		cpi r24,lo8(3)
 299 009e 11F0      		breq .L12
 184:../OSsrc/os_sem.c ****         *perr = OS_ERR_EVENT_TYPE;
 301               	.LM33:
 302 00a0 81E0      		ldi r24,lo8(1)
 303 00a2 55C0      		rjmp .L28
 304               	.L12:
 185:../OSsrc/os_sem.c ****         return (pevent);
 186:../OSsrc/os_sem.c ****     }
 187:../OSsrc/os_sem.c ****     if (OSIntNesting > 0) {                                /* See if called from ISR ...           
 306               	.LM34:
 307 00a4 8091 0000 		lds r24,OSIntNesting
 308 00a8 8823      		tst r24
 309 00aa 11F0      		breq .L13
 188:../OSsrc/os_sem.c ****         *perr = OS_ERR_DEL_ISR;                             /* ... can't DELETE from an ISR        
 311               	.LM35:
 312 00ac 8FE0      		ldi r24,lo8(15)
 313 00ae 4FC0      		rjmp .L28
 314               	.L13:
 189:../OSsrc/os_sem.c ****         return (pevent);
 190:../OSsrc/os_sem.c ****     }
 191:../OSsrc/os_sem.c ****     OS_ENTER_CRITICAL();
 316               	.LM36:
 317               	/* #APP */
 318 00b0 F894      		cli
 192:../OSsrc/os_sem.c ****     if (pevent->OSEventGrp != 0) {                         /* See if any tasks waiting on semaphore
 320               	.LM37:
 321               	/* #NOAPP */
 322 00b2 8D81      		ldd r24,Y+5
 323 00b4 8823      		tst r24
 324 00b6 19F0      		breq .L14
 193:../OSsrc/os_sem.c ****         tasks_waiting = OS_TRUE;                           /* Yes                                  
 326               	.LM38:
 327 00b8 91E0      		ldi r25,lo8(1)
 328 00ba F92E      		mov r15,r25
 329 00bc 01C0      		rjmp .L15
 330               	.L14:
 194:../OSsrc/os_sem.c ****     } else {
 195:../OSsrc/os_sem.c ****         tasks_waiting = OS_FALSE;                          /* No                                   
 332               	.LM39:
 333 00be F82E      		mov r15,r24
 334               	.L15:
 196:../OSsrc/os_sem.c ****     }
 197:../OSsrc/os_sem.c ****     switch (opt) {
 336               	.LM40:
 337 00c0 7727      		clr r23
 338 00c2 6115      		cp r22,__zero_reg__
 339 00c4 7105      		cpc r23,__zero_reg__
 340 00c6 21F0      		breq .L17
 341 00c8 6130      		cpi r22,1
 342 00ca 7105      		cpc r23,__zero_reg__
 343 00cc C1F0      		breq .L20
 344 00ce 3DC0      		rjmp .L25
 345               	.L17:
 198:../OSsrc/os_sem.c ****         case OS_DEL_NO_PEND:                               /* Delete semaphore only if no task wait
 199:../OSsrc/os_sem.c ****              if (tasks_waiting == OS_FALSE) {
 347               	.LM41:
 348 00d0 FF20      		tst r15
 349 00d2 91F4      		brne .L18
 200:../OSsrc/os_sem.c **** #if OS_EVENT_NAME_SIZE > 1
 201:../OSsrc/os_sem.c ****                  pevent->OSEventName[0] = '?';             /* Unknown name                         
 351               	.LM42:
 352 00d4 8FE3      		ldi r24,lo8(63)
 353 00d6 8E87      		std Y+14,r24
 202:../OSsrc/os_sem.c ****                  pevent->OSEventName[1] = OS_ASCII_NUL;
 355               	.LM43:
 356 00d8 FF86      		std Y+15,r15
 203:../OSsrc/os_sem.c **** #endif
 204:../OSsrc/os_sem.c ****                  pevent->OSEventType    = OS_EVENT_TYPE_UNUSED;
 358               	.LM44:
 359 00da F882      		st Y,r15
 205:../OSsrc/os_sem.c ****                  pevent->OSEventPtr     = OSEventFreeList; /* Return Event Control Block to free li
 361               	.LM45:
 362 00dc 8091 0000 		lds r24,OSEventFreeList
 363 00e0 9091 0000 		lds r25,(OSEventFreeList)+1
 364 00e4 9A83      		std Y+2,r25
 365 00e6 8983      		std Y+1,r24
 206:../OSsrc/os_sem.c ****                  pevent->OSEventCnt     = 0;
 367               	.LM46:
 368 00e8 7C83      		std Y+4,r23
 369 00ea 6B83      		std Y+3,r22
 207:../OSsrc/os_sem.c ****                  OSEventFreeList        = pevent;          /* Get next free event control block    
 371               	.LM47:
 372 00ec D093 0000 		sts (OSEventFreeList)+1,r29
 373 00f0 C093 0000 		sts OSEventFreeList,r28
 208:../OSsrc/os_sem.c ****                  OS_EXIT_CRITICAL();
 375               	.LM48:
 376               	/* #APP */
 377 00f4 7894      		sei
 378               	/* #NOAPP */
 379 00f6 24C0      		rjmp .L24
 380               	.L18:
 209:../OSsrc/os_sem.c ****                  *perr                  = OS_ERR_NONE;
 210:../OSsrc/os_sem.c ****                  pevent_return          = (OS_EVENT *)0;   /* Semaphore has been deleted           
 211:../OSsrc/os_sem.c ****              } else {
 212:../OSsrc/os_sem.c ****                  OS_EXIT_CRITICAL();
 382               	.LM49:
 383               	/* #APP */
 384 00f8 7894      		sei
 213:../OSsrc/os_sem.c ****                  *perr                  = OS_ERR_TASK_WAITING;
 386               	.LM50:
 387               	/* #NOAPP */
 388 00fa 89E4      		ldi r24,lo8(73)
 389 00fc 28C0      		rjmp .L28
 390               	.L20:
 214:../OSsrc/os_sem.c ****                  pevent_return          = pevent;
 215:../OSsrc/os_sem.c ****              }
 216:../OSsrc/os_sem.c ****              break;
 217:../OSsrc/os_sem.c **** 
 218:../OSsrc/os_sem.c ****         case OS_DEL_ALWAYS:                                /* Always delete the semaphore          
 219:../OSsrc/os_sem.c ****              while (pevent->OSEventGrp != 0) {             /* Ready ALL tasks waiting for semaphore
 220:../OSsrc/os_sem.c ****                  (void)OS_EventTaskRdy(pevent, (void *)0, OS_STAT_SEM, OS_STAT_PEND_OK);
 392               	.LM51:
 393 00fe 8823      		tst r24
 394 0100 49F0      		breq .L27
 395 0102 20E0      		ldi r18,lo8(0)
 396 0104 41E0      		ldi r20,lo8(1)
 397 0106 60E0      		ldi r22,lo8(0)
 398 0108 70E0      		ldi r23,hi8(0)
 399 010a CE01      		movw r24,r28
 400 010c 0E94 0000 		call OS_EventTaskRdy
 401 0110 8D81      		ldd r24,Y+5
 402 0112 F5CF      		rjmp .L20
 403               	.L27:
 221:../OSsrc/os_sem.c ****              }
 222:../OSsrc/os_sem.c **** #if OS_EVENT_NAME_SIZE > 1
 223:../OSsrc/os_sem.c ****              pevent->OSEventName[0] = '?';                 /* Unknown name                         
 405               	.LM52:
 406 0114 8FE3      		ldi r24,lo8(63)
 407 0116 8E87      		std Y+14,r24
 224:../OSsrc/os_sem.c ****              pevent->OSEventName[1] = OS_ASCII_NUL;
 409               	.LM53:
 410 0118 1F86      		std Y+15,__zero_reg__
 225:../OSsrc/os_sem.c **** #endif
 226:../OSsrc/os_sem.c ****              pevent->OSEventType    = OS_EVENT_TYPE_UNUSED;
 412               	.LM54:
 413 011a 1882      		st Y,__zero_reg__
 227:../OSsrc/os_sem.c ****              pevent->OSEventPtr     = OSEventFreeList;     /* Return Event Control Block to free li
 415               	.LM55:
 416 011c 8091 0000 		lds r24,OSEventFreeList
 417 0120 9091 0000 		lds r25,(OSEventFreeList)+1
 418 0124 9A83      		std Y+2,r25
 419 0126 8983      		std Y+1,r24
 228:../OSsrc/os_sem.c ****              pevent->OSEventCnt     = 0;
 421               	.LM56:
 422 0128 1C82      		std Y+4,__zero_reg__
 423 012a 1B82      		std Y+3,__zero_reg__
 229:../OSsrc/os_sem.c ****              OSEventFreeList        = pevent;              /* Get next free event control block    
 425               	.LM57:
 426 012c D093 0000 		sts (OSEventFreeList)+1,r29
 427 0130 C093 0000 		sts OSEventFreeList,r28
 230:../OSsrc/os_sem.c ****              OS_EXIT_CRITICAL();
 429               	.LM58:
 430               	/* #APP */
 431 0134 7894      		sei
 231:../OSsrc/os_sem.c ****              if (tasks_waiting == OS_TRUE) {               /* Reschedule only if task(s) were waiti
 433               	.LM59:
 434               	/* #NOAPP */
 435 0136 F1E0      		ldi r31,lo8(1)
 436 0138 FF16      		cp r15,r31
 437 013a 11F4      		brne .L24
 232:../OSsrc/os_sem.c ****                  OS_Sched();                               /* Find highest priority task ready to r
 439               	.LM60:
 440 013c 0E94 0000 		call OS_Sched
 441               	.L24:
 233:../OSsrc/os_sem.c ****              }
 234:../OSsrc/os_sem.c ****              *perr                  = OS_ERR_NONE;
 443               	.LM61:
 444 0140 F801      		movw r30,r16
 445 0142 1082      		st Z,__zero_reg__
 235:../OSsrc/os_sem.c ****              pevent_return          = (OS_EVENT *)0;       /* Semaphore has been deleted           
 447               	.LM62:
 448 0144 80E0      		ldi r24,lo8(0)
 449 0146 90E0      		ldi r25,hi8(0)
 236:../OSsrc/os_sem.c ****              break;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -