enable start-stop-daemon by default, i want to use this to clean up a few init script...
[openwrt/staging/florian.git] / target / linux / adm5120-2.6 / files / arch / mips / adm5120 / prom / cfe.c
1 /*
2 * $Id$
3 *
4 * Broadcom's CFE specific prom routines
5 *
6 * Copyright (C) 2007 OpenWrt.org
7 * Copyright (C) 2007 Gabor Juhos <juhosg at openwrt.org>
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the
21 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22 * Boston, MA 02110-1301, USA.
23 */
24
25 #include <linux/types.h>
26 #include <linux/init.h>
27
28 #include <asm/bootinfo.h>
29 #include <asm/addrspace.h>
30
31 #include <prom/cfe.h>
32 #include "prom_read.h"
33
34 /*
35 * CFE based boards
36 */
37 #define CFE_EPTSEAL 0x43464531 /* CFE1 is the magic number to recognize CFE
38 from other bootloaders */
39
40 static int cfe_found = 0;
41
42 static u32 cfe_handle;
43 static u32 cfe_entry;
44 static u32 cfe_seal;
45
46 int __init cfe_present(void)
47 {
48 /*
49 * This method only works, when we are booted directly from the CFE.
50 */
51 u32 a1 = (u32) fw_arg1;
52
53 if (cfe_found)
54 return 1;
55
56 cfe_handle = (u32) fw_arg0;
57 cfe_entry = (u32) fw_arg2;
58 cfe_seal = (u32) fw_arg3;
59
60 /* Check for CFE by finding the CFE magic number */
61 if (cfe_seal != CFE_EPTSEAL) {
62 /* We are not booted from CFE */
63 return 0;
64 }
65
66 /* cfe_a1_val must be 0, because only one CPU present in the ADM5120 */
67 if (a1 != 0) {
68 return 0;
69 }
70
71 /* The cfe_handle, and the cfe_entry must be kernel mode addresses */
72 if ((cfe_handle < KSEG0) || (cfe_entry < KSEG0)) {
73 return 0;
74 }
75
76 cfe_found = 1;
77 return 1;
78 }
79
80 char *cfe_getenv(char *envname)
81 {
82 if (cfe_found == 0)
83 return NULL;
84
85 return NULL;
86 }