📄 os_q.lst
字号:
108 * Arguments : start is a pointer to the base address of the message queue storage area. The
109 * storage area MUST be declared as an array of pointers to 'void' as follows
110 *
111 * void *MessageStorage[size]
112 *
113 * size is the number of elements in the storage area
114 *
115 * Returns : != (OS_EVENT *)0 is a pointer to the event control clock (OS_EVENT) associated with the
116 * created queue
117 * == (OS_EVENT *)0 if no event control blocks were available or an error was detected
118 *********************************************************************************************************
119 */
120
\ In segment CODE, align 4, keep-with-next
121 OS_EVENT *OSQCreate (void **start, INT16U size)
122 {
\ OSQCreate:
\ 00000000 F0412DE9 PUSH {R4-R8,LR}
\ 00000004 0040B0E1 MOVS R4,R0
\ 00000008 0150B0E1 MOVS R5,R1
123 OS_EVENT *pevent;
124 OS_Q *pq;
125 #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
126 OS_CPU_SR cpu_sr = 0;
\ 0000000C 0000A0E3 MOV R0,#+0
\ 00000010 0080B0E1 MOVS R8,R0
127 #endif
128
129
130
131 if (OSIntNesting > 0) { /* See if called from ISR ... */
\ 00000014 ........ LDR R0,??DataTable19 ;; OSIntNesting
\ 00000018 0000D0E5 LDRB R0,[R0, #+0]
\ 0000001C 010050E3 CMP R0,#+1
\ 00000020 0100003A BCC ??OSQCreate_0
132 return ((OS_EVENT *)0); /* ... can't CREATE from an ISR */
\ 00000024 0000A0E3 MOV R0,#+0
\ 00000028 3F0000EA B ??OSQCreate_1
133 }
134 OS_ENTER_CRITICAL();
\ ??OSQCreate_0:
\ 0000002C ........ _BLF OS_CPU_SR_Save,??OS_CPU_SR_Save??rA
\ 00000030 0080B0E1 MOVS R8,R0
135 pevent = OSEventFreeList; /* Get next free event control block */
\ 00000034 ........ LDR R0,??DataTable18 ;; OSEventFreeList
\ 00000038 000090E5 LDR R0,[R0, #+0]
\ 0000003C 0060B0E1 MOVS R6,R0
136 if (OSEventFreeList != (OS_EVENT *)0) { /* See if pool of free ECB pool was empty */
\ 00000040 ........ LDR R0,??DataTable18 ;; OSEventFreeList
\ 00000044 000090E5 LDR R0,[R0, #+0]
\ 00000048 000050E3 CMP R0,#+0
\ 0000004C 0400000A BEQ ??OSQCreate_2
137 OSEventFreeList = (OS_EVENT *)OSEventFreeList->OSEventPtr;
\ 00000050 ........ LDR R0,??DataTable18 ;; OSEventFreeList
\ 00000054 ........ LDR R1,??DataTable18 ;; OSEventFreeList
\ 00000058 001091E5 LDR R1,[R1, #+0]
\ 0000005C 041091E5 LDR R1,[R1, #+4]
\ 00000060 001080E5 STR R1,[R0, #+0]
138 }
139 OS_EXIT_CRITICAL();
\ ??OSQCreate_2:
\ 00000064 0800B0E1 MOVS R0,R8
\ 00000068 ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rA
140 if (pevent != (OS_EVENT *)0) { /* See if we have an event control block */
\ 0000006C 000056E3 CMP R6,#+0
\ 00000070 2C00000A BEQ ??OSQCreate_3
141 OS_ENTER_CRITICAL();
\ 00000074 ........ _BLF OS_CPU_SR_Save,??OS_CPU_SR_Save??rA
\ 00000078 0080B0E1 MOVS R8,R0
142 pq = OSQFreeList; /* Get a free queue control block */
\ 0000007C ........ LDR R0,??DataTable20 ;; OSQFreeList
\ 00000080 000090E5 LDR R0,[R0, #+0]
\ 00000084 0070B0E1 MOVS R7,R0
143 if (pq != (OS_Q *)0) { /* Were we able to get a queue control block ? */
\ 00000088 000057E3 CMP R7,#+0
\ 0000008C 1C00000A BEQ ??OSQCreate_4
144 OSQFreeList = OSQFreeList->OSQPtr; /* Yes, Adjust free list pointer to next free*/
\ 00000090 ........ LDR R0,??DataTable20 ;; OSQFreeList
\ 00000094 ........ LDR R1,??DataTable20 ;; OSQFreeList
\ 00000098 001091E5 LDR R1,[R1, #+0]
\ 0000009C 001091E5 LDR R1,[R1, #+0]
\ 000000A0 001080E5 STR R1,[R0, #+0]
145 OS_EXIT_CRITICAL();
\ 000000A4 0800B0E1 MOVS R0,R8
\ 000000A8 ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rA
146 pq->OSQStart = start; /* Initialize the queue */
\ 000000AC 044087E5 STR R4,[R7, #+4]
147 pq->OSQEnd = &start[size];
\ 000000B0 0500B0E1 MOVS R0,R5
\ 000000B4 0410A0E3 MOV R1,#+4
\ 000000B8 914020E0 MLA R0,R1,R0,R4
\ 000000BC 080087E5 STR R0,[R7, #+8]
148 pq->OSQIn = start;
\ 000000C0 0C4087E5 STR R4,[R7, #+12]
149 pq->OSQOut = start;
\ 000000C4 104087E5 STR R4,[R7, #+16]
150 pq->OSQSize = size;
\ 000000C8 B451C7E1 STRH R5,[R7, #+20]
151 pq->OSQEntries = 0;
\ 000000CC 0000A0E3 MOV R0,#+0
\ 000000D0 B601C7E1 STRH R0,[R7, #+22]
152 pevent->OSEventType = OS_EVENT_TYPE_Q;
\ 000000D4 0200A0E3 MOV R0,#+2
\ 000000D8 0000C6E5 STRB R0,[R6, #+0]
153 pevent->OSEventCnt = 0;
\ 000000DC 0000A0E3 MOV R0,#+0
\ 000000E0 B800C6E1 STRH R0,[R6, #+8]
154 pevent->OSEventPtr = pq;
\ 000000E4 047086E5 STR R7,[R6, #+4]
155 #if OS_EVENT_NAME_SIZE > 1
156 pevent->OSEventName[0] = '?'; /* Unknown name */
\ 000000E8 3F00A0E3 MOV R0,#+63
\ 000000EC 0F00C6E5 STRB R0,[R6, #+15]
157 pevent->OSEventName[1] = OS_ASCII_NUL;
\ 000000F0 0000A0E3 MOV R0,#+0
\ 000000F4 1000C6E5 STRB R0,[R6, #+16]
158 #endif
159 OS_EventWaitListInit(pevent); /* Initalize the wait list */
\ 000000F8 0600B0E1 MOVS R0,R6
\ 000000FC ........ _BLF OS_EventWaitListInit,??OS_EventWaitListInit??rA
\ 00000100 080000EA B ??OSQCreate_3
160 } else {
161 pevent->OSEventPtr = (void *)OSEventFreeList; /* No, Return event control block on error */
\ ??OSQCreate_4:
\ 00000104 ........ LDR R0,??DataTable18 ;; OSEventFreeList
\ 00000108 000090E5 LDR R0,[R0, #+0]
\ 0000010C 040086E5 STR R0,[R6, #+4]
162 OSEventFreeList = pevent;
\ 00000110 ........ LDR R0,??DataTable18 ;; OSEventFreeList
\ 00000114 006080E5 STR R6,[R0, #+0]
163 OS_EXIT_CRITICAL();
\ 00000118 0800B0E1 MOVS R0,R8
\ 0000011C ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rA
164 pevent = (OS_EVENT *)0;
\ 00000120 0000A0E3 MOV R0,#+0
\ 00000124 0060B0E1 MOVS R6,R0
165 }
166 }
167 return (pevent);
\ ??OSQCreate_3:
\ 00000128 0600B0E1 MOVS R0,R6
\ ??OSQCreate_1:
\ 0000012C F081BDE8 POP {R4-R8,PC} ;; return
168 }
169 /*$PAGE*/
170 /*
171 *********************************************************************************************************
172 * DELETE A MESSAGE QUEUE
173 *
174 * Description: This function deletes a message queue and readies all tasks pending on the queue.
175 *
176 * Arguments : pevent is a pointer to the event control block associated with the desired
177 * queue.
178 *
179 * opt determines delete options as follows:
180 * opt == OS_DEL_NO_PEND Delete the queue ONLY if no task pending
181 * opt == OS_DEL_ALWAYS Deletes the queue even if tasks are waiting.
182 * In this case, all the tasks pending will be readied.
183 *
184 * err is a pointer to an error code that can contain one of the following values:
185 * OS_ERR_NONE The call was successful and the queue was deleted
186 * OS_ERR_DEL_ISR If you tried to delete the queue from an ISR
187 * OS_ERR_INVALID_OPT An invalid option was specified
188 * OS_ERR_TASK_WAITING One or more tasks were waiting on the queue
189 * OS_ERR_EVENT_TYPE If you didn't pass a pointer to a queue
190 * OS_ERR_PEVENT_NULL If 'pevent' is a NULL pointer.
191 *
192 * Returns : pevent upon error
193 * (OS_EVENT *)0 if the queue was successfully deleted.
194 *
195 * Note(s) : 1) This function must be used with care. Tasks that would normally expect the presence of
196 * the queue MUST check the return code of OSQPend().
197 * 2) OSQAccept() callers will not know that the intended queue has been deleted unless
198 * they check 'pevent' to see that it's a NULL pointer.
199 * 3) This call can potentially disable interrupts for a long time. The interrupt disable
200 * time is directly proportional to the number of tasks waiting on the queue.
201 * 4) Because ALL tasks pending on the queue will be readied, you MUST be careful in
202 * applications where the queue is used for mutual exclusion because the resource(s)
203 * will no longer be guarded by the queue.
204 * 5) If the storage for the message queue was allocated dynamically (i.e. using a malloc()
205 * type call) then your application MUST release the memory storage by call the counterpart
206 * call of the dynamic allocation scheme used. If the queue storage was created statically
207 * then, the storage can be reused.
208 *********************************************************************************************************
209 */
210
211 #if OS_Q_DEL_EN > 0
\ In segment CODE, align 4, keep-with-next
212 OS_EVENT *OSQDel (OS_EVENT *pevent, INT8U opt, INT8U *err)
213 {
\ OSQDel:
\ 00000000 F0472DE9 PUSH {R4-R10,LR}
\ 00000004 00A0B0E1 MOVS R10,R0
\ 00000008 0140B0E1 MOVS R4,R1
\ 0000000C 0250B0E1 MOVS R5,R2
214 BOOLEAN tasks_waiting;
215 OS_EVENT *pevent_return;
216 OS_Q *pq;
217 #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
218 OS_CPU_SR cpu_sr = 0;
\ 00000010 0000A0E3 MOV R0,#+0
\ 00000014 0090B0E1 MOVS R9,R0
219 #endif
220
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -