Skip to contentSkip to conversation

fdt: rework fdt_fixup_ethernet() to use env instead of bd_t

PATCH Superseded Kumar Gala 3 participants 4 messages Aug 19, 2008

v3 of 8 Superseded Latest is v8 →

lore
Share & tools
lore

Kumar Gala

author
#0 lore raw

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
index 7089706..9894cf5 100644
@@ -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
index ea43c9a..c007abc 100644
@@ -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
index 703e188..1f39ac4 100644
@@ -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
index 4d5d141..efb8ed6 100644
@@ -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
index fda85c1..39bd9dc 100644
@@ -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
index c159934..bc1550d 100644
@@ -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
index 80a5c78..12d9052 100644
@@ -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
index 567094a..7130983 100644
@@ -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
index 0323dc5..a97484f 100644
@@ -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
index 06ed278..eb865f3 100644
@@ -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
index a7c6326..f2f2cd5 100644
@@ -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
#1 lore raw

PATCH 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
author
#2 lore raw

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

#3 lore raw

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