Skip to contentSkip to conversation

ppc/85xx,86xx: Handling Unknown SOC version

PATCH New Poonam Aggrwal 2 participants 3 messages Sep 2, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ppc/85xx,86xx: Handling Unknown SOC version

Incase the system is detected with Unknown SVR, let the system boot with a default value and a proper message.
Now with dynamic detection of SOC properties from SVR, this is necessary to prevent a crash.

---
applies on git.am.freescale.net/mirrors/u-boot.git

 cpu/mpc85xx/cpu.c           |   10 +++-------
 cpu/mpc86xx/cpu.c           |    5 +----
 cpu/mpc8xxx/cpu.c           |    4 ++--
 include/asm-ppc/processor.h |    2 ++
 4 files changed, 8 insertions(+), 13 deletions(-)
cpu/mpc85xx/cpu.c +3 -7
index 6be98dc..63bdb6f 100644
@@ -69,13 +69,9 @@ int checkcpu (void)
 
 	cpu = gd->cpu;
 
-	if (cpu->name) {
-		puts(cpu->name);
-		if (IS_E_PROCESSOR(svr))
-			puts("E");
-	} else {
-		puts("Unknown");
-	}
+	puts(cpu->name);
+	if (IS_E_PROCESSOR(svr))
+		puts("E");
 
 	printf(", Version: %d.%d, (0x%08x)\n", major, minor, svr);
 
cpu/mpc86xx/cpu.c +1 -4
index 04409ce..e97ab6d 100644
@@ -65,10 +65,7 @@ checkcpu(void)
 
 	cpu = gd->cpu;
 
-	if (cpu->name)
-		puts(cpu->name);
-	else
-		puts("Unknown");
+	puts(cpu->name);
 
 	printf(", Version: %d.%d, (0x%08x)\n", major, minor, svr);
 	puts("Core:  ");
cpu/mpc8xxx/cpu.c +2 -2
index 339f6d9..56fb141 100644
@@ -77,6 +77,7 @@ struct cpu_type cpu_type_list [] = {
 	CPU_TYPE_ENTRY(8641, 8641, 2),
 	CPU_TYPE_ENTRY(8641D, 8641D, 2),
 #endif
+	CPU_TYPE_ENTRY(Unknown, Unknown, 1),
 };
 
 struct cpu_type *identify_cpu(u32 ver)
@@ -86,8 +87,7 @@ struct cpu_type *identify_cpu(u32 ver)
 		if (cpu_type_list[i].soc_ver == ver)
 			return &cpu_type_list[i];
 	}
-
-	return NULL;
+	return &cpu_type_list[i-1];
 }
 
 int cpu_numcores() {
include/asm-ppc/processor.h +2 -0
index dcaf8c0..9b27634 100644
@@ -1022,6 +1022,8 @@
 #define SVR_8641	0x809000
 #define SVR_8641D	0x809001
 
+#define SVR_Unknown	0x000000
+
 #define _GLOBAL(n)\
 	.globl n;\
 n:
Signature · 1 line
1.5.6.5
#1 lore raw

PATCH 1/1 ppc/85xx, 86xx: Handling Unknown SOC version

Dear Poonam Aggrwal,

Quoted 8 lines · In message <[email protected]>…

Incase the system is detected with Unknown SVR, let the system boot with a default value and a proper message.
Now with dynamic detection of SOC properties from SVR, this is necessary to prevent a crash.

---

...

Quoted 11 lines
cpu/mpc8xxx/cpu.c +1 -0
@@ -77,6 +77,7 @@ struct cpu_type cpu_type_list [] = {
 	CPU_TYPE_ENTRY(8641, 8641, 2),
 	CPU_TYPE_ENTRY(8641D, 8641D, 2),
 #endif
+	CPU_TYPE_ENTRY(Unknown, Unknown, 1),
 };
 
 struct cpu_type *identify_cpu(u32 ver)

cpu/mpc8xxx/cpu.c struct cpu_type *identify_cpu(u32 ver) · line 90

Quoted 6 lines
cpu/mpc8xxx/cpu.c +1 -2
@@ -86,8 +87,7 @@ struct cpu_type *identify_cpu(u32 ver)
 		if (cpu_type_list[i].soc_ver == ver)
 			return &cpu_type_list[i];
 	}
