]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
API: Use stack pointer as API signature search hint in the glue layer.
authorRafal Jaworowski <raj@semihalf.com>
Fri, 23 Jan 2009 12:27:15 +0000 (13:27 +0100)
committerWolfgang Denk <wd@denx.de>
Tue, 17 Feb 2009 23:39:34 +0000 (00:39 +0100)
De-hardcode range in RAM we search for the API signature. Instead use the stack
pointer as a hint to narrow down the range in which the signature could reside
(it is malloc'ed on the U-Boot heap, and is hoped to remain in some proximity
from stack area). Adjust PowerPC code in API demo to the new scheme.

Signed-off-by: Rafal Czubak <rcz@semihalf.com>
Signed-off-by: Rafal Jaworowski <raj@semihalf.com>
api_examples/crt0.S
api_examples/glue.c
api_examples/glue.h

index 8d4f7064eb9bf768ac63c542898ad9a10e433726..3129a07bcba698d4ac0c80e5aa197fc79592f323 100644 (file)
@@ -29,6 +29,9 @@
 
        .globl _start
 _start:
+       lis     %r11, search_hint@ha
+       addi    %r11, %r11, search_hint@l
+       stw     %r1, 0(%r11)
        b       main
 
 
@@ -39,12 +42,15 @@ syscall:
        lwz     %r11, 0(%r11)
        mtctr   %r11
        bctr
-
+#else
+#error No support for this arch!
+#endif
 
        .globl syscall_ptr
 syscall_ptr:
        .align  4
        .long   0
-#else
-#error No support for this arch!
-#endif
+
+       .globl search_hint
+search_hint:
+       .long   0
index 2bf47ae3d212f9f383c27683a23a4bc00f0d98b8..200b1637396cee3e9620406ad907bec67cfa8044 100644 (file)
@@ -60,13 +60,20 @@ static int valid_sig(struct api_signature *sig)
 int api_search_sig(struct api_signature **sig) {
 
        unsigned char *sp;
+       uint32_t search_start = 0;
+       uint32_t search_end = 0;
 
        if (sig == NULL)
                return 0;
 
-       sp = (unsigned char *)API_SEARCH_START;
+       if (search_hint == 0)
+               search_hint = 255 * 1024 * 1024;
 
-       while ((sp + (int)API_SIG_MAGLEN) < (unsigned char *)API_SEARCH_END) {
+       search_start = search_hint & ~0x000fffff;
+       search_end = search_start + API_SEARCH_LEN - API_SIG_MAGLEN;
+
+       sp = (unsigned char *)search_start;
+       while ((sp + API_SIG_MAGLEN) < (unsigned char *)search_end) {
                if (!memcmp(sp, API_SIG_MAGIC, API_SIG_MAGLEN)) {
                        *sig = (struct api_signature *)sp;
                        if (valid_sig(*sig))
index a82f783cbe08163566dfa7803ad81b7f7c1be76b..0adb8b388aa3b5ed1671cac0d2590d4f39b5c588 100644 (file)
 #ifndef _API_GLUE_H_
 #define _API_GLUE_H_
 
-#define API_SEARCH_START       (255 * 1024 * 1024)     /* start at 1MB below top RAM */
-#define API_SEARCH_END         (256 * 1024 * 1024 - 1) /* ...and search to the end */
+#define API_SEARCH_LEN         (3 * 1024 * 1024)       /* 3MB search range */
 
-int    syscall(int, int *, ...);
-void * syscall_ptr;
+extern void *syscall_ptr;
+extern uint32_t search_hint;
 
+int    syscall(int, int *, ...);
 int    api_search_sig(struct api_signature **sig);
 
 /*