📄 os_mutex.lst
字号:
\ 000000B4 2E10D1E5 LDRB R1,[R1, #+46]
\ 000000B8 000091E1 ORRS R0,R1,R0
\ 000000BC B800C4E1 STRH R0,[R4, #+8]
115 pevent->OSEventPtr = (void *)OSTCBCur; /* Link TCB of task owning Mutex */
\ 000000C0 ........ LDR R0,??DataTable44 ;; OSTCBCur
\ 000000C4 000090E5 LDR R0,[R0, #+0]
\ 000000C8 040084E5 STR R0,[R4, #+4]
116 if (OSTCBCur->OSTCBPrio <= pip) { /* PIP 'must' have a SMALLER prio ... */
\ 000000CC ........ LDR R0,??DataTable44 ;; OSTCBCur
\ 000000D0 000090E5 LDR R0,[R0, #+0]
\ 000000D4 2E00D0E5 LDRB R0,[R0, #+46]
\ 000000D8 FF6016E2 ANDS R6,R6,#0xFF ;; Zero extend
\ 000000DC 000056E1 CMP R6,R0
\ 000000E0 0400003A BCC ??OSMutexAccept_6
117 OS_EXIT_CRITICAL(); /* ... than current task! */
\ 000000E4 0700B0E1 MOVS R0,R7
\ 000000E8 ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rA
118 *err = OS_ERR_PIP_LOWER;
\ 000000EC 7800A0E3 MOV R0,#+120
\ 000000F0 0000C5E5 STRB R0,[R5, #+0]
\ 000000F4 030000EA B ??OSMutexAccept_7
119 } else {
120 OS_EXIT_CRITICAL();
\ ??OSMutexAccept_6:
\ 000000F8 0700B0E1 MOVS R0,R7
\ 000000FC ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rA
121 *err = OS_ERR_NONE;
\ 00000100 0000A0E3 MOV R0,#+0
\ 00000104 0000C5E5 STRB R0,[R5, #+0]
122 }
123 return (1);
\ ??OSMutexAccept_7:
\ 00000108 0100A0E3 MOV R0,#+1
\ 0000010C 040000EA B ??OSMutexAccept_1
124 }
125 OS_EXIT_CRITICAL();
\ ??OSMutexAccept_5:
\ 00000110 0700B0E1 MOVS R0,R7
\ 00000114 ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rA
126 *err = OS_ERR_NONE;
\ 00000118 0000A0E3 MOV R0,#+0
\ 0000011C 0000C5E5 STRB R0,[R5, #+0]
127 return (0);
\ 00000120 0000A0E3 MOV R0,#+0
\ ??OSMutexAccept_1:
\ 00000124 F080BDE8 POP {R4-R7,PC} ;; return
128 }
129 #endif
130
131 /*$PAGE*/
132 /*
133 *********************************************************************************************************
134 * CREATE A MUTUAL EXCLUSION SEMAPHORE
135 *
136 * Description: This function creates a mutual exclusion semaphore.
137 *
138 * Arguments : prio is the priority to use when accessing the mutual exclusion semaphore. In
139 * other words, when the semaphore is acquired and a higher priority task
140 * attempts to obtain the semaphore then the priority of the task owning the
141 * semaphore is raised to this priority. It is assumed that you will specify
142 * a priority that is LOWER in value than ANY of the tasks competing for the
143 * mutex.
144 *
145 * err is a pointer to an error code which will be returned to your application:
146 * OS_ERR_NONE if the call was successful.
147 * OS_ERR_CREATE_ISR if you attempted to create a MUTEX from an ISR
148 * OS_ERR_PRIO_EXIST if a task at the priority inheritance priority
149 * already exist.
150 * OS_ERR_PEVENT_NULL No more event control blocks available.
151 * OS_ERR_PRIO_INVALID if the priority you specify is higher that the
152 * maximum allowed (i.e. > OS_LOWEST_PRIO)
153 *
154 * Returns : != (void *)0 is a pointer to the event control clock (OS_EVENT) associated with the
155 * created mutex.
156 * == (void *)0 if an error is detected.
157 *
158 * Note(s) : 1) The LEAST significant 8 bits of '.OSEventCnt' are used to hold the priority number
159 * of the task owning the mutex or 0xFF if no task owns the mutex.
160 *
161 * 2) The MOST significant 8 bits of '.OSEventCnt' are used to hold the priority number
162 * to use to reduce priority inversion.
163 *********************************************************************************************************
164 */
165
\ In segment CODE, align 4, keep-with-next
166 OS_EVENT *OSMutexCreate (INT8U prio, INT8U *err)
167 {
\ OSMutexCreate:
\ 00000000 F0402DE9 PUSH {R4-R7,LR}
\ 00000004 0040B0E1 MOVS R4,R0
\ 00000008 0150B0E1 MOVS R5,R1
168 OS_EVENT *pevent;
169 #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
170 OS_CPU_SR cpu_sr = 0;
\ 0000000C 0000A0E3 MOV R0,#+0
\ 00000010 0070B0E1 MOVS R7,R0
171 #endif
172
173
174
175 #if OS_ARG_CHK_EN > 0
176 if (err == (INT8U *)0) { /* Validate 'err' */
\ 00000014 000055E3 CMP R5,#+0
\ 00000018 0100001A BNE ??OSMutexCreate_0
177 return ((OS_EVENT *)0);
\ 0000001C 0000A0E3 MOV R0,#+0
\ 00000020 4B0000EA B ??OSMutexCreate_1
178 }
179 if (prio >= OS_LOWEST_PRIO) { /* Validate PIP */
\ ??OSMutexCreate_0:
\ 00000024 1F0054E3 CMP R4,#+31
\ 00000028 0300003A BCC ??OSMutexCreate_2
180 *err = OS_ERR_PRIO_INVALID;
\ 0000002C 2A00A0E3 MOV R0,#+42
\ 00000030 0000C5E5 STRB R0,[R5, #+0]
181 return ((OS_EVENT *)0);
\ 00000034 0000A0E3 MOV R0,#+0
\ 00000038 450000EA B ??OSMutexCreate_1
182 }
183 #endif
184 if (OSIntNesting > 0) { /* See if called from ISR ... */
\ ??OSMutexCreate_2:
\ 0000003C ........ LDR R0,??DataTable47 ;; OSIntNesting
\ 00000040 0000D0E5 LDRB R0,[R0, #+0]
\ 00000044 010050E3 CMP R0,#+1
\ 00000048 0300003A BCC ??OSMutexCreate_3
185 *err = OS_ERR_CREATE_ISR; /* ... can't CREATE mutex from an ISR */
\ 0000004C 1000A0E3 MOV R0,#+16
\ 00000050 0000C5E5 STRB R0,[R5, #+0]
186 return ((OS_EVENT *)0);
\ 00000054 0000A0E3 MOV R0,#+0
\ 00000058 3D0000EA B ??OSMutexCreate_1
187 }
188 OS_ENTER_CRITICAL();
\ ??OSMutexCreate_3:
\ 0000005C ........ _BLF OS_CPU_SR_Save,??OS_CPU_SR_Save??rA
\ 00000060 0070B0E1 MOVS R7,R0
189 if (OSTCBPrioTbl[prio] != (OS_TCB *)0) { /* Mutex priority must not already exist */
\ 00000064 0400B0E1 MOVS R0,R4
\ 00000068 0410A0E3 MOV R1,#+4
\ 0000006C ........ LDR R2,??DataTable57 ;; OSTCBPrioTbl
\ 00000070 912020E0 MLA R0,R1,R0,R2
\ 00000074 000090E5 LDR R0,[R0, #+0]
\ 00000078 000050E3 CMP R0,#+0
\ 0000007C 0500000A BEQ ??OSMutexCreate_4
190 OS_EXIT_CRITICAL(); /* Task already exist at priority ... */
\ 00000080 0700B0E1 MOVS R0,R7
\ 00000084 ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rA
191 *err = OS_ERR_PRIO_EXIST; /* ... inheritance priority */
\ 00000088 2800A0E3 MOV R0,#+40
\ 0000008C 0000C5E5 STRB R0,[R5, #+0]
192 return ((OS_EVENT *)0);
\ 00000090 0000A0E3 MOV R0,#+0
\ 00000094 2E0000EA B ??OSMutexCreate_1
193 }
194 OSTCBPrioTbl[prio] = (OS_TCB *)1; /* Reserve the table entry */
\ ??OSMutexCreate_4:
\ 00000098 0400B0E1 MOVS R0,R4
\ 0000009C 0410A0E3 MOV R1,#+4
\ 000000A0 ........ LDR R2,??DataTable57 ;; OSTCBPrioTbl
\ 000000A4 912020E0 MLA R0,R1,R0,R2
\ 000000A8 0110A0E3 MOV R1,#+1
\ 000000AC 001080E5 STR R1,[R0, #+0]
195 pevent = OSEventFreeList; /* Get next free event control block */
\ 000000B0 ........ LDR R0,??DataTable17 ;; OSEventFreeList
\ 000000B4 000090E5 LDR R0,[R0, #+0]
\ 000000B8 0060B0E1 MOVS R6,R0
196 if (pevent == (OS_EVENT *)0) { /* See if an ECB was available */
\ 000000BC 000056E3 CMP R6,#+0
\ 000000C0 0B00001A BNE ??OSMutexCreate_5
197 OSTCBPrioTbl[prio] = (OS_TCB *)0; /* No, Release the table entry */
\ 000000C4 0400B0E1 MOVS R0,R4
\ 000000C8 0410A0E3 MOV R1,#+4
\ 000000CC ........ LDR R2,??DataTable57 ;; OSTCBPrioTbl
\ 000000D0 912020E0 MLA R0,R1,R0,R2
\ 000000D4 0010A0E3 MOV R1,#+0
\ 000000D8 001080E5 STR R1,[R0, #+0]
198 OS_EXIT_CRITICAL();
\ 000000DC 0700B0E1 MOVS R0,R7
\ 000000E0 ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rA
199 *err = OS_ERR_PEVENT_NULL; /* No more event control blocks */
\ 000000E4 0400A0E3 MOV R0,#+4
\ 000000E8 0000C5E5 STRB R0,[R5, #+0]
200 return (pevent);
\ 000000EC 0600B0E1 MOVS R0,R6
\ 000000F0 170000EA B ??OSMutexCreate_1
201 }
202 OSEventFreeList = (OS_EVENT *)OSEventFreeList->OSEventPtr; /* Adjust the free list */
\ ??OSMutexCreate_5:
\ 000000F4 ........ LDR R0,??DataTable17 ;; OSEventFreeList
\ 000000F8 ........ LDR R1,??DataTable17 ;; OSEventFreeList
\ 000000FC 001091E5 LDR R1,[R1, #+0]
\ 00000100 041091E5 LDR R1,[R1, #+4]
\ 00000104 001080E5 STR R1,[R0, #+0]
203 OS_EXIT_CRITICAL();
\ 00000108 0700B0E1 MOVS R0,R7
\ 0000010C ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rA
204 pevent->OSEventType = OS_EVENT_TYPE_MUTEX;
\ 00000110 0400A0E3 MOV R0,#+4
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -