Backport the ugetp/uputp changes from upstream.
authorDavid Given <dg@cowlark.com>
Mon, 19 Oct 2015 18:19:35 +0000 (20:19 +0200)
committerDavid Given <dg@cowlark.com>
Mon, 19 Oct 2015 18:19:35 +0000 (20:19 +0200)
Kernel/cpu-msp430x/cpu.h
Kernel/syscall_exec16.c

index 9a14e5a..6fbfdef 100644 (file)
@@ -19,6 +19,7 @@ typedef uint8_t irqflags_t;
 typedef uint16_t arg_t;
 typedef uint16_t uarg_t;
 typedef uint16_t uaddr_t;
+typedef uint16_t uptr_t;
 typedef uint16_t usize_t;              /* Largest value passed by userspace */
 typedef int16_t susize_t;
 typedef uint32_t clock_t;
index 40ff5e3..219c83d 100644 (file)
@@ -206,7 +206,7 @@ arg_t _execve(void)
           that on 8bit boxes, but defer it to brk/sbrk() */
        uzero((uint8_t *)progptr, bss);
 
-       // Set initial break for program
+       /* Set initial break for program */
        udata.u_break = (int)ALIGNUP(progptr + bss);
 
        /* Turn off caught signals */
@@ -263,13 +263,15 @@ nogood3:
 bool rargs(char **userspace_argv, struct s_argblk * argbuf)
 {
        char *ptr;              /* Address of base of arg strings in user space */
+       char *up = (char *)userspace_argv;
        uint8_t c;
        uint8_t *bufp;
 
        argbuf->a_argc = 0;     /* Store argc in argbuf */
        bufp = argbuf->a_buf;
 
-       while ((ptr = (char *) ugetw(userspace_argv++)) != NULL) {
+       while ((ptr = (char *) ugetp(up)) != NULL) {
+               up += sizeof(uptr_t);
                ++(argbuf->a_argc);     /* Store argc in argbuf. */
                do {
                        *bufp++ = c = ugetc(ptr++);
@@ -287,9 +289,9 @@ bool rargs(char **userspace_argv, struct s_argblk * argbuf)
 
 char **wargs(char *ptr, struct s_argblk *argbuf, int *cnt)     // ptr is in userspace
 {
-       char **argv;            /* Address of users argv[], just below ptr */
+       char *argv;             /* Address of users argv[], just below ptr */
        int argc, arglen;
-       char **argbase;
+       char *argbase;
        uint8_t *sptr;
 
        sptr = argbuf->a_buf;
@@ -303,7 +305,7 @@ char **wargs(char *ptr, struct s_argblk *argbuf, int *cnt)  // ptr is in userspac
 
        /* Set argv to point below the argument strings */
        argc = argbuf->a_argc;
-       argbase = argv = (char **) ptr - (argc + 1);
+       argbase = argv = ptr - sizeof(uptr_t) * (argc + 1);
 
        if (cnt) {
                *cnt = argc;
@@ -311,15 +313,16 @@ char **wargs(char *ptr, struct s_argblk *argbuf, int *cnt)        // ptr is in userspac
 
        /* Set each element of argv[] to point to its argument string */
        while (argc--) {
-               uputw((uint16_t) ptr, argv++);
+               uputp((uptr_t) ptr, argv);
+               argv += sizeof(uptr_t);
                if (argc) {
                        do
                                ++ptr;
                        while (*sptr++);
                }
        }
-       uputw(0, argv);         /*;;26Feb- Add Null Pointer to end of array */
-       return ((char **) argbase);
+       uputp(0, argv);         /*;;26Feb- Add Null Pointer to end of array */
+       return (char **) argbase;
 }
 
 /*