2 * (C) Copyright 2008-2011
12 * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
15 * See file CREDITS for list of people who contributed to this
18 * This program is free software; you can redistribute it and/or
19 * modify it under the terms of the GNU General Public License as
20 * published by the Free Software Foundation; either version 2 of
21 * the License, or (at your option) any later version.
23 * This program is distributed in the hope that it will be useful,
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 * GNU General Public License for more details.
28 * You should have received a copy of the GNU General Public License
29 * along with this program; if not, write to the Free Software
30 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
37 #include <asm/u-boot-x86.h>
39 DECLARE_GLOBAL_DATA_PTR;
41 unsigned long do_go_exec(ulong (*entry)(int, char * const []),
42 int argc, char * const argv[])
44 unsigned long ret = 0;
48 * x86 does not use a dedicated register to pass the pointer to
49 * the global_data, so it is instead passed as argv[-1]. By using
50 * argv[-1], the called 'Application' can use the contents of
51 * argv natively. However, to safely use argv[-1] a new copy of
52 * argv is needed with the extra element
54 argv_tmp = malloc(sizeof(char *) * (argc + 1));
57 argv_tmp[0] = (char *)gd;
59 memcpy(&argv_tmp[1], argv, (size_t)(sizeof(char *) * argc));
61 ret = (entry) (argc, &argv_tmp[1]);