public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot-Users] [patch] Search the exception table with linear algorithm
@ 2007-05-09  0:10 Zang Roy-r61911
  2007-05-15 21:40 ` Wolfgang Denk
  0 siblings, 1 reply; 2+ messages in thread
From: Zang Roy-r61911 @ 2007-05-09  0:10 UTC (permalink / raw)
  To: u-boot

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>
---
 lib_ppc/extable.c |   39 ++++++++++++++++++---------------------
 1 files changed, 18 insertions(+), 21 deletions(-)

diff --git a/lib_ppc/extable.c b/lib_ppc/extable.c
index b14d661..8354411 100644
--- a/lib_ppc/extable.c
+++ b/lib_ppc/extable.c
@@ -52,30 +52,27 @@ search_one_table(const struct exception_table_entry *first,
 		 const struct exception_table_entry *last,
 		 unsigned long value)
 {
-	while (first <= last) {
-		const struct exception_table_entry *mid;
-		long diff;
-
-		mid = (last - first) / 2 + first;
-		if ((ulong) mid > CFG_MONITOR_BASE) {
-			/* exception occurs in FLASH, before u-boot relocation.
-			 * No relocation offset is needed.
-			 */
-			diff = mid->insn - value;
+	long diff;
+	if ((ulong) first > CFG_MONITOR_BASE) {
+		/* exception occurs in FLASH, before u-boot relocation.
+		 * No relocation offset is needed.
+		 */
+		while (first <= last) {
+			diff = first->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;
+				return first->fixup;
+			first++;
+		}
+	} else {
+		/* exception occurs in RAM, after u-boot relocation.
+		 * A relocation offset should be added.
+		 */
+		while (first <= last) {
+			diff = (first->insn + gd->reloc_off) - value;
 			if (diff == 0)
-				return (mid->fixup + gd->reloc_off);
+				return (first->fixup + gd->reloc_off);
+			first++;
 		}
-		if (diff < 0)
-			first = mid + 1;
-		else
-			last = mid - 1;
 	}
 	return 0;
 }
-- 
1.5.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [U-Boot-Users] [patch] Search the exception table with linear algorithm
  2007-05-09  0:10 [U-Boot-Users] [patch] Search the exception table with linear algorithm Zang Roy-r61911
@ 2007-05-15 21:40 ` Wolfgang Denk
  0 siblings, 0 replies; 2+ messages in thread
From: Wolfgang Denk @ 2007-05-15 21:40 UTC (permalink / raw)
  To: u-boot

In message <1178669456.10535.2.camel@localhost.localdomain> you wrote:
> Search the exception table with linear algorithm instead of
> bisecting algorithm.
> Because the exception table might be unsorted.

Applied to u-boot-testing.

Thanks.

Best regards,

Wolfgang Denk

-- 
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
Don't put off for tomorrow what you can  do  today,  because  if  you
enjoy it today you can do it again tomorrow.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-05-15 21:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-05-09  0:10 [U-Boot-Users] [patch] Search the exception table with linear algorithm Zang Roy-r61911
2007-05-15 21:40 ` Wolfgang Denk

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox