Skip to content

Instantly share code, notes, and snippets.

@bkrepo
Created September 8, 2016 06:18
Show Gist options
  • Save bkrepo/aded8b7e02ebff62404bb008c6a3158c to your computer and use it in GitHub Desktop.
Save bkrepo/aded8b7e02ebff62404bb008c6a3158c to your computer and use it in GitHub Desktop.
examples: api: support arm64 target
diff --git a/examples/api/crt0.S b/examples/api/crt0.S
index df2b542..d9313d0 100644
--- a/examples/api/crt0.S
+++ b/examples/api/crt0.S
@@ -26,7 +26,21 @@ syscall:
bctr
#elif defined(CONFIG_ARM)
+#ifdef CONFIG_ARM64
+ .text
+ .globl _start
+_start:
+ ldr x10, =search_hint
+ str xzr, [x10]
+ b main
+
+ .globl syscall
+syscall:
+ ldr x10, =syscall_ptr
+ ldr x30, [x10]
+ ret
+#else
.text
.globl _start
_start:
@@ -39,6 +53,7 @@ _start:
syscall:
ldr ip, =syscall_ptr
ldr pc, [ip]
+#endif
#elif defined(CONFIG_MIPS)
#include <asm/asm.h>
@@ -69,9 +84,9 @@ return_addr:
#error No support for this arch!
#endif
+ .align 8
.globl syscall_ptr
syscall_ptr:
- .align 8
.long 0
.globl search_hint
diff --git a/examples/api/demo.c b/examples/api/demo.c
index 8c30457..5c395ce 100644
--- a/examples/api/demo.c
+++ b/examples/api/demo.c
@@ -43,12 +43,12 @@ int main(int argc, char * const argv[])
if (sig->version > API_SIG_VERSION)
return -3;
- printf("API signature found @%x\n", (unsigned int)sig);
+ printf("API signature found @%lx\n", (unsigned long)sig);
test_dump_sig(sig);
printf("\n*** Consumer API test ***\n");
- printf("syscall ptr 0x%08x@%08x\n", (unsigned int)syscall_ptr,
- (unsigned int)&syscall_ptr);
+ printf("syscall ptr 0x%08lx@%08lx\n", (unsigned long)syscall_ptr,
+ (unsigned long)&syscall_ptr);
/* console activities */
ub_putc('B');
@@ -203,7 +203,7 @@ void test_dump_sig(struct api_signature *sig)
printf("signature:\n");
printf(" version\t= %d\n", sig->version);
printf(" checksum\t= 0x%08x\n", sig->checksum);
- printf(" sc entry\t= 0x%08x\n", (unsigned int)sig->syscall);
+ printf(" sc entry\t= 0x%08lx\n", (unsigned long)sig->syscall);
}
void test_dump_si(struct sys_info *si)
@@ -211,9 +211,9 @@ void test_dump_si(struct sys_info *si)
int i;
printf("sys info:\n");
- printf(" clkbus\t= 0x%08x\n", (unsigned int)si->clk_bus);
- printf(" clkcpu\t= 0x%08x\n", (unsigned int)si->clk_cpu);
- printf(" bar\t\t= 0x%08x\n", (unsigned int)si->bar);
+ printf(" clkbus\t= 0x%08lx\n", (unsigned long)si->clk_bus);
+ printf(" clkcpu\t= 0x%08lx\n", (unsigned long)si->clk_cpu);
+ printf(" bar\t\t= 0x%08lx\n", (unsigned long)si->bar);
printf("---\n");
for (i = 0; i < si->mr_no; i++) {
@@ -296,7 +296,7 @@ void test_dump_di(int handle)
struct device_info *di = ub_dev_get(handle);
printf("device info (%d):\n", handle);
- printf(" cookie\t= 0x%08x\n", (uint32_t)di->cookie);
+ printf(" cookie\t= 0x%08lx\n", (uintptr_t)di->cookie);
printf(" type\t\t= 0x%08x\n", di->type);
if (di->type == DEV_TYP_NET) {
diff --git a/examples/api/glue.c b/examples/api/glue.c
index 8aabf32..fc63ec8 100644
--- a/examples/api/glue.c
+++ b/examples/api/glue.c
@@ -41,8 +41,8 @@ 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;
+ uintptr_t search_start = 0;
+ uintptr_t search_end = 0;
if (sig == NULL)
return 0;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment