From f4ec64a787587ec71be9767dc4d44b3a6a6ab8c6 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Thu, 14 Dec 2017 15:22:43 +0000 Subject: [PATCH] 65c816: add register hints --- Kernel/devio.c | 18 +++++------- Kernel/filesys.c | 21 ++++++------- Kernel/inode.c | 12 ++++---- Kernel/syscall_fs.c | 2 +- Kernel/syscall_fs2.c | 2 +- Kernel/syscall_fs3.c | 2 +- Kernel/syscall_other.c | 8 ++--- Kernel/syscall_proc.c | 67 +++++++++++++++++++++--------------------- 8 files changed, 65 insertions(+), 67 deletions(-) diff --git a/Kernel/devio.c b/Kernel/devio.c index 79719a05..9369b279 100644 --- a/Kernel/devio.c +++ b/Kernel/devio.c @@ -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; diff --git a/Kernel/filesys.c b/Kernel/filesys.c index b2378e20..57e67b30 100644 --- a/Kernel/filesys.c +++ b/Kernel/filesys.c @@ -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) diff --git a/Kernel/inode.c b/Kernel/inode.c index 23219895..240c37cd 100644 --- a/Kernel/inode.c +++ b/Kernel/inode.c @@ -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 */ diff --git a/Kernel/syscall_fs.c b/Kernel/syscall_fs.c index 4748b4d9..8e1de08f 100644 --- a/Kernel/syscall_fs.c +++ b/Kernel/syscall_fs.c @@ -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) diff --git a/Kernel/syscall_fs2.c b/Kernel/syscall_fs2.c index b8537038..98acb7bb 100644 --- a/Kernel/syscall_fs2.c +++ b/Kernel/syscall_fs2.c @@ -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))) diff --git a/Kernel/syscall_fs3.c b/Kernel/syscall_fs3.c index cabcded5..e5f20caf 100644 --- a/Kernel/syscall_fs3.c +++ b/Kernel/syscall_fs3.c @@ -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; diff --git a/Kernel/syscall_other.c b/Kernel/syscall_other.c index e57eb41c..1f55c4df 100644 --- a/Kernel/syscall_other.c +++ b/Kernel/syscall_other.c @@ -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()) diff --git a/Kernel/syscall_proc.c b/Kernel/syscall_proc.c index ea93928e..441fb575 100644 --- a/Kernel/syscall_proc.c +++ b/Kernel/syscall_proc.c @@ -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) { -- 2.34.1