fdt: rework fdt_fixup_ethernet() to use env instead of bd_t
PATCH v3 1/1 fdt: rework fdt_fixup_ethernet() to use env instead of bd_t
Move to using the environment variables 'ethaddr', 'eth1addr', etc.. instead of bd->bi_enetaddr, bi_enet1addr, etc.
This makes the code a bit more flexible to the number of ethernet interfaces.
---
We walk through the env now searching for 'eth*addr' and parse a match to deal with the fixup.
- k
common/cmd_nvedit.c | 17 +++++++ common/fdt_support.c | 123 ++++++++++++++++++++++++++++++++---------------- cpu/74xx_7xx/cpu.c | 2 +- cpu/mpc512x/cpu.c | 2 +- cpu/mpc8260/cpu.c | 2 +- cpu/mpc83xx/fdt.c | 2 +- cpu/mpc85xx/fdt.c | 2 +- cpu/mpc86xx/fdt.c | 2 +- cpu/mpc8xx/fdt.c | 2 +- cpu/ppc4xx/fdt.c | 2 +- include/common.h | 2 + include/fdt_support.h | 2 +- 12 files changed, 110 insertions(+), 50 deletions(-)
common/cmd_nvedit.c +17 -0
@@ -576,6 +576,23 @@ int envmatch (uchar *s1, int i2)return (-1 ); } +/* compare memory to a portion of the environment, similiar +* to memcmp, except s2 is provided by an index into the environment +*/ +int envcmp (const void *s1,int i2,size_t count) +{ +const unsigned char *su1; +unsigned char c; +int res =0 , j; + +for (su1 = s1, j = i2;0 < count; ++su1, ++j, count--) { + c =env_get_char (j); +if ((res = *su1 - c) !=0 ) +break ; + } + +return res; +}/**************************************************/
common/fdt_support.c +82 -41
137 lines not on this page · raw message
cpu/74xx_7xx/cpu.c +1 -1
@@ -314,7 +314,7 @@ void ft_cpu_setup(void *blob, bd_t *bd)fdt_fixup_memory (blob, (u64 )bd->bi_memstart, (u64 )bd->bi_memsize); - fdt_fixup_ethernet(blob, bd); + fdt_fixup_ethernet(blob); }#endif /* ------------------------------------------------------------------------- */
cpu/mpc512x/cpu.c +1 -1
@@ -191,7 +191,7 @@ void ft_cpu_setup(void *blob, bd_t *bd)#endif ft_clock_setup (blob, bd);#ifdef CONFIG_HAS_ETH0 -fdt_fixup_ethernet (blob, bd); +fdt_fixup_ethernet (blob); #endif }#endif
cpu/mpc8260/cpu.c +1 -1
@@ -307,7 +307,7 @@ void ft_cpu_setup (void *blob, bd_t *bd)#if defined(CONFIG_HAS_ETH0 ) || defined(CONFIG_HAS_ETH1 ) ||\ defined(CONFIG_HAS_ETH2 ) || defined(CONFIG_HAS_ETH3 ) -fdt_fixup_ethernet (blob, bd); +fdt_fixup_ethernet (blob);#endif do_fixup_by_path_u32 (blob, cpu_path,"bus-frequency" , bd->bi_busfreq,1 );
cpu/mpc83xx/fdt.c +1 -1
@@ -53,7 +53,7 @@ void ft_cpu_setup(void *blob, bd_t *bd)#if defined(CONFIG_HAS_ETH0 ) || defined(CONFIG_HAS_ETH1 ) ||\ defined(CONFIG_HAS_ETH2 ) || defined(CONFIG_HAS_ETH3 ) -fdt_fixup_ethernet (blob, bd); +fdt_fixup_ethernet (blob);#endif do_fixup_by_prop_u32(blob, "device_type", "cpu", 4,
cpu/mpc85xx/fdt.c +1 -1
@@ -212,7 +212,7 @@ void ft_cpu_setup(void *blob, bd_t *bd)#if defined(CONFIG_HAS_ETH0 ) || defined(CONFIG_HAS_ETH1 ) ||\ defined(CONFIG_HAS_ETH2 ) || defined(CONFIG_HAS_ETH3 ) -fdt_fixup_ethernet (blob, bd); +fdt_fixup_ethernet (blob);#endif do_fixup_by_prop_u32(blob, "device_type", "cpu", 4,
cpu/mpc86xx/fdt.c +1 -1
@@ -25,7 +25,7 @@ void ft_cpu_setup(void *blob, bd_t *bd)#if defined(CONFIG_HAS_ETH0 ) || defined(CONFIG_HAS_ETH1 ) \ || defined(CONFIG_HAS_ETH2 ) || defined(CONFIG_HAS_ETH3 ) -fdt_fixup_ethernet (blob, bd); +fdt_fixup_ethernet (blob);#endif #ifdef CFG_NS16550
cpu/mpc8xx/fdt.c +1 -1
@@ -40,7 +40,7 @@ void ft_cpu_setup(void *blob, bd_t *bd) gd->brg_clk, 1);/* Fixup ethernet MAC addresses */ -fdt_fixup_ethernet (blob, bd); +fdt_fixup_ethernet (blob);fdt_fixup_memory (blob, (u64 )bd->bi_memstart, (u64 )bd->bi_memsize); }
cpu/ppc4xx/fdt.c +1 -1
@@ -130,7 +130,7 @@ void ft_cpu_setup(void *blob, bd_t *bd)* Fixup all ethernet nodes * Note: aliases in the dts are required for this */ -fdt_fixup_ethernet (blob, bd); +fdt_fixup_ethernet (blob);/* * Fixup all available PCIe nodes by setting the device_type property
include/common.h +2 -0
@@ -241,6 +241,7 @@ extern ulong load_addr; /* Default Load Address */int env_init (void );void env_relocate (void );int envmatch (uchar *,int ); +int envcmp (const void *s1,int i2,size_t count);char *getenv (char *);int getenv_r (char *name,char *buf,unsigned len);int saveenv (void );
@@ -260,6 +261,7 @@ void forceenv (char *, char *);#ifdef CONFIG_I386 /* x86 version to be fixed! */ # include <asm/u-boot-i386.h> #endif /* CONFIG_I386 */ +uchar env_get_char (int index);#ifdef CONFIG_AUTO_COMPLETE int env_complete (char *var,int maxv,char *cmdv[],int maxsz,char *buf);
include/fdt_support.h +1 -1
@@ -45,7 +45,7 @@ void do_fixup_by_compat(void *fdt, const char *compat,void do_fixup_by_compat_u32 (void *fdt,const char *compat,const char *prop,u32 val,int create);int fdt_fixup_memory (void *blob,u64 start,u64 size); -void fdt_fixup_ethernet (void *fdt,bd_t *bd); +void fdt_fixup_ethernet (void *fdt);int fdt_find_and_setprop (void *fdt,const char *node,const char *prop,const void *val,int len,int create);void fdt_fixup_qe_firmware (void *fdt);
Signature · 1 line
1.5.5.1
Wolfgang Denk
NAKPATCH v3 1/1 fdt: rework fdt_fixup_ethernet() to use env instead of bd_t
Dear Kumar Gala,
Quoted 4 lines · In message <[email protected]> you wrote:
common/fdt_support.c +0
-0@@ -368,55 +368,96 @@ int fdt_fixup_memory(void *blob, u64 start, u64 size)
...
common/fdt_support.c int fdt_fixup_memory(void *blob, u64 start, u64 size) · line 401
Quoted 4 lines
common/fdt_support.c +4
-0+/* walk the env looking for eth[.*]addr */ +for (i=0 ;env_get_char (i) !='\0' ; i=nxt+1 ) { +for (nxt=i;env_get_char (nxt) !='\0' ; ++nxt) + ;
Please do not do this. env_get_char() is a function that is internal to the environment handling code. It is not supposed to be exported to arbitrary code. Please do not make any assumptions about the internals of how the environment is stored.
NAK.
Best regards,
Wolfgang Denk
Signature · 6 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de "There are three principal ways to lose money: wine, women, and en- gineers. While the first two are more pleasant, the third is by far the more certain." -- Baron Rothschild, ca. 1800
PATCH v3 1/1 fdt: rework fdt_fixup_ethernet() to use env instead of bd_t
Quoted 20 lines · Wolfgang Denk
Dear Kumar Gala,
In message <[email protected]>
Quoted 5 lines · you
common/fdt_support.c +0
-0@@ -368,55 +368,96 @@ int fdt_fixup_memory(void *blob, u64 start, u64 size)...
common/fdt_support.c int fdt_fixup_memory(void *blob, u64 start, u64 size) · line 401
Quoted 4 lines
common/fdt_support.c +4
-0+/* walk the env looking for eth[.*]addr */ +for (i=0 ;env_get_char (i) !='\0' ; i=nxt+1 ) { +for (nxt=i;env_get_char (nxt) !='\0' ; ++nxt) + ;Please do not do this.
env_get_char()is a function that is internal to the environment handling code. It is not supposed to be exported to arbitrary code. Please do not make any assumptions about the internals of how the environment is stored.
Quoted 1 line
NAK.
I'm so confused.. how does one 'iterate' over the environment than? As you agree with Scott's suggestion in:
http://lists.denx.de/pipermail/u-boot/2008-August/000498.html
- k
PATCH v3 1/1 fdt: rework fdt_fixup_ethernet() to use env instead of bd_t
Quoted 11 lines · Kumar Gala
Quoted 6 lines
Please do not do this.
env_get_char()is a function that is internal to the environment handling code. It is not supposed to be exported to arbitrary code. Please do not make any assumptions about the internals of how the environment is stored.NAK.
I'm so confused.. how does one 'iterate' over the environment than? As you agree with Scott's suggestion in:
http://lists.denx.de/pipermail/u-boot/2008-August/000498.html
Add something to the env code itself to iterate with a callback pointer.
-Scott