2021-09-23 20:31:49 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								/*
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 *  SPDX - FileCopyrightText :  2019 - 2021  Espressif  Systems  ( Shanghai )  CO  LTD 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 * 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 *  SPDX - License - Identifier :  Apache - 2.0 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-07-23 13:40:10 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								# include  <stdint.h> 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# include  <stdlib.h> 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# include  "sdkconfig.h" 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# include  "esp_attr.h" 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# include  "soc/soc.h" 
 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-22 23:32:36 +03:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# include  "soc/dport_reg.h" 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# include  "soc/tracemem_config.h" 
 
							 
						 
					
						
							
								
									
										
										
										
											2021-06-18 14:51:11 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# include  "heap_memory_layout.h" 
 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-23 13:40:10 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								# include  "esp_heap_caps.h" 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								/**
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 *  @ brief  Memory  type  descriptors .  These  describe  the  capabilities  of  a  type  of  memory  in  the  SoC . 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 *  Each  type  of  memory  map  consists  of  one  or  more  regions  in  the  address  space . 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 *  Each  type  contains  an  array  of  prioritized  capabilities . 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 *  Types  with  later  entries  are  only  taken  if  earlier  ones  can ' t  fulfill  the  memory  request . 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 * 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 *  -  For  a  normal  malloc  ( MALLOC_CAP_DEFAULT ) ,  give  away  the  DRAM - only  memory  first ,  then  pass  off  any  dual - use  IRAM  regions ,  finally  eat  into  the  application  memory . 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 *  -  For  a  malloc  where  32 - bit - aligned - only  access  is  okay ,  first  allocate  IRAM ,  then  DRAM ,  finally  application  IRAM . 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 *  -  Application  mallocs  ( PIDx )  will  allocate  IRAM  first ,  if  possible ,  then  DRAM . 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 *  -  Most  other  malloc  caps  only  fit  in  one  region  anyway . 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 * 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 */ 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-29 10:51:08 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								/* Index of memory in `soc_memory_types[]` */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								enum  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-25 11:13:09 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    SOC_MEMORY_TYPE_DRAM         =  0 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    SOC_MEMORY_TYPE_STACK_DRAM   =  1 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    SOC_MEMORY_TYPE_DIRAM        =  2 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    SOC_MEMORY_TYPE_STACK_DIRAM  =  3 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    SOC_MEMORY_TYPE_IRAM         =  4 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    SOC_MEMORY_TYPE_SPIRAM       =  5 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    SOC_MEMORY_TYPE_NODMARAM     =  6 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    SOC_MEMORY_TYPE_RTCRAM       =  7 , 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-29 10:51:08 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    SOC_MEMORY_TYPE_NUM , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								const  soc_memory_type_desc_t  soc_memory_types [ SOC_MEMORY_TYPE_NUM ]  =  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-23 13:40:10 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								    // Type 0: DRAM
 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-29 10:51:08 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    [ SOC_MEMORY_TYPE_DRAM ]  =  {  " DRAM " ,  {  MALLOC_CAP_8BIT  |  MALLOC_CAP_DEFAULT ,  MALLOC_CAP_INTERNAL  |  MALLOC_CAP_DMA  |  MALLOC_CAP_32BIT ,  0  } ,  false ,  false } , 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-23 13:40:10 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								    // Type 1: DRAM used for startup stacks
 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-25 11:13:09 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    [ SOC_MEMORY_TYPE_STACK_DRAM ]  =  {  " STACK/DRAM " ,  {  MALLOC_CAP_8BIT  |  MALLOC_CAP_DEFAULT  |  MALLOC_CAP_RETENTION ,  MALLOC_CAP_INTERNAL  |  MALLOC_CAP_DMA  |  MALLOC_CAP_32BIT ,  0  } ,  false ,  true } , 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-23 13:40:10 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								    // Type 2: DRAM which has an alias on the I-port
 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-03 16:13:17 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    [ SOC_MEMORY_TYPE_DIRAM ]  =  {  " D/IRAM " ,  {  0 ,  MALLOC_CAP_DMA  |  MALLOC_CAP_8BIT  |  MALLOC_CAP_INTERNAL  |  MALLOC_CAP_DEFAULT ,  MALLOC_CAP_32BIT  |  MALLOC_CAP_EXEC  |  MALLOC_CAP_RETENTION } ,  true ,  false } , 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-25 11:13:09 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    // Type 3: DIRAM used for startup stacks
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    [ SOC_MEMORY_TYPE_STACK_DIRAM ]  =  {  " STACK/DIRAM " ,  {  MALLOC_CAP_8BIT  |  MALLOC_CAP_DEFAULT  |  MALLOC_CAP_RETENTION ,  MALLOC_CAP_EXEC  |  MALLOC_CAP_INTERNAL  |  MALLOC_CAP_DMA  |  MALLOC_CAP_32BIT ,  0  } ,  true ,  true } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    // Type 4: IRAM
 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-29 10:51:08 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    [ SOC_MEMORY_TYPE_IRAM ]  =  {  " IRAM " ,  {  MALLOC_CAP_EXEC  |  MALLOC_CAP_32BIT  |  MALLOC_CAP_INTERNAL ,  0 ,  0  } ,  false ,  false } , 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-25 11:13:09 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    // Type 5: SPI SRAM data
 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-29 10:51:08 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    [ SOC_MEMORY_TYPE_SPIRAM ]  =  {  " SPIRAM " ,  {  MALLOC_CAP_SPIRAM  |  MALLOC_CAP_DEFAULT ,  0 ,  MALLOC_CAP_8BIT  |  MALLOC_CAP_32BIT } ,  false ,  false } , 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-25 11:13:09 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    // Type 6: DRAM which is not DMA accesible
 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-29 10:51:08 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    [ SOC_MEMORY_TYPE_NODMARAM ]  =  {  " NON_DMA_DRAM " ,  {  MALLOC_CAP_8BIT  |  MALLOC_CAP_DEFAULT ,  MALLOC_CAP_INTERNAL  |  MALLOC_CAP_32BIT ,  0  } ,  false ,  false } , 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-25 11:13:09 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    // Type 7: RTC Fast RAM
 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-29 10:51:08 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    [ SOC_MEMORY_TYPE_RTCRAM ]  =  {  " RTCRAM " ,  {  MALLOC_CAP_RTCRAM ,  MALLOC_CAP_8BIT  |  MALLOC_CAP_DEFAULT ,  MALLOC_CAP_INTERNAL  |  MALLOC_CAP_32BIT  } ,  false ,  false } , 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-23 13:40:10 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								} ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-01-25 11:13:09 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# ifdef CONFIG_ESP_SYSTEM_MEMPROT_FEATURE 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# define SOC_MEMORY_TYPE_DEFAULT SOC_MEMORY_TYPE_DRAM 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# define SOC_MEMORY_TYPE_STACK_DEFAULT SOC_MEMORY_TYPE_STACK_DRAM 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# else 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# define SOC_MEMORY_TYPE_DEFAULT SOC_MEMORY_TYPE_DIRAM 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# define SOC_MEMORY_TYPE_STACK_DEFAULT SOC_MEMORY_TYPE_STACK_DIRAM 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# endif 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-07-23 13:40:10 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								const  size_t  soc_memory_type_count  =  sizeof ( soc_memory_types )  /  sizeof ( soc_memory_type_desc_t ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								/**
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 *  @ brief  Region  descriptors .  These  describe  all  regions  of  memory  available ,  and  map  them  to  a  type  in  the  above  type . 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 * 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 *  @ note  Because  of  requirements  in  the  coalescing  code  which  merges  adjacent  regions , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 *        this  list  should  always  be  sorted  from  low  to  high  by  start  address . 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 * 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 */ 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-01 17:46:17 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								/**
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 *  Register  the  shared  buffer  area  of  the  last  memory  block  into  the  heap  during  heap  initialization 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# define APP_USABLE_DRAM_END           (SOC_ROM_STACK_START - SOC_ROM_STACK_SIZE) 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-07-23 13:40:10 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								const  soc_memory_region_t  soc_memory_regions [ ]  =  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# ifdef CONFIG_SPIRAM 
 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-29 10:51:08 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    {  SOC_EXTRAM_DATA_LOW ,   SOC_EXTRAM_DATA_SIZE ,                        SOC_MEMORY_TYPE_SPIRAM ,      0 } ,  //SPI SRAM, if available
 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-23 13:40:10 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								# endif 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# if CONFIG_ESP32S3_INSTRUCTION_CACHE_16KB 
 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-29 10:51:08 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    {  0x40374000 ,            0x4000 ,                                      SOC_MEMORY_TYPE_IRAM ,        0 } ,           //Level 1, IRAM
 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-23 13:40:10 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								# endif 
 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-25 11:13:09 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    {  0x3FC88000 ,            0x8000 ,                                      SOC_MEMORY_TYPE_DEFAULT ,       0x40378000 } ,  //Level 2, IDRAM, can be used as trace memory
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    {  0x3FC90000 ,            0x10000 ,                                     SOC_MEMORY_TYPE_DEFAULT ,       0x40380000 } ,  //Level 3, IDRAM, can be used as trace memory
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    {  0x3FCA0000 ,            0x10000 ,                                     SOC_MEMORY_TYPE_DEFAULT ,       0x40390000 } ,  //Level 4, IDRAM, can be used as trace memory
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    {  0x3FCB0000 ,            0x10000 ,                                     SOC_MEMORY_TYPE_DEFAULT ,       0x403A0000 } ,  //Level 5, IDRAM, can be used as trace memory
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    {  0x3FCC0000 ,            0x10000 ,                                     SOC_MEMORY_TYPE_DEFAULT ,       0x403B0000 } ,  //Level 6, IDRAM, can be used as trace memory
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    {  0x3FCD0000 ,            0x10000 ,                                     SOC_MEMORY_TYPE_DEFAULT ,       0x403C0000 } ,  //Level 7, IDRAM, can be used as trace memory
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    {  0x3FCE0000 ,            ( APP_USABLE_DRAM_END - 0x3FCE0000 ) ,            SOC_MEMORY_TYPE_DEFAULT ,       0x403D0000 } ,  //Level 8, IDRAM, can be used as trace memory,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    {  APP_USABLE_DRAM_END ,   ( SOC_DIRAM_DRAM_HIGH - APP_USABLE_DRAM_END ) ,   SOC_MEMORY_TYPE_STACK_DEFAULT ,  MAP_DRAM_TO_IRAM ( APP_USABLE_DRAM_END ) } ,  //Level 8, IDRAM, can be used as trace memory, ROM reserved area, recycled by heap allocator in app_main task
 
							 
						 
					
						
							
								
									
										
										
										
											2020-10-10 16:22:49 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# if CONFIG_ESP32S3_DATA_CACHE_16KB || CONFIG_ESP32S3_DATA_CACHE_32KB 
 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-03 16:13:17 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    {  0x3FCF0000 ,            0x8000 ,                                      SOC_MEMORY_TYPE_DRAM ,        0 } ,  //Level 9, DRAM, DMA is accessible but retention DMA is inaccessible
 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-23 13:40:10 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								# endif 
 
							 
						 
					
						
							
								
									
										
										
										
											2020-10-10 16:22:49 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# if CONFIG_ESP32S3_DATA_CACHE_16KB 
 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-03 16:13:17 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    {  0x3C000000 ,            0x4000 ,                                      SOC_MEMORY_TYPE_DRAM ,        0 } ,  //Level 10, DRAM, DMA is accessible but retention DMA is inaccessible
 
							 
						 
					
						
							
								
									
										
										
										
											2020-10-10 16:22:49 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# endif 
 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-04 10:05:21 +11:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# ifdef CONFIG_ESP_SYSTEM_ALLOW_RTC_FAST_MEM_AS_HEAP 
 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-29 10:51:08 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    {  0x600fe000 ,            0x2000 ,                                      SOC_MEMORY_TYPE_RTCRAM ,      0 } ,  //Fast RTC memory
 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-04 10:05:21 +11:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# endif 
 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-23 13:40:10 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								} ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								const  size_t  soc_memory_region_count  =  sizeof ( soc_memory_regions )  /  sizeof ( soc_memory_region_t ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-08-13 10:28:58 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								extern  int  _data_start ,  _heap_start ,  _iram_start ,  _iram_end ,  _rtc_force_fast_end ,  _rtc_noinit_end ;  // defined in sections.ld.in
 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-01 00:41:40 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								extern  int  _rtc_reserved_start ,  _rtc_reserved_end ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-23 13:40:10 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								/**
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 *  Reserved  memory  regions . 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 *  These  are  removed  from  the  soc_memory_regions  array  when  heaps  are  created . 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 * 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								// Static data region. DRAM used by data+bss and possibly rodata
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								SOC_RESERVE_MEMORY_REGION ( ( intptr_t ) & _data_start ,  ( intptr_t ) & _heap_start ,  dram_data ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								// ESP32S3 has a big D/IRAM region, the part used by code is reserved
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								// The address of the D/I bus are in the same order, directly shift IRAM address to get reserved DRAM address
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# define I_D_OFFSET (SOC_DIRAM_IRAM_LOW - SOC_DIRAM_DRAM_LOW) 
 
							 
						 
					
						
							
								
									
										
										
										
											2020-10-30 13:31:24 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								// .text region in diram. DRAM used by text (shared with IBUS).
 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-23 13:40:10 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								SOC_RESERVE_MEMORY_REGION ( ( intptr_t ) & _iram_start  -  I_D_OFFSET ,  ( intptr_t ) & _iram_end  -  I_D_OFFSET ,  iram_code ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-10-30 13:31:24 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# if CONFIG_ESP32S3_INSTRUCTION_CACHE_16KB 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								SOC_RESERVE_MEMORY_REGION ( ( intptr_t ) & _iram_start ,  ( intptr_t ) & _iram_end ,  iram_code_2 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-23 13:40:10 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								# endif 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# ifdef CONFIG_SPIRAM 
 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-29 13:13:51 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								/* Reserve the whole possible SPIRAM region here, spiram.c will add some or all of this
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 *  memory  to  heap  depending  on  the  actual  SPIRAM  chip  size .  */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								SOC_RESERVE_MEMORY_REGION (  SOC_EXTRAM_DATA_LOW ,  SOC_EXTRAM_DATA_HIGH ,  extram_data_region ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-23 13:40:10 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								# endif 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# if CONFIG_ESP32S3_TRACEMEM_RESERVE_DRAM > 0 
 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-22 23:32:36 +03:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								SOC_RESERVE_MEMORY_REGION ( TRACEMEM_BLK0_ADDR ,  TRACEMEM_BLK0_ADDR  +  CONFIG_ESP32S3_TRACEMEM_RESERVE_DRAM  /  2 ,  trace_mem0 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								SOC_RESERVE_MEMORY_REGION ( TRACEMEM_BLK1_ADDR ,  TRACEMEM_BLK1_ADDR  +  CONFIG_ESP32S3_TRACEMEM_RESERVE_DRAM  /  2 ,  trace_mem1 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-23 13:40:10 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								# endif 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-08-13 10:28:58 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								// RTC Fast RAM region
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# ifdef CONFIG_ESP_SYSTEM_ALLOW_RTC_FAST_MEM_AS_HEAP 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# ifdef CONFIG_ESP32S3_RTCDATA_IN_FAST_MEM 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								SOC_RESERVE_MEMORY_REGION ( SOC_RTC_DRAM_LOW ,  ( intptr_t ) & _rtc_noinit_end ,  rtcram_data ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# else 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								SOC_RESERVE_MEMORY_REGION ( SOC_RTC_DRAM_LOW ,  ( intptr_t ) & _rtc_force_fast_end ,  rtcram_data ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# endif 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# endif 
 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-01 00:41:40 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								SOC_RESERVE_MEMORY_REGION ( ( intptr_t ) & _rtc_reserved_start ,  ( intptr_t ) & _rtc_reserved_end ,  rtc_reserved_data ) ;