]> git.sur5r.net Git - u-boot/commitdiff
Fix the exception occuring in RAM table search issue.
authorroy zang <tie-fei.zang@freescale.com>
Fri, 1 Dec 2006 11:01:25 +0000 (19:01 +0800)
committerZang Tiefei <roy@bus.ap.freescale.net>
Fri, 1 Dec 2006 11:01:25 +0000 (19:01 +0800)
The original search_one_table() function code can only processes the search
for the exception occurring in FLASH/ROM, because the exception and fixup
table usually locate in FLASH. If the exception address is also in
FLASH, it will be OK.
If the exception occurs in RAM, after the u-boot relocation, a
relocation offset should be added.

clean up the code in cpu/74xx_7xx/cpu.c

Signed-off-by: Roy Zang <tie-fei.zang@freescale.com>
cpu/74xx_7xx/cpu.c
include/configs/mpc7448hpc2.h
lib_ppc/extable.c

index ca45ca0457fd748f5a9dece526d768a013bdd282..84d5da3116babd52295e21c12a4eae7a8beadc66 100644 (file)
@@ -108,11 +108,11 @@ get_cpu_type(void)
        case 0x8003:
                type = CPU_7447A;
                break;
-               
+
        case 0x8004:
                type = CPU_7448;
                break;
-               
+
        default:
                break;
        }
@@ -164,6 +164,10 @@ int checkcpu (void)
                str = "MPC7410";
                break;
 
+       case CPU_7447A:
+               str = "MPC7447A";
+               break;
+
        case CPU_7448:
                str = "MPC7448";
                break;
@@ -180,14 +184,6 @@ int checkcpu (void)
                str = "MPC7457";
                break;
 
-       case CPU_7447A:
-               str = "MPC7447A";
-               break;
-
-       case CPU_7448:
-               str = "MPC7448";
-               break;
-
        default:
                printf("Unknown CPU -- PVR: 0x%08x\n", pvr);
                return -1;
index b13b699b59340273f1e87672282c3d51a16cae8b..c9131a432ce70903dae4af8cc07990a9017c8cb6 100644 (file)
  */
 #define BOOTFLAG_COLD  0x01    /* Normal Power-On: Boot from FLASH */
 #define BOOTFLAG_WARM  0x02    /* Software reboot */
-#define CFG_EXCEPTION_AFTER_RELOCATE
 #define CFG_SERIAL_HANG_IN_EXCEPTION
 #endif /* __CONFIG_H */
index 34b5d460cf54c1318d3676b987d00d0235c58a77..623b5f129cb79d39305996d95e1dff2aae09b592 100644 (file)
@@ -57,16 +57,22 @@ search_one_table(const struct exception_table_entry *first,
                long diff;
 
                mid = (last - first) / 2 + first;
-#ifdef CFG_EXCEPTION_AFTER_RELOCATE
-               diff = (mid->insn + gd->reloc_off) - value;
-               if (diff == 0)
-                       return (mid->fixup + gd->reloc_off);
-#else
-               diff = mid->insn - value;
-               if (diff == 0)
-                       return mid->fixup;
-#endif
-               else if (diff < 0)
+               if (mid > CFG_MONITOR_BASE){ 
+               /* exception occurs in FLASH, before u-boot relocation.
+                * No relocation offset is needed. 
+                */
+                       diff = mid->insn - value;
+                       if (diff == 0)
+                               return mid->fixup;
+               } else {
+               /* exception occurs in RAM, after u-boot relocation. 
+                * A relocation offset should be added.
+                */
+                       diff = (mid->insn + gd->reloc_off) - value;
+                       if (diff == 0)
+                               return (mid->fixup + gd->reloc_off);
+               }
+               if (diff < 0)
                        first = mid+1;
                else
                        last = mid-1;
@@ -83,6 +89,7 @@ search_exception_table(unsigned long addr)
 
        /* There is only the kernel to search.  */
        ret = search_one_table(__start___ex_table, __stop___ex_table-1, addr);
+       /* if the serial port does not hang in exception, printf can be used */
 #if !defined(CFG_SERIAL_HANG_IN_EXCEPTION)
        if (ex_tab_message)
                printf("Bus Fault @ 0x%08lx, fixup 0x%08lx\n", addr, ret);