1919#define uncached_block_hdr (hdr ) cache_to_uncache_init((struct block_hdr *)(hdr))
2020#define uncached_block_map (map ) cache_to_uncache((struct block_map *)(map))
2121
22+ /* Memory mock for memmap */
23+ #define HEAP_SYSTEM_0_BASE 0xBE100000
24+ #define HEAP_SYS_RUNTIME_0_BASE 0xBE120000
25+ #define SOF_CORE_S_START 0xBE140000
26+ #define HEAP_RUNTIME_BASE 0xBE180000
27+ #define HEAP_BUFFER_BASE 0xBE1C0000
28+
2229/* Heap blocks for system runtime for primary core */
2330static SHARED_DATA struct block_hdr sys_rt_0_block64 [HEAP_SYS_RT_0_COUNT64 ];
2431static SHARED_DATA struct block_hdr sys_rt_0_block512 [HEAP_SYS_RT_0_COUNT512 ];
@@ -69,23 +76,23 @@ static SHARED_DATA struct block_map sys_rt_heap_map[CONFIG_CORE_COUNT][3] = {
6976};
7077
7178/* Heap blocks for modules */
72- static SHARED_DATA struct block_hdr mod_block64 [HEAP_RT_COUNT64 ];
73- static SHARED_DATA struct block_hdr mod_block128 [HEAP_RT_COUNT128 ];
74- static SHARED_DATA struct block_hdr mod_block256 [HEAP_RT_COUNT256 ];
75- static SHARED_DATA struct block_hdr mod_block512 [HEAP_RT_COUNT512 ];
76- static SHARED_DATA struct block_hdr mod_block1024 [HEAP_RT_COUNT1024 ];
77- static SHARED_DATA struct block_hdr mod_block2048 [HEAP_RT_COUNT2048 ];
78- static SHARED_DATA struct block_hdr mod_block4096 [HEAP_RT_COUNT4096 ];
79+ static SHARED_DATA struct block_hdr mod_block64 [HEAP_COUNT64 ];
80+ static SHARED_DATA struct block_hdr mod_block128 [HEAP_COUNT128 ];
81+ static SHARED_DATA struct block_hdr mod_block256 [HEAP_COUNT256 ];
82+ static SHARED_DATA struct block_hdr mod_block512 [HEAP_COUNT512 ];
83+ static SHARED_DATA struct block_hdr mod_block1024 [HEAP_COUNT1024 ];
84+ static SHARED_DATA struct block_hdr mod_block2048 [HEAP_COUNT2048 ];
85+ static SHARED_DATA struct block_hdr mod_block4096 [HEAP_COUNT4096 ];
7986
8087/* Heap memory map for modules */
8188static SHARED_DATA struct block_map rt_heap_map [] = {
82- BLOCK_DEF (64 , HEAP_RT_COUNT64 , uncached_block_hdr (mod_block64 )),
83- BLOCK_DEF (128 , HEAP_RT_COUNT128 , uncached_block_hdr (mod_block128 )),
84- BLOCK_DEF (256 , HEAP_RT_COUNT256 , uncached_block_hdr (mod_block256 )),
85- BLOCK_DEF (512 , HEAP_RT_COUNT512 , uncached_block_hdr (mod_block512 )),
86- BLOCK_DEF (1024 , HEAP_RT_COUNT1024 , uncached_block_hdr (mod_block1024 )),
87- BLOCK_DEF (2048 , HEAP_RT_COUNT2048 , uncached_block_hdr (mod_block2048 )),
88- BLOCK_DEF (4096 , HEAP_RT_COUNT4096 , uncached_block_hdr (mod_block4096 )),
89+ BLOCK_DEF (64 , HEAP_COUNT64 , uncached_block_hdr (mod_block64 )),
90+ BLOCK_DEF (128 , HEAP_COUNT128 , uncached_block_hdr (mod_block128 )),
91+ BLOCK_DEF (256 , HEAP_COUNT256 , uncached_block_hdr (mod_block256 )),
92+ BLOCK_DEF (512 , HEAP_COUNT512 , uncached_block_hdr (mod_block512 )),
93+ BLOCK_DEF (1024 , HEAP_COUNT1024 , uncached_block_hdr (mod_block1024 )),
94+ BLOCK_DEF (2048 , HEAP_COUNT2048 , uncached_block_hdr (mod_block2048 )),
95+ BLOCK_DEF (4096 , HEAP_COUNT4096 , uncached_block_hdr (mod_block4096 )),
8996};
9097
9198#if CONFIG_CORE_COUNT > 1
@@ -107,12 +114,12 @@ static SHARED_DATA struct block_map rt_shared_heap_map[] = {
107114#endif
108115
109116/* Heap blocks for buffers */
110- static SHARED_DATA struct block_hdr buf_block [HEAP_BUFFER_COUNT ];
117+ static SHARED_DATA struct block_hdr buf_block [HEAP_BUFFER_COUNT_MAX ];
111118static SHARED_DATA struct block_hdr lp_buf_block [HEAP_LP_BUFFER_COUNT ];
112119
113120/* Heap memory map for buffers */
114121static SHARED_DATA struct block_map buf_heap_map [] = {
115- BLOCK_DEF (HEAP_BUFFER_BLOCK_SIZE , HEAP_BUFFER_COUNT ,
122+ BLOCK_DEF (HEAP_BUFFER_BLOCK_SIZE , HEAP_BUFFER_COUNT_MAX ,
116123 uncached_block_hdr (buf_block )),
117124};
118125
@@ -125,8 +132,21 @@ static SHARED_DATA struct mm memmap;
125132
126133void platform_init_memmap (struct sof * sof )
127134{
135+ uint32_t heap_buffer_size = SOF_FW_END - HEAP_BUFFER_BASE ;
136+ uint32_t buffer_count ;
128137 int i ;
129138
139+ /* calculate the buffer heap size */
140+ buffer_count = heap_buffer_size / HEAP_BUFFER_BLOCK_SIZE ;
141+ heap_buffer_size = buffer_count * HEAP_BUFFER_BLOCK_SIZE ;
142+
143+ for (i = 0 ; i < ARRAY_SIZE (buf_heap_map ); i ++ ) {
144+ buf_heap_map [i ].count = buffer_count ;
145+ buf_heap_map [i ].free_count = buffer_count ;
146+ }
147+ dcache_writeback_region (buf_heap_map ,
148+ sizeof (struct block_map ) * ARRAY_SIZE (buf_heap_map ));
149+
130150 /* access memory map through uncached region */
131151 sof -> memory_map = cache_to_uncache (& memmap );
132152
@@ -211,9 +231,9 @@ void platform_init_memmap(struct sof *sof)
211231 /* heap buffer init */
212232 sof -> memory_map -> buffer [0 ].blocks = ARRAY_SIZE (buf_heap_map );
213233 sof -> memory_map -> buffer [0 ].map = uncached_block_map (buf_heap_map );
214- sof -> memory_map -> buffer [0 ].heap = (unsigned long )malloc (HEAP_BUFFER_SIZE );
215- sof -> memory_map -> buffer [0 ].size = HEAP_BUFFER_SIZE ;
216- sof -> memory_map -> buffer [0 ].info .free = HEAP_BUFFER_SIZE ;
234+ sof -> memory_map -> buffer [0 ].heap = (unsigned long )malloc (heap_buffer_size );
235+ sof -> memory_map -> buffer [0 ].size = heap_buffer_size ;
236+ sof -> memory_map -> buffer [0 ].info .free = heap_buffer_size ;
217237 sof -> memory_map -> buffer [0 ].caps = SOF_MEM_CAPS_RAM | SOF_MEM_CAPS_HP |
218238 SOF_MEM_CAPS_CACHE | SOF_MEM_CAPS_DMA ;
219239
@@ -228,7 +248,7 @@ void platform_init_memmap(struct sof *sof)
228248
229249 /* .total init */
230250 sof -> memory_map -> total .free = HEAP_SYSTEM_T_SIZE +
231- HEAP_SYS_RUNTIME_T_SIZE + HEAP_RUNTIME_SIZE + HEAP_BUFFER_SIZE +
251+ HEAP_SYS_RUNTIME_T_SIZE + HEAP_RUNTIME_SIZE + heap_buffer_size +
232252 HEAP_LP_BUFFER_SIZE ;
233253
234254}
0 commit comments