65c816: add register hints
authorAlan Cox <alan@linux.intel.com>
Thu, 14 Dec 2017 15:22:43 +0000 (15:22 +0000)
committerAlan Cox <alan@linux.intel.com>
Thu, 14 Dec 2017 15:22:43 +0000 (15:22 +0000)
Kernel/devio.c
Kernel/filesys.c
Kernel/inode.c
Kernel/syscall_fs.c
Kernel/syscall_fs2.c
Kernel/syscall_fs3.c
Kernel/syscall_other.c
Kernel/syscall_proc.c

index 79719a0..9369b27 100644 (file)
@@ -42,7 +42,7 @@ uint16_t bufclock;            /* Time-stamp counter for LRU */
 
 bufptr bread(uint16_t dev, blkno_t blk, bool rewrite)
 {
-       register bufptr bp;
+       regptr bufptr bp;
 
        if ((bp = bfind(dev, blk)) != NULL) {
                if (bp->bf_busy == BF_BUSY)
@@ -85,7 +85,7 @@ void bawrite(bufptr bp)
 }
 
 
-int bfree(bufptr bp, uint8_t dirty)
+int bfree(regptr bufptr bp, uint8_t dirty)
 {                              /* dirty: 0=clean, 1=dirty (write back), 2=dirty+immediate write */
        if (dirty)
                bp->bf_dirty = true;
@@ -114,7 +114,7 @@ int bfree(bufptr bp, uint8_t dirty)
  */
 void *tmpbuf(void)
 {
-       bufptr bp;
+       regptr bufptr bp;
 
        bp = freebuf();
        bp->bf_dev = NO_DEVICE;
@@ -127,15 +127,13 @@ void *tmpbuf(void)
    on platforms where we split disk and temporary buffers */
 void *zerobuf(void)
 {
-       void *b;
-
-       b = tmpbuf();
+       void *b = tmpbuf();
        memset(b, 0, 512);
 
        return b;
 }
 
-static void bdput(bufptr bp)
+static void bdput(regptr bufptr bp)
 {
        bdwrite(bp);
        if (bp->bf_busy == BF_FREE)
@@ -145,7 +143,7 @@ static void bdput(bufptr bp)
 
 void bufsync(void)
 {
-       bufptr bp;
+       regptr bufptr bp;
 
        /* FIXME: this can generate a lot of d_flush calls when you have
           plenty of buffers */
@@ -168,7 +166,7 @@ bufptr bfind(uint16_t dev, blkno_t blk)
 
 void bdrop(uint16_t dev)
 {
-       bufptr bp;
+       regptr bufptr bp;
 
        for (bp = bufpool; bp < bufpool_end; ++bp) {
                if (bp->bf_dev == dev) {
@@ -180,7 +178,7 @@ void bdrop(uint16_t dev)
 
 bufptr freebuf(void)
 {
-       bufptr bp;
+       regptr bufptr bp;
        bufptr oldest;
        int16_t oldtime;
 
index b2378e2..57e67b3 100644 (file)
@@ -207,7 +207,8 @@ inoptr srch_mt(inoptr ino)
 inoptr i_open(uint16_t dev, uint16_t ino)
 {
     struct blkbuf *buf;
-    inoptr nindex, j;
+    regptr inoptr nindex;
+    regptr inoptr j;
     struct mount *m;
     bool isnew = false;
 
@@ -431,7 +432,7 @@ bool namecomp(char *n1, char *n2) // return true if n1 == n2
 
 inoptr newfile(inoptr pino, char *name)
 {
-    inoptr nindex;
+    regptr inoptr nindex;
     uint8_t j;
 
     /* No parent? */
@@ -489,7 +490,7 @@ nogood:
 
 fsptr getdev(uint16_t dev)
 {
-    struct mount *mnt;
+    regptr struct mount *mnt;
     time_t t;
 
     mnt = fs_tab_get(dev);
@@ -526,7 +527,7 @@ uint16_t i_alloc(uint16_t devno)
     staticfast fsptr dev;
     staticfast blkno_t blk;
     struct blkbuf *buf;
-    struct dinode *di;
+    regptr struct dinode *di;
     staticfast uint16_t j;
     uint16_t k;
     unsigned ino;
@@ -725,7 +726,7 @@ int8_t oft_alloc(void)
  *     and if we are dropping a lock that is not exclusive we must own one of
  *     the non exclusive locks.
  */
-void deflock(struct oft *ofptr)
+void deflock(regptr struct oft *ofptr)
 {
     inoptr i = ofptr->o_inode;
     uint8_t c = i->c_flags & CFLOCK;
@@ -785,7 +786,7 @@ int8_t uf_alloc(void)
  * links, the inode itself and its blocks(if not a device) is freed.
  */
 
-void i_deref(inoptr ino)
+void i_deref(regptr inoptr ino)
 {
     uint8_t mode = getmode(ino);
 
@@ -865,7 +866,7 @@ uint16_t devnum(inoptr ino)
 /* F_trunc frees all the blocks associated with the file, if it
  * is a disk file.
  */
-int f_trunc(inoptr ino)
+int f_trunc(regptr inoptr ino)
 {
     uint16_t dev;
     int8_t j;
@@ -905,7 +906,7 @@ int f_trunc(inoptr ino)
 void freeblk(uint16_t dev, blkno_t blk, uint8_t level)
 {
     struct blkbuf *buf;
-    blkno_t *bn;
+    regptr blkno_t *bn;
     int16_t j;
 
     if(!blk)
@@ -931,7 +932,7 @@ void freeblk(uint16_t dev, blkno_t blk, uint8_t level)
 void freeblk(uint16_t dev, blkno_t blk, uint8_t level)
 {
     struct blkbuf *buf;
-    blkno_t *bn;
+    regptr blkno_t *bn;
     int16_t j;
 
     if(!blk)
@@ -1179,7 +1180,7 @@ struct mount *fs_tab_get(uint16_t dev)
 bool fmount(uint16_t dev, inoptr ino, uint16_t flags)
 {
     struct mount *m;
-    struct filesys *fp;
+    regptr struct filesys *fp;
     bufptr buf;
 
     if(d_open(dev, 0) != 0)
index 2321989..240c37c 100644 (file)
@@ -26,7 +26,7 @@ static uint8_t pipewait(inoptr ino, uint8_t flag)
 }
 
 /* Writei (and readi) need more i/o error handling */
-void readi(inoptr ino, uint8_t flag)
+void readi(regptr inoptr ino, uint8_t flag)
 {
        usize_t amount;
        usize_t toread;
@@ -135,7 +135,7 @@ void readi(inoptr ino, uint8_t flag)
 
 
 
-void writei(inoptr ino, uint8_t flag)
+void writei(regptr inoptr ino, uint8_t flag)
 {
        usize_t amount;
        usize_t towrite;
@@ -249,7 +249,7 @@ int16_t doclose(uint8_t uindex)
 {
        int8_t oftindex;
        struct oft *oftp;
-       inoptr ino;
+       regptr inoptr ino;
        uint16_t flush_dev = NO_DEVICE;
        uint8_t m;
 
@@ -288,7 +288,7 @@ int16_t doclose(uint8_t uindex)
 inoptr rwsetup(bool is_read, uint8_t * flag)
 {
        inoptr ino;
-       struct oft *oftp;
+       regptr struct oft *oftp;
 
        udata.u_sysio = false;  /* I/O to user data space */
        udata.u_base = (unsigned char *) udata.u_argn1; /* buf */
@@ -354,8 +354,8 @@ int dev_openi(inoptr *ino, uint16_t flag)
 
 void sync(void)
 {
-       inoptr ino;
-       struct mount *m;
+       regptr inoptr ino;
+       regptr struct mount *m;
        bufptr buf;
 
        /* Write out modified inodes */
index 4748b4d..8e1de08 100644 (file)
@@ -310,7 +310,7 @@ int fildes[];
 arg_t _pipe(void)
 {
        int8_t u1, u2, oft1, oft2;
-       inoptr ino;
+       regptr inoptr ino;
 
 /* bug fix SN */
        if ((u1 = uf_alloc()) == -1)
index b853703..98acb7b 100644 (file)
@@ -312,7 +312,7 @@ arg_t _fchown(void)
 
 arg_t _utime(void)
 {
-       inoptr ino;
+       regptr inoptr ino;
        time_t t[2];
 
        if (!(ino = n_open(file, NULLINOPTR)))
index cabcded..e5f20ca 100644 (file)
@@ -326,7 +326,7 @@ arg_t _flock(void)
 {
 #ifndef CONFIG_LEVEL_0
        inoptr ino;
-       struct oft *o;
+       regptr struct oft *o;
        staticfast uint8_t c;
        staticfast uint8_t lock;
        staticfast int self;
index e57eb41..1f55c4d 100644 (file)
@@ -356,9 +356,9 @@ arg_t _mount(void)
 
 static int do_umount(uint16_t dev)
 {
-       struct mount *mnt;
+       regptr struct mount *mnt;
        uint8_t rm = flags & MS_REMOUNT;
-       inoptr ptr;
+       regptr inoptr ptr;
 
        mnt = fs_tab_get(dev);
        if (mnt == NULL) {
@@ -471,7 +471,7 @@ arg_t _profil(void)
        /* For performance reasons scale as
           passed to the kernel is a shift value
           not a divider */
-       ptptr p = udata.u_ptab;
+       regptr ptptr p = udata.u_ptab;
 
        if (scale == 0) {
                p->p_profscale = scale;
@@ -533,7 +533,7 @@ int16_t pri;
 
 arg_t _nice(void)
 {
-       ptptr p = udata.u_ptab;
+       regptr ptptr p = udata.u_ptab;
        int16_t np;
 
        if (pri < 0 && !esuper())
index ea93928..441fb57 100644 (file)
@@ -275,25 +275,15 @@ int options;
 
 arg_t _waitpid(void)
 {
-       ptptr p;
+       regptr ptptr p;
        int retval;
+       uint8_t found;
 
        if (statloc && !valaddr((char *) statloc, sizeof(int))) {
                udata.u_error = EFAULT;
                return (-1);
        }
 
-       /* FIXME: move this scan into the main loop and also error
-          on a complete loop finding no matchi for pid */
-       /* See if we have any children. */
-       for (p = ptab; p < ptab_end; ++p) {
-               if (p->p_status && p->p_pptr == udata.u_ptab
-                   && p != udata.u_ptab)
-                       goto ok;
-       }
-       udata.u_error = ECHILD;
-       return (-1);
-      ok:
        if (pid == 0)
                pid = -udata.u_ptab->p_pgrp;
        /* Search for an exited child; */
@@ -303,31 +293,40 @@ arg_t _waitpid(void)
                        udata.u_error = EINTR;
                        return -1;
                }
+               /* Each scan we check that we have a child, if we have a child
+                  then all is good. If not then we ECHILD out */
+               found = 0;
                for (p = ptab; p < ptab_end; ++p) {
-                       if (p->p_pptr == udata.u_ptab &&
-                               (pid == -1 || p->p_pid == pid ||
-                                       p->p_pgrp == -pid)) {
-                               if (p->p_status == P_ZOMBIE) {
-                                       if (statloc)
-                                               uputi(p->p_exitval, statloc);
-                                       retval = p->p_pid;
-                                       p->p_status = P_EMPTY;
-
-                                       /* Add in child's time info.  It was stored on top */
-                                       /* of p_priority in the childs process table entry. */
-                                       /* FIXME: make these a union so we don't do type
-                                          punning and break strict aliasing */
-                                       udata.u_cutime += ((clock_t *)&p->p_priority)[0];
-                                       udata.u_cstime += ((clock_t *)&p->p_priority)[1];
-                                       return retval;
-                               }
-                               if (p->p_event && (options & WUNTRACED)) {
-                                       retval = (uint16_t)p->p_event << 8 | _WSTOPPED;
-                                       p->p_event = 0;
-                                       return retval;
+                       if (p->p_status && p->p_pptr == udata.u_ptab) {
+                               found = 1;
+                               if (pid == -1 || p->p_pid == pid ||
+                                       p->p_pgrp == -pid) {
+                                       if (p->p_status == P_ZOMBIE) {
+                                               if (statloc)
+                                                       uputi(p->p_exitval, statloc);
+                                               retval = p->p_pid;
+                                               p->p_status = P_EMPTY;
+
+                                               /* Add in child's time info.  It was stored on top */
+                                               /* of p_priority in the childs process table entry. */
+                                               /* FIXME: make these a union so we don't do type
+                                                  punning and break strict aliasing */
+                                               udata.u_cutime += ((clock_t *)&p->p_priority)[0];
+                                               udata.u_cstime += ((clock_t *)&p->p_priority)[1];
+                                               return retval;
+                                       }
+                                       if (p->p_event && (options & WUNTRACED)) {
+                                               retval = (uint16_t)p->p_event << 8 | _WSTOPPED;
+                                               p->p_event = 0;
+                                               return retval;
+                                       }
                                }
                        }
                }
+               if (!found) {
+                       udata.u_error = ECHILD;
+                       return -1;
+               }
                /* Nothing yet, so wait */
                if (options & WNOHANG)
                        break;
@@ -532,7 +531,7 @@ int16_t sig;
 
 arg_t _kill(void)
 {
-       ptptr p;
+       regptr ptptr p;
        int f = 0, s = 0;
 
        if (sig < 0 || sig >= NSIGS) {