[U-Boot-Users] Fix malloc problem introduced with the relocation fixup for the PPC platform

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.
Signed-off-by: Stefan Roese sr@denx.de
--- commit 3a1e66ba75172959973377d6069f1d12e1a4ecb3 tree 6fdde574dd5328b805e0e438ebb32cc7e7de8f4d parent dcc0264878406d52b879d2e5a63d3d793371434e author Stefan Roese sr@denx.de Sun, 08 Jul 2007 13:42:52 +0200 committer Stefan Roese sr@denx.de Sun, 08 Jul 2007 13:42:52 +0200
lib_ppc/board.c | 9 +++++---- 1 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/lib_ppc/board.c b/lib_ppc/board.c index 8bb885d..5e156ab 100644 --- a/lib_ppc/board.c +++ b/lib_ppc/board.c @@ -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

On 7/8/07, Stefan Roese sr@denx.de 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.
Signed-off-by: Stefan Roese sr@denx.de
Acked-by: Grant Likely grant.likely@secretlab.ca
commit 3a1e66ba75172959973377d6069f1d12e1a4ecb3 tree 6fdde574dd5328b805e0e438ebb32cc7e7de8f4d parent dcc0264878406d52b879d2e5a63d3d793371434e author Stefan Roese sr@denx.de Sun, 08 Jul 2007 13:42:52 +0200 committer Stefan Roese sr@denx.de Sun, 08 Jul 2007 13:42:52 +0200
lib_ppc/board.c | 9 +++++---- 1 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/lib_ppc/board.c b/lib_ppc/board.c index 8bb885d..5e156ab 100644 --- a/lib_ppc/board.c +++ b/lib_ppc/board.c @@ -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

Dear Stefan,
in message 200707081344.27628.sr@denx.de 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?
--- a/lib_ppc/board.c +++ b/lib_ppc/board.c @@ -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 ...
@@ -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

On 7/8/07, Wolfgang Denk wd@denx.de wrote:
--- a/lib_ppc/board.c +++ b/lib_ppc/board.c @@ -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 ...
@@ -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.

Hi Wolfgang,
On Sunday 08 July 2007, Wolfgang Denk wrote:
in message 200707081344.27628.sr@denx.de 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.
--- a/lib_ppc/board.c +++ b/lib_ppc/board.c @@ -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 ...
@@ -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@denx.de =====================================================================

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

In message 200707081344.27628.sr@denx.de 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.
Signed-off-by: Stefan Roese sr@denx.de
Applied to u-boot-testing.
Best regards,
Wolfgang Denk
participants (4)
-
Grant Likely
-
Jin Zhengxiong-R64188
-
Stefan Roese
-
Wolfgang Denk