GUI: Fix Tomato RAF theme for all builds. Compilation typo.
[tomato.git] / release / src-rt-6.x.4708 / cfe / cfe / arch / mips / cpu / sb1250 / src / cfe_device_ldr.c
blob1b663ce8fea3d77f30a942ce79f20505700aff56
1 /* *********************************************************************
2 * Broadcom Common Firmware Environment (CFE)
3 *
4 * SB1250 PCI Device-mode downloader File: cfe_device_ldr.c
5 *
6 * This invokes the CFE loader to retrieve an elf binary from the
7 * PCI host using the host0 device.
8 *
9 *********************************************************************
11 * Copyright 2000,2001,2002,2003
12 * Broadcom Corporation. All rights reserved.
14 * This software is furnished under license and may be used and
15 * copied only in accordance with the following terms and
16 * conditions. Subject to these conditions, you may download,
17 * copy, install, use, modify and distribute modified or unmodified
18 * copies of this software in source and/or binary form. No title
19 * or ownership is transferred hereby.
21 * 1) Any source code used, modified or distributed must reproduce
22 * and retain this copyright notice and list of conditions
23 * as they appear in the source file.
25 * 2) No right is granted to use any trade name, trademark, or
26 * logo of Broadcom Corporation. The "Broadcom Corporation"
27 * name may not be used to endorse or promote products derived
28 * from this software without the prior written permission of
29 * Broadcom Corporation.
31 * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR
32 * IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED
33 * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
34 * PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT
35 * SHALL BROADCOM BE LIABLE FOR ANY DAMAGES WHATSOEVER, AND IN
36 * PARTICULAR, BROADCOM SHALL NOT BE LIABLE FOR DIRECT, INDIRECT,
37 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
38 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
39 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
40 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
41 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
42 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE), EVEN IF ADVISED OF
43 * THE POSSIBILITY OF SUCH DAMAGE.
44 ********************************************************************* */
47 #include "sbmips.h"
48 #include "lib_types.h"
49 #include "lib_printf.h"
51 #include "cfe_loader.h"
52 #include "cfe_timer.h"
53 #include "sb1250_defs.h"
54 #include "sb1250_regs.h"
55 #define K1_PTR64(pa) ((uint64_t *)(PHYS_TO_K1(pa)))
57 extern cfe_loadargs_t cfe_loadargs;
59 #define MBOX_ARG_WORD 0
60 #define MBOX_CMD_WORD 1
62 int cfe_device_download(int boot, char *options);
63 int
64 cfe_device_download(int boot, char *options)
66 cfe_loadargs_t *la = &cfe_loadargs;
67 int res;
68 uint64_t *mbox_p = K1_PTR64 (A_IMR_REG(NULL, ISTER(0, R_IMR_MAILBOX_CPU));
69 uint64_t *mbox_clr = K1_PTR64 (A_IMR_REG(NULL, ISTER(0, R_IMR_MAILBOX_CLR_CPU));
70 uint64_t *mbox_set = K1_PTR64 (A_IMR_REG(NULL, ISTER(0, R_IMR_MAILBOX_SET_CPU));
71 uint32_t *cmd_p = ((uint32_t *)mbox_p) + MBOX_CMD_WORD;
73 xprintf("Loader:elf Filesys:raw Dev:host0");
75 /* Wait for the host to supply any host-selected options. There
76 is no timeout here because we don't know the host's timing and,
77 on a real device card, probably wouldn't have anything to do
78 until downloaded. */
80 while ((*cmd_p & 0x3) == 0) {
81 POLL();
84 /* Fill out the loadargs */
86 la->la_flags = LOADFLG_NOISY;
88 la->la_device = "host0";
89 la->la_filesys = "raw";
90 la->la_filename = NULL;
92 if ((*cmd_p & 0x2) != 0) la->la_flags |= LOADFLG_COMPRESSED;
93 la->la_options = options;
95 xprintf(" Options:%s\n", la->la_options);
97 res = cfe_boot("elf", la);
99 /* First supply the result code */
100 *((uint32_t *)mbox_clr + MBOX_ARG_WORD) = 0xffffffff;
101 *((uint32_t *)mbox_set + MBOX_ARG_WORD) = (uint32_t)res;
103 /* Then the ack (0x0) */
104 *((uint32_t *)mbox_clr + MBOX_CMD_WORD) = 0xffffff;
106 if (res < 0) {
107 xprintf("Could not download from %s:\n", la->la_device);
108 return res;
111 if (boot && la->la_entrypt != 0) {
112 cfe_go(la);
113 /* We won't actually return to here */
116 return res;