target/ast10x0: add .ram_nc section for non-cached DMA buffers Add RAM_NC memory region (0x000A0000, 128K) to target.ld.tmpl and a .ram_nc (NOLOAD) section so statics tagged with #[unsafe(link_section = ".ram_nc")] are placed in the AST1060's non-cached SRAM window rather than cached RAM. Shrink ram_size_bytes in all system.json5 files that used 384KB (ending at 0x000A0500) so that the cached RAM region ends exactly at the RAM_NC boundary (0x000A0000).
diff --git a/target/ast10x0/target.ld.tmpl b/target/ast10x0/target.ld.tmpl index 9aede6b..6f5ce8b 100644 --- a/target/ast10x0/target.ld.tmpl +++ b/target/ast10x0/target.ld.tmpl
@@ -33,10 +33,17 @@ /* Internal Flash */ FLASH(rx) : ORIGIN = {{kernel.flash_start_address | hex}}, LENGTH = {{kernel.flash_size_bytes}} - /* Internal SRAM */ + /* Internal SRAM (cached window: 0x00000000 – 0x0009FFFF) */ RAM(rwx) : ORIGIN = {{kernel.ram_start_address | hex}}, LENGTH = {{kernel.ram_size_bytes}} + /* Non-cached SRAM window (hardware alias of the top 128 KB of SRAM, + * 0x000A0000 – 0x000BFFFF). DMA masters on the AST1060 see coherent + * data only through this window. Statics tagged with + * #[unsafe(link_section = ".ram_nc")] must be placed here. + */ + RAM_NC(rw) : ORIGIN = 0x000A0000, LENGTH = 128K + /* Each memory region above has an associated .*.unused_space section that * overlays the unused space at the end of the memory segment. These segments * are used by pw_bloat.bloaty_config to create the utilization data source @@ -214,6 +221,26 @@ . = ABSOLUTE(ORIGIN(RAM) + LENGTH(RAM)); } >RAM + /* Non-cached SRAM: DMA-visible buffers that bypass the AST1060 data cache. + * All statics tagged #[unsafe(link_section = ".ram_nc")] land here. + */ + .ram_nc (NOLOAD) : ALIGN(16) + { + __ram_nc_start = .; + *(.ram_nc) + *(.ram_nc*) + . = ALIGN(16); + __ram_nc_end = .; + } >RAM_NC + + /* Represents unused space in the RAM_NC segment. This MUST be the last + * section assigned to the RAM_NC region. + */ + .RAM_NC.unused_space (NOLOAD) : ALIGN(4) + { + . = ABSOLUTE(ORIGIN(RAM_NC) + LENGTH(RAM_NC)); + } >RAM_NC + /* Discard unwind info. */ .ARM.extab 0x0 (INFO) : {
diff --git a/target/ast10x0/tests/interrupts/kernel/system.json5 b/target/ast10x0/tests/interrupts/kernel/system.json5 index fc896be..5f67cd5 100644 --- a/target/ast10x0/tests/interrupts/kernel/system.json5 +++ b/target/ast10x0/tests/interrupts/kernel/system.json5
@@ -15,7 +15,7 @@ flash_start_address: 0x00000500, // After vector table flash_size_bytes: 262144, // 256KB for kernel code (in RAM) ram_start_address: 0x00040500, // RAM starts after code - ram_size_bytes: 393216, // 384KB for data + ram_size_bytes: 391936, // ends at RAM_NC boundary (0x000A0000) interrupt_table: { table: { "42": "test_interrupts::test_interrupt_handler",
diff --git a/target/ast10x0/tests/peripherals/i2c/i2c_init/system.json5 b/target/ast10x0/tests/peripherals/i2c/i2c_init/system.json5 index 91aaeba..fc775ae 100644 --- a/target/ast10x0/tests/peripherals/i2c/i2c_init/system.json5 +++ b/target/ast10x0/tests/peripherals/i2c/i2c_init/system.json5
@@ -13,6 +13,6 @@ flash_start_address: 0x00000500, // After vector table flash_size_bytes: 262144, // 256KB for kernel code (in RAM) ram_start_address: 0x00040500, // RAM starts after code - ram_size_bytes: 393216, // 384KB for data + ram_size_bytes: 391936, // ends at RAM_NC boundary (0x000A0000) }, }
diff --git a/target/ast10x0/tests/peripherals/i2c/i2c_irq/slave_system.json5 b/target/ast10x0/tests/peripherals/i2c/i2c_irq/slave_system.json5 index 3a30e0f..2e672a0 100644 --- a/target/ast10x0/tests/peripherals/i2c/i2c_irq/slave_system.json5 +++ b/target/ast10x0/tests/peripherals/i2c/i2c_irq/slave_system.json5
@@ -12,6 +12,6 @@ flash_start_address: 0x00000500, flash_size_bytes: 262144, ram_start_address: 0x00040500, - ram_size_bytes: 393216, + ram_size_bytes: 391936, // ends at RAM_NC boundary (0x000A0000) }, }
diff --git a/target/ast10x0/tests/peripherals/i2c/i2c_irq/system.json5 b/target/ast10x0/tests/peripherals/i2c/i2c_irq/system.json5 index c11b564..bc5cc4d 100644 --- a/target/ast10x0/tests/peripherals/i2c/i2c_irq/system.json5 +++ b/target/ast10x0/tests/peripherals/i2c/i2c_irq/system.json5
@@ -14,6 +14,6 @@ flash_start_address: 0x00000500, // After vector table flash_size_bytes: 262144, // 256KB for kernel code (in RAM) ram_start_address: 0x00040500, // RAM starts after code - ram_size_bytes: 393216, // 384KB for data + ram_size_bytes: 391936, // ends at RAM_NC boundary (0x000A0000) }, }
diff --git a/target/ast10x0/tests/peripherals/i2c/i2c_slave_rx/master_system.json5 b/target/ast10x0/tests/peripherals/i2c/i2c_slave_rx/master_system.json5 index 62af599..f32bb66 100644 --- a/target/ast10x0/tests/peripherals/i2c/i2c_slave_rx/master_system.json5 +++ b/target/ast10x0/tests/peripherals/i2c/i2c_slave_rx/master_system.json5
@@ -13,6 +13,6 @@ flash_start_address: 0x00000500, flash_size_bytes: 262144, // 256KB ram_start_address: 0x00040500, - ram_size_bytes: 393216, // 384KB + ram_size_bytes: 391936, // ends at RAM_NC boundary (0x000A0000) }, }
diff --git a/target/ast10x0/tests/peripherals/i2c/i2c_slave_rx/system.json5 b/target/ast10x0/tests/peripherals/i2c/i2c_slave_rx/system.json5 index 96d9f40..e616a9e 100644 --- a/target/ast10x0/tests/peripherals/i2c/i2c_slave_rx/system.json5 +++ b/target/ast10x0/tests/peripherals/i2c/i2c_slave_rx/system.json5
@@ -13,6 +13,6 @@ flash_start_address: 0x00000500, // After vector table flash_size_bytes: 262144, // 256KB for kernel code (in RAM) ram_start_address: 0x00040500, // RAM starts after code - ram_size_bytes: 393216, // 384KB for data + ram_size_bytes: 391936, // ends at RAM_NC boundary (0x000A0000) }, }
diff --git a/target/ast10x0/tests/peripherals/i2c/i2c_slave_rx_ipc/master_system.json5 b/target/ast10x0/tests/peripherals/i2c/i2c_slave_rx_ipc/master_system.json5 index 5f50abb..5ed25ec 100644 --- a/target/ast10x0/tests/peripherals/i2c/i2c_slave_rx_ipc/master_system.json5 +++ b/target/ast10x0/tests/peripherals/i2c/i2c_slave_rx_ipc/master_system.json5
@@ -13,6 +13,6 @@ flash_start_address: 0x00000500, flash_size_bytes: 262144, // 256KB ram_start_address: 0x00040500, - ram_size_bytes: 393216, // 384KB + ram_size_bytes: 391936, // ends at RAM_NC boundary (0x000A0000) }, }
diff --git a/target/ast10x0/tests/smc/dma_irq/system.json5 b/target/ast10x0/tests/smc/dma_irq/system.json5 index ed5fedc..a956468 100644 --- a/target/ast10x0/tests/smc/dma_irq/system.json5 +++ b/target/ast10x0/tests/smc/dma_irq/system.json5
@@ -12,7 +12,7 @@ flash_start_address: 0x00000500, flash_size_bytes: 262144, ram_start_address: 0x00040500, - ram_size_bytes: 393216, + ram_size_bytes: 391936, // ends at RAM_NC boundary (0x000A0000) interrupt_table: { table: { // FMC IRQ.
diff --git a/target/ast10x0/tests/smc/read/system.json5 b/target/ast10x0/tests/smc/read/system.json5 index ed5fedc..a956468 100644 --- a/target/ast10x0/tests/smc/read/system.json5 +++ b/target/ast10x0/tests/smc/read/system.json5
@@ -12,7 +12,7 @@ flash_start_address: 0x00000500, flash_size_bytes: 262144, ram_start_address: 0x00040500, - ram_size_bytes: 393216, + ram_size_bytes: 391936, // ends at RAM_NC boundary (0x000A0000) interrupt_table: { table: { // FMC IRQ.
diff --git a/target/ast10x0/tests/smc/write/system.json5 b/target/ast10x0/tests/smc/write/system.json5 index 6c3a1a6..fa1cac1 100644 --- a/target/ast10x0/tests/smc/write/system.json5 +++ b/target/ast10x0/tests/smc/write/system.json5
@@ -12,6 +12,6 @@ flash_start_address: 0x00000500, flash_size_bytes: 262144, ram_start_address: 0x00040500, - ram_size_bytes: 393216, + ram_size_bytes: 391936, // ends at RAM_NC boundary (0x000A0000) }, }
diff --git a/target/ast10x0/tests/stress/mutex/kernel/system.json5 b/target/ast10x0/tests/stress/mutex/kernel/system.json5 index 56ff708..4fcbf11 100644 --- a/target/ast10x0/tests/stress/mutex/kernel/system.json5 +++ b/target/ast10x0/tests/stress/mutex/kernel/system.json5
@@ -14,6 +14,6 @@ flash_start_address: 0x00000500, // After vector table flash_size_bytes: 262144, // 256KB for kernel code ram_start_address: 0x00040500, // RAM starts after code - ram_size_bytes: 393216, // 384KB for data + ram_size_bytes: 391936, // ends at RAM_NC boundary (0x000A0000) }, }
diff --git a/target/ast10x0/tests/threads/kernel/system.json5 b/target/ast10x0/tests/threads/kernel/system.json5 index cc3ae8b..333dd2a 100644 --- a/target/ast10x0/tests/threads/kernel/system.json5 +++ b/target/ast10x0/tests/threads/kernel/system.json5
@@ -15,6 +15,6 @@ flash_start_address: 0x00000500, // After vector table flash_size_bytes: 262144, // 256KB for kernel code ram_start_address: 0x00040500, // RAM starts after code - ram_size_bytes: 393216, // 384KB for data + ram_size_bytes: 391936, // ends at RAM_NC boundary (0x000A0000) }, }
diff --git a/target/ast10x0/tests/unittest_runner/system.json5 b/target/ast10x0/tests/unittest_runner/system.json5 index 737b396..95673f8 100644 --- a/target/ast10x0/tests/unittest_runner/system.json5 +++ b/target/ast10x0/tests/unittest_runner/system.json5
@@ -15,6 +15,6 @@ flash_start_address: 0x00000500, // After vector table flash_size_bytes: 262144, // 256KB for kernel code ram_start_address: 0x00040500, // RAM starts after code - ram_size_bytes: 393216, // 384KB for data + ram_size_bytes: 391936, // ends at RAM_NC boundary (0x000A0000) }, }