]> git.ipfire.org Git - people/ms/u-boot.git/blame - board/w7o/fsboot.c
integrator: switch to generic board
[people/ms/u-boot.git] / board / w7o / fsboot.c
CommitLineData
affae2bf
WD
1/*
2 * (C) Copyright 2001
3 * Wave 7 Optics, Inc.
4 *
1a459660 5 * SPDX-License-Identifier: GPL-2.0+
affae2bf
WD
6 */
7
8#include <common.h>
9#include <config.h>
10#include <command.h>
affae2bf
WD
11
12/*
13 * FIXME: Add code to test image and it's header.
14 */
8bde7f77
WD
15extern int valid_elf_image (unsigned long addr);
16
affae2bf
WD
17static int
18image_check(ulong addr)
19{
20 return valid_elf_image(addr);
21}
22
23void
24init_fsboot(void)
25{
26 char *envp;
27 ulong loadaddr;
28 ulong testaddr;
29 ulong alt_loadaddr;
30 char buf[9];
31
32 /*
33 * Get test image address
34 */
35 if ((envp = getenv("testaddr")) != NULL)
36 testaddr = simple_strtoul(envp, NULL, 16);
37 else
38 testaddr = -1;
39
40 /*
41 * Are we going to test boot and image?
42 */
43 if ((testaddr != -1) && image_check(testaddr)) {
44
45 /* Set alt_loadaddr */
46 alt_loadaddr = testaddr;
47 sprintf(buf, "%lX", alt_loadaddr);
48 setenv("alt_loadaddr", buf);
49
50 /* Clear test_addr */
51 setenv("testaddr", NULL);
52
53 /*
54 * Save current environment with alt_loadaddr,
55 * and cleared testaddr.
56 */
57 saveenv();
58
59 /*
60 * Setup temporary loadaddr to alt_loadaddr
61 * XXX - DO NOT SAVE ENVIRONMENT!
62 */
63 loadaddr = alt_loadaddr;
64 sprintf(buf, "%lX", loadaddr);
65 setenv("loadaddr", buf);
66
67 } else { /* Normal boot */
68 setenv("alt_loadaddr", NULL); /* Clear alt_loadaddr */
69 setenv("testaddr", NULL); /* Clear testaddr */
70 saveenv();
71 }
72
73 return;
74}