M carrera/main.c => carrera/main.c +1 -1
@@ 503,7 503,7 @@ rdbginit(void)
{
uchar *vec;
ulong jba;
-return;
+return;/**/
/* Only interested in the PC */
Mipsjmpbuf.pc = 0x8001C020;
M port/devmnt.c => port/devmnt.c +19 -23
@@ 79,7 79,6 @@ Chan*
mntattach(char *muxattach)
{
Mnt *m;
- int nest;
Chan *c, *mc;
char buf[NAMELEN];
struct bogus{
@@ 168,23 167,6 @@ mntattach(char *muxattach)
mattach(m, c, bogus.spec);
poperror();
-#ifdef STUPIDHACK
- /* Work out how deep we are nested and reduce the blocksize
- * accordingly
- */
- nest = 0;
- mc = m->c;
- while(mc) {
- if(mc->type != devno('M', 0))
- break;
- nest++;
- if(mc->mntptr == 0)
- break;
- mc = mc->mntptr->c;
- }
- m->blocksize -= nest * 32;
-#endif STUPIDHACK
-
/*
* Detect a recursive mount for a mount point served by exportfs.
* If CHDIR is clear in the returned qid the foreign server is
@@ 496,6 478,12 @@ mntwstat(Chan *c, char *dp)
}
long
+mntread9p(Chan *c, void *buf, long n, ulong offset)
+{
+ return mntrdwr(Tread, c, buf, n, offset, 1);
+}
+
+long
mntread(Chan *c, void *buf, long n, ulong offset)
{
uchar *p, *e;
@@ 563,9 551,14 @@ mntrdwr(int type, Chan *c, void *buf, long n, ulong offset, int p9msg)
r->request.fid = c->fid;
r->request.offset = offset;
r->request.data = uba;
- if(p9msg)
- r->request.count = limit(n, m->blocksize + MAXMSG - 20);
- else
+ if(p9msg) {
+ if(n > MAXRPC-32){
+ if(type == Twrite)
+ error("write9p too long");
+ n = MAXRPC-32;
+ }
+ r->request.count = n;
+ } else
r->request.count = limit(n, m->blocksize);
mountrpc(m, r);
nr = r->reply.count;
@@ 641,7 634,7 @@ mountio(Mnt *m, Mntrpc *r)
}
else {
if(devchar[m->c->type] == L'M'){
- if(mntwrite9p(m->c, r->rpc, n, 0) != n)
+ if(mntrdwr(Twrite, m->c, r->rpc, n, 0, 1) != n)
error(Emountrpc);
}else{
if((*devtab[m->c->type].write)(m->c, r->rpc, n, 0) != n)
@@ 696,7 689,10 @@ mntrpcread(Mnt *m, Mntrpc *r)
}
r->reply.type = 0;
r->reply.tag = 0;
- n = devtab[m->c->type].read(m->c, r->rpc, MAXRPC, 0);
+ if(devchar[m->c->type] == L'M')
+ n = mntrdwr(Tread, m->c, r->rpc, MAXRPC, 0, 1);
+ else
+ n = devtab[m->c->type].read(m->c, r->rpc, MAXRPC, 0);
poperror();
if(n == 0)
continue;
M port/portfns.h => port/portfns.h +2 -1
@@ 135,7 135,9 @@ void mfreeseg(Segment*, ulong, int);
void mmurelease(Proc*);
void mmuswitch(Proc*);
void mntdump(void);
+long mntread9p(Chan*, void*, long, ulong);
void mntrepl(char*);
+long mntwrite9p(Chan*, void*, long, ulong);
int mount(Chan*, Chan*, int, char*);
void mountfree(Mount*);
void mousebuttons(int);
@@ 262,7 264,6 @@ void* vmemchr(void*, int, int);
void wakeup(Rendez*);
Chan* walk(Chan*, char*, int);
void wlock(RWlock*);
-long mntwrite9p(Chan*, void*, long, ulong);
void wunlock(RWlock*);
#define xalloc(s) xallocz(s, 1)
void* xallocz(ulong, int);
M port/sysfile.c => port/sysfile.c +41 -1
@@ 288,6 288,47 @@ unionread(Chan *c, void *va, long n)
}
long
+sysread9p(ulong *arg)
+{
+ int dir;
+ long n;
+ Chan *c;
+
+ validaddr(arg[1], arg[2], 1);
+ c = fdtochan(arg[0], OREAD, 1, 1);
+ if(waserror()) {
+ close(c);
+ nexterror();
+ }
+
+ n = arg[2];
+ dir = c->qid.path&CHDIR;
+
+ if(dir) {
+ n -= n%DIRLEN;
+ if(c->offset%DIRLEN || n==0)
+ error(Etoosmall);
+ }
+
+ if(dir && c->mnt)
+ n = unionread(c, (void*)arg[1], n);
+ else if(devchar[c->type] != L'M')
+ n = (*devtab[c->type].read)(c, (void*)arg[1], n, c->offset);
+ else
+ n = mntread9p(c, (void*)arg[1], n, c->offset);
+
+
+ lock(c);
+ c->offset += n;
+ unlock(c);
+
+ poperror();
+ close(c);
+
+ return n;
+}
+
+long
sysread(ulong *arg)
{
int dir;
@@ 345,7 386,6 @@ syswrite9p(ulong *arg)
n = (*devtab[c->type].write)(c, (void*)arg[1], arg[2], c->offset);
else
n = mntwrite9p(c, (void*)arg[1], arg[2], c->offset);
-
lock(c);
c->offset += n;
unlock(c);
M port/systab.h => port/systab.h +3 -3
@@ 41,7 41,7 @@ Syscall sysrendezvous;
Syscall sysunmount;
Syscall syswait;
Syscall syswrite9p;
-Syscall ;
+Syscall sysread9p;
Syscall ;
Syscall sysdeath;
@@ 84,7 84,7 @@ Syscall *systab[]={
[UNMOUNT] sysunmount,
[WAIT] syswait,
[WRITE9P] syswrite9p,
-
+ [READ9P] sysread9p,
};
@@ 127,6 127,6 @@ char *sysctab[]={
[UNMOUNT] "Unmount",
[WAIT] "Wait",
[WRITE9P] "Write9p",
-
+ [READ9P] "Read9p",
};
M power/conf.h => power/conf.h +1 -0
@@ 15,6 15,7 @@ Conftab conftab[] = {
{"arp", &conf.arp },
{"frag", &conf.frag },
{"debugger", &conf.debugger },
+ {"ialloc", &conf.ialloc },
{ 0, 0 },
};
M power/dat.h => power/dat.h +7 -0
@@ 25,6 25,7 @@ struct Lock
{
int val;
ulong pc;
+ ulong sr;
};
struct Label
@@ 51,6 52,7 @@ struct Conf
ulong arp; /* Arp table size */
ulong frag; /* Ip fragment assemble queue size */
ulong debugger; /* use processor 1 as a kernel debugger */
+ ulong ialloc; /* bytes available for interrupt time allocation */
};
/*
@@ 134,6 136,11 @@ struct Mach
Schedq hiq;
Schedq loq;
+ Callbk* cbin;
+ Callbk* cbout;
+ Callbk* cbend;
+ Callbk calls[NCALLBACK];
+
int stack[1];
};
M power/lock.c => power/lock.c +34 -0
@@ 114,6 114,29 @@ lock(Lock *lk)
dumpstack();
}
+void
+ilock(Lock *lk)
+{
+ int *hwsem, hash;
+ ulong x;
+
+ x = splhi();
+ hash = lhash(lk);
+ hwsem = (int*)SBSEM+hash;
+
+ for(;;) {
+ if(muxlock(hwsem, &lk->val)){
+ lk->sr = x;
+ return;
+ }
+ while(lk->val)
+ ;
+ }
+ splx(x);
+ print("lock loop %lux pc %lux held by pc %lux\n", lk, getcallerpc(lk), lk->pc);
+ dumpstack();
+}
+
int
canlock(Lock *lk)
{
@@ 129,3 152,14 @@ unlock(Lock *l)
l->pc = 0;
l->val = 0;
}
+
+void
+iunlock(Lock *l)
+{
+ ulong sr;
+
+ sr = l->sr;
+ l->pc = 0;
+ l->val = 0;
+ splx(sr);
+}
M power/mem.h => power/mem.h +3 -1
@@ 9,10 9,12 @@
#define BI2BY 8 /* bits per byte */
#define BI2WD 32 /* bits per word */
#define BY2WD 4 /* bytes per word */
+#define BY2V 8 /* bytes per very long word */
#define BY2PG 4096 /* bytes per page */
#define WD2PG (BY2PG/BY2WD) /* words per page */
#define PGSHIFT 12 /* log(BY2PG) */
-#define PGROUND(s) (((s)+(BY2PG-1))&~(BY2PG-1))
+#define ROUND(s, sz) (((s)+(sz-1))&~(sz-1))
+#define PGROUND(s) ROUND(s, BY2PG)
#define ICACHESIZE (64*1024) /* Power series */
#define MAXMACH 4 /* max # cpus system can run */