Skip to content

Commit

Permalink
65c816: add register hints
Browse files Browse the repository at this point in the history
  • Loading branch information
Alan Cox committed Dec 14, 2017
1 parent 8883576 commit f4ec64a
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 67 deletions.
18 changes: 8 additions & 10 deletions Kernel/devio.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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)
Expand All @@ -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 */
Expand All @@ -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) {
Expand All @@ -180,7 +178,7 @@ void bdrop(uint16_t dev)

bufptr freebuf(void)
{
bufptr bp;
regptr bufptr bp;
bufptr oldest;
int16_t oldtime;

Expand Down
21 changes: 11 additions & 10 deletions Kernel/filesys.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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? */
Expand Down Expand Up @@ -489,7 +490,7 @@ inoptr newfile(inoptr pino, char *name)

fsptr getdev(uint16_t dev)
{
struct mount *mnt;
regptr struct mount *mnt;
time_t t;

mnt = fs_tab_get(dev);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
12 changes: 6 additions & 6 deletions Kernel/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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 */
Expand Down
2 changes: 1 addition & 1 deletion Kernel/syscall_fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion Kernel/syscall_fs2.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand Down
2 changes: 1 addition & 1 deletion Kernel/syscall_fs3.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions Kernel/syscall_other.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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())
Expand Down
67 changes: 33 additions & 34 deletions Kernel/syscall_proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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; */
Expand All @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit f4ec64a

Please sign in to comment.