source: rtems/c/src/lib/libbsp/powerpc/shared/uboot_getenv.c @ 39ee704e

4.115
Last change on this file since 39ee704e was 9b4422a2, checked in by Joel Sherrill <joel.sherrill@…>, on 05/03/12 at 15:09:24

Remove All CVS Id Strings Possible Using a Script

Script does what is expected and tries to do it as
smartly as possible.

+ remove occurrences of two blank comment lines

next to each other after Id string line removed.

+ remove entire comment blocks which only exited to

contain CVS Ids

+ If the processing left a blank line at the top of

a file, it was removed.

  • Property mode set to 100644
File size: 1.6 KB
Line 
1/*
2 *  COPYRIGHT (c) 1989-2008.
3 *  On-Line Applications Research Corporation (OAR).
4 *
5 *  The license and distribution terms for this file may be
6 *  found in the file LICENSE in this distribution or at
7 *  http://www.rtems.com/license/LICENSE.
8 */
9
10#include <stdint.h>
11#include <string.h>
12
13/* Assumed to be provided by BSP */
14extern const uint8_t *uboot_environment;
15extern const size_t uboot_environment_size;
16
17/*
18 * The U-Boot source code appears to use the CRC32 code from zlib.
19 * But I cannot find a way to get the crc32() in zlib code to
20 * generate the CRC found in the Flash on the Icecube board.
21 * So for now, always return TRUE.
22 */
23static int bsp_uboot_environ_check_crc(void)
24{
25#if 0
26  unsigned long crc;
27  unsigned long max;
28
29  for (max=0 ; max <= 0x20000 ; max+=4 ) {
30    crc = crc32( 0, NULL, 0 );
31    crc = crc32( crc, &uboot_environment[4], max);
32    printk( "crc=0x%08lx need %0x max=%d\n", crc,
33            *(int *)uboot_environment, max  );
34  }
35#endif
36  return 1;
37}
38
39const char *bsp_uboot_getenv(
40  const char *name
41)
42{
43  char   lhs[64];
44  size_t i, j;
45
46  if ( !bsp_uboot_environ_check_crc() )
47    return NULL;
48
49  for ( i=4 ; i<uboot_environment_size ; i++ ) {
50    memset( lhs, '\0', sizeof(lhs) );
51    for( j=0 ; uboot_environment[i] != '=' && j<sizeof(lhs) ; i++, j++ ) {
52      lhs[j] = uboot_environment[i];
53    }
54    if ( !strncmp( name, lhs, sizeof(lhs) ) ) {
55      return (const char *)&uboot_environment[i+1];
56    }
57
58    for ( i++ ; uboot_environment[i] && i<uboot_environment_size ; i++ )
59      ;
60    if ( !uboot_environment[i+1] )
61      return NULL;
62  }
63  return NULL;
64}
65
66
Note: See TracBrowser for help on using the repository browser.