[U-Boot-Users] [PATCH 00/07 v2]: Add mpc7448hpc2 (Taiga) board support

Zang Roy-r61911
2006-12-01T08:09:27Z

Dear Wolfgang

On Mon, 2006-11-27 at 23:49, Wolfgang Denk wrote:

>
> 12) In lib_ppc/extable.c you add code with a "#ifdef
> CFG_EXCEPTION_AFTER_RELOCATE; there is absolutely no explanation
> nor comment anywhere why you think this is necessary.
>

I do not think the search_one_table()function can deal with all the
exception conditions.The original 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.

I am sadly to see that there is no other ppc board encountering the
exception in RAM phase. While for mpc7448hpc2 board, tsi108 pci config
read will generate such kind of exception.

After consideration , I do not think provide
CFG_EXCEPTION_AFTER_RELOCATE is a good option :-). I change it to the
following code. How do you think?
If it is OK, I will provide it with all the mpc7448hpc2 board support
code.
Thanks.
Roy

diff --git a/lib_ppc/extable.c b/lib_ppc/extable.c
index d92f142..8a4d141 100644
--- a/lib_ppc/extable.c
+++ b/lib_ppc/extable.c
@@ -50,15 +50,29 @@ search_one_table(const struct exception_
const struct exception_table_entry *last,
unsigned long value)
{
+ DECLARE_GLOBAL_DATA_PTR;
+
while (first <= last) {
const struct exception_table_entry *mid;
long diff;

mid = (last - first) / 2 + first;
- diff = mid->insn - value;
- if (diff == 0)
- return mid->fixup;
- 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;