1 //==========================================================================
3 // redboot_linux_exec.c
5 // RedBoot exec command for Linux booting
7 //==========================================================================
8 //####ECOSGPLCOPYRIGHTBEGIN####
9 // -------------------------------------------
10 // This file is part of eCos, the Embedded Configurable Operating System.
11 // Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Red Hat, Inc.
13 // eCos is free software; you can redistribute it and/or modify it under
14 // the terms of the GNU General Public License as published by the Free
15 // Software Foundation; either version 2 or (at your option) any later version.
17 // eCos is distributed in the hope that it will be useful, but WITHOUT ANY
18 // WARRANTY; without even the implied warranty of MERCHANTABILITY or
19 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 // You should have received a copy of the GNU General Public License along
23 // with eCos; if not, write to the Free Software Foundation, Inc.,
24 // 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
26 // As a special exception, if other files instantiate templates or use macros
27 // or inline functions from this file, or you compile this file and link it
28 // with other works to produce a work based on this file, this file does not
29 // by itself cause the resulting work to be covered by the GNU General Public
30 // License. However the source code for this file must still be made available
31 // in accordance with section (3) of the GNU General Public License.
33 // This exception does not invalidate any other reasons why a work based on
34 // this file might be covered by the GNU General Public License.
36 // Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
37 // at http://sources.redhat.com/ecos/ecos-license/
38 // -------------------------------------------
39 //####ECOSGPLCOPYRIGHTEND####
40 //==========================================================================
41 //#####DESCRIPTIONBEGIN####
43 // Author(s): t@keshi.org
44 // Contributors: t@keshi.org, jskov, dwmw2
46 // Purpose: RedBoot exec command for Linux booting, from MIPS arch
48 //####DESCRIPTIONEND####
50 //===========================================================================
54 #include <cyg/infra/cyg_type.h>
55 #include <cyg/hal/hal_intr.h>
56 #include <cyg/hal/hal_cache.h>
57 #include <cyg/hal/hal_if.h>
59 #ifdef CYGPKG_IO_ETH_DRIVERS
60 #include <cyg/io/eth/eth_drv.h> // Logical driver interfaces
63 #define xstr(s) str(s)
66 static void do_exec(int argc, char *argv[]);
69 "[-c \"kernel command line\"] [-w <timeout>]\n"
75 do_exec(int argc, char *argv[])
77 cyg_uint32 entry = (cyg_uint32)entry_address?:CYGDAT_REDBOOT_FRV_LINUX_BOOT_ENTRY;
78 char *cmd_line = xstr(CYGDAT_REDBOOT_FRV_LINUX_BOOT_COMMAND_LINE);
79 bool cmd_line_set, wait_time_set;
83 struct option_info opts[3];
84 void (*linux_boot)(unsigned long, char *);
86 hal_virtual_comm_table_t *__chan;
89 init_opts(&opts[0], 'w', true, OPTION_ARG_TYPE_NUM,
90 (void **)&wait_time, (bool *)&wait_time_set, "wait timeout");
91 init_opts(&opts[1], 'c', true, OPTION_ARG_TYPE_STR,
92 (void **)&cmd_line, &cmd_line_set, "kernel command line");
94 if (!scan_opts(argc, argv, 1, opts, 2, (void *)&entry,
95 OPTION_ARG_TYPE_NUM, "entry address"))
98 linux_boot = (void *)entry;
100 __chan = CYGACC_CALL_IF_CONSOLE_PROCS();
101 baud = CYGACC_COMM_IF_CONTROL(*__chan, __COMMCTL_GETBAUD);
103 diag_printf("Now booting linux kernel:\n");
104 diag_printf(" Entry 0x%08x\n", entry);
105 diag_printf(" Cmdline : %s\n", cmd_line);
108 diag_printf("About to start execution at %p - abort with ^C within %d seconds\n",
109 (void *)entry, wait_time);
110 res = _rb_gets(line, sizeof(line), wait_time*1000);
111 if (res == _GETS_CTRLC) {
116 HAL_DISABLE_INTERRUPTS(oldints);
118 #ifdef CYGPKG_IO_ETH_DRIVERS
123 HAL_ICACHE_DISABLE();
124 HAL_DCACHE_DISABLE();
126 HAL_ICACHE_INVALIDATE_ALL();
127 HAL_DCACHE_INVALIDATE_ALL();
129 linux_boot(0xdead1eaf, cmd_line);