From a060e34ff1d6710ace7ed73faa35bb49cad7dc31 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Tue, 1 Jul 2008 19:13:22 +0000 Subject: [PATCH] 2008-07-01 Joel Sherrill * shared/uboot_getenv.c: New file. --- c/src/lib/libbsp/powerpc/ChangeLog | 4 ++ .../lib/libbsp/powerpc/shared/uboot_getenv.c | 68 +++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 c/src/lib/libbsp/powerpc/shared/uboot_getenv.c diff --git a/c/src/lib/libbsp/powerpc/ChangeLog b/c/src/lib/libbsp/powerpc/ChangeLog index 2cd358f54e..bd98525401 100644 --- a/c/src/lib/libbsp/powerpc/ChangeLog +++ b/c/src/lib/libbsp/powerpc/ChangeLog @@ -1,3 +1,7 @@ +2008-07-01 Joel Sherrill + + * shared/uboot_getenv.c: New file. + 2008-06-02 Joel Sherrill * shared/startup/panic.c: Convention calls for leading underscore on diff --git a/c/src/lib/libbsp/powerpc/shared/uboot_getenv.c b/c/src/lib/libbsp/powerpc/shared/uboot_getenv.c new file mode 100644 index 0000000000..9fb5875c62 --- /dev/null +++ b/c/src/lib/libbsp/powerpc/shared/uboot_getenv.c @@ -0,0 +1,68 @@ +/* + * COPYRIGHT (c) 1989-2008. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.com/license/LICENSE. + * + * $Id$ + */ + +#include +#include + +/* Assumed to be provided by BSP */ +extern const uint8_t *uboot_environment; +extern const size_t uboot_environment_size; + +/* + * The U-Boot source code appears to use the CRC32 code from zlib. + * But I cannot find a way to get the crc32() in zlib code to + * generate the CRC found in the Flash on the Icecube board. + * So for now, always return TRUE. + */ +static int bsp_uboot_environ_check_crc(void) +{ +#if 0 + unsigned long crc; + unsigned long max; + + for (max=0 ; max <= 0x20000 ; max+=4 ) { + crc = crc32( 0, NULL, 0 ); + crc = crc32( crc, &uboot_environment[4], max); + printk( "crc=0x%08lx need %0x max=%d\n", crc, + *(int *)uboot_environment, max ); + } +#endif + return 1; +} + +const char *bsp_uboot_getenv( + const char *name +) +{ + char lhs[64]; + size_t i, j; + + if ( !bsp_uboot_environ_check_crc() ) + return NULL; + + for ( i=4 ; i