M bitsy/fns.h => bitsy/fns.h +1 -0
@@ 7,6 7,7 @@ void cacheflush(void);
void cachewb(void);
void cachewbaddr(void*);
void cachewbregion(ulong, int);
+void coma(ulong);
void dcacheinvalidate(void);
int cistrcmp(char*, char*);
int cistrncmp(char*, char*, int);
M bitsy/l.s => bitsy/l.s +65 -109
@@ 672,121 672,77 @@ loop:
TEXT power_down(SB), $-4
- /* disable clock switching */
- MCR CpPWR, 0, R0, C(CpTest), C(0x2), 2
-
- /* Adjust memory timing before lowering CPU clock
- * Clock speed ajdustment without changing memory
- * timing makes CPU hang in some cases
- */
- MOVW $(MEMCONFREGS+0x1c),R0
- MOVW (R0),R1 /* mdrefr */
- ORR $(1<<22), R1 /* set K1DB2 */
- MOVW R1,(R0)
-
- /* delay 90us and set CPU PLL to lowest speed */
- /* fixes resume problem on high speed SA1110 */
+ TEXT sa1100_power_off<>+0(SB),$8
+ MOVW resetregs+0(SB),R7
+ MOVW gpioregs+0(SB),R6
+ MOVW memconfregs+0(SB),R5
+ MOVW powerregs+0(SB),R3
+ MOVW 0x1c(R5),R1
+ ORR $0x30400000,R1
+ MOVW R1,refr-4(SP)
+ MOVW $0x80000003,R2
+ MOVW R2,0xc(R3)
+ MOVW $15,R2
+ MOVW R2,0x4(R7)
+ MOVW $7,R2
+ MOVW R2,0x10(R3)
+ MOVW $0,R2
+ MOVW R2,0x18(R3)
+ MOVW $sa1100_power_resume+0(SB),R2
+ MOVW R2,0x8(R3)
+ MOVW $0,R2
+ MOVW R2,0x4(R6)
+ MOVW 0x1c(R5),R2
+ ORR $0x400000,R2
+ MOVW R2,0x1c(R5)
MOVW $(90*206),R0
-d1:
- SUB $1,R0
- BNE d1
-
- MOVW $(POWERREGS+0x14),R0
- MOVW $0,R1
- MOVW R1,(R0) /* clear PPCR */
-
+l13: SUB $1,R0
+ BGT l13
+ MOVW powerregs+0(SB),R3
+ MOVW $0,R2
+ MOVW R2,20(R3)
MOVW $(90*206),R0
-d2:
- SUB $1,R0
- BNE d2
-
-
-/* setup up register contents for jump to page containing SA1110 SDRAM controller bug fix suspend code
- *
- * r0 points to MSC0 register
- * r1 points to MSC1 register
- * r2 points to MSC2 register
- * r3 is MSC0 value
- * r4 is MSC1 value
- * r5 is MSC2 value
- * r6 points to MDREFR register
- * r7 is first MDREFR value
- * r8 is second MDREFR value
- * r9 is pointer to MDCNFG register
- * r10 is MDCNFG value
- * r11 is third MDREFR value
- * r12 is pointer to PMCR register
- * r13 is PMCR value (1)
- *
- */
-
- MOVW $(MEMCONFREGS+0x10),R0
- MOVW $(MEMCONFREGS+0x14),R1
- MOVW $(MEMCONFREGS+0x2c),R2
-
- MOVW (R0),R3
- BIC $0x00030003,R3 /* MSC_RT fields */
-
- MOVW (R1),R4
- BIC $0x00030003,R4 /* MSC_RT fields */
-
- MOVW (R2),R5
- BIC $0x00030003,R5 /* MSC_RT fields */
-
- MOVW $(MEMCONFREGS+0x1c),R6
-
- MOVW (R6),R7
- BIC $0x0000FFF0,R7 /* DRI 0 .. 11 */
- ORR $(1<<31),R7,R8 /* prepare to set self refresh */
-
- MOVW $(MEMCONFREGS+0x0),R9
- MOVW (R9),R10
- BIC $(0x00030003),R10 /* clear DE0 ⋯ DE3 */
-
- BIC $(1<<31 | 1<<20),R8,R11 /* self-refresh and e1pin */
-
- MOVW $(POWERREGS+0x0),R12
- MOVW $1,R13 /* sleep force bit */
-
- MOVW R0,R0
- MOVW R0,R0
- MOVW R0,R0
- MOVW R0,R0
- MOVW R0,R0
- MOVW R0,R0
- MOVW R0,R0
- /* Fall through */
-
-/* .align 5 Needs to be on a cache line boundary? */
- TEXT sdram_controller_fix(SB),$0
-
- /* Step 1 clear RT field of all MSCx registers */
- MOVW R3,(R0)
- MOVW R4,(R1)
- MOVW R5,(R2)
-
- /* Step 2 clear DRI field in MDREFR */
- MOVW R7,(R6)
-
- /* Step 3 set SLFRSH bit in MDREFR */
- MOVW R8,(R6)
-
- /* Step 4 clear DE bis in MDCNFG */
- MOVW R10,(R9)
-
- /* Step 5 clear DRAM refresh control register */
- MOVW R11,(R6)
-
- /* Wow, now the hardware suspend request pins can be used, that makes them functional for */
- /* about 7 ns out of the entire time that the CPU is running! */
-
- /* Step 6 set force sleep bit in PMCR */
-
- MOVW R13,(R12)
+l14: SUB $1,R0
+ BGT l14
+ MOVW powerregs+0(SB),R5
+ MOVW refr-4(SP),R4
+ AND $(~0xfff0),R4
+ ORR $0x80000000,R4,R6
+ AND $(~0x80100000),R6,R11
+
+ MOVW memconfregs+0(SB),R3
+ MOVW (R3),R12
+ AND $(~0x30003),R12
+
+ MOVW 0x10(R3),R2
+ AND $0xfffcfffc,R2
+ MOVW R2,0x10(R3)
+ MOVW 0x14(R3),R2
+ AND $0xfffcfffc,R2
+ MOVW R2,0x14(R3)
+ MOVW 0x2c(R3),R2
+ AND $0xfffcfffc,R2
+ MOVW R2,0x2c(R3)
+
+ MOVW $1,R2
+ MOVW R4,0x1c(R3)
+// MOVW R6,0x1c(R3)
+// MOVW R12,(R3)
+// MOVW R11,0x1c(R3)
+ MOVW R2,0(R5)
slloop:
B slloop /* loop waiting for sleep */
+TEXT coma(SB), $-4
+ MOVW $1,R1
+ MOVW $(MEMCONFREGS+0x1c),R2
+ MOVW $(POWERREGS+0x0),R3
+// MOVW R0,(R2)
+ MOVW R1,(R3)
+comaloop:
+ B comaloop
+
/* The first MCR instruction of this function needs to be on a cache-line
* boundary; to make this happen, it will be copied (in trap.c).
*
M bitsy/power.c => bitsy/power.c +5 -2
@@ 178,9 178,11 @@ sa1100_power_off(void)
memconfregs->msc0 &= ~0x30003;
memconfregs->msc1 &= ~0x30003;
memconfregs->msc2 &= ~0x30003;
+ refr &= ~0xfff0;
memconfregs->mdrefr = refr; /* Clear dri 0 ⋯ 11 */
refr |= 1<<REFR_slfrsh;
-// memconfregs->mdrefr = refr; /* Set selfrefresh */
+
+ memconfregs->mdrefr = refr; /* Set selfrefresh */
powerregs->pmcr = PCFR_suspend;
for(;;);
}
@@ 259,7 261,8 @@ deepsleep(void) {
}
cacheflush();
delay(100);
- sa1100_power_off();
+ power_down();
+// sa1100_power_off();
/* no return */
}
M boot/boot.c => boot/boot.c +4 -23
@@ 99,16 99,15 @@ boot(int argc, char *argv[])
fatal("can't connect to file server");
if(getenv("srvold9p"))
fd = old9p(fd);
+ if(!islocal && !ishybrid){
+ if(cfs)
+ fd = (*cfs)(fd);
+ }
print("version...");
buf[0] = '\0';
n = fversion(fd, 0, buf, sizeof buf);
if(n < 0)
fatal("can't init 9P");
- print("(%.*s)...", n, buf);
- if(!islocal && !ishybrid){
- if(cfs)
- fd = (*cfs)(fd);
- }
srvcreate("boot", fd);
/*
@@ 152,24 151,6 @@ boot(int argc, char *argv[])
close(fd);
setenv("rootdir", rp);
- /*
- * if a local file server exists and it's not
- * running, start it and mount it onto /n/kfs
- */
- if(0 && access("#s/kfs", 0) < 0){ /* BUG: DISABLED UNTIL KFS SUPPORTS 9P2000 */
- for(mp = method; mp->name; mp++){
- if(strcmp(mp->name, "local") != 0)
- continue;
- (*mp->config)(mp);
- fd = (*mp->connect)();
- if(fd < 0)
- break;
- mount(fd, -1, "/n/kfs", MAFTER|MCREATE, "") ;
- close(fd);
- break;
- }
- }
-
settime(islocal, afd);
swapproc();
M boot/boot.h => boot/boot.h +6 -5
@@ 6,6 6,11 @@ struct Method
int (*connect)(void);
char *arg;
};
+enum
+{
+ Statsz= 256,
+ Nbarg= 16,
+};
extern void authentication(int);
extern char* bootdisk;
@@ 20,11 25,7 @@ extern void (*pword)(int, Method*);
extern char sys[];
extern uchar hostkey[];
extern char username[];
-extern uchar statbuf[STATMAX];
-enum
-{
- Nbarg= 16,
-};
+extern uchar statbuf[Statsz];
extern int bargc;
extern char *bargv[Nbarg];
M boot/bootauth.c => boot/bootauth.c +0 -29
@@ 11,7 11,6 @@ authentication(int cpuflag)
{
char *argv[16], **av;
int ac;
- int factotumpid, pid;
/* start agent */
ac = 0;
@@ 43,32 42,4 @@ authentication(int cpuflag)
if(cpuflag)
return;
- /* ask for password */
-#ifdef quux
- /* start agent */
- ac = 0;
- av = argv;
- av[ac++] = "factotum";
- av[ac++] = "-gd";
- av[ac++] = "p9sk1";
- av[ac++] = "cs.bell-labs.com";
- av[ac] = 0;
- switch((factotumpid = fork())){
- case -1:
- fatal("starting factotum: %r");
- case 0:
- exec("/factotum", av);
- fatal("execing /factotum");
- default:
- break;
- }
-
- for(;;){
- pid = waitpid();
- if(pid == factotumpid)
- break;
- if(pid == -1)
- fatal("waiting for factotum");
- }
-#endif quux
}
M boot/bootcache.c => boot/bootcache.c +2 -2
@@ 2,7 2,7 @@
#include <libc.h>
#include <../boot/boot.h>
-uchar statbuf[STATMAX];
+uchar statbuf[Statsz];
int
cache(int fd)
@@ 65,7 65,7 @@ cache(int fd)
if(fflag)
execl("/cfs", "bootcfs", "-rs", "-f", partition, 0);
else
- execl("/cfs", "bootcfs", "-ds", "-f", partition, 0);
+ execl("/cfs", "bootcfs", "-s", "-f", partition, 0);
break;
default:
close(p[0]);
M port/dev.c => port/dev.c +0 -2
@@ 34,8 34,6 @@ void
devdir(Chan *c, Qid qid, char *n, vlong length, char *user, long perm, Dir *db)
{
db->name = n;
- if(c->flag&CMSG)
- qid.type |= QTMOUNT;
db->qid = qid;
db->type = devtab[c->type]->dc;
db->dev = c->dev;
M port/devcons.c => port/devcons.c +1 -1
@@ 241,7 241,7 @@ panic(char *fmt, ...)
spllo();
prflush();
putstrn(buf, n+1);
-// dumpstack();
+ dumpstack();
exit(1);
}
M port/devdup.c => port/devdup.c +1 -1
@@ 23,7 23,7 @@ dupgen(Chan *c, char *, Dirtab*, int, int s, Dir *dp)
if(s == 0)
return 0;
s--;
- if(s > 2*fgrp->maxfd)
+ if(s/2 > fgrp->maxfd)
return -1;
if((f=fgrp->fd[s/2]) == nil)
return 0;
M port/devmnt.c => port/devmnt.c +29 -26
@@ 110,7 110,9 @@ mntversion(Chan *c, char *version, int msize, int returnlen)
/* defaults */
if(msize == 0)
- msize = MAXRPC-IOHDRSZ;
+ msize = MAXRPC;
+ if(msize > c->iounit && c->iounit != 0)
+ msize = c->iounit;
v = version;
if(v == nil || v[0] == '\0')
v = VERSION9P;
@@ 190,9 192,6 @@ mntversion(Chan *c, char *version, int msize, int returnlen)
error("nonsense value of msize in fversion");
if(strncmp(f.version, v, strlen(f.version)) != 0)
error("bad 9P version returned from server");
- c->iounit = f.msize;
- if(c->iounit == 0)
- c->iounit = MAXRPC;
/* now build Mnt associated with this connection */
lock(&mntalloc);
@@ 208,9 207,11 @@ mntversion(Chan *c, char *version, int msize, int returnlen)
}
m->list = mntalloc.list;
mntalloc.list = m;
+ m->version = nil;
kstrdup(&m->version, f.version);
m->id = mntalloc.id++;
m->q = qopen(10*MAXRPC, 0, nil, nil);
+ m->msize = f.msize;
unlock(&mntalloc);
poperror(); /* msg */
@@ 262,7 263,7 @@ mntauth(Chan *c, char *spec)
nexterror();
}
- r = mntralloc(0, m->c->iounit);
+ r = mntralloc(0, m->msize);
if(waserror()) {
mntfree(r);
@@ 324,7 325,7 @@ mntattach(char *muxattach)
nexterror();
}
- r = mntralloc(0, m->c->iounit);
+ r = mntralloc(0, m->msize);
if(waserror()) {
mntfree(r);
@@ 394,7 395,7 @@ mntwalk(Chan *c, Chan *nc, char **name, int nname)
alloc = 0;
m = mntchk(c);
- r = mntralloc(c, m->c->iounit);
+ r = mntralloc(c, m->msize);
if(nc == nil){
nc = devclone(c);
/*
@@ 462,7 463,7 @@ mntstat(Chan *c, uchar *dp, int n)
if(n < BIT16SZ)
error(Eshortstat);
m = mntchk(c);
- r = mntralloc(c, m->c->iounit);
+ r = mntralloc(c, m->msize);
if(waserror()) {
mntfree(r);
nexterror();
@@ 496,7 497,7 @@ mntopencreate(int type, Chan *c, char *name, int omode, ulong perm)
Mntrpc *r;
m = mntchk(c);
- r = mntralloc(c, m->c->iounit);
+ r = mntralloc(c, m->msize);
if(waserror()) {
mntfree(r);
nexterror();
@@ 514,6 515,8 @@ mntopencreate(int type, Chan *c, char *name, int omode, ulong perm)
c->offset = 0;
c->mode = openmode(omode);
c->iounit = r->reply.iounit;
+ if(c->iounit > m->msize-IOHDRSZ)
+ c->iounit = m->msize-IOHDRSZ;
c->flag |= COPEN;
poperror();
mntfree(r);
@@ 543,7 546,7 @@ mntclunk(Chan *c, int t)
Mntrpc *r;
m = mntchk(c);
- r = mntralloc(c, m->c->iounit);
+ r = mntralloc(c, m->msize);
if(waserror()){
mntfree(r);
nexterror();
@@ 566,6 569,8 @@ muxclose(Mnt *m)
mntfree(q);
}
m->id = 0;
+ free(m->version);
+ m->version = nil;
mntpntfree(m);
}
@@ 611,7 616,7 @@ mntwstat(Chan *c, uchar *dp, int n)
Mntrpc *r;
m = mntchk(c);
- r = mntralloc(c, m->c->iounit);
+ r = mntralloc(c, m->msize);
if(waserror()) {
mntfree(r);
nexterror();
@@ 692,7 697,7 @@ mntrdwr(int type, Chan *c, void *buf, long n, vlong off)
if(c->qid.type & QTDIR)
cache = 0;
for(;;) {
- r = mntralloc(c, m->c->iounit);
+ r = mntralloc(c, m->msize);
if(waserror()) {
mntfree(r);
nexterror();
@@ 702,10 707,8 @@ mntrdwr(int type, Chan *c, void *buf, long n, vlong off)
r->request.offset = off;
r->request.data = uba;
nr = n;
- if(nr > m->c->iounit-IOHDRSZ)
- nr = m->c->iounit-IOHDRSZ;
- if(c->iounit != 0 && nr > c->iounit)
- nr = c->iounit;
+ if(nr > m->msize-IOHDRSZ)
+ nr = m->msize-IOHDRSZ;
r->request.count = nr;
mountrpc(m, r);
nreq = r->request.count;
@@ 776,7 779,7 @@ mountio(Mnt *m, Mntrpc *r)
mntflushfree(m, r);
nexterror();
}
- r = mntflushalloc(r, m->c->iounit);
+ r = mntflushalloc(r, m->msize);
}
lock(m);
@@ 786,9 789,9 @@ mountio(Mnt *m, Mntrpc *r)
unlock(m);
/* Transmit a file system rpc */
- if(m->c->iounit == 0)
- panic("iounit");
- n = convS2M(&r->request, r->rpc, m->c->iounit);
+ if(m->msize == 0)
+ panic("msize");
+ n = convS2M(&r->request, r->rpc, m->msize);
if(n < 0)
panic("bad message type in mountio");
if(devtab[m->c->type]->write(m->c, r->rpc, n, 0) != n)
@@ 994,7 997,7 @@ mntflushfree(Mnt *m, Mntrpc *r)
}
Mntrpc*
-mntralloc(Chan *c, ulong iounit)
+mntralloc(Chan *c, ulong msize)
{
Mntrpc *new;
@@ 1010,28 1013,28 @@ mntralloc(Chan *c, ulong iounit)
* The header is split from the data buffer as
* mountmux may swap the buffer with another header.
*/
- new->rpc = mallocz(iounit, 0);
+ new->rpc = mallocz(msize, 0);
if(new->rpc == nil){
free(new);
unlock(&mntalloc);
exhausted("mount rpc buffer");
}
- new->rpclen = iounit;
+ new->rpclen = msize;
new->request.tag = mntalloc.rpctag++;
}
else {
mntalloc.rpcfree = new->list;
mntalloc.nrpcfree--;
- if(new->rpclen < iounit){
+ if(new->rpclen < msize){
free(new->rpc);
- new->rpc = mallocz(iounit, 0);
+ new->rpc = mallocz(msize, 0);
if(new->rpc == nil){
free(new);
mntalloc.nrpcused--;
unlock(&mntalloc);
exhausted("mount rpc buffer");
}
- new->rpclen = iounit;
+ new->rpclen = msize;
}
}
mntalloc.nrpcused++;
M port/lib.h => port/lib.h +0 -1
@@ 122,7 122,6 @@ typedef struct Waitmsg Waitmsg;
#define QTDIR 0x80 /* type bit for directories */
#define QTAPPEND 0x40 /* type bit for append only files */
#define QTEXCL 0x20 /* type bit for exclusive use files */
-#define QTMOUNT 0x10 /* type bit for mounted channel */
#define QTAUTH 0x08 /* type bit for authentication file */
#define QTFILE 0x00 /* plain file */
M port/portdat.h => port/portdat.h +1 -0
@@ 261,6 261,7 @@ struct Mnt
ulong id; /* Multiplexer id for channel check */
Mnt *list; /* Free list */
int flags; /* cache */
+ int msize; /* data + IOHDRSZ */
char *version; /* 9P version */
Queue *q; /* input queue */
};
M port/sysfile.c => port/sysfile.c +0 -1
@@ 271,7 271,6 @@ sysopen(ulong *arg)
if(fd < 0)
error(Enofd);
poperror();
-if(strstr(up->text, "syscall")!=0) pprint("open %s ref count %d\n", c2name(c), c->ref); // BUG
return fd;
}