📄 os_mbox.lst
字号:
108 /*
109 *********************************************************************************************************
110 * DELETE A MAIBOX
111 *
112 * Description: This function deletes a mailbox and readies all tasks pending on the mailbox.
113 *
114 * Arguments : pevent is a pointer to the event control block associated with the desired
115 * mailbox.
116 *
117 * opt determines delete options as follows:
118 * opt == OS_DEL_NO_PEND Delete the mailbox ONLY if no task pending
119 * opt == OS_DEL_ALWAYS Deletes the mailbox even if tasks are waiting.
120 * In this case, all the tasks pending will be readied.
121 *
122 * err is a pointer to an error code that can contain one of the following values:
123 * OS_NO_ERR The call was successful and the mailbox was deleted
124 * OS_ERR_DEL_ISR If you attempted to delete the mailbox from an ISR
125 * OS_ERR_INVALID_OPT An invalid option was specified
126 * OS_ERR_TASK_WAITING One or more tasks were waiting on the mailbox
127 * OS_ERR_EVENT_TYPE If you didn't pass a pointer to a mailbox
128 * OS_ERR_PEVENT_NULL If 'pevent' is a NULL pointer.
129 *
130 * Returns : pevent upon error
131 * (OS_EVENT *)0 if the mailbox was successfully deleted.
132 *
133 * Note(s) : 1) This function must be used with care. Tasks that would normally expect the presence of
134 * the mailbox MUST check the return code of OSMboxPend().
135 * 2) OSMboxAccept() callers will not know that the intended mailbox has been deleted!
136 * 3) This call can potentially disable interrupts for a long time. The interrupt disable
137 * time is directly proportional to the number of tasks waiting on the mailbox.
138 * 4) Because ALL tasks pending on the mailbox will be readied, you MUST be careful in
139 * applications where the mailbox is used for mutual exclusion because the resource(s)
140 * will no longer be guarded by the mailbox.
141 *********************************************************************************************************
142 */
143
144 #if OS_MBOX_DEL_EN > 0
\ In segment CODE, align 4, keep-with-next
145 OS_EVENT *OSMboxDel (OS_EVENT *pevent, INT8U opt, INT8U *err)
146 {
\ OSMboxDel:
\ 00000000 F2B5 PUSH {R1,R4-R7,LR}
\ 00000002 0400 MOVS R4,R0
\ 00000004 1500 MOVS R5,R2
147 #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
148 OS_CPU_SR cpu_sr;
149 #endif
150 BOOLEAN tasks_waiting;
151
152
153 if (OSIntNesting > 0) { /* See if called from ISR ... */
\ 00000006 .... LDR R0,??DataTable10 ;; OSIntNesting
\ 00000008 0078 LDRB R0,[R0, #+0]
\ 0000000A 0128 CMP R0,#+1
\ 0000000C 03D3 BCC ??OSMboxDel_0
154 *err = OS_ERR_DEL_ISR; /* ... can't DELETE from an ISR */
\ 0000000E 8C20 MOVS R0,#+140
\ 00000010 2870 STRB R0,[R5, #+0]
155 return (pevent);
\ 00000012 2000 MOVS R0,R4
\ 00000014 5FE0 B ??OSMboxDel_1
156 }
157 #if OS_ARG_CHK_EN > 0
158 if (pevent == (OS_EVENT *)0) { /* Validate 'pevent' */
\ ??OSMboxDel_0:
\ 00000016 002C CMP R4,#+0
\ 00000018 03D1 BNE ??OSMboxDel_2
159 *err = OS_ERR_PEVENT_NULL;
\ 0000001A 0420 MOVS R0,#+4
\ 0000001C 2870 STRB R0,[R5, #+0]
160 return (pevent);
\ 0000001E 2000 MOVS R0,R4
\ 00000020 59E0 B ??OSMboxDel_1
161 }
162 #endif
163 if (pevent->OSEventType != OS_EVENT_TYPE_MBOX) { /* Validate event block type */
\ ??OSMboxDel_2:
\ 00000022 2078 LDRB R0,[R4, #+0]
\ 00000024 0128 CMP R0,#+1
\ 00000026 03D0 BEQ ??OSMboxDel_3
164 *err = OS_ERR_EVENT_TYPE;
\ 00000028 0120 MOVS R0,#+1
\ 0000002A 2870 STRB R0,[R5, #+0]
165 return (pevent);
\ 0000002C 2000 MOVS R0,R4
\ 0000002E 52E0 B ??OSMboxDel_1
166 }
167 OS_ENTER_CRITICAL();
\ ??OSMboxDel_3:
\ 00000030 ........ _BLF OS_CPU_SR_Save,??OS_CPU_SR_Save??rT
\ 00000034 0600 MOVS R6,R0
168 if (pevent->OSEventGrp != 0x00) { /* See if any tasks waiting on mailbox */
\ 00000036 6078 LDRB R0,[R4, #+1]
\ 00000038 0028 CMP R0,#+0
\ 0000003A 01D0 BEQ ??OSMboxDel_4
169 tasks_waiting = TRUE; /* Yes */
\ 0000003C 0127 MOVS R7,#+1
\ 0000003E 00E0 B ??OSMboxDel_5
170 } else {
171 tasks_waiting = FALSE; /* No */
\ ??OSMboxDel_4:
\ 00000040 0027 MOVS R7,#+0
172 }
173 switch (opt) {
\ ??OSMboxDel_5:
\ 00000042 6846 MOV R0,SP
\ 00000044 0078 LDRB R0,[R0, #+0]
\ 00000046 0028 CMP R0,#+0
\ 00000048 02D0 BEQ ??OSMboxDel_6
\ 0000004A 0128 CMP R0,#+1
\ 0000004C 22D0 BEQ ??OSMboxDel_7
\ 0000004E 3CE0 B ??OSMboxDel_8
174 case OS_DEL_NO_PEND: /* Delete mailbox only if no task waiting */
175 if (tasks_waiting == FALSE) {
\ ??OSMboxDel_6:
\ 00000050 002F CMP R7,#+0
\ 00000052 13D1 BNE ??OSMboxDel_9
176 #if OS_EVENT_NAME_SIZE > 1
177 pevent->OSEventName[0] = '?'; /* Unknown name */
\ 00000054 3F20 MOVS R0,#+63
\ 00000056 2074 STRB R0,[R4, #+16]
178 pevent->OSEventName[1] = OS_ASCII_NUL;
\ 00000058 0020 MOVS R0,#+0
\ 0000005A 6074 STRB R0,[R4, #+17]
179 #endif
180 pevent->OSEventType = OS_EVENT_TYPE_UNUSED;
\ 0000005C 0020 MOVS R0,#+0
\ 0000005E 2070 STRB R0,[R4, #+0]
181 pevent->OSEventPtr = OSEventFreeList; /* Return Event Control Block to free list */
\ 00000060 .... LDR R0,??DataTable9 ;; OSEventFreeList
\ 00000062 0068 LDR R0,[R0, #+0]
\ 00000064 6060 STR R0,[R4, #+4]
182 pevent->OSEventCnt = 0;
\ 00000066 0020 MOVS R0,#+0
\ 00000068 6080 STRH R0,[R4, #+2]
183 OSEventFreeList = pevent; /* Get next free event control block */
\ 0000006A .... LDR R0,??DataTable9 ;; OSEventFreeList
\ 0000006C 0460 STR R4,[R0, #+0]
184 OS_EXIT_CRITICAL();
\ 0000006E 3000 MOVS R0,R6
\ 00000070 ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
185 *err = OS_NO_ERR;
\ 00000074 0020 MOVS R0,#+0
\ 00000076 2870 STRB R0,[R5, #+0]
186 return ((OS_EVENT *)0); /* Mailbox has been deleted */
\ 00000078 0020 MOVS R0,#+0
\ 0000007A 2CE0 B ??OSMboxDel_1
187 } else {
188 OS_EXIT_CRITICAL();
\ ??OSMboxDel_9:
\ 0000007C 3000 MOVS R0,R6
\ 0000007E ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
189 *err = OS_ERR_TASK_WAITING;
\ 00000082 0820 MOVS R0,#+8
\ 00000084 2870 STRB R0,[R5, #+0]
190 return (pevent);
\ 00000086 2000 MOVS R0,R4
\ 00000088 25E0 B ??OSMboxDel_1
191 }
192
193 case OS_DEL_ALWAYS: /* Always delete the mailbox */
194 while (pevent->OSEventGrp != 0x00) { /* Ready ALL tasks waiting for mailbox */
195 OS_EventTaskRdy(pevent, (void *)0, OS_STAT_MBOX);
\ ??OSMboxDel_10:
\ 0000008A 0222 MOVS R2,#+2
\ 0000008C 0021 MOVS R1,#+0
\ 0000008E 2000 MOVS R0,R4
\ 00000090 ........ _BLF OS_EventTaskRdy,??OS_EventTaskRdy??rT
196 }
\ ??OSMboxDel_7:
\ 00000094 6078 LDRB R0,[R4, #+1]
\ 00000096 0028 CMP R0,#+0
\ 00000098 F7D1 BNE ??OSMboxDel_10
197 #if OS_EVENT_NAME_SIZE > 1
198 pevent->OSEventName[0] = '?'; /* Unknown name */
\ 0000009A 3F20 MOVS R0,#+63
\ 0000009C 2074 STRB R0,[R4, #+16]
199 pevent->OSEventName[1] = OS_ASCII_NUL;
\ 0000009E 0020 MOVS R0,#+0
\ 000000A0 6074 STRB R0,[R4, #+17]
200 #endif
201 pevent->OSEventType = OS_EVENT_TYPE_UNUSED;
\ 000000A2 0020 MOVS R0,#+0
\ 000000A4 2070 STRB R0,[R4, #+0]
202 pevent->OSEventPtr = OSEventFreeList; /* Return Event Control Block to free list */
\ 000000A6 .... LDR R0,??DataTable9 ;; OSEventFreeList
\ 000000A8 0068 LDR R0,[R0, #+0]
\ 000000AA 6060 STR R0,[R4, #+4]
203 pevent->OSEventCnt = 0;
\ 000000AC 0020 MOVS R0,#+0
\ 000000AE 6080 STRH R0,[R4, #+2]
204 OSEventFreeList = pevent; /* Get next free event control block */
\ 000000B0 .... LDR R0,??DataTable9 ;; OSEventFreeList
\ 000000B2 0460 STR R4,[R0, #+0]
205 OS_EXIT_CRITICAL();
\ 000000B4 3000 MOVS R0,R6
\ 000000B6 ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rT
206 if (tasks_waiting == TRUE) { /* Reschedule only if task(s) were waiting */
\ 000000BA 012F CMP R7,#+1
\ 000000BC 01D1 BNE ??OSMboxDel_11
207 OS_Sched(); /* Find highest priority task ready to run */
\ 000000BE ........ _BLF OS_Sched,??OS_Sched??rT
208 }
209 *err = OS_NO_ERR;
\ ??OSMboxDel_11:
\ 000000C2 0020 MOVS R0,#+0
\ 000000C4 2870 STRB R0,[R5, #+0]
210 return ((OS_EVENT *)0); /* Mailbox has been deleted */
\ 000000C6 0020 MOVS R0,#+0
\ 000000C8 05E0 B ??OSMboxDel_1
211
212 default:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -