1 // SPDX-License-Identifier: GPL-2.0+
3 * (C) Copyright 2008-2011
4 * Graeme Russ, <graeme.russ@gmail.com>
7 * Daniel Engström, Omicron Ceti AB, <daniel@omicron.se>
10 * Wolfgang Denk, DENX Software Engineering, <wd@denx.de>
13 * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
14 * Marius Groeger <mgroeger@sysgo.de>
20 #include <asm/u-boot-x86.h>
22 DECLARE_GLOBAL_DATA_PTR;
24 unsigned long do_go_exec(ulong (*entry)(int, char * const []),
25 int argc, char * const argv[])
27 unsigned long ret = 0;
31 * x86 does not use a dedicated register to pass the pointer to
32 * the global_data, so it is instead passed as argv[-1]. By using
33 * argv[-1], the called 'Application' can use the contents of
34 * argv natively. However, to safely use argv[-1] a new copy of
35 * argv is needed with the extra element
37 argv_tmp = malloc(sizeof(char *) * (argc + 1));
40 argv_tmp[0] = (char *)gd;
42 memcpy(&argv_tmp[1], argv, (size_t)(sizeof(char *) * argc));
44 ret = (entry) (argc, &argv_tmp[1]);