📄 os_mem.lst
字号:
\ 00000078 141094E2 ADDS R1,R4,#+20
\ 0000007C 0500B0E1 MOVS R0,R5
\ 00000080 ........ _BLF OS_StrCopy,??OS_StrCopy??rA
\ 00000084 0070B0E1 MOVS R7,R0
223 OS_EXIT_CRITICAL();
\ 00000088 0800B0E1 MOVS R0,R8
\ 0000008C ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rA
224 *err = OS_ERR_NONE;
\ 00000090 0000A0E3 MOV R0,#+0
\ 00000094 0000C6E5 STRB R0,[R6, #+0]
225 return (len);
\ 00000098 0700B0E1 MOVS R0,R7
\ ??OSMemNameGet_1:
\ 0000009C F081BDE8 POP {R4-R8,PC} ;; return
226 }
227 #endif
228
229 /*$PAGE*/
230 /*
231 *********************************************************************************************************
232 * ASSIGN A NAME TO A MEMORY PARTITION
233 *
234 * Description: This function assigns a name to a memory partition.
235 *
236 * Arguments : pmem is a pointer to the memory partition
237 *
238 * pname is a pointer to an ASCII string that contains the name of the memory partition.
239 *
240 * err is a pointer to an error code that can contain one of the following values:
241 *
242 * OS_ERR_NONE if the name was copied to 'pname'
243 * OS_ERR_MEM_INVALID_PMEM if you passed a NULL pointer for 'pmem'
244 * OS_ERR_PNAME_NULL You passed a NULL pointer for 'pname'
245 * OS_ERR_MEM_NAME_TOO_LONG if the name doesn't fit in the storage area
246 *
247 * Returns : None
248 *********************************************************************************************************
249 */
250
251 #if OS_MEM_NAME_SIZE > 1
\ In segment CODE, align 4, keep-with-next
252 void OSMemNameSet (OS_MEM *pmem, INT8U *pname, INT8U *err)
253 {
\ OSMemNameSet:
\ 00000000 F0412DE9 PUSH {R4-R8,LR}
\ 00000004 0040B0E1 MOVS R4,R0
\ 00000008 0150B0E1 MOVS R5,R1
\ 0000000C 0260B0E1 MOVS R6,R2
254 INT8U len;
255 #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
256 OS_CPU_SR cpu_sr = 0;
\ 00000010 0000A0E3 MOV R0,#+0
\ 00000014 0080B0E1 MOVS R8,R0
257 #endif
258
259
260
261 OS_ENTER_CRITICAL();
\ 00000018 ........ _BLF OS_CPU_SR_Save,??OS_CPU_SR_Save??rA
\ 0000001C 0080B0E1 MOVS R8,R0
262 #if OS_ARG_CHK_EN > 0
263 if (err == (INT8U *)0) { /* Validate 'err' */
\ 00000020 000056E3 CMP R6,#+0
\ 00000024 0200001A BNE ??OSMemNameSet_0
264 OS_EXIT_CRITICAL();
\ 00000028 0800B0E1 MOVS R0,R8
\ 0000002C ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rA
265 return;
\ 00000030 1E0000EA B ??OSMemNameSet_1
266 }
267 if (pmem == (OS_MEM *)0) { /* Is 'pmem' a NULL pointer? */
\ ??OSMemNameSet_0:
\ 00000034 000054E3 CMP R4,#+0
\ 00000038 0400001A BNE ??OSMemNameSet_2
268 OS_EXIT_CRITICAL(); /* Yes */
\ 0000003C 0800B0E1 MOVS R0,R8
\ 00000040 ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rA
269 *err = OS_ERR_MEM_INVALID_PMEM;
\ 00000044 6000A0E3 MOV R0,#+96
\ 00000048 0000C6E5 STRB R0,[R6, #+0]
270 return;
\ 0000004C 170000EA B ??OSMemNameSet_1
271 }
272 if (pname == (INT8U *)0) { /* Is 'pname' a NULL pointer? */
\ ??OSMemNameSet_2:
\ 00000050 000055E3 CMP R5,#+0
\ 00000054 0400001A BNE ??OSMemNameSet_3
273 OS_EXIT_CRITICAL(); /* Yes */
\ 00000058 0800B0E1 MOVS R0,R8
\ 0000005C ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rA
274 *err = OS_ERR_PNAME_NULL;
\ 00000060 0C00A0E3 MOV R0,#+12
\ 00000064 0000C6E5 STRB R0,[R6, #+0]
275 return;
\ 00000068 100000EA B ??OSMemNameSet_1
276 }
277 #endif
278 len = OS_StrLen(pname); /* Can we fit the string in the storage area? */
\ ??OSMemNameSet_3:
\ 0000006C 0500B0E1 MOVS R0,R5
\ 00000070 ........ _BLF OS_StrLen,??OS_StrLen??rA
\ 00000074 0070B0E1 MOVS R7,R0
279 if (len > (OS_MEM_NAME_SIZE - 1)) { /* No */
\ 00000078 100057E3 CMP R7,#+16
\ 0000007C 0400003A BCC ??OSMemNameSet_4
280 OS_EXIT_CRITICAL();
\ 00000080 0800B0E1 MOVS R0,R8
\ 00000084 ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rA
281 *err = OS_ERR_MEM_NAME_TOO_LONG;
\ 00000088 6300A0E3 MOV R0,#+99
\ 0000008C 0000C6E5 STRB R0,[R6, #+0]
282 return;
\ 00000090 060000EA B ??OSMemNameSet_1
283 }
284 (void)OS_StrCopy(pmem->OSMemName, pname); /* Yes, copy name to the memory partition header */
\ ??OSMemNameSet_4:
\ 00000094 0510B0E1 MOVS R1,R5
\ 00000098 140094E2 ADDS R0,R4,#+20
\ 0000009C ........ _BLF OS_StrCopy,??OS_StrCopy??rA
285 OS_EXIT_CRITICAL();
\ 000000A0 0800B0E1 MOVS R0,R8
\ 000000A4 ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rA
286 *err = OS_ERR_NONE;
\ 000000A8 0000A0E3 MOV R0,#+0
\ 000000AC 0000C6E5 STRB R0,[R6, #+0]
287 }
\ ??OSMemNameSet_1:
\ 000000B0 F081BDE8 POP {R4-R8,PC} ;; return
288 #endif
289
290 /*$PAGE*/
291 /*
292 *********************************************************************************************************
293 * RELEASE A MEMORY BLOCK
294 *
295 * Description : Returns a memory block to a partition
296 *
297 * Arguments : pmem is a pointer to the memory partition control block
298 *
299 * pblk is a pointer to the memory block being released.
300 *
301 * Returns : OS_ERR_NONE if the memory block was inserted into the partition
302 * OS_ERR_MEM_FULL if you are returning a memory block to an already FULL memory
303 * partition (You freed more blocks than you allocated!)
304 * OS_ERR_MEM_INVALID_PMEM if you passed a NULL pointer for 'pmem'
305 * OS_ERR_MEM_INVALID_PBLK if you passed a NULL pointer for the block to release.
306 *********************************************************************************************************
307 */
308
\ In segment CODE, align 4, keep-with-next
309 INT8U OSMemPut (OS_MEM *pmem, void *pblk)
310 {
\ OSMemPut:
\ 00000000 70402DE9 PUSH {R4-R6,LR}
\ 00000004 0040B0E1 MOVS R4,R0
\ 00000008 0150B0E1 MOVS R5,R1
311 #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
312 OS_CPU_SR cpu_sr = 0;
\ 0000000C 0000A0E3 MOV R0,#+0
\ 00000010 0060B0E1 MOVS R6,R0
313 #endif
314
315
316
317 #if OS_ARG_CHK_EN > 0
318 if (pmem == (OS_MEM *)0) { /* Must point to a valid memory partition */
\ 00000014 000054E3 CMP R4,#+0
\ 00000018 0100001A BNE ??OSMemPut_0
319 return (OS_ERR_MEM_INVALID_PMEM);
\ 0000001C 6000A0E3 MOV R0,#+96
\ 00000020 160000EA B ??OSMemPut_1
320 }
321 if (pblk == (void *)0) { /* Must release a valid block */
\ ??OSMemPut_0:
\ 00000024 000055E3 CMP R5,#+0
\ 00000028 0100001A BNE ??OSMemPut_2
322 return (OS_ERR_MEM_INVALID_PBLK);
\ 0000002C 5F00A0E3 MOV R0,#+95
\ 00000030 120000EA B ??OSMemPut_1
323 }
324 #endif
325 OS_ENTER_CRITICAL();
\ ??OSMemPut_2:
\ 00000034 ........ _BLF OS_CPU_SR_Save,??OS_CPU_SR_Save??rA
\ 00000038 0060B0E1 MOVS R6,R0
326 if (pmem->OSMemNFree >= pmem->OSMemNBlks) { /* Make sure all blocks not already returned */
\ 0000003C 100094E5 LDR R0,[R4, #+16]
\ 00000040 0C1094E5 LDR R1,[R4, #+12]
\ 00000044 010050E1 CMP R0,R1
\ 00000048 0300003A BCC ??OSMemPut_3
327 OS_EXIT_CRITICAL();
\ 0000004C 0600B0E1 MOVS R0,R6
\ 00000050 ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rA
328 return (OS_ERR_MEM_FULL);
\ 00000054 5E00A0E3 MOV R0,#+94
\ 00000058 080000EA B ??OSMemPut_1
329 }
330 *(void **)pblk = pmem->OSMemFreeList; /* Insert released block into free block list */
\ ??OSMemPut_3:
\ 0000005C 040094E5 LDR R0,[R4, #+4]
\ 00000060 000085E5 STR R0,[R5, #+0]
331 pmem->OSMemFreeList = pblk;
\ 00000064 045084E5 STR R5,[R4, #+4]
332 pmem->OSMemNFree++; /* One more memory block in this partition */
\ 00000068 100094E5 LDR R0,[R4, #+16]
\ 0000006C 010090E2 ADDS R0,R0,#+1
\ 00000070 100084E5 STR R0,[R4, #+16]
333 OS_EXIT_CRITICAL();
\ 00000074 0600B0E1 MOVS R0,R6
\ 00000078 ........ _BLF OS_CPU_SR_Restore,??OS_CPU_SR_Restore??rA
334 return (OS_ERR_NONE); /* Notify caller that memory block was released */
\ 0000007C 0000A0E3 MOV R0,#+0
\ ??OSMemPut_1:
\ 00000080 7080BDE8 POP {R4-R6,PC} ;; return
335 }
336 /*$PAGE*/
337 /*
338 *********************************************************************************************************
339 * QUERY MEMORY PARTITION
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -