xiaoxiang781216 commented on code in PR #7799:
URL: https://github.com/apache/nuttx/pull/7799#discussion_r1041165568
##########
arch/xtensa/src/esp32s3/esp32s3_allocateheap.c:
##########
@@ -50,23 +53,84 @@
* Description:
* This function will be called to dynamically set aside the heap region.
*
- * For the kernel build (CONFIG_BUILD_KERNEL=y) with both kernel- and
- * user-space heaps (CONFIG_MM_KERNEL_HEAP=y), this function provides the
- * size of the unprotected, user-space heap.
+ * For the kernel build (CONFIG_BUILD_KERNEL=y) with both kernel and
+ * userspace heaps (CONFIG_MM_KERNEL_HEAP=y), this function provides the
+ * size of the unprotected, userspace heap.
*
- * If a protected kernel-space heap is provided, the kernel heap must be
+ * If a protected kernel space heap is provided, the kernel heap must be
* allocated (and protected) by an analogous up_allocate_kheap().
*
****************************************************************************/
void up_allocate_heap(void **heap_start, size_t *heap_size)
{
+#if defined(CONFIG_BUILD_PROTECTED) && defined(CONFIG_MM_KERNEL_HEAP)
+ uintptr_t ubase = USERSPACE->us_dataend;
+ uintptr_t utop = ets_rom_layout_p->dram0_rtos_reserved_start;
+ size_t usize = utop - ubase;
+
+ minfo("Heap: start=%" PRIxPTR " end=%" PRIxPTR " size=%zu\n",
+ ubase, utop, usize);
+
+ board_autoled_on(LED_HEAPALLOCATE);
+
+ /* Return the userspace heap settings */
+
+ *heap_start = (void *)ubase;
+ *heap_size = usize;
+
+ /* Allow user-mode access to the user heap memory in PMP
+ * is already done in esp32s3_userspace().
+ */
+
+#else
+ /* These values come from the linker scripts (esp32s3_sections.ld and
+ * flat_memory.ld).
+ * Check boards/xtensa/esp32s3.
+ */
+
+ board_autoled_on(LED_HEAPALLOCATE);
+
+ *heap_start = _sheap;
+ *heap_size = ets_rom_layout_p->dram0_rtos_reserved_start -
+ (uintptr_t)_sheap;
+#endif /* CONFIG_BUILD_PROTECTED && CONFIG_MM_KERNEL_HEAP */
+}
+
+/****************************************************************************
+ * Name: up_allocate_kheap
+ *
+ * Description:
+ * This function will be called to dynamically set aside the heap region.
+ *
+ * For the kernel build (CONFIG_BUILD_PROTECTED=y) with both kernel and
+ * userspace heaps (CONFIG_MM_KERNEL_HEAP=y), this function allocates
+ * (and protects) the kernel space heap.
+ *
+ ****************************************************************************/
+
+#if defined(CONFIG_BUILD_PROTECTED) && defined(CONFIG_MM_KERNEL_HEAP) && \
+ defined(__KERNEL__)
Review Comment:
don't need check __KERNEL__ which should be always true for arch code
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]