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 Red Hat, Inc.
12 // Copyright (C) 2004 Gary Thomas
14 // eCos is free software; you can redistribute it and/or modify it under
15 // the terms of the GNU General Public License as published by the Free
16 // Software Foundation; either version 2 or (at your option) any later version.
18 // eCos is distributed in the hope that it will be useful, but WITHOUT ANY
19 // WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
23 // You should have received a copy of the GNU General Public License along
24 // with eCos; if not, write to the Free Software Foundation, Inc.,
25 // 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
27 // As a special exception, if other files instantiate templates or use macros
28 // or inline functions from this file, or you compile this file and link it
29 // with other works to produce a work based on this file, this file does not
30 // by itself cause the resulting work to be covered by the GNU General Public
31 // License. However the source code for this file must still be made available
32 // in accordance with section (3) of the GNU General Public License.
34 // This exception does not invalidate any other reasons why a work based on
35 // this file might be covered by the GNU General Public License.
37 // Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
38 // at http://sources.redhat.com/ecos/ecos-license/
39 // -------------------------------------------
40 //####ECOSGPLCOPYRIGHTEND####
41 //==========================================================================
42 //#####DESCRIPTIONBEGIN####
44 // Author(s): yoshinori sato
45 // Contributors: yoshinori sato
47 // Purpose: RedBoot exec command for uClinux booting
49 //####DESCRIPTIONEND####
51 //===========================================================================
55 #include <cyg/infra/cyg_type.h>
56 #include <cyg/hal/hal_intr.h>
57 #include <cyg/hal/hal_cache.h>
59 #define xstr(s) str(s)
62 #if defined(CYGDAT_REDBOOT_H8300_LINUX_COMMAND_START)
64 do_exec(int argc, char *argv[])
66 cyg_uint32 entry = CYGDAT_REDBOOT_H8300_LINUX_BOOT_ENTRY;
67 cyg_uint32 command_addr = CYGDAT_REDBOOT_H8300_LINUX_COMMAND_START;
68 char *cmd_line = xstr( CYGDAT_REDBOOT_H8300_LINUX_BOOT_COMMAND_LINE );
70 bool command_addr_set,command_line_set;
72 struct option_info opts[2];
76 init_opts(&opts[0], 'b', true, OPTION_ARG_TYPE_NUM,
77 &command_addr, &command_addr_set, "command line address");
78 init_opts(&opts[1], 'c', true, OPTION_ARG_TYPE_STR,
79 &cmd_line, &command_line_set, "kernel command line");
81 if (!scan_opts(argc, argv, 1, opts, 2, (void *)&entry,
82 OPTION_ARG_TYPE_NUM, "entry address"))
84 if (entry == (unsigned long)NO_MEMORY) {
85 diag_printf("Can't execute Linux - invalid entry address\n");
89 diag_printf("Now booting linux kernel:\n");
90 diag_printf(" Entry Address 0x%08x\n", entry);
91 diag_printf(" Cmdline : %s\n", cmd_line);
93 HAL_DISABLE_INTERRUPTS(oldints);
98 HAL_ICACHE_INVALIDATE_ALL();
99 HAL_DCACHE_INVALIDATE_ALL();
101 pcmd = (char *)command_addr;
102 while ((*pcmd++ = *cmd_line++));
104 asm ("jmp @%0" : : "r" (entry));
109 "[-b <command line addr>] [-c \"kernel command line\"]\n"
116 do_set_mem(int argc, char *argv[])
118 struct option_info opts[5];
119 unsigned long base, data;
120 bool base_set, data_set,len_set = 0;
121 static char _size = 1;
122 bool set_32bit, set_16bit, set_8bit;
124 init_opts(&opts[0], 'b', true, OPTION_ARG_TYPE_NUM,
125 &base, (bool *)&base_set, "base address");
126 init_opts(&opts[1], 'd', true, OPTION_ARG_TYPE_NUM,
127 &data, (bool *)&data_set, "write_data");
128 init_opts(&opts[2], '4', false, OPTION_ARG_TYPE_FLG,
129 &set_32bit, (bool *)0, "dump 32 bit units");
130 init_opts(&opts[3], '2', false, OPTION_ARG_TYPE_FLG,
131 &set_16bit, (bool *)0, "dump 16 bit units");
132 init_opts(&opts[4], '1', false, OPTION_ARG_TYPE_FLG,
133 &set_8bit, (bool *)0, "dump 8 bit units");
134 if (!scan_opts(argc, argv, 1, opts, 5, 0, 0, "")) {
138 diag_printf("illigal base\n");
143 diag_printf("illigal data\n");
149 } else if (set_16bit) {
151 } else if (set_8bit) {
158 diag_printf("%d %x = %x\n",_size,base,data);
161 *(unsigned char *)base=data;
164 *(unsigned short *)base=data;
167 *(unsigned long *)base=data;
174 "-b address -[1|2|4] -d data",