-
-	return NULL;
+	return &cpu_type_list[i-1];

This looks unlogical to me. First, with this change you should change the 'for' loop into

	for (i = 0; i < ARRAY_SIZE(cpu_type_list) - 1; i++) {
		...
	}

But all this makes the code just harder to read and understand.

Why not add a separate

	struct cpu_type cpu_type_unknown = CPU_TYPE_ENTRY(Unknown, Unknown, 1);

and then do a simple

	return &cpu_type_unknown;

?

include/asm-ppc/processor.h line 1025

Quoted 9 lines
include/asm-ppc/processor.h +1 -0
index dcaf8c0..9b27634 100644
@@ -1022,6 +1022,8 @@
 #define SVR_8641	0x809000
 #define SVR_8641D	0x809001
 
+#define SVR_Unknown	0x000000

Is this a good and reliable choice? I don't know the rules for SVR contents... Maybe 0xFFFFFF would be better?

Best regards,

Wolfgang Denk

Signature · 4 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
"Intelligence without character is a dangerous thing."   - G. Steinem
#2 lore raw

PATCH 1/1 ppc/85xx, 86xx: Handling Unknown SOC version

Quoted 13 lines

-----Original Message-----
From: Wolfgang Denk [mailto:wd at denx.de]
Sent: Wednesday, September 02, 2009 1:03 PM
To: Aggrwal Poonam-B10812
Cc: u-boot at lists.denx.de; Kumar Gala
Subject: Re: [U-Boot] [PATCH][v1] ppc/85xx,86xx: Handling Unknown SOC version

Dear Poonam Aggrwal,

In message <[email protected]

Quoted 56 lines · m> you wrote:
Quoted 8 lines

Incase the system is detected with Unknown SVR, let the system boot with a default value and a proper message.
Now with dynamic detection of SOC properties from SVR, this is necessary to prevent a crash.

---

...

Quoted 11 lines
cpu/mpc8xxx/cpu.c +1 -0
@@ -77,6 +77,7 @@ struct cpu_type cpu_type_list [] = {
 	CPU_TYPE_ENTRY(8641, 8641, 2),
 	CPU_TYPE_ENTRY(8641D, 8641D, 2),
 #endif
+	CPU_TYPE_ENTRY(Unknown, Unknown, 1),
 };
 
 struct cpu_type *identify_cpu(u32 ver) @@ -86,8 +87,7 @@ struct 

cpu_type *identify_cpu(u32 ver)

cpu/mpc8xxx/cpu.c struct cpu_type *identify_cpu(u32 ver) · line 90

Quoted 6 lines
cpu/mpc8xxx/cpu.c +1 -2
 		if (cpu_type_list[i].soc_ver == ver)
 			return &cpu_type_list[i];
 	}
-
-	return NULL;
+	return &cpu_type_list[i-1];

This looks unlogical to me. First, with this change you should change the 'for' loop into

	for (i = 0; i < ARRAY_SIZE(cpu_type_list) - 1; i++) {
		...
	}

But all this makes the code just harder to read and understand.

Why not add a separate

struct cpu_type cpu_type_unknown =
CPU_TYPE_ENTRY(Unknown, Unknown, 1);

and then do a simple

	return &cpu_type_unknown;

?

Review

Quoted 1 line
(quoted diff) +0 -0

b/include/asm-ppc/processor.h

Quoted 7 lines

index dcaf8c0..9b27634 100644

include/asm-ppc/processor.h +0 -0
@@ -1022,6 +1022,8 @@
 #define SVR_8641	0x809000
 #define SVR_8641D	0x809001
 
Quoted 5 lines

include/asm-ppc/processor.h line 1025

Quoted 1 line
include/asm-ppc/processor.h +1 -0
+#define SVR_Unknown	0x000000

Is this a good and reliable choice? I don't know the rules for SVR contents... Maybe 0xFFFFFF would be better?

Thanks for the comments , let me incorporate them and resend. Regards
Poonam

Quoted 11 lines

Best regards,

Wolfgang Denk

Signature · 4 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
"Intelligence without character is a dangerous thing."   - G. Steinem