diff --git a/api/api.c b/api/api.c index c5f6edb..2639ee5 100644 --- a/api/api.c +++ b/api/api.c @@ -52,7 +52,7 @@ static int API_getc(va_list ap) { int *c; - if ((c = (int *)va_arg(ap, u_int32_t)) == NULL) + if ((c = (int *)va_arg(ap, uintptr_t)) == NULL) return API_EINVAL; *c = getc(); @@ -68,7 +68,7 @@ static int API_tstc(va_list ap) { int *t; - if ((t = (int *)va_arg(ap, u_int32_t)) == NULL) + if ((t = (int *)va_arg(ap, uintptr_t)) == NULL) return API_EINVAL; *t = tstc(); @@ -84,7 +84,7 @@ static int API_putc(va_list ap) { char *c; - if ((c = (char *)va_arg(ap, u_int32_t)) == NULL) + if ((c = (char *)va_arg(ap, uintptr_t)) == NULL) return API_EINVAL; putc(*c); @@ -100,7 +100,7 @@ static int API_puts(va_list ap) { char *s; - if ((s = (char *)va_arg(ap, u_int32_t)) == NULL) + if ((s = (char *)va_arg(ap, uintptr_t)) == NULL) return API_EINVAL; puts(s); @@ -132,7 +132,7 @@ static int API_get_sys_info(va_list ap) { struct sys_info *si; - si = (struct sys_info *)va_arg(ap, u_int32_t); + si = (struct sys_info *)va_arg(ap, uintptr_t); if (si == NULL) return API_ENOMEM; @@ -148,7 +148,7 @@ static int API_udelay(va_list ap) { unsigned long *d; - if ((d = (unsigned long *)va_arg(ap, u_int32_t)) == NULL) + if ((d = (unsigned long *)va_arg(ap, uintptr_t)) == NULL) return API_EINVAL; udelay(*d); @@ -164,11 +164,11 @@ static int API_get_timer(va_list ap) { unsigned long *base, *cur; - cur = (unsigned long *)va_arg(ap, u_int32_t); + cur = (unsigned long *)va_arg(ap, uintptr_t); if (cur == NULL) return API_EINVAL; - base = (unsigned long *)va_arg(ap, u_int32_t); + base = (unsigned long *)va_arg(ap, uintptr_t); if (base == NULL) return API_EINVAL; @@ -199,7 +199,7 @@ static int API_dev_enum(va_list ap) struct device_info *di; /* arg is ptr to the device_info struct we are going to fill out */ - di = (struct device_info *)va_arg(ap, u_int32_t); + di = (struct device_info *)va_arg(ap, uintptr_t); if (di == NULL) return API_EINVAL; @@ -233,7 +233,7 @@ static int API_dev_open(va_list ap) int err = 0; /* arg is ptr to the device_info struct */ - di = (struct device_info *)va_arg(ap, u_int32_t); + di = (struct device_info *)va_arg(ap, uintptr_t); if (di == NULL) return API_EINVAL; @@ -265,7 +265,7 @@ static int API_dev_close(va_list ap) int err = 0; /* arg is ptr to the device_info struct */ - di = (struct device_info *)va_arg(ap, u_int32_t); + di = (struct device_info *)va_arg(ap, uintptr_t); if (di == NULL) return API_EINVAL; @@ -319,7 +319,7 @@ static int API_dev_write(va_list ap) int err = 0; /* 1. arg is ptr to the device_info struct */ - di = (struct device_info *)va_arg(ap, u_int32_t); + di = (struct device_info *)va_arg(ap, uintptr_t); if (di == NULL) return API_EINVAL; @@ -329,12 +329,12 @@ static int API_dev_write(va_list ap) return API_ENODEV; /* 2. arg is ptr to buffer from where to get data to write */ - buf = (void *)va_arg(ap, u_int32_t); + buf = (void *)va_arg(ap, uintptr_t); if (buf == NULL) return API_EINVAL; /* 3. arg is length of buffer */ - len = (int *)va_arg(ap, u_int32_t); + len = (int *)va_arg(ap, uintptr_t); if (len == NULL) return API_EINVAL; if (*len <= 0) @@ -387,7 +387,7 @@ static int API_dev_read(va_list ap) int *len_net, *act_len_net; /* 1. arg is ptr to the device_info struct */ - di = (struct device_info *)va_arg(ap, u_int32_t); + di = (struct device_info *)va_arg(ap, uintptr_t); if (di == NULL) return API_EINVAL; @@ -397,23 +397,23 @@ static int API_dev_read(va_list ap) return API_ENODEV; /* 2. arg is ptr to buffer from where to put the read data */ - buf = (void *)va_arg(ap, u_int32_t); + buf = (void *)va_arg(ap, uintptr_t); if (buf == NULL) return API_EINVAL; if (di->type & DEV_TYP_STOR) { /* 3. arg - ptr to var with # of blocks to read */ - len_stor = (lbasize_t *)va_arg(ap, u_int32_t); + len_stor = (lbasize_t *)va_arg(ap, uintptr_t); if (!len_stor) return API_EINVAL; if (*len_stor <= 0) return API_EINVAL; /* 4. arg - ptr to var with start block */ - start = (lbastart_t *)va_arg(ap, u_int32_t); + start = (lbastart_t *)va_arg(ap, uintptr_t); /* 5. arg - ptr to var where to put the len actually read */ - act_len_stor = (lbasize_t *)va_arg(ap, u_int32_t); + act_len_stor = (lbasize_t *)va_arg(ap, uintptr_t); if (!act_len_stor) return API_EINVAL; @@ -422,14 +422,14 @@ static int API_dev_read(va_list ap) } else if (di->type & DEV_TYP_NET) { /* 3. arg points to the var with length of packet to read */ - len_net = (int *)va_arg(ap, u_int32_t); + len_net = (int *)va_arg(ap, uintptr_t); if (!len_net) return API_EINVAL; if (*len_net <= 0) return API_EINVAL; /* 4. - ptr to var where to put the len actually read */ - act_len_net = (int *)va_arg(ap, u_int32_t); + act_len_net = (int *)va_arg(ap, uintptr_t); if (!act_len_net) return API_EINVAL; @@ -453,9 +453,9 @@ static int API_env_get(va_list ap) { char *name, **value; - if ((name = (char *)va_arg(ap, u_int32_t)) == NULL) + if ((name = (char *)va_arg(ap, uintptr_t)) == NULL) return API_EINVAL; - if ((value = (char **)va_arg(ap, u_int32_t)) == NULL) + if ((value = (char **)va_arg(ap, uintptr_t)) == NULL) return API_EINVAL; *value = getenv(name); @@ -476,9 +476,9 @@ static int API_env_set(va_list ap) { char *name, *value; - if ((name = (char *)va_arg(ap, u_int32_t)) == NULL) + if ((name = (char *)va_arg(ap, uintptr_t)) == NULL) return API_EINVAL; - if ((value = (char *)va_arg(ap, u_int32_t)) == NULL) + if ((value = (char *)va_arg(ap, uintptr_t)) == NULL) return API_EINVAL; setenv(name, value); @@ -498,9 +498,9 @@ static int API_env_enum(va_list ap) int i, n; char *last, **next; - last = (char *)va_arg(ap, u_int32_t); + last = (char *)va_arg(ap, uintptr_t); - if ((next = (char **)va_arg(ap, u_int32_t)) == NULL) + if ((next = (char **)va_arg(ap, uintptr_t)) == NULL) return API_EINVAL; if (last == NULL) @@ -586,7 +586,7 @@ static cfp_t calls_table[API_MAXCALL] = { NULL, }; * The main syscall entry point - this is not reentrant, only one call is * serviced until finished. * - * e.g. syscall(1, int *, u_int32_t, u_int32_t, u_int32_t, u_int32_t); + * e.g. syscall(1, int *, uintptr_t, uintptr_t, uintptr_t, uintptr_t); * * call: syscall number * diff --git a/examples/api/crt0.S b/examples/api/crt0.S index 78d35a2..eb6312e 100644 --- a/examples/api/crt0.S +++ b/examples/api/crt0.S @@ -25,6 +25,22 @@ syscall: mtctr %r11 bctr +#elif defined(CONFIG_ARM64) + + .text + .globl _start +_start: + ldr x14, =search_hint + mov x15, sp + str x15, [x14] + b main + + + .globl syscall +syscall: + ldr x15, syscall_ptr + br x15 + #elif defined(CONFIG_ARM) .text @@ -45,10 +61,10 @@ syscall: #endif .globl syscall_ptr + .align 3 syscall_ptr: - .align 4 - .long 0 + .quad 0 .globl search_hint search_hint: - .long 0 + .quad 0 diff --git a/examples/api/demo.c b/examples/api/demo.c index 8c30457..e1693ef 100644 --- a/examples/api/demo.c +++ b/examples/api/demo.c @@ -43,12 +43,11 @@ 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 @0x%p\n", 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%p @0x%p\n", syscall_ptr, &syscall_ptr); /* console activities */ ub_putc('B'); @@ -203,7 +202,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%p\n", (void *)sig->syscall); } void test_dump_si(struct sys_info *si) @@ -296,7 +295,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%p\n", 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 d619518..d5c1809 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; @@ -77,7 +77,7 @@ int ub_getc(void) { int c; - if (!syscall(API_GETC, NULL, (uint32_t)&c)) + if (!syscall(API_GETC, NULL, (uintptr_t)&c)) return -1; return c; @@ -87,7 +87,7 @@ int ub_tstc(void) { int t; - if (!syscall(API_TSTC, NULL, (uint32_t)&t)) + if (!syscall(API_TSTC, NULL, (uintptr_t)&t)) return -1; return t; @@ -95,12 +95,12 @@ int ub_tstc(void) void ub_putc(char c) { - syscall(API_PUTC, NULL, (uint32_t)&c); + syscall(API_PUTC, NULL, (uintptr_t)&c); } void ub_puts(const char *s) { - syscall(API_PUTS, NULL, (uint32_t)s); + syscall(API_PUTS, NULL, (uintptr_t)s); } /**************************************** @@ -126,7 +126,7 @@ struct sys_info * ub_get_sys_info(void) si.mr_no = UB_MAX_MR; memset(&mr, 0, sizeof(mr)); - if (!syscall(API_GET_SYS_INFO, &err, (u_int32_t)&si)) + if (!syscall(API_GET_SYS_INFO, &err, (uintptr_t)&si)) return NULL; return ((err) ? NULL : &si); @@ -344,7 +344,7 @@ char * ub_env_get(const char *name) { char *value; - if (!syscall(API_ENV_GET, NULL, (uint32_t)name, (uint32_t)&value)) + if (!syscall(API_ENV_GET, NULL, (uintptr_t)name, (uintptr_t)&value)) return NULL; return value; @@ -352,7 +352,7 @@ char * ub_env_get(const char *name) void ub_env_set(const char *name, char *value) { - syscall(API_ENV_SET, NULL, (uint32_t)name, (uint32_t)value); + syscall(API_ENV_SET, NULL, (uintptr_t)name, (uintptr_t)value); } static char env_name[256]; @@ -369,7 +369,7 @@ const char * ub_env_enum(const char *last) * 'name=val' string), since the API_ENUM_ENV call uses envmatch() * internally, which handles such case */ - if (!syscall(API_ENV_ENUM, NULL, (uint32_t)last, (uint32_t)&env)) + if (!syscall(API_ENV_ENUM, NULL, (uintptr_t)last, (uintptr_t)&env)) return NULL; if (!env) @@ -396,7 +396,8 @@ int ub_display_get_info(int type, struct display_info *di) { int err = 0; - if (!syscall(API_DISPLAY_GET_INFO, &err, (uint32_t)type, (uint32_t)di)) + if (!syscall(API_DISPLAY_GET_INFO, &err, (uintptr_t)type, + (uintptr_t)di)) return API_ESYSC; return err; diff --git a/examples/api/glue.h b/examples/api/glue.h index 91c8c1c..3e27a4e 100644 --- a/examples/api/glue.h +++ b/examples/api/glue.h @@ -19,7 +19,7 @@ #define UB_MAX_DEV 6 /* max devices number */ extern void *syscall_ptr; -extern uint32_t search_hint; +extern uintptr_t search_hint; int syscall(int, int *, ...); int api_search_sig(struct api_signature **sig); diff --git a/examples/api/libgenwrap.c b/examples/api/libgenwrap.c index c1afa5b..4f78c15 100644 --- a/examples/api/libgenwrap.c +++ b/examples/api/libgenwrap.c @@ -23,7 +23,7 @@ int printf (const char *fmt, ...) { va_list args; uint i; - char printbuffer[256]; + char printbuffer[512]; va_start (args, fmt);