Search the exception table with linear algorithm

Search the exception table with linear algorithm instead of
bisecting algorithm.
Because the exception table might be unsorted.

Signed-off-by: Roy Zang <tie-fei.zang@freescale.com>
This commit is contained in:
Zang Roy-r61911 2007-05-09 08:10:57 +08:00 committed by Wolfgang Denk
parent 5dfaa50eb8
commit 1b305bdc75

View File

@ -52,30 +52,27 @@ search_one_table(const struct exception_table_entry *first,
const struct exception_table_entry *last, const struct exception_table_entry *last,
unsigned long value) unsigned long value)
{ {
while (first <= last) { long diff;
const struct exception_table_entry *mid; if ((ulong) first > CFG_MONITOR_BASE) {
long diff; /* exception occurs in FLASH, before u-boot relocation.
* No relocation offset is needed.
mid = (last - first) / 2 + first; */
if ((ulong) mid > CFG_MONITOR_BASE) { while (first <= last) {
/* exception occurs in FLASH, before u-boot relocation. diff = first->insn - value;
* No relocation offset is needed.
*/
diff = mid->insn - value;
if (diff == 0) if (diff == 0)
return mid->fixup; return first->fixup;
} else { first++;
/* exception occurs in RAM, after u-boot relocation. }
* A relocation offset should be added. } else {
*/ /* exception occurs in RAM, after u-boot relocation.
diff = (mid->insn + gd->reloc_off) - value; * A relocation offset should be added.
if (diff == 0) */
return (mid->fixup + gd->reloc_off); while (first <= last) {
diff = (first->insn + gd->reloc_off) - value;
if (diff == 0)
return (first->fixup + gd->reloc_off);
first++;
} }
if (diff < 0)
first = mid + 1;
else
last = mid - 1;
} }
return 0; return 0;
} }