blob: b4451795cc70c0688d2424885e45fc988f37a47d [file] [log] [blame]
wdenk2262cfe2002-11-18 00:14:45 +00001/*
Graeme Russdbf71152011-04-13 19:43:26 +10002 * (C) Copyright 2008-2011
3 * Graeme Russ, <graeme.russ@gmail.com>
wdenk8bde7f72003-06-27 21:31:46 +00004 *
wdenk2262cfe2002-11-18 00:14:45 +00005 * (C) Copyright 2002
Albert ARIBAUDfa82f872011-08-04 18:45:45 +02006 * Daniel Engström, Omicron Ceti AB, <daniel@omicron.se>
Graeme Russdbf71152011-04-13 19:43:26 +10007 *
8 * (C) Copyright 2002
9 * Wolfgang Denk, DENX Software Engineering, <wd@denx.de>
wdenk8bde7f72003-06-27 21:31:46 +000010 *
wdenk2262cfe2002-11-18 00:14:45 +000011 * (C) Copyright 2002
12 * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
13 * Marius Groeger <mgroeger@sysgo.de>
14 *
15 * See file CREDITS for list of people who contributed to this
16 * project.
17 *
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.
22 *
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.
27 *
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,
31 * MA 02111-1307 USA
32 */
33
34#include <common.h>
35#include <watchdog.h>
36#include <command.h>
Jean-Christophe PLAGNIOL-VILLARD52cb4d42009-05-16 12:14:54 +020037#include <stdio_dev.h>
wdenk2262cfe2002-11-18 00:14:45 +000038#include <version.h>
39#include <malloc.h>
wdenk2262cfe2002-11-18 00:14:45 +000040#include <net.h>
41#include <ide.h>
Graeme Russbf165002010-04-24 00:05:47 +100042#include <serial.h>
Graeme Russfea25722011-04-13 19:43:28 +100043#include <asm/u-boot-x86.h>
Graeme Russ1c409bc2009-11-24 20:04:21 +110044#include <elf.h>
wdenk2262cfe2002-11-18 00:14:45 +000045
Luigi 'Comio' Mantellini310cecb2009-10-10 12:42:21 +020046#ifdef CONFIG_BITBANGMII
47#include <miiphy.h>
48#endif
49
Graeme Russ2e2613d2011-02-12 15:11:50 +110050/*
51 * Pointer to initial global data area
52 *
53 * Here we initialize it.
54 */
55#undef XTRN_DECLARE_GLOBAL_DATA_PTR
56#define XTRN_DECLARE_GLOBAL_DATA_PTR /* empty = allocate here */
57DECLARE_GLOBAL_DATA_PTR = (gd_t *) (CONFIG_SYS_INIT_GD_ADDR);
58
wdenk2262cfe2002-11-18 00:14:45 +000059/************************************************************************
60 * Init Utilities *
61 ************************************************************************
62 * Some of this code should be moved into the core functions,
63 * or dropped completely,
64 * but let's get it working (again) first...
65 */
Graeme Russ83088af2011-11-08 02:33:15 +000066static int init_baudrate(void)
wdenk2262cfe2002-11-18 00:14:45 +000067{
Simon Glassf5ca20c2011-10-13 14:43:14 +000068 gd->baudrate = getenv_ulong("baudrate", 10, CONFIG_BAUDRATE);
69 return 0;
wdenk2262cfe2002-11-18 00:14:45 +000070}
71
Graeme Russ83088af2011-11-08 02:33:15 +000072static int display_banner(void)
wdenk2262cfe2002-11-18 00:14:45 +000073{
74
Graeme Russ83088af2011-11-08 02:33:15 +000075 printf("\n\n%s\n\n", version_string);
wdenk8bde7f72003-06-27 21:31:46 +000076
Graeme Russ83088af2011-11-08 02:33:15 +000077 return 0;
wdenk2262cfe2002-11-18 00:14:45 +000078}
79
Graeme Russ83088af2011-11-08 02:33:15 +000080static int display_dram_config(void)
wdenk2262cfe2002-11-18 00:14:45 +000081{
wdenk2262cfe2002-11-18 00:14:45 +000082 int i;
83
Graeme Russ83088af2011-11-08 02:33:15 +000084 puts("DRAM Configuration:\n");
wdenk2262cfe2002-11-18 00:14:45 +000085
Graeme Russ83088af2011-11-08 02:33:15 +000086 for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
87 printf("Bank #%d: %08lx ", i, gd->bd->bi_dram[i].start);
88 print_size(gd->bd->bi_dram[i].size, "\n");
wdenk2262cfe2002-11-18 00:14:45 +000089 }
wdenk8bde7f72003-06-27 21:31:46 +000090
Graeme Russ83088af2011-11-08 02:33:15 +000091 return 0;
wdenk2262cfe2002-11-18 00:14:45 +000092}
93
Graeme Russa76fc702011-11-08 02:33:20 +000094#ifndef CONFIG_SYS_NO_FLASH
Graeme Russ83088af2011-11-08 02:33:15 +000095static void display_flash_config(ulong size)
wdenk2262cfe2002-11-18 00:14:45 +000096{
Graeme Russ83088af2011-11-08 02:33:15 +000097 puts("Flash: ");
98 print_size(size, "\n");
wdenk2262cfe2002-11-18 00:14:45 +000099}
Graeme Russa76fc702011-11-08 02:33:20 +0000100#endif
wdenk2262cfe2002-11-18 00:14:45 +0000101
wdenk2262cfe2002-11-18 00:14:45 +0000102/*
103 * Breath some life into the board...
104 *
105 * Initialize an SMC for serial comms, and carry out some hardware
106 * tests.
107 *
108 * The first part of initialization is running from Flash memory;
109 * its main purpose is to initialize the RAM so that we
110 * can relocate the monitor code to RAM.
111 */
112
113/*
114 * All attempts to come up with a "common" initialization sequence
115 * that works for all boards and architectures failed: some of the
116 * requirements are just _too_ different. To get rid of the resulting
117 * mess of board dependend #ifdef'ed code we now make the whole
118 * initialization sequence configurable to the user.
119 *
120 * The requirements for any new initalization function is simple: it
121 * receives a pointer to the "global data" structure as it's only
122 * argument, and returns an integer return code, where 0 means
123 * "continue" and != 0 means "fatal error, hang the system".
124 */
125typedef int (init_fnc_t) (void);
126
Graeme Russe4f78d72011-02-12 15:12:10 +1100127static int calculate_relocation_address(void);
128static int copy_uboot_to_ram(void);
129static int clear_bss(void);
130static int do_elf_reloc_fixups(void);
131
132init_fnc_t *init_sequence_f[] = {
133 cpu_init_f,
134 board_early_init_f,
135 env_init,
136 init_baudrate,
137 serial_init,
138 console_init_f,
139 dram_init_f,
140 calculate_relocation_address,
141 copy_uboot_to_ram,
142 clear_bss,
143 do_elf_reloc_fixups,
144
145 NULL,
146};
147
148init_fnc_t *init_sequence_r[] = {
Graeme Russ1c409bc2009-11-24 20:04:21 +1100149 cpu_init_r, /* basic cpu dependent setup */
150 board_early_init_r, /* basic board dependent setup */
wdenk2262cfe2002-11-18 00:14:45 +0000151 dram_init, /* configure available RAM banks */
wdenk2262cfe2002-11-18 00:14:45 +0000152 interrupt_init, /* set up exceptions */
wdenk8bde7f72003-06-27 21:31:46 +0000153 timer_init,
wdenk2262cfe2002-11-18 00:14:45 +0000154 display_banner,
155 display_dram_config,
156
157 NULL,
158};
159
Graeme Russ3ef96de2008-09-07 07:08:42 +1000160gd_t *gd;
wdenk2262cfe2002-11-18 00:14:45 +0000161
Graeme Russ71a54042011-02-12 15:12:06 +1100162static int calculate_relocation_address(void)
163{
164 void *text_start = &__text_start;
165 void *bss_end = &__bss_end;
166 void *dest_addr;
167 ulong rel_offset;
168
169 /* Calculate destination RAM Address and relocation offset */
170 dest_addr = (void *)gd->ram_size;
171 dest_addr -= CONFIG_SYS_STACK_SIZE;
172 dest_addr -= (bss_end - text_start);
173 rel_offset = dest_addr - text_start;
174
175 gd->start_addr_sp = gd->ram_size;
176 gd->relocaddr = (ulong)dest_addr;
177 gd->reloc_off = rel_offset;
178
179 return 0;
180}
181
182static int copy_uboot_to_ram(void)
183{
184 ulong *dst_addr = (ulong *)gd->relocaddr;
185 ulong *src_addr = (ulong *)&__text_start;
186 ulong *end_addr = (ulong *)&__data_end;
187
188 while (src_addr < end_addr)
189 *dst_addr++ = *src_addr++;
190
191 return 0;
192}
193
194static int clear_bss(void)
195{
196 void *bss_start = &__bss_start;
197 void *bss_end = &__bss_end;
198
199 ulong *dst_addr = (ulong *)(bss_start + gd->reloc_off);
Graeme Russ83088af2011-11-08 02:33:15 +0000200 ulong *end_addr = (ulong *)(bss_end + gd->reloc_off);
Graeme Russ71a54042011-02-12 15:12:06 +1100201
202 while (dst_addr < end_addr)
203 *dst_addr++ = 0x00000000;
204
205 return 0;
206}
207
208static int do_elf_reloc_fixups(void)
209{
210 Elf32_Rel *re_src = (Elf32_Rel *)(&__rel_dyn_start);
211 Elf32_Rel *re_end = (Elf32_Rel *)(&__rel_dyn_end);
212
Graeme Russ83088af2011-11-08 02:33:15 +0000213 Elf32_Addr *offset_ptr_rom;
214 Elf32_Addr *offset_ptr_ram;
215
Graeme Russ71a54042011-02-12 15:12:06 +1100216 do {
Graeme Russ83088af2011-11-08 02:33:15 +0000217 /* Get the location from the relocation entry */
218 offset_ptr_rom = (Elf32_Addr *)re_src->r_offset;
219
220 /* Check that the location of the relocation is in .text */
221 if (offset_ptr_rom >= (Elf32_Addr *)CONFIG_SYS_TEXT_BASE) {
222
223 /* Switch to the in-RAM version */
224 offset_ptr_ram = offset_ptr_rom + gd->reloc_off;
225
226 /* Check that the target points into .text */
227 if (*offset_ptr_ram >= CONFIG_SYS_TEXT_BASE)
228 *offset_ptr_ram += gd->reloc_off;
229 }
Graeme Russ71a54042011-02-12 15:12:06 +1100230 } while (re_src++ < re_end);
231
232 return 0;
233}
234
Graeme Russdbf71152011-04-13 19:43:26 +1000235/* Load U-Boot into RAM, initialize BSS, perform relocation adjustments */
Graeme Russ96cd6642011-02-12 15:11:54 +1100236void board_init_f(ulong boot_flags)
Graeme Russ1c409bc2009-11-24 20:04:21 +1100237{
Graeme Russe4f78d72011-02-12 15:12:10 +1100238 init_fnc_t **init_fnc_ptr;
Graeme Russa3824142011-02-12 15:12:08 +1100239
Graeme Russdbf71152011-04-13 19:43:26 +1000240 gd->flags = boot_flags;
241
Graeme Russe4f78d72011-02-12 15:12:10 +1100242 for (init_fnc_ptr = init_sequence_f; *init_fnc_ptr; ++init_fnc_ptr) {
243 if ((*init_fnc_ptr)() != 0)
244 hang();
245 }
Graeme Russf2ff75c2010-10-07 20:03:33 +1100246
Graeme Russ2e2613d2011-02-12 15:11:50 +1100247 gd->flags |= GD_FLG_RELOC;
Graeme Russ161b3582010-10-07 20:03:29 +1100248
Graeme Russ2fb1bc42010-04-24 00:05:44 +1000249 /* Enter the relocated U-Boot! */
Graeme Russ71a54042011-02-12 15:12:06 +1100250 relocate_code(gd->start_addr_sp, gd, gd->relocaddr);
Graeme Russ161b3582010-10-07 20:03:29 +1100251
Graeme Russfb002902011-02-12 15:11:58 +1100252 /* NOTREACHED - relocate_code() does not return */
Graeme Russ83088af2011-11-08 02:33:15 +0000253 while (1)
254 ;
Graeme Russ1c409bc2009-11-24 20:04:21 +1100255}
256
Graeme Russ2fb1bc42010-04-24 00:05:44 +1000257void board_init_r(gd_t *id, ulong dest_addr)
wdenk2262cfe2002-11-18 00:14:45 +0000258{
Graeme Russa76fc702011-11-08 02:33:20 +0000259#if defined(CONFIG_CMD_NET)
wdenk2262cfe2002-11-18 00:14:45 +0000260 char *s;
Graeme Russa76fc702011-11-08 02:33:20 +0000261#endif
262#ifndef CONFIG_SYS_NO_FLASH
wdenk2262cfe2002-11-18 00:14:45 +0000263 ulong size;
Graeme Russa76fc702011-11-08 02:33:20 +0000264#endif
wdenk2262cfe2002-11-18 00:14:45 +0000265 static bd_t bd_data;
Graeme Russ2e2613d2011-02-12 15:11:50 +1100266 static gd_t gd_data;
wdenk2262cfe2002-11-18 00:14:45 +0000267 init_fnc_t **init_fnc_ptr;
wdenk8bde7f72003-06-27 21:31:46 +0000268
wdenk2262cfe2002-11-18 00:14:45 +0000269 show_boot_progress(0x21);
270
Graeme Russ2e2613d2011-02-12 15:11:50 +1100271 /* Global data pointer is now writable */
272 gd = &gd_data;
273 memcpy(gd, id, sizeof(gd_t));
274
wdenk93f6a672004-07-01 20:28:03 +0000275 /* compiler optimization barrier needed for GCC >= 3.4 */
Graeme Russ83088af2011-11-08 02:33:15 +0000276 __asm__ __volatile__("" : : : "memory");
wdenk8bde7f72003-06-27 21:31:46 +0000277
wdenk2262cfe2002-11-18 00:14:45 +0000278 gd->bd = &bd_data;
Graeme Russ83088af2011-11-08 02:33:15 +0000279 memset(gd->bd, 0, sizeof(bd_t));
wdenk2262cfe2002-11-18 00:14:45 +0000280 show_boot_progress(0x22);
281
wdenk7a8e9bed2003-05-31 18:35:21 +0000282 gd->baudrate = CONFIG_BAUDRATE;
wdenk8bde7f72003-06-27 21:31:46 +0000283
Graeme Russ2fb1bc42010-04-24 00:05:44 +1000284 mem_malloc_init((((ulong)dest_addr - CONFIG_SYS_MALLOC_LEN)+3)&~3,
Graeme Russ1c409bc2009-11-24 20:04:21 +1100285 CONFIG_SYS_MALLOC_LEN);
286
Graeme Russe4f78d72011-02-12 15:12:10 +1100287 for (init_fnc_ptr = init_sequence_r; *init_fnc_ptr; ++init_fnc_ptr) {
288 if ((*init_fnc_ptr)() != 0)
Graeme Russ83088af2011-11-08 02:33:15 +0000289 hang();
wdenk2262cfe2002-11-18 00:14:45 +0000290 }
291 show_boot_progress(0x23);
292
Graeme Russbf165002010-04-24 00:05:47 +1000293#ifdef CONFIG_SERIAL_MULTI
294 serial_initialize();
295#endif
Graeme Russa76fc702011-11-08 02:33:20 +0000296
297#ifndef CONFIG_SYS_NO_FLASH
wdenk2262cfe2002-11-18 00:14:45 +0000298 /* configure available FLASH banks */
299 size = flash_init();
300 display_flash_config(size);
301 show_boot_progress(0x24);
Graeme Russa76fc702011-11-08 02:33:20 +0000302#endif
wdenk2262cfe2002-11-18 00:14:45 +0000303
304 show_boot_progress(0x25);
305
306 /* initialize environment */
Graeme Russ83088af2011-11-08 02:33:15 +0000307 env_relocate();
wdenk2262cfe2002-11-18 00:14:45 +0000308 show_boot_progress(0x26);
309
310
Graeme Russ535ad2d2010-04-24 00:05:36 +1000311#ifdef CONFIG_CMD_NET
wdenk2262cfe2002-11-18 00:14:45 +0000312 /* IP Address */
Graeme Russ83088af2011-11-08 02:33:15 +0000313 bd_data.bi_ip_addr = getenv_IPaddr("ipaddr");
Graeme Russ535ad2d2010-04-24 00:05:36 +1000314#endif
wdenk2262cfe2002-11-18 00:14:45 +0000315
wdenk2262cfe2002-11-18 00:14:45 +0000316#if defined(CONFIG_PCI)
317 /*
318 * Do pci configuration
319 */
320 pci_init();
321#endif
322
323 show_boot_progress(0x27);
324
325
Graeme Russ83088af2011-11-08 02:33:15 +0000326 stdio_init();
wdenk2262cfe2002-11-18 00:14:45 +0000327
Graeme Russ83088af2011-11-08 02:33:15 +0000328 jumptable_init();
wdenk8bde7f72003-06-27 21:31:46 +0000329
wdenk2262cfe2002-11-18 00:14:45 +0000330 /* Initialize the console (after the relocation and devices init) */
331 console_init_r();
wdenk2262cfe2002-11-18 00:14:45 +0000332
333#ifdef CONFIG_MISC_INIT_R
334 /* miscellaneous platform dependent initialisations */
335 misc_init_r();
336#endif
337
Jon Loeliger67350562007-07-09 18:05:38 -0500338#if defined(CONFIG_CMD_PCMCIA) && !defined(CONFIG_CMD_IDE)
wdenk2262cfe2002-11-18 00:14:45 +0000339 WATCHDOG_RESET();
Graeme Russ83088af2011-11-08 02:33:15 +0000340 puts("PCMCIA:");
wdenk2262cfe2002-11-18 00:14:45 +0000341 pcmcia_init();
342#endif
343
Jon Loeliger67350562007-07-09 18:05:38 -0500344#if defined(CONFIG_CMD_KGDB)
wdenk2262cfe2002-11-18 00:14:45 +0000345 WATCHDOG_RESET();
346 puts("KGDB: ");
347 kgdb_init();
348#endif
349
350 /* enable exceptions */
wdenk7a8e9bed2003-05-31 18:35:21 +0000351 enable_interrupts();
wdenk2262cfe2002-11-18 00:14:45 +0000352 show_boot_progress(0x28);
353
wdenk2262cfe2002-11-18 00:14:45 +0000354#ifdef CONFIG_STATUS_LED
Graeme Russ83088af2011-11-08 02:33:15 +0000355 status_led_set(STATUS_LED_BOOT, STATUS_LED_BLINKING);
wdenk2262cfe2002-11-18 00:14:45 +0000356#endif
357
wdenk7a8e9bed2003-05-31 18:35:21 +0000358 udelay(20);
wdenk2262cfe2002-11-18 00:14:45 +0000359
wdenk2262cfe2002-11-18 00:14:45 +0000360 /* Initialize from environment */
Simon Glassf5ca20c2011-10-13 14:43:14 +0000361 load_addr = getenv_ulong("loadaddr", 16, load_addr);
Jon Loeliger67350562007-07-09 18:05:38 -0500362#if defined(CONFIG_CMD_NET)
Graeme Russ83088af2011-11-08 02:33:15 +0000363 s = getenv("bootfile");
364
365 if (s != NULL)
366 copy_filename(BootFile, s, sizeof(BootFile));
Jon Loeligerb3aff0c2007-07-10 11:19:50 -0500367#endif
wdenk2262cfe2002-11-18 00:14:45 +0000368
369 WATCHDOG_RESET();
370
Jon Loeliger67350562007-07-09 18:05:38 -0500371#if defined(CONFIG_CMD_IDE)
wdenk2262cfe2002-11-18 00:14:45 +0000372 WATCHDOG_RESET();
373 puts("IDE: ");
374 ide_init();
Jon Loeligerb3aff0c2007-07-10 11:19:50 -0500375#endif
wdenk2262cfe2002-11-18 00:14:45 +0000376
Jon Loeliger67350562007-07-09 18:05:38 -0500377#if defined(CONFIG_CMD_SCSI)
wdenk2262cfe2002-11-18 00:14:45 +0000378 WATCHDOG_RESET();
379 puts("SCSI: ");
380 scsi_init();
381#endif
382
Jon Loeliger67350562007-07-09 18:05:38 -0500383#if defined(CONFIG_CMD_DOC)
wdenk2262cfe2002-11-18 00:14:45 +0000384 WATCHDOG_RESET();
wdenk7a8e9bed2003-05-31 18:35:21 +0000385 puts("DOC: ");
wdenk2262cfe2002-11-18 00:14:45 +0000386 doc_init();
387#endif
388
Luigi 'Comio' Mantellini310cecb2009-10-10 12:42:21 +0200389#ifdef CONFIG_BITBANGMII
390 bb_miiphy_init();
391#endif
Jon Loeliger67350562007-07-09 18:05:38 -0500392#if defined(CONFIG_CMD_NET)
wdenk2262cfe2002-11-18 00:14:45 +0000393 WATCHDOG_RESET();
394 puts("Net: ");
395 eth_initialize(gd->bd);
396#endif
397
Graeme Russ83088af2011-11-08 02:33:15 +0000398#if (defined(CONFIG_CMD_NET)) && (0)
Marian Balakowicz63ff0042005-10-28 22:30:33 +0200399 WATCHDOG_RESET();
400# ifdef DEBUG
Graeme Russ83088af2011-11-08 02:33:15 +0000401 puts("Reset Ethernet PHY\n");
Marian Balakowicz63ff0042005-10-28 22:30:33 +0200402# endif
403 reset_phy();
404#endif
405
wdenk2262cfe2002-11-18 00:14:45 +0000406#ifdef CONFIG_LAST_STAGE_INIT
407 WATCHDOG_RESET();
408 /*
409 * Some parts can be only initialized if all others (like
410 * Interrupts) are up and running (i.e. the PC-style ISA
411 * keyboard).
412 */
413 last_stage_init();
414#endif
415
416
wdenk2262cfe2002-11-18 00:14:45 +0000417#ifdef CONFIG_POST
Graeme Russ83088af2011-11-08 02:33:15 +0000418 post_run(NULL, POST_RAM | post_bootmode_get(0));
wdenk2262cfe2002-11-18 00:14:45 +0000419#endif
wdenk8bde7f72003-06-27 21:31:46 +0000420
wdenk2262cfe2002-11-18 00:14:45 +0000421 show_boot_progress(0x29);
wdenk8bde7f72003-06-27 21:31:46 +0000422
wdenk2262cfe2002-11-18 00:14:45 +0000423 /* main_loop() can return to retry autoboot, if so just run it again. */
Graeme Russ83088af2011-11-08 02:33:15 +0000424 for (;;)
wdenk7a8e9bed2003-05-31 18:35:21 +0000425 main_loop();
wdenk2262cfe2002-11-18 00:14:45 +0000426
427 /* NOTREACHED - no way out of command loop except booting */
428}
429
Graeme Russ83088af2011-11-08 02:33:15 +0000430void hang(void)
wdenk2262cfe2002-11-18 00:14:45 +0000431{
Graeme Russ83088af2011-11-08 02:33:15 +0000432 puts("### ERROR ### Please RESET the board ###\n");
433 for (;;)
434 ;
wdenk2262cfe2002-11-18 00:14:45 +0000435}
Mike Frysingera4986452008-04-13 19:42:19 -0400436
Graeme Russ83088af2011-11-08 02:33:15 +0000437unsigned long do_go_exec(ulong (*entry)(int, char * const []),
438 int argc, char * const argv[])
Mike Frysingera4986452008-04-13 19:42:19 -0400439{
Graeme Russe69c0cb2010-08-22 16:25:58 +1000440 unsigned long ret = 0;
441 char **argv_tmp;
Graeme Russ9e08efc2010-04-24 00:05:39 +1000442
Graeme Russe69c0cb2010-08-22 16:25:58 +1000443 /*
444 * x86 does not use a dedicated register to pass the pointer to
445 * the global_data, so it is instead passed as argv[-1]. By using
446 * argv[-1], the called 'Application' can use the contents of
447 * argv natively. However, to safely use argv[-1] a new copy of
448 * argv is needed with the extra element
449 */
450 argv_tmp = malloc(sizeof(char *) * (argc + 1));
451
452 if (argv_tmp) {
453 argv_tmp[0] = (char *)gd;
454
455 memcpy(&argv_tmp[1], argv, (size_t)(sizeof(char *) * argc));
456
457 ret = (entry) (argc, &argv_tmp[1]);
458 free(argv_tmp);
459 }
460
461 return ret;
Mike Frysingera4986452008-04-13 19:42:19 -0400462}
Graeme Russ79ea6b82010-04-24 00:05:48 +1000463
464void setup_pcat_compatibility(void)
465 __attribute__((weak, alias("__setup_pcat_compatibility")));
466
467void __setup_pcat_compatibility(void)
468{
469}