📄 heap_1.lst
字号:
##############################################################################
# #
# IAR MSP430 C/C++ Compiler V3.41A/W32 22/Apr/2006 00:25:14 #
# Copyright 1996-2006 IAR Systems. All rights reserved. #
# #
# __rt_version = 2 #
# __double_size = 32 #
# __reg_r4 = free #
# __reg_r5 = free #
# __pic = no #
# __core = 64kb #
# Source file = C:\MSP430F169_Eval_Port\FreeRTOSv401\Source\portable\M #
# emMang\heap_1.c #
# Command line = C:\MSP430F169_Eval_Port\FreeRTOSv401\Source\portable\M #
# emMang\heap_1.c -D ROWLEY_MSP430 -D IAR_MSP430 -lC #
# C:\MSP430F169_Eval_Port\FreeRTOSv401\Debug\List\ -lA #
# C:\MSP430F169_Eval_Port\FreeRTOSv401\Debug\List\ #
# --remarks -o C:\MSP430F169_Eval_Port\FreeRTOSv401\Debu #
# g\Obj\ -s2 --no_cse --no_unroll --no_inline #
# --no_code_motion --no_tbaa --debug -e #
# --migration_preprocessor_extensions --double=32 -I #
# C:\MSP430F169_Eval_Port\FreeRTOSv401\Demo\Common\Inclu #
# de\ -I C:\MSP430F169_Eval_Port\FreeRTOSv401\Source\Inc #
# lude\ -I C:\MSP430F169_Eval_Port\FreeRTOSv401\Demo\MSP #
# 430_IAR\ -I C:\MSP430F169_Eval_Port\FreeRTOSv401\Sourc #
# e\portable\msp430f1611\ -I "C:\Program Files\IAR #
# Systems\Embedded Workbench 4.0\430\INC\" -I #
# "C:\Program Files\IAR Systems\Embedded Workbench #
# 4.0\430\INC\CLIB\" #
# List file = C:\MSP430F169_Eval_Port\FreeRTOSv401\Debug\List\heap_1 #
# .lst #
# Object file = C:\MSP430F169_Eval_Port\FreeRTOSv401\Debug\Obj\heap_1. #
# r43 #
# #
# #
##############################################################################
C:\MSP430F169_Eval_Port\FreeRTOSv401\Source\portable\MemMang\heap_1.c
1 /*
2 FreeRTOS V4.0.1 - Copyright (C) 2003-2006 Richard Barry.
3
4 This file is part of the FreeRTOS distribution.
5
6 FreeRTOS is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 FreeRTOS is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with FreeRTOS; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
20 A special exception to the GPL can be applied should you wish to distribute
21 a combined work that includes FreeRTOS, without being obliged to provide
22 the source code for any proprietary components. See the licensing section
23 of http://www.FreeRTOS.org for full details of how and when the exception
24 can be applied.
25
26 ***************************************************************************
27 See http://www.FreeRTOS.org for documentation, latest information, license
28 and contact details. Please ensure to read the configuration and relevant
29 port sections of the online documentation.
30 ***************************************************************************
31 */
32
33 /*
34
35 Changes between V2.5.1 and V2.5.1
36
37 + The memory pool has been defined within a struct to ensure correct memory
38 alignment on 32bit systems.
39
40 Changes between V2.6.1 and V3.0.0
41
42 + An overflow check has been added to ensure the next free byte variable
43 does not wrap around.
44 */
45
46
47 /*
48 * The simplest possible implementation of pvPortMalloc(). Note that this
49 * implementation does NOT allow allocated memory to be freed again.
50 *
51 * See heap_2.c and heap_3.c for alternative implementations, and the memory
52 * management pages of http://www.FreeRTOS.org for more information.
53 */
54 #include <stdlib.h>
55 #include "FreeRTOS.h"
56 #include "task.h"
57
58 /* Setup the correct byte alignment mask for the defined byte alignment. */
59 #if portBYTE_ALIGNMENT == 4
60 #define heapBYTE_ALIGNMENT_MASK ( ( size_t ) 0x0003 )
61 #endif
62
63 #if portBYTE_ALIGNMENT == 2
64 #define heapBYTE_ALIGNMENT_MASK ( ( size_t ) 0x0001 )
65 #endif
66
67 #if portBYTE_ALIGNMENT == 1
68 #define heapBYTE_ALIGNMENT_MASK ( ( size_t ) 0x0000 )
69 #endif
70
71 #ifndef heapBYTE_ALIGNMENT_MASK
72 #error "Invalid portBYTE_ALIGNMENT definition"
73 #endif
74
75 /* Allocate the memory for the heap. The struct is used to force byte
76 alignment without using any non-portable code. */
77 static struct xRTOS_HEAP
78 {
79 unsigned portLONG ulDummy;
80 unsigned portCHAR ucHeap[ configTOTAL_HEAP_SIZE ];
\ In segment DATA16_Z, align 2, align-sorted
\ 000000 REQUIRE ?cstart_init_zero
81 } xHeap;
\ xHeap:
\ 000000 DS8 9254
82
\ In segment DATA16_Z, align 2, align-sorted
\ 000000 REQUIRE ?cstart_init_zero
83 static size_t xNextFreeByte = ( size_t ) 0;
\ xNextFreeByte:
\ 000000 DS8 2
84 /*-----------------------------------------------------------*/
85
\ In segment CODE, align 2
86 void *pvPortMalloc( size_t xWantedSize )
\ pvPortMalloc:
87 {
\ 000000 0A12 PUSH.W R10
\ 000002 0B12 PUSH.W R11
\ 000004 0A4C MOV.W R12, R10
88 void *pvReturn = NULL;
\ 000006 0B43 MOV.W #0x0, R11
89
90 /* Ensure that blocks are always aligned to the required number of bytes. */
91 #if portBYTE_ALIGNMENT != 1
92 if( xWantedSize & heapBYTE_ALIGNMENT_MASK )
\ 000008 1AB3 BIT.W #0x1, R10
\ 00000A 0628 JNC ??pvPortMalloc_0
93 {
94 /* Byte alignment required. */
95 xWantedSize += ( portBYTE_ALIGNMENT - ( xWantedSize & heapBYTE_ALIGNMENT_MASK ) );
\ 00000C 0E4A MOV.W R10, R14
\ 00000E 2E53 ADD.W #0x2, R14
\ 000010 0F4A MOV.W R10, R15
\ 000012 1FF3 AND.W #0x1, R15
\ 000014 0A4E MOV.W R14, R10
\ 000016 0A8F SUB.W R15, R10
96 }
97 #endif
98
99 vTaskSuspendAll();
\ ??pvPortMalloc_0:
\ 000018 B012.... CALL #vTaskSuspendAll
100 {
101 /* Check there is enough room left for the allocation. */
102 if( ( ( xNextFreeByte + xWantedSize ) < configTOTAL_HEAP_SIZE ) &&
103 ( ( xNextFreeByte + xWantedSize ) > xNextFreeByte ) )/* Check for overflow. */
\ 00001C 0F4A MOV.W R10, R15
\ 00001E 1F52.... ADD.W &xNextFreeByte, R15
\ 000022 3F902224 CMP.W #0x2422, R15
\ 000026 0D2C JC ??pvPortMalloc_1
\ 000028 0F4A MOV.W R10, R15
\ 00002A 1F52.... ADD.W &xNextFreeByte, R15
\ 00002E 829F.... CMP.W R15, &xNextFreeByte
\ 000032 072C JC ??pvPortMalloc_1
104 {
105 /* Return the next free byte then increment the index past this
106 block. */
107 pvReturn = &( xHeap.ucHeap[ xNextFreeByte ] );
\ 000034 3F40.... MOV.W #xHeap + 4, R15
\ 000038 1F52.... ADD.W &xNextFreeByte, R15
\ 00003C 0B4F MOV.W R15, R11
108 xNextFreeByte += xWantedSize;
\ 00003E 825A.... ADD.W R10, &xNextFreeByte
109 }
110 }
111 xTaskResumeAll();
\ ??pvPortMalloc_1:
\ 000042 B012.... CALL #xTaskResumeAll
112
113 return pvReturn;
\ 000046 0C4B MOV.W R11, R12
\ 000048 3B41 POP.W R11
\ 00004A 3A41 POP.W R10
\ 00004C 3041 RET
114 }
115 /*-----------------------------------------------------------*/
116
\ In segment CODE, align 2
117 void vPortFree( void *pv )
\ vPortFree:
118 {
119 /* Memory cannot be freed using this scheme. See heap_2.c and heap_3.c
120 for alternative implementations, and the memory management pages of
121 http://www.FreeRTOS.org for more information. */
122 ( void ) pv;
123 }
\ 000000 3041 RET
124 /*-----------------------------------------------------------*/
125
\ In segment CODE, align 2
126 void vPortInitialiseBlocks( void )
\ vPortInitialiseBlocks:
127 {
128 /* Only required when static memory is not cleared. */
129 xNextFreeByte = ( size_t ) 0;
\ 000000 8243.... MOV.W #0x0, &xNextFreeByte
130 }
\ 000004 3041 RET
131
132
Maximum stack usage in bytes:
Function CSTACK
-------- ------
pvPortMalloc 6
-> vTaskSuspendAll 6
-> xTaskResumeAll 6
vPortFree 2
vPortInitialiseBlocks 2
Segment part sizes:
Function/Label Bytes
-------------- -----
xHeap 9254
xNextFreeByte 2
pvPortMalloc 78
vPortFree 2
vPortInitialiseBlocks 6
86 bytes in segment CODE
9 256 bytes in segment DATA16_Z
86 bytes of CODE memory
9 256 bytes of DATA memory
Errors: none
Warnings: none
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -