26c65340f29c473152ceceb2afcc066643ae16ca
[platform/kernel/u-boot.git] / lib_blackfin / bf533_linux.c
1 /*
2  * U-boot - bf533_linux.c
3  *
4  * Copyright (c) 2005-2007 Analog Devices Inc.
5  *
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
24  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
25  * MA 02110-1301 USA
26  */
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
39 #define CMD_LINE_ADDR 0xFF900000        /* L1 scratchpad */
40
41 #ifdef SHARED_RESOURCES
42 extern void swap_to(int device_id);
43 #endif
44
45 extern image_header_t header;
46 extern void flush_instruction_cache(void);
47 extern void flush_data_cache(void);
48 static char *make_command_line(void);
49
50 void do_bootm_linux(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[],
51                     ulong addr, ulong * len_ptr, int verify)
52 {
53         int (*appl) (char *cmdline);
54         char *cmdline;
55         image_header_t *hdr = &header;
56
57 #ifdef SHARED_RESOURCES
58         swap_to(FLASH);
59 #endif
60
61         appl = (int (*)(char *))image_get_ep (hdr);
62         printf("Starting Kernel at = %x\n", appl);
63         cmdline = make_command_line();
64         if (icache_status()) {
65                 flush_instruction_cache();
66                 icache_disable();
67         }
68         if (dcache_status()) {
69                 flush_data_cache();
70                 dcache_disable();
71         }
72         (*appl) (cmdline);
73 }
74
75 char *make_command_line(void)
76 {
77         char *dest = (char *)CMD_LINE_ADDR;
78         char *bootargs;
79
80         if ((bootargs = getenv("bootargs")) == NULL)
81                 return NULL;
82
83         strncpy(dest, bootargs, 0x1000);
84         dest[0xfff] = 0;
85         return dest;
86 }