espressif:esp32: Move app entry point call back to iram_loader_seg region

Entry point call was moved back from main to esp_loader, so it is
called from iram_loader_seg memory region

Signed-off-by: Almir Okato <almir.okato@espressif.com>
diff --git a/boot/espressif/port/esp32/ld/bootloader.ld b/boot/espressif/port/esp32/ld/bootloader.ld
index 2b7797b..30f08dc 100644
--- a/boot/espressif/port/esp32/ld/bootloader.ld
+++ b/boot/espressif/port/esp32/ld/bootloader.ld
@@ -56,6 +56,7 @@
     *libhal.a:esp_efuse_api.*(.literal .text .literal.* .text.*)
     *libhal.a:esp_efuse_utility.*(.literal .text .literal.* .text.*)
     *libhal.a:esp_efuse_api_key_esp32.*(.literal .text .literal.* .text.*)
+    *libhal.a:app_cpu_start.*(.literal .text .literal.* .text.*)
     *esp_mcuboot.*(.literal .text .literal.* .text.*)
     *esp_loader.*(.literal .text .literal.* .text.*)
     *(.fini.literal)
diff --git a/boot/espressif/port/esp_loader.c b/boot/espressif/port/esp_loader.c
index a0806d3..4978df6 100644
--- a/boot/espressif/port/esp_loader.c
+++ b/boot/espressif/port/esp_loader.c
@@ -27,6 +27,10 @@
 #include "esp_loader.h"
 #include "flash_map_backend/flash_map_backend.h"
 
+#ifdef CONFIG_ESP_MULTI_PROCESSOR_BOOT
+#include "app_cpu_start.h"
+#endif
+
 static int load_segment(const struct flash_area *fap, uint32_t data_addr, uint32_t data_len, uint32_t load_addr)
 {
     const uint32_t *data = (const uint32_t *)bootloader_mmap((fap->fa_off + data_addr), data_len);
@@ -90,3 +94,20 @@
     assert(entry_addr != NULL);
     *entry_addr = load_header.entry_addr;
 }
+
+void start_cpu0_image(int image_index, int slot, unsigned int hdr_offset)
+{
+    unsigned int entry_addr;
+    esp_app_image_load(image_index, slot, hdr_offset, &entry_addr);
+    ((void (*)(void))entry_addr)(); /* Call to application entry address should not return */
+    FIH_PANIC; /* It should not get here */
+}
+
+#ifdef CONFIG_ESP_MULTI_PROCESSOR_BOOT
+void start_cpu1_image(int image_index, int slot, unsigned int hdr_offset)
+{
+    unsigned int entry_addr;
+    esp_app_image_load(image_index, slot, hdr_offset, &entry_addr);
+    appcpu_start(entry_addr);
+}
+#endif