blob: 1ea80f4e363d6865a53d4b2906cb3898f1213df6 [file] [log] [blame]
Wolfgang Denk6cb142f2006-03-12 02:12:27 +01001/*
2 * U-boot - bf533_linux.c
3 *
Aubrey Li155fd762007-04-05 18:31:18 +08004 * Copyright (c) 2005-2007 Analog Devices Inc.
Wolfgang Denk6cb142f2006-03-12 02:12:27 +01005 *
6 * (C) Copyright 2000-2004
7 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
8 *
9 * See file CREDITS for list of people who contributed to this
10 * project.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License as
14 * published by the Free Software Foundation; either version 2 of
15 * the License, or (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
Aubrey Li155fd762007-04-05 18:31:18 +080024 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
25 * MA 02110-1301 USA
Wolfgang Denk6cb142f2006-03-12 02:12:27 +010026 */
27
28/* Dummy functions, currently not in Use */
29
30#include <common.h>
31#include <command.h>
32#include <image.h>
33#include <zlib.h>
34#include <asm/byteorder.h>
35
36#define LINUX_MAX_ENVS 256
37#define LINUX_MAX_ARGS 256
38
Aubrey.Li3f0606a2007-03-09 13:38:44 +080039#define CMD_LINE_ADDR 0xFF900000 /* L1 scratchpad */
Wolfgang Denk6cb142f2006-03-12 02:12:27 +010040
41#ifdef SHARED_RESOURCES
Aubrey.Li3f0606a2007-03-09 13:38:44 +080042extern void swap_to(int device_id);
Wolfgang Denk6cb142f2006-03-12 02:12:27 +010043#endif
44
Aubrey.Li3f0606a2007-03-09 13:38:44 +080045extern void flush_instruction_cache(void);
46extern void flush_data_cache(void);
Wolfgang Denk6cb142f2006-03-12 02:12:27 +010047static char *make_command_line(void);
48
Wolfgang Denk6cb142f2006-03-12 02:12:27 +010049void do_bootm_linux(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[],
Marian Balakowicz8a5ea3e2008-02-27 11:01:04 +010050 bootm_headers_t *images)
Wolfgang Denk6cb142f2006-03-12 02:12:27 +010051{
Marian Balakowiczd5934ad2008-02-04 08:28:09 +010052 int (*appl) (char *cmdline);
53 char *cmdline;
54 ulong ep = 0;
Wolfgang Denk6cb142f2006-03-12 02:12:27 +010055
Kumar Gala75fa0022008-02-27 21:51:51 -060056 if (!images->autostart)
57 return ;
58
Wolfgang Denk6cb142f2006-03-12 02:12:27 +010059#ifdef SHARED_RESOURCES
60 swap_to(FLASH);
61#endif
62
Marian Balakowiczd5934ad2008-02-04 08:28:09 +010063 /* find kernel entry point */
64 if (images->legacy_hdr_valid) {
65 ep = image_get_ep (images->legacy_hdr_os);
66#if defined(CONFIG_FIT)
67 } else if (images->fit_uname_os) {
Marian Balakowiczcd7c5962008-03-12 10:33:00 +010068 int ret = fit_image_get_entry (images->fit_hdr_os,
69 images->fit_noffset_os, &ep);
70 if (ret) {
71 puts ("Can't get entry point property!\n");
72 goto error;
73 }
Marian Balakowiczd5934ad2008-02-04 08:28:09 +010074#endif
75 } else {
76 puts ("Could not find kernel entry point!\n");
Marian Balakowiczcd7c5962008-03-12 10:33:00 +010077 goto error;
Marian Balakowiczd5934ad2008-02-04 08:28:09 +010078 }
79 appl = (int (*)(char *))ep;
80
Wolfgang Denk6cb142f2006-03-12 02:12:27 +010081 printf("Starting Kernel at = %x\n", appl);
82 cmdline = make_command_line();
Aubrey.Li3f0606a2007-03-09 13:38:44 +080083 if (icache_status()) {
Wolfgang Denk6cb142f2006-03-12 02:12:27 +010084 flush_instruction_cache();
85 icache_disable();
Aubrey.Li3f0606a2007-03-09 13:38:44 +080086 }
87 if (dcache_status()) {
Wolfgang Denk6cb142f2006-03-12 02:12:27 +010088 flush_data_cache();
89 dcache_disable();
Aubrey.Li3f0606a2007-03-09 13:38:44 +080090 }
91 (*appl) (cmdline);
Marian Balakowiczcd7c5962008-03-12 10:33:00 +010092 /* does not return */
93 return;
94
95error:
96 if (images->autostart)
97 do_reset (cmdtp, flag, argc, argv);
98 return;
Wolfgang Denk6cb142f2006-03-12 02:12:27 +010099}
100
101char *make_command_line(void)
102{
Aubrey.Li3f0606a2007-03-09 13:38:44 +0800103 char *dest = (char *)CMD_LINE_ADDR;
104 char *bootargs;
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100105
Aubrey.Li3f0606a2007-03-09 13:38:44 +0800106 if ((bootargs = getenv("bootargs")) == NULL)
107 return NULL;
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100108
Aubrey.Li3f0606a2007-03-09 13:38:44 +0800109 strncpy(dest, bootargs, 0x1000);
110 dest[0xfff] = 0;
111 return dest;
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100112}