📄 os_q.lst
字号:
\ 006E 0D93 CMP #0,R13
\ 0070 1E24 JEQ (?0075)
113 OSQFreeList = OSQFreeList->OSQPtr; /* Yes, Adjust free list pointer to next free*/
\ 0072 1F420000 MOV &OSQFreeList,R15
\ 0076 A24F0000 MOV @R15,&OSQFreeList
114 OS_EXIT_CRITICAL();
\ 007A 32D2 EINT
115 pq->OSQStart = start; /* Initialize the queue */
\ 007C 8D4C0200 MOV R12,2(R13)
116 pq->OSQEnd = &start[size];
\ 0080 0F4E MOV R14,R15
\ 0082 0F5F ADD R15,R15
\ 0084 0F5C ADD R12,R15
\ 0086 8D4F0400 MOV R15,4(R13)
117 pq->OSQIn = start;
\ 008A 8D4C0600 MOV R12,6(R13)
118 pq->OSQOut = start;
\ 008E 8D4C0800 MOV R12,8(R13)
119 pq->OSQSize = size;
\ 0092 8D4E0A00 MOV R14,10(R13)
120 pq->OSQEntries = 0;
\ 0096 8D430C00 MOV #0,12(R13)
121 pevent->OSEventType = OS_EVENT_TYPE_Q;
\ 009A EA430000 MOV.B #2,0(R10)
122 pevent->OSEventCnt = 0;
\ 009E 8A430200 MOV #0,2(R10)
123 pevent->OSEventPtr = pq;
\ 00A2 8A4D0400 MOV R13,4(R10)
124 OS_EventWaitListInit(pevent); /* Initalize the wait list */
\ 00A6 0C4A MOV R10,R12
\ 00A8 B0120000 CALL #OS_EventWaitListInit
125 } else {
\ 00AC 073C JMP (?0076)
\ 00AE ?0075:
126 pevent->OSEventPtr = (void *)OSEventFreeList; /* No, Return event control block on error */
\ 00AE 9A420000 MOV &OSEventFreeList,4(R10)
\ 00B2 0400
127 OSEventFreeList = pevent;
\ 00B4 824A0000 MOV R10,&OSEventFreeList
128 OS_EXIT_CRITICAL();
\ 00B8 32D2 EINT
129 pevent = (OS_EVENT *)0;
\ 00BA 0A43 MOV #0,R10
\ 00BC ?0076:
130 }
131 }
132 return (pevent);
\ 00BC 0C4A MOV R10,R12
133 }
\ 00BE ?0077:
\ 00BE 3A41 POP R10
\ 00C0 3041 RET
\ 00C2 OSQDel:
134 /*$PAGE*/
135 /*
136 *********************************************************************************************************
137 * DELETE A MESSAGE QUEUE
138 *
139 * Description: This function deletes a message queue and readies all tasks pending on the queue.
140 *
141 * Arguments : pevent is a pointer to the event control block associated with the desired
142 * queue.
143 *
144 * opt determines delete options as follows:
145 * opt == OS_DEL_NO_PEND Delete the queue ONLY if no task pending
146 * opt == OS_DEL_ALWAYS Deletes the queue even if tasks are waiting.
147 * In this case, all the tasks pending will be readied.
148 *
149 * err is a pointer to an error code that can contain one of the following values:
150 * OS_NO_ERR The call was successful and the queue was deleted
151 * OS_ERR_DEL_ISR If you tried to delete the queue from an ISR
152 * OS_ERR_INVALID_OPT An invalid option was specified
153 * OS_ERR_TASK_WAITING One or more tasks were waiting on the queue
154 * OS_ERR_EVENT_TYPE If you didn't pass a pointer to a queue
155 * OS_ERR_PEVENT_NULL If 'pevent' is a NULL pointer.
156 *
157 * Returns : pevent upon error
158 * (OS_EVENT *)0 if the queue was successfully deleted.
159 *
160 * Note(s) : 1) This function must be used with care. Tasks that would normally expect the presence of
161 * the queue MUST check the return code of OSQPend().
162 * 2) OSQAccept() callers will not know that the intended queue has been deleted unless
163 * they check 'pevent' to see that it's a NULL pointer.
164 * 3) This call can potentially disable interrupts for a long time. The interrupt disable
165 * time is directly proportional to the number of tasks waiting on the queue.
166 * 4) Because ALL tasks pending on the queue will be readied, you MUST be careful in
167 * applications where the queue is used for mutual exclusion because the resource(s)
168 * will no longer be guarded by the queue.
169 * 5) If the storage for the message queue was allocated dynamically (i.e. using a malloc()
170 * type call) then your application MUST release the memory storage by call the counterpart
171 * call of the dynamic allocation scheme used. If the queue storage was created statically
172 * then, the storage can be reused.
173 *********************************************************************************************************
174 */
175
176 #if OS_Q_DEL_EN > 0
177 OS_EVENT *OSQDel (OS_EVENT *pevent, INT8U opt, INT8U *err)
178 {
\ 00C2 0A12 PUSH R10
\ 00C4 0B12 PUSH R11
\ 00C6 0812 PUSH R8
\ 00C8 0B4C MOV R12,R11
\ 00CA 18410800 MOV 8(SP),R8
179 #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
180 OS_CPU_SR cpu_sr;
181 #endif
182 BOOLEAN tasks_waiting;
183 OS_Q *pq;
184
185
186 if (OSIntNesting > 0) { /* See if called from ISR ... */
\ 00CE C2930000 CMP.B #0,&OSIntNesting
\ 00D2 0524 JEQ (?0079)
187 *err = OS_ERR_DEL_ISR; /* ... can't DELETE from an ISR */
\ 00D4 F8408C00 MOV.B #140,0(R8)
\ 00D8 0000
188 return ((OS_EVENT *)0);
\ 00DA 0C43 MOV #0,R12
189 }
\ 00DC 5A3C JMP (?0098)
\ 00DE ?0079:
190 #if OS_ARG_CHK_EN > 0
191 if (pevent == (OS_EVENT *)0) { /* Validate 'pevent' */
\ 00DE 0B93 CMP #0,R11
\ 00E0 0420 JNE (?0081)
192 *err = OS_ERR_PEVENT_NULL;
\ 00E2 E8420000 MOV.B #4,0(R8)
193 return (pevent);
\ 00E6 0C43 MOV #0,R12
194 }
\ 00E8 543C JMP (?0098)
\ 00EA ?0081:
195 if (pevent->OSEventType != OS_EVENT_TYPE_Q) { /* Validate event block type */
\ 00EA 6C43 MOV.B #2,R12
\ 00EC 6C9B CMP.B @R11,R12
\ 00EE 0424 JEQ (?0083)
196 *err = OS_ERR_EVENT_TYPE;
\ 00F0 D8430000 MOV.B #1,0(R8)
197 return (pevent);
\ 00F4 0C4B MOV R11,R12
198 }
\ 00F6 4D3C JMP (?0098)
\ 00F8 ?0083:
199 #endif
200 OS_ENTER_CRITICAL();
\ 00F8 32C2 DINT
201 if (pevent->OSEventGrp != 0x00) { /* See if any tasks waiting on queue */
\ 00FA CB930100 CMP.B #0,1(R11)
\ 00FE 0224 JEQ (?0085)
202 tasks_waiting = TRUE; /* Yes */
\ 0100 5A43 MOV.B #1,R10
203 } else {
\ 0102 013C JMP (?0086)
\ 0104 ?0085:
204 tasks_waiting = FALSE; /* No */
\ 0104 4A43 MOV.B #0,R10
\ 0106 ?0086:
205 }
206 switch (opt) {
\ 0106 4E83 SUB.B #0,R14
\ 0108 0324 JEQ (?0088)
\ 010A 5E83 SUB.B #1,R14
\ 010C 1B24 JEQ (?0091)
\ 010E 3C3C JMP (?0097)
\ 0110 ?0088:
207 case OS_DEL_NO_PEND: /* Delete queue only if no task waiting */
208 if (tasks_waiting == FALSE) {
\ 0110 4A93 CMP.B #0,R10
\ 0112 1320 JNE (?0090)
209 pq = (OS_Q *)pevent->OSEventPtr; /* Return OS_Q to free list */
\ 0114 1C4B0400 MOV 4(R11),R12
210 pq->OSQPtr = OSQFreeList;
\ 0118 9C420000 MOV &OSQFreeList,0(R12)
\ 011C 0000
211 OSQFreeList = pq;
\ 011E 824C0000 MOV R12,&OSQFreeList
212 pevent->OSEventType = OS_EVENT_TYPE_UNUSED;
\ 0122 CB430000 MOV.B #0,0(R11)
213 pevent->OSEventPtr = OSEventFreeList; /* Return Event Control Block to free list */
\ 0126 9B420000 MOV &OSEventFreeList,4(R11)
\ 012A 0400
214 OSEventFreeList = pevent; /* Get next free event control block */
\ 012C 824B0000 MOV R11,&OSEventFreeList
215 OS_EXIT_CRITICAL();
\ 0130 32D2 EINT
216 *err = OS_NO_ERR;
\ 0132 C8430000 MOV.B #0,0(R8)
217 return ((OS_EVENT *)0); /* Queue has been deleted */
\ 0136 0C43 MOV #0,R12
218 } else {
\ 0138 2C3C JMP (?0098)
\ 013A ?0090:
219 OS_EXIT_CRITICAL();
\ 013A 32D2 EINT
220 *err = OS_ERR_TASK_WAITING;
\ 013C F8420000 MOV.B #8,0(R8)
221 return (pevent);
\ 0140 0C4B MOV R11,R12
222 }
\ 0142 273C JMP (?0098)
\ 0144 ?0091:
223
224 case OS_DEL_ALWAYS: /* Always delete the queue */
225 while (pevent->OSEventGrp != 0x00) { /* Ready ALL tasks waiting for queue */
\ 0144 CB930100 CMP.B #0,1(R11)
\ 0148 0824 JEQ (?0092)
226 OS_EventTaskRdy(pevent, (void *)0, OS_STAT_Q);
\ 014A 70120400 PUSH.B #4
\ 014E 0E43 MOV #0,R14
\ 0150 0C4B MOV R11,R12
\ 0152 B0120000 CALL #OS_EventTaskRdy
\ 0156 2153 ADD #2,SP
\ 0158 F53F JMP (?0091)
\ 015A ?0092:
227 }
228 pq = (OS_Q *)pevent->OSEventPtr; /* Return OS_Q to free list */
\ 015A 1C4B0400 MOV 4(R11),R12
229 pq->OSQPtr = OSQFreeList;
\ 015E 9C420000 MOV &OSQFreeList,0(R12)
\ 0162 0000
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -