Mercurial > ecos-v3_0-branch
annotate packages/hal/powerpc/arch/current/src/redboot_linux_exec.c @ 2729:74dbf4c3f2e1 after-copyright-change-20090129
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
| author | jlarmour |
|---|---|
| date | Thu, 29 Jan 2009 17:47:46 +0000 |
| parents | a85441e685fa |
| children |
| rev | line source |
|---|---|
|
1182
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
1 //========================================================================== |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
2 // |
| 1610 | 3 // redboot_linux_exec.c |
|
1182
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
4 // |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
5 // RedBoot command to boot Linux |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
6 // |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
7 //========================================================================== |
|
2729
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
1911
diff
changeset
|
8 // ####ECOSGPLCOPYRIGHTBEGIN#### |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
1911
diff
changeset
|
9 // ------------------------------------------- |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
1911
diff
changeset
|
10 // This file is part of eCos, the Embedded Configurable Operating System. |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
1911
diff
changeset
|
11 // Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. |
|
1182
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
12 // |
|
2729
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
1911
diff
changeset
|
13 // eCos is free software; you can redistribute it and/or modify it under |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
1911
diff
changeset
|
14 // the terms of the GNU General Public License as published by the Free |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
1911
diff
changeset
|
15 // Software Foundation; either version 2 or (at your option) any later |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
1911
diff
changeset
|
16 // version. |
|
1182
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
17 // |
|
2729
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
1911
diff
changeset
|
18 // eCos is distributed in the hope that it will be useful, but WITHOUT |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
1911
diff
changeset
|
19 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
1911
diff
changeset
|
20 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
1911
diff
changeset
|
21 // for more details. |
|
1182
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
22 // |
|
2729
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
1911
diff
changeset
|
23 // You should have received a copy of the GNU General Public License |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
1911
diff
changeset
|
24 // along with eCos; if not, write to the Free Software Foundation, Inc., |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
1911
diff
changeset
|
25 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
1182
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
26 // |
|
2729
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
1911
diff
changeset
|
27 // As a special exception, if other files instantiate templates or use |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
1911
diff
changeset
|
28 // macros or inline functions from this file, or you compile this file |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
1911
diff
changeset
|
29 // and link it with other works to produce a work based on this file, |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
1911
diff
changeset
|
30 // this file does not by itself cause the resulting work to be covered by |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
1911
diff
changeset
|
31 // the GNU General Public License. However the source code for this file |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
1911
diff
changeset
|
32 // must still be made available in accordance with section (3) of the GNU |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
1911
diff
changeset
|
33 // General Public License v2. |
|
1182
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
34 // |
|
2729
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
1911
diff
changeset
|
35 // This exception does not invalidate any other reasons why a work based |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
1911
diff
changeset
|
36 // on this file might be covered by the GNU General Public License. |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
1911
diff
changeset
|
37 // ------------------------------------------- |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
1911
diff
changeset
|
38 // ####ECOSGPLCOPYRIGHTEND#### |
|
1182
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
39 //####OTHERCOPYRIGHTBEGIN#### |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
40 // |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
41 // The structure definitions below are taken from include/asm-/redboot.h in |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
42 // the Linux kernel, Copyright (c) 2002, 2003 Gary Thomas, Copyright (c) 1997 Dan Malek. |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
43 // Their presence here is for the express purpose of communication with the Linux |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
44 // kernel being booted and is considered 'fair use' by the original author and |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
45 // are included with their permission. |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
46 // |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
47 //####OTHERCOPYRIGHTEND#### |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
48 //========================================================================== |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
49 //#####DESCRIPTIONBEGIN#### |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
50 // |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
51 // Author(s): msalter |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
52 // Contributors: gthomas,msalter |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
53 // Date: 2002-01-14 |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
54 // Purpose: |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
55 // Description: |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
56 // |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
57 // This code is part of RedBoot (tm). |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
58 // |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
59 //####DESCRIPTIONEND#### |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
60 // |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
61 //========================================================================== |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
62 |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
63 #include <redboot.h> |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
64 |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
65 #include <cyg/hal/hal_arch.h> |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
66 #include <cyg/hal/hal_if.h> |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
67 #include <cyg/hal/hal_intr.h> |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
68 #include <cyg/hal/hal_cache.h> |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
69 |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
70 #ifdef CYGPKG_REDBOOT_NETWORKING |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
71 #include <net/net.h> |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
72 #endif |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
73 |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
74 #ifdef CYGPKG_IO_ETH_DRIVERS |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
75 #include <cyg/io/eth/eth_drv.h> // Logical driver interfaces |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
76 #endif |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
77 |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
78 #include CYGHWR_MEMORY_LAYOUT_H |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
79 |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
80 #include <cyg/hal/redboot_linux_exec.h> |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
81 |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
82 //========================================================================= |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
83 |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
84 // Exported CLI function(s) |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
85 static void do_exec(int argc, char *argv[]); |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
86 RedBoot_cmd("exec", |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
87 "Execute a Linux image - with MMU off", |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
88 "[-w timeout]\n" |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
89 " [-c \"kernel command line\"] [<entry_point>]", |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
90 do_exec |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
91 ); |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
92 |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
93 // |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
94 // Execute a Linux kernel - this is a RedBoot CLI command |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
95 // |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
96 static void |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
97 do_exec(int argc, char *argv[]) |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
98 { |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
99 unsigned long entry; |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
100 bool wait_time_set, cmd_line_set; |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
101 int wait_time; |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
102 char *cmd_line; |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
103 char *cline; |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
104 struct option_info opts[2]; |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
105 hal_virtual_comm_table_t *__chan; |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
106 int baud_rate; |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
107 |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
108 bd_t *board_info; |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
109 CYG_INTERRUPT_STATE oldints; |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
110 unsigned long sp = CYGMEM_REGION_ram+CYGMEM_REGION_ram_SIZE; |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
111 |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
112 init_opts(&opts[0], 'w', true, OPTION_ARG_TYPE_NUM, |
| 1608 | 113 (void *)&wait_time, (bool *)&wait_time_set, "wait timeout"); |
|
1182
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
114 init_opts(&opts[1], 'c', true, OPTION_ARG_TYPE_STR, |
| 1608 | 115 (void *)&cmd_line, (bool *)&cmd_line_set, "kernel command line"); |
|
1182
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
116 entry = entry_address; // Default from last 'load' operation |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
117 if (!scan_opts(argc, argv, 1, opts, 2, (void *)&entry, OPTION_ARG_TYPE_NUM, |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
118 "[physical] starting address")) { |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
119 return; |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
120 } |
|
1661
431860e2ee69
Improve Linux 'exec' to be sensitive to load failures
gthomas
parents:
1610
diff
changeset
|
121 if (entry == (unsigned long)NO_MEMORY) { |
|
431860e2ee69
Improve Linux 'exec' to be sensitive to load failures
gthomas
parents:
1610
diff
changeset
|
122 diag_printf("Can't execute Linux - invalid entry address\n"); |
|
431860e2ee69
Improve Linux 'exec' to be sensitive to load failures
gthomas
parents:
1610
diff
changeset
|
123 return; |
|
431860e2ee69
Improve Linux 'exec' to be sensitive to load failures
gthomas
parents:
1610
diff
changeset
|
124 } |
|
1182
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
125 |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
126 // Determine baud rate on current console |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
127 __chan = CYGACC_CALL_IF_CONSOLE_PROCS(); |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
128 baud_rate = CYGACC_COMM_IF_CONTROL(*__chan, __COMMCTL_GETBAUD); |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
129 if (baud_rate <= 0) { |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
130 baud_rate = CYGNUM_HAL_VIRTUAL_VECTOR_CONSOLE_CHANNEL_BAUD; |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
131 } |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
132 |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
133 // Make a little space at the top of the stack, and align to |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
134 // 64-bit boundary. |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
135 sp = (sp-128) & ~7; // The Linux boot code uses this space for FIFOs |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
136 |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
137 // Copy the commandline onto the stack, and set the SP to just below it. |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
138 if (cmd_line_set) { |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
139 int len,i; |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
140 |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
141 // get length of string |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
142 for( len = 0; cmd_line[len] != '\0'; len++ ); |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
143 |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
144 // decrement sp by length of string and align to |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
145 // word boundary. |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
146 sp = (sp-(len+1)) & ~3; |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
147 |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
148 // assign this SP value to command line start |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
149 cline = (char *)sp; |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
150 |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
151 // copy command line over. |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
152 for( i = 0; i < len; i++ ) |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
153 cline[i] = cmd_line[i]; |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
154 cline[len] = '\0'; |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
155 |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
156 } else { |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
157 cline = (char *)NULL; |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
158 } |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
159 |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
160 // Set up parameter struct at top of stack |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
161 sp = sp-sizeof(bd_t); |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
162 board_info = (bd_t *)sp; |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
163 memset(board_info, sizeof(*board_info), 0); |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
164 |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
165 board_info->bi_tag = 0x42444944; |
|
1911
a85441e685fa
Fix bi_size in Linux board struct - from Peter Korsgaard
gthomas
parents:
1661
diff
changeset
|
166 board_info->bi_size = sizeof(*board_info); |
|
1182
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
167 board_info->bi_revision = 1; |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
168 board_info->bi_bdate = 0x06012002; |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
169 board_info->bi_memstart = CYGMEM_REGION_ram; |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
170 board_info->bi_memsize = CYGMEM_REGION_ram_SIZE; |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
171 board_info->bi_baudrate = baud_rate; |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
172 board_info->bi_cmdline = cline; |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
173 #ifdef CYGPKG_REDBOOT_NETWORKING |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
174 memcpy(board_info->bi_enetaddr, __local_enet_addr, sizeof(enet_addr_t)); |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
175 #endif |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
176 // Call platform specific code to fill in the platform/architecture specific details |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
177 plf_redboot_linux_exec(board_info); |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
178 |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
179 // adjust SP to 64 byte boundary, and leave a little space |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
180 // between it and the commandline for PowerPC calling |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
181 // conventions. |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
182 |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
183 sp = (sp-64)&~63; |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
184 |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
185 if (wait_time_set) { |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
186 int script_timeout_ms = wait_time * 1000; |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
187 #ifdef CYGFUN_REDBOOT_BOOT_SCRIPT |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
188 unsigned char *hold_script = script; |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
189 script = (unsigned char *)0; |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
190 #endif |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
191 diag_printf("About to start execution at %p - abort with ^C within %d seconds\n", |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
192 (void *)entry, wait_time); |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
193 while (script_timeout_ms >= CYGNUM_REDBOOT_CLI_IDLE_TIMEOUT) { |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
194 int res; |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
195 char line[80]; |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
196 res = _rb_gets(line, sizeof(line), CYGNUM_REDBOOT_CLI_IDLE_TIMEOUT); |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
197 if (res == _GETS_CTRLC) { |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
198 #ifdef CYGFUN_REDBOOT_BOOT_SCRIPT |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
199 script = hold_script; // Re-enable script |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
200 #endif |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
201 return; |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
202 } |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
203 script_timeout_ms -= CYGNUM_REDBOOT_CLI_IDLE_TIMEOUT; |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
204 } |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
205 } |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
206 |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
207 #ifdef CYGPKG_IO_ETH_DRIVERS |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
208 eth_drv_stop(); |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
209 #endif |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
210 |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
211 // Disable interrupts |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
212 HAL_DISABLE_INTERRUPTS(oldints); |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
213 |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
214 // Put the caches to sleep. |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
215 HAL_DCACHE_SYNC(); |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
216 HAL_ICACHE_DISABLE(); |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
217 HAL_DCACHE_DISABLE(); |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
218 HAL_DCACHE_SYNC(); |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
219 HAL_ICACHE_INVALIDATE_ALL(); |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
220 HAL_DCACHE_INVALIDATE_ALL(); |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
221 |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
222 // diag_printf("entry %08x, sp %08x, info %08x, cmd line %08x, baud %d\n", |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
223 // entry, sp, board_info, cline, baud_rate); |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
224 // breakpoint(); |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
225 |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
226 // Call into Linux |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
227 __asm__ volatile ( |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
228 // Start by disabling MMU - the mappings are |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
229 // 1-1 so this should not cause any problems |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
230 "mfmsr 3\n" |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
231 "li 4,0xFFFFFFCF\n" |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
232 "and 3,3,4\n" |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
233 "sync\n" |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
234 "mtmsr 3\n" |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
235 "sync\n" |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
236 |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
237 // Now set up parameters to jump into linux |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
238 |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
239 "mtlr %0\n" // set entry address in LR |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
240 "mr 1,%1\n" // set stack pointer |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
241 "mr 3,%2\n" // set board info in R3 |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
242 "mr 4,%3\n" // set command line in R4 |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
243 "blr \n" // jump into linux |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
244 : |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
245 : "r"(entry),"r"(sp),"r"(board_info),"r"(cline) |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
246 : "r3", "r4" |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
247 |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
248 ); |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
249 } |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
250 |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
251 //========================================================================= |
|
8c272f96c3ed
Better handling of RedBoot Linux 'exec' with architecture/platform layering
gthomas
parents:
diff
changeset
|
252 // EOF redboot_linux_exec.c |
