📄 os_mem.lst
字号:
\ 00000028 2868 LDR R0,[R5, #+0]
\ 0000002A ........ BL OS_StrLen
\ 0000002E 0700 MOVS R7,R0
249 OS_EXIT_CRITICAL();
\ 00000030 4046 MOV R0,R8
\ 00000032 ........ BL OS_CPU_SR_Restore
250 *perr = OS_ERR_NONE;
\ 00000036 0020 MOVS R0,#+0
\ 00000038 3070 STRB R0,[R6, #+0]
251 return (len);
\ 0000003A 3800 MOVS R0,R7
\ 0000003C C0B2 UXTB R0,R0 ;; ZeroExt R0,R0,#+24,#+24
\ ??OSMemNameGet_1:
\ 0000003E BDE8F081 POP {R4-R8,PC} ;; return
252 }
253 #endif
254
255 /*$PAGE*/
256 /*
257 *********************************************************************************************************
258 * ASSIGN A NAME TO A MEMORY PARTITION
259 *
260 * Description: This function assigns a name to a memory partition.
261 *
262 * Arguments : pmem is a pointer to the memory partition
263 *
264 * pname is a pointer to an ASCII string that contains the name of the memory partition.
265 *
266 * perr is a pointer to an error code that can contain one of the following values:
267 *
268 * OS_ERR_NONE if the name was copied to 'pname'
269 * OS_ERR_MEM_INVALID_PMEM if you passed a NULL pointer for 'pmem'
270 * OS_ERR_PNAME_NULL You passed a NULL pointer for 'pname'
271 * OS_ERR_MEM_NAME_TOO_LONG if the name doesn't fit in the storage area
272 * OS_ERR_NAME_SET_ISR if you called this function from an ISR
273 *
274 * Returns : None
275 *********************************************************************************************************
276 */
277
278 #if OS_MEM_NAME_EN > 0u
\ In section .text, align 2, keep-with-next
279 void OSMemNameSet (OS_MEM *pmem,
280 INT8U *pname,
281 INT8U *perr)
282 {
\ OSMemNameSet:
\ 00000000 F8B5 PUSH {R3-R7,LR}
\ 00000002 0400 MOVS R4,R0
\ 00000004 0D00 MOVS R5,R1
\ 00000006 1600 MOVS R6,R2
283 #if OS_CRITICAL_METHOD == 3u /* Allocate storage for CPU status register */
284 OS_CPU_SR cpu_sr = 0u;
\ 00000008 0027 MOVS R7,#+0
285 #endif
286
287
288
289 #ifdef OS_SAFETY_CRITICAL
290 if (perr == (INT8U *)0) {
291 OS_SAFETY_CRITICAL_EXCEPTION();
292 return;
293 }
294 #endif
295
296 #if OS_ARG_CHK_EN > 0u
297 if (pmem == (OS_MEM *)0) { /* Is 'pmem' a NULL pointer? */
298 *perr = OS_ERR_MEM_INVALID_PMEM;
299 return;
300 }
301 if (pname == (INT8U *)0) { /* Is 'pname' a NULL pointer? */
302 *perr = OS_ERR_PNAME_NULL;
303 return;
304 }
305 #endif
306 if (OSIntNesting > 0u) { /* See if trying to call from an ISR */
\ 0000000A .... LDR.N R0,??DataTable4_2
\ 0000000C 0078 LDRB R0,[R0, #+0]
\ 0000000E 0028 CMP R0,#+0
\ 00000010 02D0 BEQ.N ??OSMemNameSet_0
307 *perr = OS_ERR_NAME_SET_ISR;
\ 00000012 1220 MOVS R0,#+18
\ 00000014 3070 STRB R0,[R6, #+0]
308 return;
\ 00000016 08E0 B.N ??OSMemNameSet_1
309 }
310 OS_ENTER_CRITICAL();
\ ??OSMemNameSet_0:
\ 00000018 ........ BL OS_CPU_SR_Save
\ 0000001C 0700 MOVS R7,R0
311 pmem->OSMemName = pname;
\ 0000001E 6561 STR R5,[R4, #+20]
312 OS_EXIT_CRITICAL();
\ 00000020 3800 MOVS R0,R7
\ 00000022 ........ BL OS_CPU_SR_Restore
313 *perr = OS_ERR_NONE;
\ 00000026 0020 MOVS R0,#+0
\ 00000028 3070 STRB R0,[R6, #+0]
314 }
\ ??OSMemNameSet_1:
\ 0000002A F1BD POP {R0,R4-R7,PC} ;; return
315 #endif
316
317 /*$PAGE*/
318 /*
319 *********************************************************************************************************
320 * RELEASE A MEMORY BLOCK
321 *
322 * Description : Returns a memory block to a partition
323 *
324 * Arguments : pmem is a pointer to the memory partition control block
325 *
326 * pblk is a pointer to the memory block being released.
327 *
328 * Returns : OS_ERR_NONE if the memory block was inserted into the partition
329 * OS_ERR_MEM_FULL if you are returning a memory block to an already FULL memory
330 * partition (You freed more blocks than you allocated!)
331 * OS_ERR_MEM_INVALID_PMEM if you passed a NULL pointer for 'pmem'
332 * OS_ERR_MEM_INVALID_PBLK if you passed a NULL pointer for the block to release.
333 *********************************************************************************************************
334 */
335
\ In section .text, align 2, keep-with-next
336 INT8U OSMemPut (OS_MEM *pmem,
337 void *pblk)
338 {
\ OSMemPut:
\ 00000000 70B5 PUSH {R4-R6,LR}
\ 00000002 0400 MOVS R4,R0
\ 00000004 0D00 MOVS R5,R1
339 #if OS_CRITICAL_METHOD == 3u /* Allocate storage for CPU status register */
340 OS_CPU_SR cpu_sr = 0u;
\ 00000006 0026 MOVS R6,#+0
341 #endif
342
343
344
345 #if OS_ARG_CHK_EN > 0u
346 if (pmem == (OS_MEM *)0) { /* Must point to a valid memory partition */
347 return (OS_ERR_MEM_INVALID_PMEM);
348 }
349 if (pblk == (void *)0) { /* Must release a valid block */
350 return (OS_ERR_MEM_INVALID_PBLK);
351 }
352 #endif
353 OS_ENTER_CRITICAL();
\ 00000008 ........ BL OS_CPU_SR_Save
\ 0000000C 0600 MOVS R6,R0
354 if (pmem->OSMemNFree >= pmem->OSMemNBlks) { /* Make sure all blocks not already returned */
\ 0000000E 2069 LDR R0,[R4, #+16]
\ 00000010 E168 LDR R1,[R4, #+12]
\ 00000012 8842 CMP R0,R1
\ 00000014 04D3 BCC.N ??OSMemPut_0
355 OS_EXIT_CRITICAL();
\ 00000016 3000 MOVS R0,R6
\ 00000018 ........ BL OS_CPU_SR_Restore
356 return (OS_ERR_MEM_FULL);
\ 0000001C 5E20 MOVS R0,#+94
\ 0000001E 09E0 B.N ??OSMemPut_1
357 }
358 *(void **)pblk = pmem->OSMemFreeList; /* Insert released block into free block list */
\ ??OSMemPut_0:
\ 00000020 6068 LDR R0,[R4, #+4]
\ 00000022 2860 STR R0,[R5, #+0]
359 pmem->OSMemFreeList = pblk;
\ 00000024 6560 STR R5,[R4, #+4]
360 pmem->OSMemNFree++; /* One more memory block in this partition */
\ 00000026 2069 LDR R0,[R4, #+16]
\ 00000028 401C ADDS R0,R0,#+1
\ 0000002A 2061 STR R0,[R4, #+16]
361 OS_EXIT_CRITICAL();
\ 0000002C 3000 MOVS R0,R6
\ 0000002E ........ BL OS_CPU_SR_Restore
362 return (OS_ERR_NONE); /* Notify caller that memory block was released */
\ 00000032 0020 MOVS R0,#+0
\ ??OSMemPut_1:
\ 00000034 70BD POP {R4-R6,PC} ;; return
363 }
364 /*$PAGE*/
365 /*
366 *********************************************************************************************************
367 * QUERY MEMORY PARTITION
368 *
369 * Description : This function is used to determine the number of free memory blocks and the number of
370 * used memory blocks from a memory partition.
371 *
372 * Arguments : pmem is a pointer to the memory partition control block
373 *
374 * p_mem_data is a pointer to a structure that will contain information about the memory
375 * partition.
376 *
377 * Returns : OS_ERR_NONE if no errors were found.
378 * OS_ERR_MEM_INVALID_PMEM if you passed a NULL pointer for 'pmem'
379 * OS_ERR_MEM_INVALID_PDATA if you passed a NULL pointer to the data recipient.
380 *********************************************************************************************************
381 */
382
383 #if OS_MEM_QUERY_EN > 0u
\ In section .text, align 2, keep-with-next
384 INT8U OSMemQuery (OS_MEM *pmem,
385 OS_MEM_DATA *p_mem_data)
386 {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -