diff options
author | wdenk <wdenk> | 2003-07-26 08:08:08 +0000 |
---|---|---|
committer | wdenk <wdenk> | 2003-07-26 08:08:08 +0000 |
commit | 7784674852c66b0924bdc79062bd208aa51fd0a9 (patch) | |
tree | df62c40f9c04ebf3b5f8c2bea9e1bc80ae05cb8d /examples | |
parent | 27b207fd0a0941b03f27e2a82c0468b1a090c745 (diff) |
* Allow crc32 to be used at address 0x000
* Provide consistent interface to standalone applications to access
the 'global_data' structure
Provide a doc/README.standalone more useful to users/developers.
* Make IceCube MGT5100 FEC driver work
Diffstat (limited to 'examples')
-rw-r--r-- | examples/stubs.c | 4 | ||||
-rw-r--r-- | examples/x86-testapp.c | 87 |
2 files changed, 90 insertions, 1 deletions
diff --git a/examples/stubs.c b/examples/stubs.c index c0ef65048e9..9c4c51b0e4f 100644 --- a/examples/stubs.c +++ b/examples/stubs.c @@ -9,6 +9,7 @@ * to the application program. */ static void **jt; +gd_t *global_data; #define EXPORT_FUNC(x) \ asm volatile ( \ @@ -80,7 +81,8 @@ void app_startup(char **argv) { #if defined(CONFIG_I386) /* x86 does not have a dedicated register for passing global_data */ - jt = ((gd_t *)argv[-1])->jt; + global_data = (gd_t *)argv[-1]; + jt = global_data->jt; #endif } diff --git a/examples/x86-testapp.c b/examples/x86-testapp.c new file mode 100644 index 00000000000..a1ab319ae88 --- /dev/null +++ b/examples/x86-testapp.c @@ -0,0 +1,87 @@ +#include <stddef.h> +#include <stdio.h> +#include <string.h> + +void *func[8], **pfunc; + +typedef struct xxx xxx_t; +struct xxx { + int dummy; + void **pfunc; +} q; + +#define XF_strcpy 3 +#define XF_printf 4 + +#define LABEL(x) \ +asm volatile ( \ + +#if defined(__i386__) +#define EXPORT_FUNC(x) \ +asm volatile ( \ +" .globl mon_" #x "\n" \ +"mon_" #x ":\n" \ +" movl %0, %%eax\n" \ +" movl pfunc, %%ecx\n" \ +" jmp *(%%ecx,%%eax)\n" \ + : : "i"(XF_ ## x * sizeof(void *)) : "eax", "ecx"); +#elif defined(__powerpc__) +#define EXPORT_FUNC(x) \ +asm volatile ( \ +" .globl mon_" #x "\n" \ +"mon_" #x ":\n" \ +" lwz %%r11, %0(%%r29)\n" \ +" lwz %%r11, %1(%%r11)\n" \ +" mtctr %%r11\n" \ +" bctr\n" \ + : : "i"(offsetof(xxx_t, pfunc)), "i"(XF_ ## x * sizeof(void *)) : "r11", "r29"); +#elif defined(__arm__) +#define EXPORT_FUNC(x) \ +asm volatile ( \ +" .globl mon_" #x "\n" \ +"mon_" #x ":\n" \ +" ldr ip, [r8, %0]\n" \ +" ldr pc, [ip, %1]\n" \ + : : "i"(offsetof(xxx_t, pfunc)), "i"(XF_ ## x * sizeof(void *)) : "ip"); +#elif defined(__mips__) +#define EXPORT_FUNC(x) \ +asm volatile ( \ +" .globl mon_" #x "\n" \ +"mon_" #x ":\n" \ +" lw $25, %0($26)\n" \ +" lw $25, %1($25)\n" \ +" jr $25\n" \ + : : "i"(offsetof(xxx_t, pfunc)), "i"(XF_ ## x * sizeof(void *)) : "t9"); +#else +#error [No stub code for this arch] +#endif + +void dummy(void) +{ +EXPORT_FUNC(printf) +EXPORT_FUNC(strcpy) +} + +int main(void) +{ +#if defined(__i386__) + xxx_t *pq; +#elif defined(__powerpc__) + register volatile xxx_t *pq asm("r29"); +#elif defined(__arm__) + register volatile xxx_t *pq asm("r8"); +#elif defined(__mips__) + register volatile xxx_t *pq asm("k0"); +#endif + char buf[32]; + + func[XF_strcpy] = strcpy; + func[XF_printf] = printf; + pq = &q; + pq->pfunc = pfunc = func; + + mon_strcpy(buf, "test"); + mon_printf("hi %s %d z\n", buf, 444); + + return 0; +} |