os_sem.lst

来自「atmega单片机用的ucos系统 占用内存适中 是atmega单片机合适的操作」· LST 代码 · 共 1,188 行 · 第 1/4 页

LST
1,188
字号
   1               		.file	"os_sem.c"
   2               		.arch atmega128
   3               	__SREG__ = 0x3f
   4               	__SP_H__ = 0x3e
   5               	__SP_L__ = 0x3d
   6               	__tmp_reg__ = 0
   7               	__zero_reg__ = 1
   8               		.global __do_copy_data
   9               		.global __do_clear_bss
  11               		.text
  12               	.Ltext0:
  85               	.global	OSSemAccept
  87               	OSSemAccept:
   1:OSsrc/os_sem.c **** /*
   2:OSsrc/os_sem.c **** ***************************************************************************************************
   3:OSsrc/os_sem.c **** *                                                uC/OS-II
   4:OSsrc/os_sem.c **** *                                          The Real-Time Kernel
   5:OSsrc/os_sem.c **** *                                          SEMAPHORE MANAGEMENT
   6:OSsrc/os_sem.c **** *
   7:OSsrc/os_sem.c **** *                          (c) Copyright 1992-2003, Jean J. Labrosse, Weston, FL
   8:OSsrc/os_sem.c **** *                                           All Rights Reserved
   9:OSsrc/os_sem.c **** *
  10:OSsrc/os_sem.c **** * File    : OS_SEM.C
  11:OSsrc/os_sem.c **** * By      : Jean J. Labrosse
  12:OSsrc/os_sem.c **** * Version : V2.76
  13:OSsrc/os_sem.c **** ***************************************************************************************************
  14:OSsrc/os_sem.c **** */
  15:OSsrc/os_sem.c **** 
  16:OSsrc/os_sem.c **** #ifndef  OS_MASTER_FILE
  17:OSsrc/os_sem.c **** #include "ucos_ii.h"
  18:OSsrc/os_sem.c **** #endif
  19:OSsrc/os_sem.c **** 
  20:OSsrc/os_sem.c **** #if OS_SEM_EN > 0
  21:OSsrc/os_sem.c **** /*
  22:OSsrc/os_sem.c **** ***************************************************************************************************
  23:OSsrc/os_sem.c **** *                                           ACCEPT SEMAPHORE
  24:OSsrc/os_sem.c **** *
  25:OSsrc/os_sem.c **** * Description: This function checks the semaphore to see if a resource is available or, if an event
  26:OSsrc/os_sem.c **** *              occurred.  Unlike OSSemPend(), OSSemAccept() does not suspend the calling task if th
  27:OSsrc/os_sem.c **** *              resource is not available or the event did not occur.
  28:OSsrc/os_sem.c **** *
  29:OSsrc/os_sem.c **** * Arguments  : pevent     is a pointer to the event control block
  30:OSsrc/os_sem.c **** *
  31:OSsrc/os_sem.c **** * Returns    : >  0       if the resource is available or the event did not occur the semaphore is
  32:OSsrc/os_sem.c **** *                         decremented to obtain the resource.
  33:OSsrc/os_sem.c **** *              == 0       if the resource is not available or the event did not occur or,
  34:OSsrc/os_sem.c **** *                         if 'pevent' is a NULL pointer or,
  35:OSsrc/os_sem.c **** *                         if you didn't pass a pointer to a semaphore
  36:OSsrc/os_sem.c **** ***************************************************************************************************
  37:OSsrc/os_sem.c **** */
  38:OSsrc/os_sem.c **** 
  39:OSsrc/os_sem.c **** #if OS_SEM_ACCEPT_EN > 0
  40:OSsrc/os_sem.c **** INT16U  OSSemAccept (OS_EVENT *pevent)
  41:OSsrc/os_sem.c **** {
  89               	.LM1:
  90               	/* prologue: frame size=0 */
  91               	/* prologue end (size=0) */
  92 0000 FC01      		movw r30,r24
  42:OSsrc/os_sem.c ****     INT16U     cnt;
  43:OSsrc/os_sem.c **** #if OS_CRITICAL_METHOD == 3                           /* Allocate storage for CPU status register  
  44:OSsrc/os_sem.c ****     OS_CPU_SR  cpu_sr;
  45:OSsrc/os_sem.c **** 
  46:OSsrc/os_sem.c **** 
  47:OSsrc/os_sem.c **** 
  48:OSsrc/os_sem.c ****     cpu_sr = 0;                                       /* Prevent compiler warning                  
  49:OSsrc/os_sem.c **** #endif    
  50:OSsrc/os_sem.c **** #if OS_ARG_CHK_EN > 0
  51:OSsrc/os_sem.c ****     if (pevent == (OS_EVENT *)0) {                    /* Validate 'pevent'                         
  94               	.LM2:
  95 0002 0097      		sbiw r24,0
  96 0004 09F4      		brne .L2
  52:OSsrc/os_sem.c ****         return (0);
  98               	.LM3:
  99 0006 0895      		ret
 100               	.L2:
  53:OSsrc/os_sem.c ****     }
  54:OSsrc/os_sem.c **** #endif
  55:OSsrc/os_sem.c ****     if (pevent->OSEventType != OS_EVENT_TYPE_SEM) {   /* Validate event block type                 
 102               	.LM4:
 103 0008 8081      		ld r24,Z
 104 000a 8330      		cpi r24,lo8(3)
 105 000c 19F0      		breq .L3
  56:OSsrc/os_sem.c ****         return (0);
 107               	.LM5:
 108 000e 80E0      		ldi r24,lo8(0)
 109 0010 90E0      		ldi r25,hi8(0)
 110 0012 0895      		ret
 111               	.L3:
  57:OSsrc/os_sem.c ****     }
  58:OSsrc/os_sem.c ****     OS_ENTER_CRITICAL();
 113               	.LM6:
 114               	/* #APP */
 115 0014 0FB6      		in __tmp_reg__,__SREG__
 116 0016 F894      		cli
 117 0018 0F92      		push __tmp_reg__
  59:OSsrc/os_sem.c ****     cnt = pevent->OSEventCnt;
 119               	.LM7:
 120               	/* #NOAPP */
 121 001a 8281      		ldd r24,Z+2
 122 001c 9381      		ldd r25,Z+3
  60:OSsrc/os_sem.c ****     if (cnt > 0) {                                    /* See if resource is available              
 124               	.LM8:
 125 001e 0097      		sbiw r24,0
 126 0020 21F0      		breq .L4
  61:OSsrc/os_sem.c ****         pevent->OSEventCnt--;                         /* Yes, decrement semaphore and notify caller
 128               	.LM9:
 129 0022 0197      		sbiw r24,1
 130 0024 8283      		std Z+2,r24
 131 0026 9383      		std Z+3,r25
 132 0028 0196      		adiw r24,1
 133               	.L4:
  62:OSsrc/os_sem.c ****     }
  63:OSsrc/os_sem.c ****     OS_EXIT_CRITICAL();
 135               	.LM10:
 136               	/* #APP */
 137 002a 0F90      		pop __tmp_reg__
 138 002c 0FBE      		out __SREG__,__tmp_reg__
  64:OSsrc/os_sem.c ****     return (cnt);                                     /* Return semaphore count                    
  65:OSsrc/os_sem.c **** }
 140               	.LM11:
 141               	/* #NOAPP */
 142 002e 0895      		ret
 143               	/* epilogue: frame size=0 */
 144 0030 0895      		ret
 145               	/* epilogue end (size=1) */
 146               	/* function OSSemAccept size 30 (29) */
 151               	.Lscope0:
 154               	.global	OSSemCreate
 156               	OSSemCreate:
  66:OSsrc/os_sem.c **** #endif    
  67:OSsrc/os_sem.c **** 
  68:OSsrc/os_sem.c **** /*$PAGE*/
  69:OSsrc/os_sem.c **** /*
  70:OSsrc/os_sem.c **** ***************************************************************************************************
  71:OSsrc/os_sem.c **** *                                           CREATE A SEMAPHORE
  72:OSsrc/os_sem.c **** *
  73:OSsrc/os_sem.c **** * Description: This function creates a semaphore.
  74:OSsrc/os_sem.c **** *
  75:OSsrc/os_sem.c **** * Arguments  : cnt           is the initial value for the semaphore.  If the value is 0, no resourc
  76:OSsrc/os_sem.c **** *                            available (or no event has occurred).  You initialize the semaphore to
  77:OSsrc/os_sem.c **** *                            non-zero value to specify how many resources are available (e.g. if yo
  78:OSsrc/os_sem.c **** *                            10 resources, you would initialize the semaphore to 10).
  79:OSsrc/os_sem.c **** *
  80:OSsrc/os_sem.c **** * Returns    : != (void *)0  is a pointer to the event control clock (OS_EVENT) associated with the
  81:OSsrc/os_sem.c **** *                            created semaphore
  82:OSsrc/os_sem.c **** *              == (void *)0  if no event control blocks were available
  83:OSsrc/os_sem.c **** ***************************************************************************************************
  84:OSsrc/os_sem.c **** */
  85:OSsrc/os_sem.c **** 
  86:OSsrc/os_sem.c **** OS_EVENT  *OSSemCreate (INT16U cnt)
  87:OSsrc/os_sem.c **** {
 158               	.LM12:
 159               	/* prologue: frame size=0 */
 160 0032 CF93      		push r28
 161 0034 DF93      		push r29
 162               	/* prologue end (size=2) */
 163 0036 9C01      		movw r18,r24
  88:OSsrc/os_sem.c ****     OS_EVENT  *pevent;
  89:OSsrc/os_sem.c **** #if OS_CRITICAL_METHOD == 3                                /* Allocate storage for CPU status regis
  90:OSsrc/os_sem.c ****     OS_CPU_SR  cpu_sr;
  91:OSsrc/os_sem.c **** 
  92:OSsrc/os_sem.c **** 
  93:OSsrc/os_sem.c **** 
  94:OSsrc/os_sem.c ****     cpu_sr = 0;                                            /* Prevent compiler warning             
  95:OSsrc/os_sem.c **** #endif    
  96:OSsrc/os_sem.c ****     if (OSIntNesting > 0) {                                /* See if called from ISR ...           
 165               	.LM13:
 166 0038 8091 0000 		lds r24,OSIntNesting
 167 003c 8823      		tst r24
 168 003e 19F0      		breq .L6
  97:OSsrc/os_sem.c ****         return ((OS_EVENT *)0);                            /* ... can't CREATE from an ISR         
 170               	.LM14:
 171 0040 80E0      		ldi r24,lo8(0)
 172 0042 90E0      		ldi r25,hi8(0)
 173 0044 20C0      		rjmp .L5
 174               	.L6:
  98:OSsrc/os_sem.c ****     }
  99:OSsrc/os_sem.c ****     OS_ENTER_CRITICAL();
 176               	.LM15:
 177               	/* #APP */
 178 0046 0FB6      		in __tmp_reg__,__SREG__
 179 0048 F894      		cli
 180 004a 0F92      		push __tmp_reg__
 100:OSsrc/os_sem.c ****     pevent = OSEventFreeList;                              /* Get next free event control block    
 182               	.LM16:
 183               	/* #NOAPP */
 184 004c C091 0000 		lds r28,OSEventFreeList
 185 0050 D091 0000 		lds r29,(OSEventFreeList)+1
 101:OSsrc/os_sem.c ****     if (OSEventFreeList != (OS_EVENT *)0) {                /* See if pool of free ECB pool was empt
 187               	.LM17:
 188 0054 2097      		sbiw r28,0
 189 0056 31F0      		breq .L7
 102:OSsrc/os_sem.c ****         OSEventFreeList = (OS_EVENT *)OSEventFreeList->OSEventPtr;
 191               	.LM18:
 192 0058 8C81      		ldd r24,Y+4
 193 005a 9D81      		ldd r25,Y+5
 194 005c 9093 0000 		sts (OSEventFreeList)+1,r25
 195 0060 8093 0000 		sts OSEventFreeList,r24
 196               	.L7:
 103:OSsrc/os_sem.c ****     }
 104:OSsrc/os_sem.c ****     OS_EXIT_CRITICAL();
 198               	.LM19:
 199               	/* #APP */
 200 0064 0F90      		pop __tmp_reg__
 201 0066 0FBE      		out __SREG__,__tmp_reg__
 105:OSsrc/os_sem.c ****     if (pevent != (OS_EVENT *)0) {                         /* Get an event control block           
 203               	.LM20:
 204               	/* #NOAPP */
 205 0068 2097      		sbiw r28,0
 206 006a 61F0      		breq .L8
 106:OSsrc/os_sem.c ****         pevent->OSEventType    = OS_EVENT_TYPE_SEM;
 208               	.LM21:
 209 006c 83E0      		ldi r24,lo8(3)
 210 006e 8883      		st Y,r24
 107:OSsrc/os_sem.c ****         pevent->OSEventCnt     = cnt;                      /* Set semaphore value                  
 212               	.LM22:
 213 0070 2A83      		std Y+2,r18
 214 0072 3B83      		std Y+3,r19
 108:OSsrc/os_sem.c ****         pevent->OSEventPtr     = (void *)0;                /* Unlink from ECB free list            
 216               	.LM23:
 217 0074 1C82      		std Y+4,__zero_reg__
 218 0076 1D82      		std Y+5,__zero_reg__
 109:OSsrc/os_sem.c **** #if OS_EVENT_NAME_SIZE > 1
 110:OSsrc/os_sem.c ****         pevent->OSEventName[0] = '?';                      /* Unknown name                         
 220               	.LM24:
 221 0078 8FE3      		ldi r24,lo8(63)
 222 007a 8E87      		std Y+14,r24
 111:OSsrc/os_sem.c ****         pevent->OSEventName[1] = OS_ASCII_NUL;
 224               	.LM25:
 225 007c 1F86      		std Y+15,__zero_reg__
 112:OSsrc/os_sem.c **** #endif
 113:OSsrc/os_sem.c ****         OS_EventWaitListInit(pevent);                      /* Initialize to 'nobody waiting' on sem
 227               	.LM26:
 228 007e CE01      		movw r24,r28
 229 0080 0E94 0000 		call OS_EventWaitListInit
 230               	.L8:
 114:OSsrc/os_sem.c ****     }
 115:OSsrc/os_sem.c ****     return (pevent);
 232               	.LM27:
 233 0084 CE01      		movw r24,r28
 234               	.L5:
 235               	/* epilogue: frame size=0 */
 236 0086 DF91      		pop r29
 237 0088 CF91      		pop r28
 238 008a 0895      		ret
 239               	/* epilogue end (size=3) */
 240               	/* function OSSemCreate size 50 (45) */
 245               	.Lscope1:
 250               	.global	OSSemDel
 252               	OSSemDel:
 116:OSsrc/os_sem.c **** }
 117:OSsrc/os_sem.c **** 
 118:OSsrc/os_sem.c **** /*$PAGE*/
 119:OSsrc/os_sem.c **** /*
 120:OSsrc/os_sem.c **** ***************************************************************************************************
 121:OSsrc/os_sem.c **** *                                         DELETE A SEMAPHORE
 122:OSsrc/os_sem.c **** *
 123:OSsrc/os_sem.c **** * Description: This function deletes a semaphore and readies all tasks pending on the semaphore.
 124:OSsrc/os_sem.c **** *
 125:OSsrc/os_sem.c **** * Arguments  : pevent        is a pointer to the event control block associated with the desired
 126:OSsrc/os_sem.c **** *                            semaphore.
 127:OSsrc/os_sem.c **** *
 128:OSsrc/os_sem.c **** *              opt           determines delete options as follows:
 129:OSsrc/os_sem.c **** *                            opt == OS_DEL_NO_PEND   Delete semaphore ONLY if no task pending
 130:OSsrc/os_sem.c **** *                            opt == OS_DEL_ALWAYS    Deletes the semaphore even if tasks are waitin
 131:OSsrc/os_sem.c **** *                                                    In this case, all the tasks pending will be re
 132:OSsrc/os_sem.c **** *
 133:OSsrc/os_sem.c **** *              err           is a pointer to an error code that can contain one of the following va
 134:OSsrc/os_sem.c **** *                            OS_NO_ERR               The call was successful and the semaphore was 
 135:OSsrc/os_sem.c **** *                            OS_ERR_DEL_ISR          If you attempted to delete the semaphore from 
 136:OSsrc/os_sem.c **** *                            OS_ERR_INVALID_OPT      An invalid option was specified
 137:OSsrc/os_sem.c **** *                            OS_ERR_TASK_WAITING     One or more tasks were waiting on the semaphor
 138:OSsrc/os_sem.c **** *                            OS_ERR_EVENT_TYPE       If you didn't pass a pointer to a semaphore
 139:OSsrc/os_sem.c **** *                            OS_ERR_PEVENT_NULL      If 'pevent' is a NULL pointer.
 140:OSsrc/os_sem.c **** *
 141:OSsrc/os_sem.c **** * Returns    : pevent        upon error
 142:OSsrc/os_sem.c **** *              (OS_EVENT *)0 if the semaphore was successfully deleted.
 143:OSsrc/os_sem.c **** *
 144:OSsrc/os_sem.c **** * Note(s)    : 1) This function must be used with care.  Tasks that would normally expect the prese
 145:OSsrc/os_sem.c **** *                 the semaphore MUST check the return code of OSSemPend().
 146:OSsrc/os_sem.c **** *              2) OSSemAccept() callers will not know that the intended semaphore has been deleted 
 147:OSsrc/os_sem.c **** *                 they check 'pevent' to see that it's a NULL pointer.
 148:OSsrc/os_sem.c **** *              3) This call can potentially disable interrupts for a long time.  The interrupt disa
 149:OSsrc/os_sem.c **** *                 time is directly proportional to the number of tasks waiting on the semaphore.
 150:OSsrc/os_sem.c **** *              4) Because ALL tasks pending on the semaphore will be readied, you MUST be careful i
 151:OSsrc/os_sem.c **** *                 applications where the semaphore is used for mutual exclusion because the resourc
 152:OSsrc/os_sem.c **** *                 will no longer be guarded by the semaphore.
 153:OSsrc/os_sem.c **** ***************************************************************************************************
 154:OSsrc/os_sem.c **** */
 155:OSsrc/os_sem.c **** 
 156:OSsrc/os_sem.c **** #if OS_SEM_DEL_EN > 0
 157:OSsrc/os_sem.c **** OS_EVENT  *OSSemDel (OS_EVENT *pevent, INT8U opt, INT8U *err)
 158:OSsrc/os_sem.c **** {
 254               	.LM28:
 255               	/* prologue: frame size=0 */
 256 008c FF92      		push r15
 257 008e 0F93      		push r16

⌨️ 快捷键说明

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