Skip to content
Snippets Groups Projects
Commit b502611b authored by Joakim Tjernlund's avatar Joakim Tjernlund Committed by Wolfgang Denk
Browse files

Change env_get_char from a global function ptr to a function


This avoids an early global data reference.

Signed-off-by: default avatarJoakim Tjernlund <Joakim.Tjernlund@transmode.se>
parent 27269417
No related branches found
No related tags found
No related merge requests found
...@@ -50,7 +50,6 @@ extern void env_relocate_spec (void); ...@@ -50,7 +50,6 @@ extern void env_relocate_spec (void);
extern uchar env_get_char_spec(int); extern uchar env_get_char_spec(int);
static uchar env_get_char_init (int index); static uchar env_get_char_init (int index);
uchar (*env_get_char)(int) = env_get_char_init;
/************************************************************************ /************************************************************************
* Default settings to be used when no valid environment is found * Default settings to be used when no valid environment is found
...@@ -183,6 +182,19 @@ uchar env_get_char_memory (int index) ...@@ -183,6 +182,19 @@ uchar env_get_char_memory (int index)
} }
#endif #endif
uchar env_get_char (int index)
{
uchar c;
/* if relocated to RAM */
if (gd->flags & GD_FLG_RELOC)
c = env_get_char_memory(index);
else
c = env_get_char_init(index);
return (c);
}
uchar *env_get_addr (int index) uchar *env_get_addr (int index)
{ {
if (gd->env_valid) { if (gd->env_valid) {
...@@ -216,11 +228,6 @@ void env_relocate (void) ...@@ -216,11 +228,6 @@ void env_relocate (void)
DEBUGF ("%s[%d] malloced ENV at %p\n", __FUNCTION__,__LINE__,env_ptr); DEBUGF ("%s[%d] malloced ENV at %p\n", __FUNCTION__,__LINE__,env_ptr);
#endif #endif
/*
* After relocation to RAM, we can always use the "memory" functions
*/
env_get_char = env_get_char_memory;
if (gd->env_valid == 0) { if (gd->env_valid == 0) {
#if defined(CONFIG_GTH) || defined(CFG_ENV_IS_NOWHERE) /* Environment not changable */ #if defined(CONFIG_GTH) || defined(CFG_ENV_IS_NOWHERE) /* Environment not changable */
puts ("Using default environment\n\n"); puts ("Using default environment\n\n");
......
...@@ -107,8 +107,8 @@ typedef struct environment_s { ...@@ -107,8 +107,8 @@ typedef struct environment_s {
unsigned char data[ENV_SIZE]; /* Environment data */ unsigned char data[ENV_SIZE]; /* Environment data */
} env_t; } env_t;
/* Pointer to function that returns a character from the environment */ /* Function that returns a character from the environment */
extern unsigned char (*env_get_char)(int); unsigned char env_get_char (int);
/* Function that returns a pointer to a value from the environment */ /* Function that returns a pointer to a value from the environment */
unsigned char *env_get_addr(int); unsigned char *env_get_addr(int);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment