diff options
author | Peng Fan <van.freenix@gmail.com> | 2013-07-18 11:33:55 +0800 |
---|---|---|
committer | Peng Fan <van.freenix@gmail.com> | 2013-07-22 10:51:40 +0800 |
commit | 19b3b6033adfe740038a5cd483f05b7c9273a148 (patch) | |
tree | fb9b4115a78e1a06ddfa1bc88ce7ffb2fe71877f /testcase | |
parent | e4b6108400c8df19184fee30beeaa4edde9bca10 (diff) |
ARM Support
Signed-off-by: Peng Fan <van.freenix@gmail.com>
Diffstat (limited to 'testcase')
-rw-r--r-- | testcase/1.c | 106 | ||||
-rw-r--r-- | testcase/2.c | 14 | ||||
-rw-r--r-- | testcase/Readme | 11 | ||||
-rw-r--r-- | testcase/wscript | 32 |
4 files changed, 163 insertions, 0 deletions
diff --git a/testcase/1.c b/testcase/1.c new file mode 100644 index 0000000..e8a1241 --- /dev/null +++ b/testcase/1.c @@ -0,0 +1,106 @@ +int global; +static char local; + +void hello(int arg) +{ + switch (arg) { + case 1: + printf("Inner-module call hello()\n"); + break; + case 2: + printf("Inter-module call hello()\n"); + break; + default: + return; + } +} + +#if defined (__arm__) +int rtems_arm(int arg) +{ + switch (arg) { + case 24: + printf("R_ARM_JUMP24: arg = 24\n"); + break; + } + return 0; +} + +int rtems_thumb(int arg) +{ + switch (arg) { + case 19: + printf("R_ARM_THM_JUMP19: arg = 19\n"); + break; + case 24: + printf("R_ARM_THM_JUMP24: arg = 24\n"); + break; + } + return 0; +} +#endif + +/* This is the init entry, Because init() use "blx", it is not needed + * to handle arm/thumb switch here + */ +int rtems(int argc, char **argv) +{ + local = 1; + printf("In rtems() local = %d\n", local); //inner-module data access + hello(1); //inner-module call + test(argc, argv); + +#if defined (__arm__) +#ifdef THUMB_TEST + __asm__ volatile ( + "push {r0}\r\n" + "push {lr}\r\n" + "mov r0, #19\r\n" + "cmp r0, #19\r\n" + "mov lr, pc\r\n" + "add lr, #7\r\n" + "beq rtems_thumb\r\n" /*THM_JUMP19*/ + "nop\r\n" + "nop\r\n" + "nop\r\n" + "nop\r\n" + "pop {lr}\r\n" + "pop {r0}\r\n" + ); + __asm__ volatile ( + "push {r0}\r\n" + "push {lr}\r\n" + "mov r0, #24\r\n" + "mov lr, pc\r\n" + "add lr, #7\r\n" + "b.w rtems_thumb\r\n" /*THM_JUMP24*/ + "nop\r\n" + "nop\r\n" + "nop\r\n" + "nop\r\n" + "pop {lr}\r\n" + "pop {r0}\r\n" + ); +#elif defined ARM_TEST + /*arm instruction test*/ + __asm__ volatile ( + "push {r0}\r\n" + "push {lr}\r\n" + "mov r0, #24\r\n" + "mov lr, pc\r\n" + "add lr, #4\r\n" + "b rtems_arm\r\n" /*JUMP24*/ + "nop\r\n" + "nop\r\n" + "nop\r\n" + "nop\r\n" + "pop {lr}\r\n" + "pop {r0}\r\n" + ); +#endif + +#else + /* other archs */ +#endif + return 0; +} diff --git a/testcase/2.c b/testcase/2.c new file mode 100644 index 0000000..a63c1c7 --- /dev/null +++ b/testcase/2.c @@ -0,0 +1,14 @@ +extern int global; +extern void hello(int); + +int test(int argc, char **argv) +{ + global = 1; //inter-module data access + printf("In test() global = %d\n", global); + hello(2); //inter-module call +} + +int my_main(int argc, char **argv) +{ + exit(0); +} diff --git a/testcase/Readme b/testcase/Readme new file mode 100644 index 0000000..1312f60 --- /dev/null +++ b/testcase/Readme @@ -0,0 +1,11 @@ +==================== +arm: + Simulator: + qemu-system-arm -no-reboot -net none -nographic -M realview-pbx-a9 -m 256M -kernel build/arm-rtems4.11-realview_pbx_a9_qemu/rtld + add "-S -s" option and you can use gdbserver to debug rtld + use "halt" to exit qemu. + + Configuration: + waf configure --rtems=/opt/rtems-4.11 --rtems-tools=/opt/rtems-4.11 --rtems-archs=arm --rtems-bsps=arm/realview_pbx_a9_qemu + + In the wscript, you can use different cflags to test. diff --git a/testcase/wscript b/testcase/wscript new file mode 100644 index 0000000..a518cb6 --- /dev/null +++ b/testcase/wscript @@ -0,0 +1,32 @@ +import re +import rtems + +def build(bld): + arch = bld.get_env()['RTEMS_ARCH'] + + bld(target = 'x', + features = 'c cstlib', + includes = bld.includes, + defines = bld.defines, + source = ['1.c', '2.c']) + +# Note: the bsp is compiled in thumb mode +# The follow cflags is to test arm/thumb reloc code. +# cflags = '-marm -fno-common -DARM_TEST', +# cflags = '-mthumb -fno-common -DTHUMB_TEST', +# cflags = '-marm -mcpu=arm1176jzf-s -fno-common -DARM_TEST', + + if arch == 'arm': + bld(target = 'test.rap', + features = 'c rap', + xxxx = 'hello', + + cflags = '-mthumb -fno-common -DTHUMB_TEST', + + rtems_linkflags = ['--base', 'rtld.prelink', + '--entry', 'my_main'], + source = ['1.c', '2.c']) + + bld(target = '../test.rap', + source = ['test.rap'], + rule = 'cp ${SRC} ${TGT}') |