Skip to contentSkip to conversation

Fix malloc problem introduced with the relocation fixup for the PPC platform

U-Boot-Users Stefan Roese 4 participants 7 messages Jul 8, 2007 – Jul 10, 2007

lore
Share & tools
lore
#0 lore raw

The relocation fixup didn't handle the malloc pointer initialization correctly. This patch fixes this problem. Tested successfully on 4xx. The relocation fixup patches for 4xx will follow soon.

---
commit 3a1e66ba75172959973377d6069f1d12e1a4ecb3
tree 6fdde574dd5328b805e0e438ebb32cc7e7de8f4d
parent dcc0264878406d52b879d2e5a63d3d793371434e
author Stefan Roese <[email protected]> Sun, 08 Jul 2007 13:42:52 +0200 committer Stefan Roese <[email protected]> Sun, 08 Jul 2007 13:42:52 +0200

 lib_ppc/board.c |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)
lib_ppc/board.c +5 -4
index 8bb885d..5e156ab 100644
@@ -139,10 +139,10 @@ static	ulong	mem_malloc_brk	 = 0;
  */
 static void mem_malloc_init (void)
 {
-	ulong dest_addr = CFG_MONITOR_BASE + gd->reloc_off;
-
-	mem_malloc_end = dest_addr;
-	mem_malloc_start = dest_addr - TOTAL_MALLOC_LEN;
+#if !defined(CONFIG_RELOC_FIXUP_WORKS)
+	mem_malloc_end = CFG_MONITOR_BASE + gd->reloc_off;
+#endif
+	mem_malloc_start = mem_malloc_end - TOTAL_MALLOC_LEN;
 	mem_malloc_brk = mem_malloc_start;
 
 	memset ((void *) mem_malloc_start,
@@ -623,6 +623,7 @@ void board_init_r (gd_t *id, ulong dest_addr)
 
 #if defined(CONFIG_RELOC_FIXUP_WORKS)
 	gd->reloc_off = 0;
+	mem_malloc_end = dest_addr;
 #else
 	gd->reloc_off = dest_addr - CFG_MONITOR_BASE;
 #endif
Acked-by
#1 lore raw
Quoted 5 lines · Stefan Roese

The relocation fixup didn't handle the malloc pointer initialization correctly. This patch fixes this problem. Tested successfully on 4xx. The relocation fixup patches for 4xx will follow soon.

Quoted 39 lines

---
commit 3a1e66ba75172959973377d6069f1d12e1a4ecb3
tree 6fdde574dd5328b805e0e438ebb32cc7e7de8f4d
parent dcc0264878406d52b879d2e5a63d3d793371434e
author Stefan Roese <[email protected]> Sun, 08 Jul 2007 13:42:52 +0200 committer Stefan Roese <[email protected]> Sun, 08 Jul 2007 13:42:52 +0200

 lib_ppc/board.c |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)
lib_ppc/board.c +5 -4
index 8bb885d..5e156ab 100644
@@ -139,10 +139,10 @@ static    ulong   mem_malloc_brk   = 0;
  */
 static void mem_malloc_init (void)
 {
-       ulong dest_addr = CFG_MONITOR_BASE + gd->reloc_off;
-
-       mem_malloc_end = dest_addr;
-       mem_malloc_start = dest_addr - TOTAL_MALLOC_LEN;
+#if !defined(CONFIG_RELOC_FIXUP_WORKS)
+       mem_malloc_end = CFG_MONITOR_BASE + gd->reloc_off;
+#endif
+       mem_malloc_start = mem_malloc_end - TOTAL_MALLOC_LEN;
        mem_malloc_brk = mem_malloc_start;
 
        memset ((void *) mem_malloc_start,
@@ -623,6 +623,7 @@ void board_init_r (gd_t *id, ulong dest_addr)
 
 #if defined(CONFIG_RELOC_FIXUP_WORKS)
        gd->reloc_off = 0;
+       mem_malloc_end = dest_addr;
 #else
        gd->reloc_off = dest_addr - CFG_MONITOR_BASE;
 #endif
Signature · 4 lines
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.
grant.likely at secretlab.ca
(403) 399-0195
#2 lore raw
In reply to Stefan Roese

Dear Stefan,

Quoted 3 lines · in message <[email protected]> you wrote:

The relocation fixup didn't handle the malloc pointer initialization correctly. This patch fixes this problem. Tested successfully on 4xx. The relocation fixup patches for 4xx will follow soon.

Thanks.

I hiess you only tested this with CONFIG_RELOC_FIXUP_WORKS undefined?

lib_ppc/board.c static ulong mem_malloc_brk = 0; · line 142

Quoted 7 lines
lib_ppc/board.c +0 -1
@@ -139,10 +139,10 @@ static	ulong	mem_malloc_brk	 = 0;
  */
 static void mem_malloc_init (void)
 {
-	ulong dest_addr = CFG_MONITOR_BASE + gd->reloc_off;

Here you delte the declaration of dest_addr ...

lib_ppc/board.c void board_init_r (gd_t *id, ulong dest_addr) · line 626

Quoted 5 lines
lib_ppc/board.c +1 -0
@@ -623,6 +623,7 @@ void board_init_r (gd_t *id, ulong dest_addr)
 
 #if defined(CONFIG_RELOC_FIXUP_WORKS)
 	gd->reloc_off = 0;
+	mem_malloc_end = dest_addr;

...and here you try to use it again?

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
No question is too silly to ask. Of course, some  questions  are  too
silly to to answer...  - L. Wall & R. L. Schwartz, _Programming Perl_
#3 lore raw
Quoted 10 lines · Wolfgang Denk

lib_ppc/board.c static ulong mem_malloc_brk = 0; · line 142

Quoted 7 lines
lib_ppc/board.c +0 -1
@@ -139,10 +139,10 @@ static  ulong   mem_malloc_brk   = 0;
  */
 static void mem_malloc_init (void)
 {
-     ulong dest_addr = CFG_MONITOR_BASE + gd->reloc_off;

Here you delte the declaration of dest_addr ...

Quoted 7 lines

lib_ppc/board.c void board_init_r (gd_t *id, ulong dest_addr) · line 626

Quoted 5 lines
lib_ppc/board.c +1 -0
@@ -623,6 +623,7 @@ void board_init_r (gd_t *id, ulong dest_addr)
 
 #if defined(CONFIG_RELOC_FIXUP_WORKS)
      gd->reloc_off = 0;
+     mem_malloc_end = dest_addr;

...and here you try to use it again?

These two references are in different functions; mem_malloc_init (where it is an automatic variable) and board_init_r (where it is a parameter to the function).

Cheers,
g.

Signature · 4 lines
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.
grant.likely at secretlab.ca
(403) 399-0195
#4 lore raw
In reply to Wolfgang Denk

Hi Wolfgang,

Quoted 8 lines · Wolfgang Denk
Quoted 3 lines · in message <[email protected]> you wrote:

The relocation fixup didn't handle the malloc pointer initialization correctly. This patch fixes this problem. Tested successfully on 4xx. The relocation fixup patches for 4xx will follow soon.

Thanks.

I hiess you only tested this with CONFIG_RELOC_FIXUP_WORKS undefined?

No, I tested both versions. And with this patch both versions work. At least on the 2 4xx platforms I tested on. The patches for the 4xx relocation fixup will follow later. This patch is generic and needed on all ppc platforms.

Quoted 10 lines

lib_ppc/board.c static ulong mem_malloc_brk = 0; · line 142

Quoted 7 lines
lib_ppc/board.c +0 -1
@@ -139,10 +139,10 @@ static	ulong	mem_malloc_brk	 = 0;
  */
 static void mem_malloc_init (void)
 {
-	ulong dest_addr = CFG_MONITOR_BASE + gd->reloc_off;

Here you delte the declaration of dest_addr ...

Quoted 7 lines

lib_ppc/board.c void board_init_r (gd_t *id, ulong dest_addr) · line 626

Quoted 5 lines
lib_ppc/board.c +1 -0
@@ -623,6 +623,7 @@ void board_init_r (gd_t *id, ulong dest_addr)
 
 #if defined(CONFIG_RELOC_FIXUP_WORKS)
 	gd->reloc_off = 0;
+	mem_malloc_end = dest_addr;

...and here you try to use it again?

As Grant already mentionend, there are two different variables.

Best regards,
Stefan

=====================================================================
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: office at denx.de
=====================================================================

#5 lore raw

[U-Boot-Users] Is there somebody using the AmigaOneG3SE board?

In reply to Stefan Roese

Hi,

Is there somebody using the AmigaOneG3SE board or has this board in
hand?

I found some issues for this board and need some helps from those who have this board in hand.

There's a quite complex bios emulator in this board directory, and seems like have some crap in it. I tried to compile u-boot for this board but failed. The bios emulator and the code for the board both can not pass compile.

My questions is:
Is there somebody have this board and have used the u-boot code for this board? Or is there some special configuration for this board?

I ported a bios emulator to drivers directory and wish can be used by every board. The original code of the bios emulator is similar with the code of the MAI board(but more clean and small). This bios emulator has been tested on some freescale boards.

I made a patch to make the MAI board to use the bios emulator in drivers directory, removed the bios emulator in MAI board directory, and also fix the compile issue of the board. But I can not test these changes as I have no board in hand. If somebody have this board in hand and want to test this on the board, please feel free to contact me.

Thanks
Jason

#6 lore raw
In reply to Stefan Roese
Quoted 5 lines · In message <[email protected]> you wrote:

The relocation fixup didn't handle the malloc pointer initialization correctly. This patch fixes this problem. Tested successfully on 4xx. The relocation fixup patches for 4xx will follow soon.

Applied to u-boot-testing.

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
It is a good thing for an uneducated man to read books of quotations.
                        - Sir Winston Churchill _My Early Life_ ch. 9