Skip to contentSkip to conversation

ppc4xx: Add routine to retrieve the CPU number for boards with multiple CPU's.

PATCH New Adam Graham 2 participants 2 messages Sep 24, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 3/3 ppc4xx: Add routine to retrieve the CPU number for boards with multiple CPU's.

Provide a weak defined routine to retrieve the CPU number for reference boards that have multiple CPU's. Default behavior is the existing single CPU print output. Reference boards with multiple CPU's need to provide a board specific routine. See board/amcc/arches/arches.c for an example.

---
 cpu/ppc4xx/cpu.c |   19 ++++++++++++++++++-
 1 files changed, 18 insertions(+), 1 deletions(-)
cpu/ppc4xx/cpu.c +18 -1
index bc9335a..71d4ad9 100644
@@ -41,6 +41,18 @@ DECLARE_GLOBAL_DATA_PTR;
 
 void board_reset(void);
 
+/*
+ * To provide an interface to detect CPU number for boards that support
+ * more then one CPU, we implement the "weak" default functions here.
+ *
+ * Returns CPU number, else -1 if not known.
+ */
+u32 __get_cpu_num(void)
+{
+	return -1;
+}
+u32 get_cpu_num(void) __attribute__((weak, alias("__get_cpu_num")));
+
 #if defined(CONFIG_405GP) || \
     defined(CONFIG_440EP) || defined(CONFIG_440GR) || \
     defined(CONFIG_440EPX) || defined(CONFIG_440GRX)
@@ -274,8 +286,13 @@ int checkcpu (void)
 #if !defined(CONFIG_IOP480)
 	char addstr[64] = "";
 	sys_info_t sys_info;
+	int cpu_num;
 
-	puts ("CPU:   ");
+	cpu_num = get_cpu_num();
+	if (cpu_num >= 0)
+		printf("CPU%d:  ", cpu_num);
+	else
+		puts("CPU:   ");
 
 	get_sys_info(&sys_info);
 
Signature · 1 line
1.5.5
#1 lore raw

PATCH 3/3 ppc4xx: Add routine to retrieve the CPU number for boards with multiple CPU's.

Dear Adam Graham,

Quoted 18 lines · In message <[email protected]> you wrote:

Provide a weak defined routine to retrieve the CPU number for reference boards that have multiple CPU's. Default behavior is the existing single CPU print output. Reference boards with multiple CPU's need to provide a board specific routine. See boar d/amcc/arches/arches.c for an example.

---
 cpu/ppc4xx/cpu.c |   19 ++++++++++++++++++-
 1 files changed, 18 insertions(+), 1 deletions(-)
cpu/ppc4xx/cpu.c +0 -0
index bc9335a..71d4ad9 100644
@@ -41,6 +41,18 @@ DECLARE_GLOBAL_DATA_PTR;
 
 void board_reset(void);
 

cpu/ppc4xx/cpu.c DECLARE_GLOBAL_DATA_PTR; · line 53

Quoted 10 lines
cpu/ppc4xx/cpu.c +10 -0
+/*
+ * To provide an interface to detect CPU number for boards that support
+ * more then one CPU, we implement the "weak" default functions here.
+ *
+ * Returns CPU number, else -1 if not known.
+ */
+u32 __get_cpu_num(void)
+{
+	return -1;
+}

Returning "-1" when the function type is an unsigned? This makes little sense to me.

Quoted 6 lines
cpu/ppc4xx/cpu.c +2 -0
+u32 get_cpu_num(void) __attribute__((weak, alias("__get_cpu_num")));
+
 #if defined(CONFIG_405GP) || \
     defined(CONFIG_440EP) || defined(CONFIG_440GR) || \
     defined(CONFIG_440EPX) || defined(CONFIG_440GRX)

cpu/ppc4xx/cpu.c int checkcpu (void) · line 292

Quoted 8 lines
cpu/ppc4xx/cpu.c +3 -1
@@ -274,8 +286,13 @@ int checkcpu (void)
 #if !defined(CONFIG_IOP480)
 	char addstr[64] = "";
 	sys_info_t sys_info;
+	int cpu_num;
 
-	puts ("CPU:   ");
+	cpu_num = get_cpu_num();
+	if (cpu_num >= 0)

get_cpu_num() return an unsigned ...

Please fix.

Best regards,

Wolfgang Denk

Signature · 5 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
"Once they go up, who cares where  they  come  down?  That's  not  my
department."                                       - Werner von Braun