to make u-boot work for fat32 filesystem
[jz_uboot.git] / board / w7o / fsboot.c
blob0ef9a61be644d79c27d70e15f8eb2ffb702e257d
1 /*
2 * (C) Copyright 2001
3 * Wave 7 Optics, Inc.
5 * See file CREDITS for list of people who contributed to this
6 * project.
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21 * MA 02111-1307 USA
24 #include <common.h>
25 #include <config.h>
26 #include <command.h>
29 * FIXME: Add code to test image and it's header.
31 extern int valid_elf_image (unsigned long addr);
33 static int
34 image_check(ulong addr)
36 return valid_elf_image(addr);
39 void
40 init_fsboot(void)
42 char *envp;
43 ulong loadaddr;
44 ulong testaddr;
45 ulong alt_loadaddr;
46 char buf[9];
49 * Get test image address
51 if ((envp = getenv("testaddr")) != NULL)
52 testaddr = simple_strtoul(envp, NULL, 16);
53 else
54 testaddr = -1;
57 * Are we going to test boot and image?
59 if ((testaddr != -1) && image_check(testaddr)) {
61 /* Set alt_loadaddr */
62 alt_loadaddr = testaddr;
63 sprintf(buf, "%lX", alt_loadaddr);
64 setenv("alt_loadaddr", buf);
66 /* Clear test_addr */
67 setenv("testaddr", NULL);
70 * Save current environment with alt_loadaddr,
71 * and cleared testaddr.
73 saveenv();
76 * Setup temporary loadaddr to alt_loadaddr
77 * XXX - DO NOT SAVE ENVIRONMENT!
79 loadaddr = alt_loadaddr;
80 sprintf(buf, "%lX", loadaddr);
81 setenv("loadaddr", buf);
83 } else { /* Normal boot */
84 setenv("alt_loadaddr", NULL); /* Clear alt_loadaddr */
85 setenv("testaddr", NULL); /* Clear testaddr */
86 saveenv();
89 return;