X-Git-Url: https://git.archive.openwrt.org/?a=blobdiff_plain;f=target%2Flinux%2Fadm5120%2Ffiles-3.14%2Farch%2Fmips%2Fadm5120%2Fprom%2Fcfe.c;fp=target%2Flinux%2Fadm5120%2Ffiles-3.14%2Farch%2Fmips%2Fadm5120%2Fprom%2Fcfe.c;h=5a343cd7e44076efc1fa60bd066d63eacef7ea1f;hb=1f07007293c2a98abd721bf6bbe112c5cae71525;hp=0000000000000000000000000000000000000000;hpb=57a3eb31a2a14cd25099c0e1e3569b2c75a9e38e;p=15.05%2Fopenwrt.git diff --git a/target/linux/adm5120/files-3.14/arch/mips/adm5120/prom/cfe.c b/target/linux/adm5120/files-3.14/arch/mips/adm5120/prom/cfe.c new file mode 100644 index 0000000000..5a343cd7e4 --- /dev/null +++ b/target/linux/adm5120/files-3.14/arch/mips/adm5120/prom/cfe.c @@ -0,0 +1,69 @@ +/* + * Broadcom's CFE specific prom routines + * + * Copyright (C) 2007-2008 Gabor Juhos + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published + * by the Free Software Foundation. + * + */ + +#include +#include + +#include +#include + +#include +#include "prom_read.h" + +/* + * CFE based boards + */ +#define CFE_EPTSEAL 0x43464531 /* CFE1 is the magic number to recognize CFE +from other bootloaders */ + +static int cfe_found; + +static u32 cfe_handle; +static u32 cfe_entry; +static u32 cfe_seal; + +int __init cfe_present(void) +{ + /* + * This method only works, when we are booted directly from the CFE. + */ + u32 a1 = (u32) fw_arg1; + + if (cfe_found) + return 1; + + cfe_handle = (u32) fw_arg0; + cfe_entry = (u32) fw_arg2; + cfe_seal = (u32) fw_arg3; + + /* Check for CFE by finding the CFE magic number */ + if (cfe_seal != CFE_EPTSEAL) + return 0; + + /* cfe_a1_val must be 0, because only one CPU present in the ADM5120 */ + if (a1 != 0) + return 0; + + /* The cfe_handle, and the cfe_entry must be kernel mode addresses */ + if ((cfe_handle < KSEG0) || (cfe_entry < KSEG0)) + return 0; + + cfe_found = 1; + return 1; +} + +char *cfe_getenv(char *envname) +{ + if (cfe_found == 0) + return NULL; + + return NULL; +}