diff --git a/src/arch/x86/include/arch/stages.h b/src/arch/x86/include/arch/stages.h index 8cbf5da34a..91d0db6957 100644 --- a/src/arch/x86/include/arch/stages.h +++ b/src/arch/x86/include/arch/stages.h @@ -24,4 +24,12 @@ void asmlinkage copy_and_run(void); void jmp_to_elf_entry(void *entry, unsigned long buffer, unsigned long size); + +static inline void stage_exit(void *entry) +{ + __asm__ volatile ( + "jmp *%%edi\n" + :: "D"(entry) + ); +} #endif diff --git a/src/arch/x86/lib/cbfs_and_run.c b/src/arch/x86/lib/cbfs_and_run.c index 5a0b1fc9e6..6173d03d58 100644 --- a/src/arch/x86/lib/cbfs_and_run.c +++ b/src/arch/x86/lib/cbfs_and_run.c @@ -34,10 +34,7 @@ static void cbfs_and_run_core(const char *filename) timestamp_add_now(TS_END_COPYRAM); print_debug("Jumping to image.\n"); - __asm__ volatile ( - "jmp *%%edi\n" - :: "D"(dst) - ); + stage_exit(dst); } void asmlinkage copy_and_run(void) diff --git a/src/vendorcode/google/chromeos/vboot_loader.c b/src/vendorcode/google/chromeos/vboot_loader.c index 314f2bd2f3..007380f21f 100644 --- a/src/vendorcode/google/chromeos/vboot_loader.c +++ b/src/vendorcode/google/chromeos/vboot_loader.c @@ -17,6 +17,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include #include #include #include @@ -353,15 +354,7 @@ static void vboot_load_ramstage(struct vboot_handoff *vboot_handoff, timestamp_add_now(TS_END_COPYRAM); -#if CONFIG_ARCH_X86 - __asm__ volatile ( - "movl $0, %%ebp\n" - "jmp *%%edi\n" - :: "D"(rmod_load.entry) - ); -#elif CONFIG_ARCH_ARM stage_exit(rmod_load.entry); -#endif } #else /* CONFIG_RELOCATABLE_RAMSTAGE */ static void vboot_load_ramstage(struct vboot_handoff *vboot_handoff, @@ -408,15 +401,7 @@ static void vboot_load_ramstage(struct vboot_handoff *vboot_handoff, timestamp_add_now(TS_END_COPYRAM); -#if CONFIG_ARCH_X86 - __asm__ volatile ( - "movl $0, %%ebp\n" - "jmp *%%edi\n" - :: "D"(stage->entry) - ); -#elif CONFIG_ARCH_ARM stage_exit((void *)(uintptr_t)stage->entry); -#endif } #endif /* CONFIG_RELOCATABLE_RAMSTAGE */