⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 heap_2.lst

📁 great linker script for your uC LPC 2148 with usb support
💻 LST
📖 第 1 页 / 共 2 页
字号:
   1              		.code	16
   2              		.file	"heap_2.c"
  10              	.Ltext0:
  11              		.align	2
  12              		.global	vPortFree
  13              		.code 16
  14              		.thumb_func
  16              	vPortFree:
  17              	.LFB3:
  18              		.file 1 "rtos/Source/portable/MemMang/heap_2.c"
   1:rtos/Source/portable/MemMang/heap_2.c **** /*
   2:rtos/Source/portable/MemMang/heap_2.c **** 	FreeRTOS.org V4.1.1 - Copyright (C) 2003-2006 Richard Barry.
   3:rtos/Source/portable/MemMang/heap_2.c **** 
   4:rtos/Source/portable/MemMang/heap_2.c **** 	This file is part of the FreeRTOS.org distribution.
   5:rtos/Source/portable/MemMang/heap_2.c **** 
   6:rtos/Source/portable/MemMang/heap_2.c **** 	FreeRTOS.org is free software; you can redistribute it and/or modify
   7:rtos/Source/portable/MemMang/heap_2.c **** 	it under the terms of the GNU General Public License as published by
   8:rtos/Source/portable/MemMang/heap_2.c **** 	the Free Software Foundation; either version 2 of the License, or
   9:rtos/Source/portable/MemMang/heap_2.c **** 	(at your option) any later version.
  10:rtos/Source/portable/MemMang/heap_2.c **** 
  11:rtos/Source/portable/MemMang/heap_2.c **** 	FreeRTOS.org is distributed in the hope that it will be useful,
  12:rtos/Source/portable/MemMang/heap_2.c **** 	but WITHOUT ANY WARRANTY; without even the implied warranty of
  13:rtos/Source/portable/MemMang/heap_2.c **** 	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14:rtos/Source/portable/MemMang/heap_2.c **** 	GNU General Public License for more details.
  15:rtos/Source/portable/MemMang/heap_2.c **** 
  16:rtos/Source/portable/MemMang/heap_2.c **** 	You should have received a copy of the GNU General Public License
  17:rtos/Source/portable/MemMang/heap_2.c **** 	along with FreeRTOS.org; if not, write to the Free Software
  18:rtos/Source/portable/MemMang/heap_2.c **** 	Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  19:rtos/Source/portable/MemMang/heap_2.c **** 
  20:rtos/Source/portable/MemMang/heap_2.c **** 	A special exception to the GPL can be applied should you wish to distribute
  21:rtos/Source/portable/MemMang/heap_2.c **** 	a combined work that includes FreeRTOS.org, without being obliged to provide
  22:rtos/Source/portable/MemMang/heap_2.c **** 	the source code for any proprietary components.  See the licensing section
  23:rtos/Source/portable/MemMang/heap_2.c **** 	of http://www.FreeRTOS.org for full details of how and when the exception
  24:rtos/Source/portable/MemMang/heap_2.c **** 	can be applied.
  25:rtos/Source/portable/MemMang/heap_2.c **** 
  26:rtos/Source/portable/MemMang/heap_2.c **** 	***************************************************************************
  27:rtos/Source/portable/MemMang/heap_2.c **** 	See http://www.FreeRTOS.org for documentation, latest information, license
  28:rtos/Source/portable/MemMang/heap_2.c **** 	and contact details.  Please ensure to read the configuration and relevant
  29:rtos/Source/portable/MemMang/heap_2.c **** 	port sections of the online documentation.
  30:rtos/Source/portable/MemMang/heap_2.c **** 	***************************************************************************
  31:rtos/Source/portable/MemMang/heap_2.c **** */
  32:rtos/Source/portable/MemMang/heap_2.c **** 
  33:rtos/Source/portable/MemMang/heap_2.c **** /*
  34:rtos/Source/portable/MemMang/heap_2.c ****  * A sample implementation of pvPortMalloc() and vPortFree() that permits
  35:rtos/Source/portable/MemMang/heap_2.c ****  * allocated blocks to be freed, but does not combine adjacent free blocks
  36:rtos/Source/portable/MemMang/heap_2.c ****  * into a single larger block.
  37:rtos/Source/portable/MemMang/heap_2.c ****  *
  38:rtos/Source/portable/MemMang/heap_2.c ****  * See heap_1.c and heap_3.c for alternative implementations, and the memory
  39:rtos/Source/portable/MemMang/heap_2.c ****  * management pages of http://www.FreeRTOS.org for more information.
  40:rtos/Source/portable/MemMang/heap_2.c ****  */
  41:rtos/Source/portable/MemMang/heap_2.c **** #include <stdlib.h>
  42:rtos/Source/portable/MemMang/heap_2.c **** 
  43:rtos/Source/portable/MemMang/heap_2.c **** #include "FreeRTOS.h"
  44:rtos/Source/portable/MemMang/heap_2.c **** #include "task.h"
  45:rtos/Source/portable/MemMang/heap_2.c **** 
  46:rtos/Source/portable/MemMang/heap_2.c **** /* Setup the correct byte alignment mask for the defined byte alignment. */
  47:rtos/Source/portable/MemMang/heap_2.c **** #if portBYTE_ALIGNMENT == 4
  48:rtos/Source/portable/MemMang/heap_2.c **** 	#define heapBYTE_ALIGNMENT_MASK	( ( size_t ) 0x0003 )
  49:rtos/Source/portable/MemMang/heap_2.c **** #endif
  50:rtos/Source/portable/MemMang/heap_2.c **** 
  51:rtos/Source/portable/MemMang/heap_2.c **** #if portBYTE_ALIGNMENT == 2
  52:rtos/Source/portable/MemMang/heap_2.c **** 	#define heapBYTE_ALIGNMENT_MASK	( ( size_t ) 0x0001 )
  53:rtos/Source/portable/MemMang/heap_2.c **** #endif
  54:rtos/Source/portable/MemMang/heap_2.c **** 
  55:rtos/Source/portable/MemMang/heap_2.c **** #if portBYTE_ALIGNMENT == 1
  56:rtos/Source/portable/MemMang/heap_2.c **** 	#define heapBYTE_ALIGNMENT_MASK	( ( size_t ) 0x0000 )
  57:rtos/Source/portable/MemMang/heap_2.c **** #endif
  58:rtos/Source/portable/MemMang/heap_2.c **** 
  59:rtos/Source/portable/MemMang/heap_2.c **** #ifndef heapBYTE_ALIGNMENT_MASK
  60:rtos/Source/portable/MemMang/heap_2.c **** 	#error "Invalid portBYTE_ALIGNMENT definition"
  61:rtos/Source/portable/MemMang/heap_2.c **** #endif
  62:rtos/Source/portable/MemMang/heap_2.c **** 
  63:rtos/Source/portable/MemMang/heap_2.c **** /* Allocate the memory for the heap.  The struct is used to force byte
  64:rtos/Source/portable/MemMang/heap_2.c **** alignment without using any non-portable code. */
  65:rtos/Source/portable/MemMang/heap_2.c **** static struct xRTOS_HEAP
  66:rtos/Source/portable/MemMang/heap_2.c **** {
  67:rtos/Source/portable/MemMang/heap_2.c **** 	unsigned portLONG ulDummy;
  68:rtos/Source/portable/MemMang/heap_2.c **** 	unsigned portCHAR ucHeap[ configTOTAL_HEAP_SIZE ];
  69:rtos/Source/portable/MemMang/heap_2.c **** } xHeap;
  70:rtos/Source/portable/MemMang/heap_2.c **** 
  71:rtos/Source/portable/MemMang/heap_2.c **** /* Define the linked list structure.  This is used to link free blocks in order
  72:rtos/Source/portable/MemMang/heap_2.c **** of their size. */
  73:rtos/Source/portable/MemMang/heap_2.c **** typedef struct A_BLOCK_LINK
  74:rtos/Source/portable/MemMang/heap_2.c **** {
  75:rtos/Source/portable/MemMang/heap_2.c **** 	struct A_BLOCK_LINK *pxNextFreeBlock;	/*<< The next free block in the list. */
  76:rtos/Source/portable/MemMang/heap_2.c **** 	size_t xBlockSize;						/*<< The size of the free block. */
  77:rtos/Source/portable/MemMang/heap_2.c **** } xBlockLink;
  78:rtos/Source/portable/MemMang/heap_2.c **** 
  79:rtos/Source/portable/MemMang/heap_2.c **** 
  80:rtos/Source/portable/MemMang/heap_2.c **** static const unsigned portSHORT  heapSTRUCT_SIZE	= ( sizeof( xBlockLink ) + ( sizeof( xBlockLink ) 
  81:rtos/Source/portable/MemMang/heap_2.c **** #define heapMINIMUM_BLOCK_SIZE	( ( size_t ) ( heapSTRUCT_SIZE * 2 ) )
  82:rtos/Source/portable/MemMang/heap_2.c **** 
  83:rtos/Source/portable/MemMang/heap_2.c **** /* Create a couple of list links to mark the start and end of the list. */
  84:rtos/Source/portable/MemMang/heap_2.c **** static xBlockLink xStart, xEnd;
  85:rtos/Source/portable/MemMang/heap_2.c **** 
  86:rtos/Source/portable/MemMang/heap_2.c **** /* STATIC FUNCTIONS ARE DEFINED AS MACROS TO MINIMIZE THE FUNCTION CALL DEPTH. */
  87:rtos/Source/portable/MemMang/heap_2.c **** 
  88:rtos/Source/portable/MemMang/heap_2.c **** /*
  89:rtos/Source/portable/MemMang/heap_2.c ****  * Insert a block into the list of free blocks - which is ordered by size of
  90:rtos/Source/portable/MemMang/heap_2.c ****  * the block.  Small blocks at the start of the list and large blocks at the end
  91:rtos/Source/portable/MemMang/heap_2.c ****  * of the list.
  92:rtos/Source/portable/MemMang/heap_2.c ****  */
  93:rtos/Source/portable/MemMang/heap_2.c **** #define prvInsertBlockIntoFreeList( pxBlockToInsert )								\
  94:rtos/Source/portable/MemMang/heap_2.c **** {																					\
  95:rtos/Source/portable/MemMang/heap_2.c **** xBlockLink *pxIterator;																\
  96:rtos/Source/portable/MemMang/heap_2.c **** size_t xBlockSize;																	\
  97:rtos/Source/portable/MemMang/heap_2.c **** 																					\
  98:rtos/Source/portable/MemMang/heap_2.c **** 	xBlockSize = pxBlockToInsert->xBlockSize;										\
  99:rtos/Source/portable/MemMang/heap_2.c **** 																					\
 100:rtos/Source/portable/MemMang/heap_2.c **** 	/* Iterate through the list until a block is found that has a larger size */	\
 101:rtos/Source/portable/MemMang/heap_2.c **** 	/* than the block we are inserting. */											\
 102:rtos/Source/portable/MemMang/heap_2.c **** 	for( pxIterator = &xStart; pxIterator->pxNextFreeBlock->xBlockSize < xBlockSize; pxIterator = pxIt
 103:rtos/Source/portable/MemMang/heap_2.c **** 	{																				\
 104:rtos/Source/portable/MemMang/heap_2.c **** 		/* There is nothing to do here - just iterate to the correct position. */	\
 105:rtos/Source/portable/MemMang/heap_2.c **** 	}																				\
 106:rtos/Source/portable/MemMang/heap_2.c **** 																					\
 107:rtos/Source/portable/MemMang/heap_2.c **** 	/* Update the list to include the block being inserted in the correct */		\
 108:rtos/Source/portable/MemMang/heap_2.c **** 	/* position. */																	\
 109:rtos/Source/portable/MemMang/heap_2.c **** 	pxBlockToInsert->pxNextFreeBlock = pxIterator->pxNextFreeBlock;					\
 110:rtos/Source/portable/MemMang/heap_2.c **** 	pxIterator->pxNextFreeBlock = pxBlockToInsert;									\
 111:rtos/Source/portable/MemMang/heap_2.c **** }
 112:rtos/Source/portable/MemMang/heap_2.c **** /*-----------------------------------------------------------*/
 113:rtos/Source/portable/MemMang/heap_2.c **** 
 114:rtos/Source/portable/MemMang/heap_2.c **** #define prvHeapInit()																\
 115:rtos/Source/portable/MemMang/heap_2.c **** {																					\
 116:rtos/Source/portable/MemMang/heap_2.c **** xBlockLink *pxFirstFreeBlock;														\
 117:rtos/Source/portable/MemMang/heap_2.c **** 																					\
 118:rtos/Source/portable/MemMang/heap_2.c **** 	/* xStart is used to hold a pointer to the first item in the list of free */	\
 119:rtos/Source/portable/MemMang/heap_2.c **** 	/* blocks.  The void cast is used to prevent compiler warnings. */				\
 120:rtos/Source/portable/MemMang/heap_2.c **** 	xStart.pxNextFreeBlock = ( void * ) xHeap.ucHeap;								\
 121:rtos/Source/portable/MemMang/heap_2.c **** 	xStart.xBlockSize = ( size_t ) 0;												\
 122:rtos/Source/portable/MemMang/heap_2.c **** 																					\
 123:rtos/Source/portable/MemMang/heap_2.c **** 	/* xEnd is used to mark the end of the list of free blocks. */					\
 124:rtos/Source/portable/MemMang/heap_2.c **** 	xEnd.xBlockSize = configTOTAL_HEAP_SIZE;										\
 125:rtos/Source/portable/MemMang/heap_2.c **** 	xEnd.pxNextFreeBlock = NULL;													\
 126:rtos/Source/portable/MemMang/heap_2.c **** 																					\
 127:rtos/Source/portable/MemMang/heap_2.c **** 	/* To start with there is a single free block that is sized to take up the		\
 128:rtos/Source/portable/MemMang/heap_2.c **** 	entire heap space. */															\
 129:rtos/Source/portable/MemMang/heap_2.c **** 	pxFirstFreeBlock = ( void * ) xHeap.ucHeap;										\
 130:rtos/Source/portable/MemMang/heap_2.c **** 	pxFirstFreeBlock->xBlockSize = configTOTAL_HEAP_SIZE;							\
 131:rtos/Source/portable/MemMang/heap_2.c **** 	pxFirstFreeBlock->pxNextFreeBlock = &xEnd;										\
 132:rtos/Source/portable/MemMang/heap_2.c **** }
 133:rtos/Source/portable/MemMang/heap_2.c **** /*-----------------------------------------------------------*/
 134:rtos/Source/portable/MemMang/heap_2.c **** 
 135:rtos/Source/portable/MemMang/heap_2.c **** void *pvPortMalloc( size_t xWantedSize )
 136:rtos/Source/portable/MemMang/heap_2.c **** {
 137:rtos/Source/portable/MemMang/heap_2.c **** xBlockLink *pxBlock, *pxPreviousBlock, *pxNewBlockLink;
 138:rtos/Source/portable/MemMang/heap_2.c **** static portBASE_TYPE xHeapHasBeenInitialised = pdFALSE;
 139:rtos/Source/portable/MemMang/heap_2.c **** void *pvReturn = NULL;
 140:rtos/Source/portable/MemMang/heap_2.c **** 
 141:rtos/Source/portable/MemMang/heap_2.c **** 	vTaskSuspendAll();
 142:rtos/Source/portable/MemMang/heap_2.c **** 	{
 143:rtos/Source/portable/MemMang/heap_2.c **** 		/* If this is the first call to malloc then the heap will require
 144:rtos/Source/portable/MemMang/heap_2.c **** 		initialisation to setup the list of free blocks. */
 145:rtos/Source/portable/MemMang/heap_2.c **** 		if( xHeapHasBeenInitialised == pdFALSE )
 146:rtos/Source/portable/MemMang/heap_2.c **** 		{
 147:rtos/Source/portable/MemMang/heap_2.c **** 			prvHeapInit();
 148:rtos/Source/portable/MemMang/heap_2.c **** 			xHeapHasBeenInitialised = pdTRUE;
 149:rtos/Source/portable/MemMang/heap_2.c **** 		}
 150:rtos/Source/portable/MemMang/heap_2.c **** 
 151:rtos/Source/portable/MemMang/heap_2.c **** 		/* The wanted size is increased so it can contain a xBlockLink
 152:rtos/Source/portable/MemMang/heap_2.c **** 		structure in addition to the requested amount of bytes. */
 153:rtos/Source/portable/MemMang/heap_2.c **** 		if( xWantedSize > 0 )
 154:rtos/Source/portable/MemMang/heap_2.c **** 		{
 155:rtos/Source/portable/MemMang/heap_2.c **** 			xWantedSize += heapSTRUCT_SIZE;
 156:rtos/Source/portable/MemMang/heap_2.c **** 
 157:rtos/Source/portable/MemMang/heap_2.c **** 			/* Ensure that blocks are always aligned to the required number of bytes. */
 158:rtos/Source/portable/MemMang/heap_2.c **** 			if( xWantedSize & heapBYTE_ALIGNMENT_MASK )
 159:rtos/Source/portable/MemMang/heap_2.c **** 			{
 160:rtos/Source/portable/MemMang/heap_2.c **** 				/* Byte alignment required. */
 161:rtos/Source/portable/MemMang/heap_2.c **** 				xWantedSize += ( portBYTE_ALIGNMENT - ( xWantedSize & heapBYTE_ALIGNMENT_MASK ) );
 162:rtos/Source/portable/MemMang/heap_2.c **** 			}
 163:rtos/Source/portable/MemMang/heap_2.c **** 		}
 164:rtos/Source/portable/MemMang/heap_2.c **** 
 165:rtos/Source/portable/MemMang/heap_2.c **** 		if( ( xWantedSize > 0 ) && ( xWantedSize < configTOTAL_HEAP_SIZE ) )
 166:rtos/Source/portable/MemMang/heap_2.c **** 		{
 167:rtos/Source/portable/MemMang/heap_2.c **** 			/* Blocks are stored in byte order - traverse the list from the start
 168:rtos/Source/portable/MemMang/heap_2.c **** 			(smallest) block until one of adequate size is found. */
 169:rtos/Source/portable/MemMang/heap_2.c **** 			pxPreviousBlock = &xStart;
 170:rtos/Source/portable/MemMang/heap_2.c **** 			pxBlock = xStart.pxNextFreeBlock;
 171:rtos/Source/portable/MemMang/heap_2.c **** 			while( ( pxBlock->xBlockSize < xWantedSize ) && ( pxBlock->pxNextFreeBlock ) )
 172:rtos/Source/portable/MemMang/heap_2.c **** 			{
 173:rtos/Source/portable/MemMang/heap_2.c **** 				pxPreviousBlock = pxBlock;
 174:rtos/Source/portable/MemMang/heap_2.c **** 				pxBlock = pxBlock->pxNextFreeBlock;
 175:rtos/Source/portable/MemMang/heap_2.c **** 			}
 176:rtos/Source/portable/MemMang/heap_2.c **** 
 177:rtos/Source/portable/MemMang/heap_2.c **** 			/* If we found the end marker then a block of adequate size was not found. */
 178:rtos/Source/portable/MemMang/heap_2.c **** 			if( pxBlock != &xEnd )
 179:rtos/Source/portable/MemMang/heap_2.c **** 			{
 180:rtos/Source/portable/MemMang/heap_2.c **** 				/* Return the memory space - jumping over the xBlockLink structure
 181:rtos/Source/portable/MemMang/heap_2.c **** 				at its start. */
 182:rtos/Source/portable/MemMang/heap_2.c **** 				pvReturn = ( void * ) ( ( ( unsigned portCHAR * ) pxPreviousBlock->pxNextFreeBlock ) + heapSTRU
 183:rtos/Source/portable/MemMang/heap_2.c **** 
 184:rtos/Source/portable/MemMang/heap_2.c **** 				/* This block is being returned for use so must be taken our of the
 185:rtos/Source/portable/MemMang/heap_2.c **** 				list of free blocks. */
 186:rtos/Source/portable/MemMang/heap_2.c **** 				pxPreviousBlock->pxNextFreeBlock = pxBlock->pxNextFreeBlock;
 187:rtos/Source/portable/MemMang/heap_2.c **** 
 188:rtos/Source/portable/MemMang/heap_2.c **** 				/* If the block is larger than required it can be split into two. */
 189:rtos/Source/portable/MemMang/heap_2.c **** 				if( ( pxBlock->xBlockSize - xWantedSize ) > heapMINIMUM_BLOCK_SIZE )
 190:rtos/Source/portable/MemMang/heap_2.c **** 				{
 191:rtos/Source/portable/MemMang/heap_2.c **** 					/* This block is to be split into two.  Create a new block
 192:rtos/Source/portable/MemMang/heap_2.c **** 					following the number of bytes requested. The void cast is
 193:rtos/Source/portable/MemMang/heap_2.c **** 					used to prevent byte alignment warnings from the compiler. */
 194:rtos/Source/portable/MemMang/heap_2.c **** 					pxNewBlockLink = ( void * ) ( ( ( unsigned portCHAR * ) pxBlock ) + xWantedSize );
 195:rtos/Source/portable/MemMang/heap_2.c **** 					
 196:rtos/Source/portable/MemMang/heap_2.c **** 					/* Calculate the sizes of two blocks split from the single
 197:rtos/Source/portable/MemMang/heap_2.c **** 					block. */
 198:rtos/Source/portable/MemMang/heap_2.c **** 					pxNewBlockLink->xBlockSize = pxBlock->xBlockSize - xWantedSize;	
 199:rtos/Source/portable/MemMang/heap_2.c **** 					pxBlock->xBlockSize = xWantedSize;			
 200:rtos/Source/portable/MemMang/heap_2.c **** 					
 201:rtos/Source/portable/MemMang/heap_2.c **** 					/* Insert the new block into the list of free blocks. */
 202:rtos/Source/portable/MemMang/heap_2.c **** 					prvInsertBlockIntoFreeList( ( pxNewBlockLink ) );
 203:rtos/Source/portable/MemMang/heap_2.c **** 				}
 204:rtos/Source/portable/MemMang/heap_2.c **** 			}
 205:rtos/Source/portable/MemMang/heap_2.c **** 		}
 206:rtos/Source/portable/MemMang/heap_2.c **** 	}
 207:rtos/Source/portable/MemMang/heap_2.c **** 	xTaskResumeAll();
 208:rtos/Source/portable/MemMang/heap_2.c **** 
 209:rtos/Source/portable/MemMang/heap_2.c **** 	return pvReturn;
 210:rtos/Source/portable/MemMang/heap_2.c **** }
 211:rtos/Source/portable/MemMang/heap_2.c **** /*-----------------------------------------------------------*/
 212:rtos/Source/portable/MemMang/heap_2.c **** 
 213:rtos/Source/portable/MemMang/heap_2.c **** void vPortFree( void *pv )
 214:rtos/Source/portable/MemMang/heap_2.c **** {
  19              	h	{r4, lr}
  20 0000 10B5     	.LCFI0:
  21              	.LVL0:
  22              		.loc 1 218 0
 215:rtos/Source/portable/MemMang/heap_2.c **** unsigned portCHAR *puc = ( unsigned portCHAR * ) pv;
 216:rtos/Source/portable/MemMang/heap_2.c **** xBlockLink *pxLink;
 217:rtos/Source/portable/MemMang/heap_2.c **** 
 218:rtos/Source/portable/MemMang/heap_2.c **** 	if( pv )
  23              		r0, #0
  24 0002 0028     		beq	.L7
  25 0004 0FD0     		.loc 1 225 0
 219:rtos/Source/portable/MemMang/heap_2.c **** 	{
 220:rtos/Source/portable/MemMang/heap_2.c **** 		/* The memory being freed will have an xBlockLink structure immediately
 221:rtos/Source/portable/MemMang/heap_2.c **** 		before it. */
 222:rtos/Source/portable/MemMang/heap_2.c **** 		puc -= heapSTRUCT_SIZE;
 223:rtos/Source/portable/MemMang/heap_2.c **** 
 224:rtos/Source/portable/MemMang/heap_2.c **** 		/* This casting is to keep the compiler from issuing warnings. */
 225:rtos/Source/portable/MemMang/heap_2.c **** 		pxLink = ( void * ) puc;
  26              	v	r4, r0
  27 0006 041C     	.LVL1:
  28              		sub	r4, r4, #8

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -