📄 os_mem.lst
字号:
\ ??OSMemCreate_3:
\ 0000004E 0098 LDR R0,[SP, #+0]
\ 00000050 8245 CMP R10,R0
\ 00000052 07D2 BCS.N ??OSMemCreate_4
121 pblk += blksize; /* Point to the FOLLOWING block */
\ 00000054 16EB0808 ADDS R8,R6,R8
122 *plink = (void *)pblk; /* Save pointer to NEXT block in CURRENT block */
\ 00000058 C9F80080 STR R8,[R9, #+0]
123 plink = (void **)pblk; /* Position to NEXT block */
\ 0000005C C146 MOV R9,R8
124 }
\ 0000005E 1AF1010A ADDS R10,R10,#+1
\ 00000062 F4E7 B.N ??OSMemCreate_3
125 *plink = (void *)0; /* Last memory block points to NULL */
\ ??OSMemCreate_4:
\ 00000064 0020 MOVS R0,#+0
\ 00000066 C9F80000 STR R0,[R9, #+0]
126 pmem->OSMemAddr = addr; /* Store start address of memory partition */
\ 0000006A 3C60 STR R4,[R7, #+0]
127 pmem->OSMemFreeList = addr; /* Initialize pointer to pool of free blocks */
\ 0000006C 7C60 STR R4,[R7, #+4]
128 pmem->OSMemNFree = nblks; /* Store number of free blocks in MCB */
\ 0000006E 3D61 STR R5,[R7, #+16]
129 pmem->OSMemNBlks = nblks;
\ 00000070 FD60 STR R5,[R7, #+12]
130 pmem->OSMemBlkSize = blksize; /* Store block size of each memory blocks */
\ 00000072 BE60 STR R6,[R7, #+8]
131 *perr = OS_ERR_NONE;
\ 00000074 0298 LDR R0,[SP, #+8]
\ 00000076 0021 MOVS R1,#+0
\ 00000078 0170 STRB R1,[R0, #+0]
132 return (pmem);
\ 0000007A 3800 MOVS R0,R7
\ ??OSMemCreate_2:
\ 0000007C BDE8FE8F POP {R1-R11,PC} ;; return
133 }
134 /*$PAGE*/
135 /*
136 *********************************************************************************************************
137 * GET A MEMORY BLOCK
138 *
139 * Description : Get a memory block from a partition
140 *
141 * Arguments : pmem is a pointer to the memory partition control block
142 *
143 * perr is a pointer to a variable containing an error message which will be set by this
144 * function to either:
145 *
146 * OS_ERR_NONE if the memory partition has been created correctly.
147 * OS_ERR_MEM_NO_FREE_BLKS if there are no more free memory blocks to allocate to caller
148 * OS_ERR_MEM_INVALID_PMEM if you passed a NULL pointer for 'pmem'
149 *
150 * Returns : A pointer to a memory block if no error is detected
151 * A pointer to NULL if an error is detected
152 *********************************************************************************************************
153 */
154
\ In section .text, align 2, keep-with-next
155 void *OSMemGet (OS_MEM *pmem,
156 INT8U *perr)
157 {
\ OSMemGet:
\ 00000000 F8B5 PUSH {R3-R7,LR}
\ 00000002 0400 MOVS R4,R0
\ 00000004 0D00 MOVS R5,R1
158 void *pblk;
159 #if OS_CRITICAL_METHOD == 3u /* Allocate storage for CPU status register */
160 OS_CPU_SR cpu_sr = 0u;
\ 00000006 0027 MOVS R7,#+0
161 #endif
162
163
164
165 #ifdef OS_SAFETY_CRITICAL
166 if (perr == (INT8U *)0) {
167 OS_SAFETY_CRITICAL_EXCEPTION();
168 return ((void *)0);
169 }
170 #endif
171
172 #if OS_ARG_CHK_EN > 0u
173 if (pmem == (OS_MEM *)0) { /* Must point to a valid memory partition */
174 *perr = OS_ERR_MEM_INVALID_PMEM;
175 return ((void *)0);
176 }
177 #endif
178 OS_ENTER_CRITICAL();
\ 00000008 ........ BL OS_CPU_SR_Save
\ 0000000C 0700 MOVS R7,R0
179 if (pmem->OSMemNFree > 0u) { /* See if there are any free memory blocks */
\ 0000000E 2069 LDR R0,[R4, #+16]
\ 00000010 0028 CMP R0,#+0
\ 00000012 0DD0 BEQ.N ??OSMemGet_0
180 pblk = pmem->OSMemFreeList; /* Yes, point to next free memory block */
\ 00000014 6068 LDR R0,[R4, #+4]
\ 00000016 0600 MOVS R6,R0
181 pmem->OSMemFreeList = *(void **)pblk; /* Adjust pointer to new free list */
\ 00000018 3068 LDR R0,[R6, #+0]
\ 0000001A 6060 STR R0,[R4, #+4]
182 pmem->OSMemNFree--; /* One less memory block in this partition */
\ 0000001C 2069 LDR R0,[R4, #+16]
\ 0000001E 401E SUBS R0,R0,#+1
\ 00000020 2061 STR R0,[R4, #+16]
183 OS_EXIT_CRITICAL();
\ 00000022 3800 MOVS R0,R7
\ 00000024 ........ BL OS_CPU_SR_Restore
184 *perr = OS_ERR_NONE; /* No error */
\ 00000028 0020 MOVS R0,#+0
\ 0000002A 2870 STRB R0,[R5, #+0]
185 return (pblk); /* Return memory block to caller */
\ 0000002C 3000 MOVS R0,R6
\ 0000002E 05E0 B.N ??OSMemGet_1
186 }
187 OS_EXIT_CRITICAL();
\ ??OSMemGet_0:
\ 00000030 3800 MOVS R0,R7
\ 00000032 ........ BL OS_CPU_SR_Restore
188 *perr = OS_ERR_MEM_NO_FREE_BLKS; /* No, Notify caller of empty memory partition */
\ 00000036 5D20 MOVS R0,#+93
\ 00000038 2870 STRB R0,[R5, #+0]
189 return ((void *)0); /* Return NULL pointer to caller */
\ 0000003A 0020 MOVS R0,#+0
\ ??OSMemGet_1:
\ 0000003C F2BD POP {R1,R4-R7,PC} ;; return
190 }
191 /*$PAGE*/
192 /*
193 *********************************************************************************************************
194 * GET THE NAME OF A MEMORY PARTITION
195 *
196 * Description: This function is used to obtain the name assigned to a memory partition.
197 *
198 * Arguments : pmem is a pointer to the memory partition
199 *
200 * pname is a pointer to a pointer to an ASCII string that will receive the name of the memory partition.
201 *
202 * perr is a pointer to an error code that can contain one of the following values:
203 *
204 * OS_ERR_NONE if the name was copied to 'pname'
205 * OS_ERR_MEM_INVALID_PMEM if you passed a NULL pointer for 'pmem'
206 * OS_ERR_PNAME_NULL You passed a NULL pointer for 'pname'
207 * OS_ERR_NAME_GET_ISR You called this function from an ISR
208 *
209 * Returns : The length of the string or 0 if 'pmem' is a NULL pointer.
210 *********************************************************************************************************
211 */
212
213 #if OS_MEM_NAME_EN > 0u
\ In section .text, align 2, keep-with-next
214 INT8U OSMemNameGet (OS_MEM *pmem,
215 INT8U **pname,
216 INT8U *perr)
217 {
\ OSMemNameGet:
\ 00000000 2DE9F041 PUSH {R4-R8,LR}
\ 00000004 0400 MOVS R4,R0
\ 00000006 0D00 MOVS R5,R1
\ 00000008 1600 MOVS R6,R2
218 INT8U len;
219 #if OS_CRITICAL_METHOD == 3u /* Allocate storage for CPU status register */
220 OS_CPU_SR cpu_sr = 0u;
\ 0000000A 5FF00008 MOVS R8,#+0
221 #endif
222
223
224
225 #ifdef OS_SAFETY_CRITICAL
226 if (perr == (INT8U *)0) {
227 OS_SAFETY_CRITICAL_EXCEPTION();
228 return (0u);
229 }
230 #endif
231
232 #if OS_ARG_CHK_EN > 0u
233 if (pmem == (OS_MEM *)0) { /* Is 'pmem' a NULL pointer? */
234 *perr = OS_ERR_MEM_INVALID_PMEM;
235 return (0u);
236 }
237 if (pname == (INT8U **)0) { /* Is 'pname' a NULL pointer? */
238 *perr = OS_ERR_PNAME_NULL;
239 return (0u);
240 }
241 #endif
242 if (OSIntNesting > 0u) { /* See if trying to call from an ISR */
\ 0000000E .... LDR.N R0,??DataTable4_2
\ 00000010 0078 LDRB R0,[R0, #+0]
\ 00000012 0028 CMP R0,#+0
\ 00000014 03D0 BEQ.N ??OSMemNameGet_0
243 *perr = OS_ERR_NAME_GET_ISR;
\ 00000016 1120 MOVS R0,#+17
\ 00000018 3070 STRB R0,[R6, #+0]
244 return (0u);
\ 0000001A 0020 MOVS R0,#+0
\ 0000001C 0FE0 B.N ??OSMemNameGet_1
245 }
246 OS_ENTER_CRITICAL();
\ ??OSMemNameGet_0:
\ 0000001E ........ BL OS_CPU_SR_Save
\ 00000022 8046 MOV R8,R0
247 *pname = pmem->OSMemName;
\ 00000024 6069 LDR R0,[R4, #+20]
\ 00000026 2860 STR R0,[R5, #+0]
248 len = OS_StrLen(*pname);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -