commit 2229984ae9f84f9cae7012fc37907ec887d7480d
Author: Nikhil Dasan <n-dasan@ti.com>
Date:   Fri Dec 13 14:43:39 2024 +0530

    2GB
    
    Signed-off-by: Nikhil Dasan <n-dasan@ti.com>

diff --git a/platform/j721s2/rtos/c7x_1/main.c b/platform/j721s2/rtos/c7x_1/main.c
index 03301ef..8b2f85e 100755
--- a/platform/j721s2/rtos/c7x_1/main.c
+++ b/platform/j721s2/rtos/c7x_1/main.c
@@ -291,13 +291,13 @@ void appMmuMap(Bool is_secure)
         goto mmu_exit;
     }
 
-    retVal = Mmu_map(DDR_C7X_1_LOCAL_HEAP_VADDR, DDR_C7X_1_LOCAL_HEAP_PADDR, DDR_C7X_1_LOCAL_HEAP_SIZE, &attrs, is_secure); /* ddr            */
+    retVal = Mmu_map(DDR_C7X_1_LOCAL_HEAP_VADDR, DDR_C7X_1_LOCAL_HEAP_VADDR, DDR_C7X_1_LOCAL_HEAP_SIZE, &attrs, is_secure); /* ddr            */
     if(retVal == UFALSE)
     {
         goto mmu_exit;
     }
 
-    retVal = Mmu_map(DDR_C7X_1_SCRATCH_VADDR, DDR_C7X_1_SCRATCH_PADDR, DDR_C7X_1_SCRATCH_SIZE, &attrs, is_secure); /* ddr            */
+    retVal = Mmu_map(DDR_C7X_1_SCRATCH_VADDR, DDR_C7X_1_SCRATCH_VADDR, DDR_C7X_1_SCRATCH_SIZE, &attrs, is_secure); /* ddr            */
     if(retVal == UFALSE)
     {
         goto mmu_exit;
diff --git a/platform/j721s2/rtos/c7x_2/main.c b/platform/j721s2/rtos/c7x_2/main.c
index d4eef58..189fabc 100755
--- a/platform/j721s2/rtos/c7x_2/main.c
+++ b/platform/j721s2/rtos/c7x_2/main.c
@@ -299,13 +299,13 @@ void appMmuMap(Bool is_secure)
         goto mmu_exit;
     }
 
-    retVal = Mmu_map(DDR_C7X_2_LOCAL_HEAP_VADDR, DDR_C7X_2_LOCAL_HEAP_PADDR, DDR_C7X_2_LOCAL_HEAP_SIZE, &attrs, is_secure); /* ddr            */
+    retVal = Mmu_map(DDR_C7X_2_LOCAL_HEAP_VADDR, DDR_C7X_2_LOCAL_HEAP_VADDR, DDR_C7X_2_LOCAL_HEAP_SIZE, &attrs, is_secure); /* ddr            */
     if(retVal == UFALSE)
     {
         goto mmu_exit;
     }
 
