mirror of
https://github.com/Fishwaldo/u-boot.git
synced 2025-03-28 01:51:33 +00:00
Make getenv() work before relocation.
So far, getenv() would work before relocation is most cases, even though it was not intended to be used that way. When switching to a hash table based implementation, this would break a number of boards. For convenience, we make getenv() check if it's running before relocation and, if so, use getenv_f() internally. Note that this is limited to simple cases, as we use a small static buffer (32 bytes) in the global data for this purpose. For this reason, it is also not a good idea to convert all current uses of getenv_f() into getenv() - some of the existing use cases need to be able to deal with longer variable values, so getenv_f() is still needed and recommended for use before relocation. Signed-off-by: Wolfgang Denk <wd@denx.de>
This commit is contained in:
parent
6d014adfa2
commit
91a76751a0
12 changed files with 51 additions and 39 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* (C) Copyright 2002
|
||||
* (C) Copyright 2002-2010
|
||||
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
|
||||
*
|
||||
* See file CREDITS for list of people who contributed to this
|
||||
|
@ -46,14 +46,9 @@ typedef struct global_data {
|
|||
#endif
|
||||
#ifdef CONFIG_FSL_ESDHC
|
||||
unsigned long sdhc_clk;
|
||||
#endif
|
||||
#if 0
|
||||
unsigned long cpu_clk; /* CPU clock in Hz! */
|
||||
unsigned long bus_clk;
|
||||
phys_size_t ram_size; /* RAM size */
|
||||
unsigned long reset_status; /* reset status register at boot */
|
||||
#endif
|
||||
void **jt; /* jump table */
|
||||
char env_buf[32]; /* buffer for getenv() before reloc. */
|
||||
} gd_t;
|
||||
|
||||
/*
|
||||
|
|
|
@ -46,6 +46,7 @@ typedef struct global_data {
|
|||
void *fb_base; /* framebuffer address */
|
||||
#endif
|
||||
void **jt; /* jump table */
|
||||
char env_buf[32]; /* buffer for getenv() before reloc. */
|
||||
} gd_t;
|
||||
|
||||
/*
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
*
|
||||
* Copyright (c) 2005-2007 Analog Devices Inc.
|
||||
*
|
||||
* (C) Copyright 2000-2004
|
||||
* (C) Copyright 2000-2010
|
||||
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
|
||||
*
|
||||
* See file CREDITS for list of people who contributed to this
|
||||
|
@ -54,6 +54,7 @@ typedef struct global_data {
|
|||
#endif
|
||||
|
||||
void **jt; /* jump table */
|
||||
char env_buf[32]; /* buffer for getenv() before reloc. */
|
||||
} gd_t;
|
||||
|
||||
/*
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* (C) Copyright 2002
|
||||
* (C) Copyright 2002-2010
|
||||
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
|
||||
*
|
||||
* See file CREDITS for list of people who contributed to this
|
||||
|
@ -46,6 +46,7 @@ typedef struct {
|
|||
phys_size_t ram_size; /* RAM size */
|
||||
unsigned long reset_status; /* reset status register at boot */
|
||||
void **jt; /* jump table */
|
||||
char env_buf[32]; /* buffer for getenv() before reloc. */
|
||||
} gd_t;
|
||||
|
||||
/*
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* (C) Copyright 2002 - 2003
|
||||
* (C) Copyright 2002 - 2010
|
||||
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
|
||||
*
|
||||
* See file CREDITS for list of people who contributed to this
|
||||
|
@ -64,6 +64,7 @@ typedef struct global_data {
|
|||
unsigned long board_type;
|
||||
#endif
|
||||
void **jt; /* Standalone app jump table */
|
||||
char env_buf[32]; /* buffer for getenv() before reloc. */
|
||||
} gd_t;
|
||||
|
||||
/*
|
||||
|
|
|
@ -43,6 +43,7 @@ typedef struct global_data {
|
|||
unsigned long env_valid; /* Checksum of Environment valid? */
|
||||
unsigned long fb_base; /* base address of frame buffer */
|
||||
void **jt; /* jump table */
|
||||
char env_buf[32]; /* buffer for getenv() before reloc. */
|
||||
} gd_t;
|
||||
|
||||
/*
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* (C) Copyright 2002-2003
|
||||
* (C) Copyright 2002-2010
|
||||
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
|
||||
*
|
||||
* See file CREDITS for list of people who contributed to this
|
||||
|
@ -46,6 +46,7 @@ typedef struct global_data {
|
|||
unsigned long env_addr; /* Address of Environment struct */
|
||||
unsigned long env_valid; /* Checksum of Environment valid? */
|
||||
void **jt; /* jump table */
|
||||
char env_buf[32]; /* buffer for getenv() before reloc. */
|
||||
} gd_t;
|
||||
|
||||
/*
|
||||
|
|
|
@ -37,6 +37,7 @@ typedef struct global_data {
|
|||
unsigned long post_init_f_time; /* When post_init_f started */
|
||||
#endif
|
||||
void **jt; /* Standalone app jump table */
|
||||
char env_buf[32]; /* buffer for getenv() before reloc. */
|
||||
} gd_t;
|
||||
|
||||
/* flags */
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* (C) Copyright 2002
|
||||
* (C) Copyright 2002-2010
|
||||
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
|
||||
*
|
||||
* See file CREDITS for list of people who contributed to this
|
||||
|
@ -176,6 +176,7 @@ typedef struct global_data {
|
|||
unsigned long long wdt_last; /* trace watch-dog triggering rate */
|
||||
#endif
|
||||
void **jt; /* jump table */
|
||||
char env_buf[32]; /* buffer for getenv() before reloc. */
|
||||
} gd_t;
|
||||
|
||||
/*
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* (C) Copyright 2002
|
||||
* (C) Copyright 2002-2010
|
||||
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
|
||||
*
|
||||
* (C) Copyright 2007
|
||||
|
@ -38,7 +38,8 @@ typedef struct global_data
|
|||
unsigned long env_addr; /* Address of Environment struct */
|
||||
unsigned long env_valid; /* Checksum of Environment valid */
|
||||
void **jt; /* Standalone app jump table */
|
||||
}gd_t;
|
||||
char env_buf[32]; /* buffer for getenv() before reloc. */
|
||||
} gd_t;
|
||||
|
||||
#define GD_FLG_RELOC 0x00001 /* Code was relocated to RAM */
|
||||
#define GD_FLG_DEVINIT 0x00002 /* Devices have been initialized */
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* (C) Copyright 2002
|
||||
* (C) Copyright 2002-2010
|
||||
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
|
||||
*
|
||||
* (C) Copyright 2007
|
||||
|
@ -71,6 +71,7 @@ typedef struct global_data {
|
|||
unsigned long kbd_status;
|
||||
#endif
|
||||
void **jt; /* jump table */
|
||||
char env_buf[32]; /* buffer for getenv() before reloc. */
|
||||
} gd_t;
|
||||
|
||||
/*
|
||||
|
|
|
@ -511,6 +511,7 @@ int do_editenv(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
|
|||
|
||||
char *getenv (char *name)
|
||||
{
|
||||
if (gd->flags & GD_FLG_RELOC) { /* full C runtime after reloc */
|
||||
int i, nxt;
|
||||
|
||||
WATCHDOG_RESET();
|
||||
|
@ -529,6 +530,12 @@ char *getenv (char *name)
|
|||
}
|
||||
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
/* restricted C runtime before reloc */
|
||||
|
||||
return ((getenv_f(name,gd->env_buf,sizeof(gd->env_buf)) > 0) ?
|
||||
gd->env_buf : NULL);
|
||||
}
|
||||
|
||||
int getenv_f(char *name, char *buf, unsigned len)
|
||||
|
|
Loading…
Add table
Reference in a new issue