-    retVal = Mmu_map(DDR_C7X_2_SCRATCH_VADDR, DDR_C7X_2_SCRATCH_PADDR, DDR_C7X_2_SCRATCH_SIZE, &attrs, is_secure); /* ddr            */
+    retVal = Mmu_map(DDR_C7X_2_SCRATCH_VADDR, DDR_C7X_2_SCRATCH_VADDR, DDR_C7X_2_SCRATCH_SIZE, &attrs, is_secure); /* ddr            */
     if(retVal == UFALSE)
     {
         goto mmu_exit;
diff --git a/platform/j721s2/rtos/gen_linker_mem_map.py b/platform/j721s2/rtos/gen_linker_mem_map.py
index ce16d7e..7ae9238 100755
--- a/platform/j721s2/rtos/gen_linker_mem_map.py
+++ b/platform/j721s2/rtos/gen_linker_mem_map.py
@@ -88,6 +88,8 @@ KB = 1024;
 MB = KB*KB;
 GB = KB*MB;
 
+SHARED_MEM_SIZE = 512*MB;
+
 #
 # Notes,
 # - recommend to keep all memory segment sizes in units of KB at least
@@ -113,7 +115,7 @@ GB = KB*MB;
 # virtual lower DDR address range 0x0001_0000_0000
 #
 
-ddr_mem_addr  = 0xa0000000;
+ddr_mem_addr  = 0x90000000;
 ddr_mem_size  = 1*GB + 448*MB; # Last 64MB is used by Linux
 
 ddr_mem_addr_hi_phy = 0x880000000;
@@ -124,6 +126,9 @@ msmc_mem_addr = 0x70000000;
 main_ocram_mem_addr = 0x60000000; # Note: uses RAT to translate to proper address
 main_ocram_mem_addr_phys = 0x4F02000000;
 
+uboot_reloc_mem_addr = 0xFC000000;
+uboot_reloc_mem_size = 64*MB;
+
 #
 # Other constant sizes
 #
@@ -258,12 +263,8 @@ mcu3_0_ddr_local_heap_size  = 8*MB;
 mcu3_1_ddr_local_heap_addr  = mcu3_0_ddr_local_heap_addr + mcu3_0_ddr_local_heap_size;
 mcu3_1_ddr_local_heap_size  = 8*MB;
 
-# Shared memory for DMA Buf FD carveout
-ddr_shared_mem_addr     = 0xC0000000; # This will be the virtual address used for R5F's / C7X's
-ddr_shared_mem_size     = 512*MB;
-
-c7x_1_ddr_scratch_addr     = ddr_mem_addr_hi;
-c7x_1_ddr_scratch_size     = 368*MB;
+c7x_1_ddr_scratch_addr     = mcu3_1_ddr_local_heap_addr + mcu3_1_ddr_local_heap_size;
+c7x_1_ddr_scratch_size     = 240*MB;
 
 c7x_1_ddr_local_heap_addr  = c7x_1_ddr_scratch_addr + c7x_1_ddr_scratch_size;
 c7x_1_ddr_local_heap_size  = 256*MB;
@@ -273,9 +274,13 @@ c7x_2_ddr_local_heap_size = 16*MB;
 c7x_2_ddr_scratch_addr    = c7x_2_ddr_local_heap_addr + c7x_2_ddr_local_heap_size;
 c7x_2_ddr_scratch_size    = 64*MB;
 
+# Shared memory for DMA Buf FD carveout
+ddr_shared_mem_addr     = c7x_2_ddr_scratch_addr + c7x_2_ddr_scratch_size; # This will be the virtual address used for R5F's / C7X's
+ddr_shared_mem_size     = SHARED_MEM_SIZE - uboot_reloc_mem_size;
+
 # Shared memory for DMA Buf FD carveout (located in high mem)
-ddr_shared_mem_addr_phys  = 0x900000000; # TODO: Clean this up
-ddr_shared_mem_size       = 512*MB;
+ddr_shared_mem_addr_phys  = ddr_shared_mem_addr; # TODO: Clean this up
+ddr_shared_mem_size       = SHARED_MEM_SIZE - uboot_reloc_mem_size;
 
 #
 # Create memory section based on addr and size defined above, including
@@ -296,6 +301,8 @@ mpu1_msmc   = MemSection("MSMC_MPU1", "RWIX", mpu1_msmc_addr  , mpu1_msmc_size
 c7x_1_msmc  = MemSection("MSMC_C7x_1", "RWIX", c7x_1_msmc_addr  , c7x_1_msmc_size  , "MSMC for C7x_1");
 dmsc_msmc  = MemSection("MSMC_DMSC", "RWIX", dmsc_msmc_addr  , dmsc_msmc_size  , "MSMC reserved for DMSC IPC");
 
+uboot_reloc_mem = MemSection("UBOOT_RELOC_MEM", "", uboot_reloc_mem_addr  , uboot_reloc_mem_size  , "Uboot DDR relocation memory");
+
 # C7x L1/L2 memory sections
 c7x_1_l2   = MemSection("L2RAM_C7x_1", "RWIX", c7x_1_l2_addr  , c7x_1_l2_size  , "L2 for C7x_1");
 c7x_1_l1   = MemSection("L1RAM_C7x_1", "RWIX", c7x_1_l1_addr  , c7x_1_l1_size  , "L1 for C7x_1");
@@ -429,16 +436,10 @@ vision_apps_core_heaps_lo.concat(mcu2_0_ddr_viss_config_heap);
 vision_apps_core_heaps_lo.concat(mcu2_1_ddr_local_heap);
 vision_apps_core_heaps_lo.concat(mcu3_0_ddr_local_heap);
 vision_apps_core_heaps_lo.concat(mcu3_1_ddr_local_heap);
+c7x_1_ddr_local_heap_phy  = MemSection("DDR_C7X_1_LOCAL_HEAP", "RWIX", c7x_1_ddr_scratch_addr, (c7x_1_ddr_scratch_size + c7x_1_ddr_local_heap_size + c7x_2_ddr_scratch_size + c7x_2_ddr_local_heap_size), "DDR for c7x_1, c7x_2 for scratch memory and local heap");
+vision_apps_core_heaps_lo.concat(c7x_1_ddr_local_heap_phy);
 vision_apps_core_heaps_lo.setDtsName("vision_apps_core_heaps_lo", "vision-apps-core-heap-memory-lo");
 
-
-c7x_1_ddr_local_heap_phy  = MemSection("DDR_C7X_1_LOCAL_HEAP", "RWIX", ddr_mem_addr_hi_phy, (c7x_1_ddr_scratch_size + c7x_1_ddr_local_heap_size + c7x_2_ddr_scratch_size + c7x_2_ddr_local_heap_size), "DDR for c7x_1, c7x_2 for scratch memory and local heap");
-
-c7x_ddr_heaps_hi = MemSection("DDR_VISION_APPS_CORE_HEAPS_HI_DTS", "", 0, 0, "Vision Apps Core Heaps in 40bit address range of DDR");
-c7x_ddr_heaps_hi.concat(c7x_1_ddr_local_heap_phy);
-c7x_ddr_heaps_hi.setDtsName("c7x_ddr_heaps_hi", "c7x_ddr_heaps_hi-apps-core-heap-memory-hi");
-c7x_ddr_heaps_hi.splitOrigin(True)
-
 # this region should NOT have the "no-map" flag since we want ION to map this memory and do cache ops on it as needed
 ddr_shared_mem     = MemSection("DDR_SHARED_MEM"    , "", ddr_shared_mem_addr    , ddr_shared_mem_size    , "Memory for shared memory buffers in DDR");
 ddr_shared_mem_phys  = MemSection("DDR_SHARED_MEM_PHYS"    , "", ddr_shared_mem_addr_phys  , ddr_shared_mem_size    , "Physical address of memory for shared memory buffers in DDR");
@@ -642,6 +643,7 @@ html_mmap.addMemSection( ddr_shared_mem     );
 html_mmap.addMemSection( tiovx_log_rt_mem );
 html_mmap.addMemSection( mcu2_0_main_ocram );
 html_mmap.addMemSection( mcu2_1_main_ocram );
+html_mmap.addMemSection( uboot_reloc_mem    );
 html_mmap.checkOverlap();
 
 c_header_mmap = MemoryMap("Memory Map for C header file");
@@ -690,6 +692,7 @@ c_header_mmap.addMemSection( mcu2_0_main_ocram  );
 c_header_mmap.addMemSection( mcu2_1_main_ocram  );
 c_header_mmap.addMemSection( mcu2_0_main_ocram_phys  );
 c_header_mmap.addMemSection( mcu2_1_main_ocram_phys  );
+c_header_mmap.addMemSection( uboot_reloc_mem     );
 c_header_mmap.checkOverlap();
 
 dts_mmap = MemoryMap("Memory Map for Linux kernel dts/dtsi file");
@@ -712,7 +715,6 @@ dts_mmap.addMemSection( c7x_2_ddr_total    );
 dts_mmap.addMemSection( vision_apps_ddr_total );
 dts_mmap.addMemSection( ipc_vring_mem      );
 dts_mmap.addMemSection( vision_apps_core_heaps_lo );
-dts_mmap.addMemSection( c7x_ddr_heaps_hi );
 dts_mmap.addMemSection( ddr_shared_mem_phys );
 dts_mmap.checkOverlap();
 
