commit ebe81893c829dee99c4c10e42e18784ccae0b989
parent 5324a21439b8ad818d63b2db7159a1149e4c005c
Author: yiyus <yiyu.jgl@gmail.com>
Date: Sat, 17 Jul 2010 22:45:05 +0200
devproc.ed, devroot.ed and devsd.ed
Diffstat:
7 files changed, 77 insertions(+), 63 deletions(-)
diff --git a/src/9vx/a/devproc.c b/src/9vx/a/devproc.c
@@ -1,5 +1,5 @@
#include "u.h"
-#include "trace.h"
+#include "trace.h"
#include "tos.h"
#include "lib.h"
#include "mem.h"
@@ -145,19 +145,6 @@ extern int unfair;
static void
profclock(Ureg *ur, Timer *t)
{
-#if 0
- Tos *tos;
-
- if(up == 0 || up->state != Running)
- return;
-
- /* user profiling clock */
- if(userureg(ur)){
- tos = (Tos*)(USTKTOP-sizeof(Tos));
- tos->clock += TK2MS(1);
- segclock(ur->pc);
- }
-#endif
}
static int
@@ -421,7 +408,7 @@ procopen(Chan *c, int omode)
break;
default:
- pprint("procopen %lux\n", c->qid);
+ pprint("procopen %#lux\n", QID(c->qid));
error(Egreg);
}
@@ -719,7 +706,6 @@ procread(Chan *c, void *va, long n, vlong off)
if(offset < USTKTOP)
return procctlmemio(p, offset, n, va, 1);
error("no kernel memory access");
-
case Qprofile:
s = p->seg[TSEG];
if(s == 0 || s->profile == 0)
diff --git a/src/9vx/a/devproc.ed b/src/9vx/a/devproc.ed
@@ -27,3 +27,29 @@ g/real time/d
/if(s->flushme)/d
d
,s/MACHP(0)->ticks/msec()/g
+/Qprofile,/a
+ Qsyscall,
+.
+/{Qprofile}/a
+ "syscall", {Qsyscall}, 0, 0400,
+.
+/^profclock/ s/^//
+/^{/+1,/^}/-1d
+/^procopen/ s/^//
+/case Qfpregs/a
+ case Qsyscall:
+.
+/^procread/ s/^//
+/Confmem/d
+/case Qmem/i
+ case Qsyscall:
+ if(!p->syscalltrace)
+ return 0;
+ n = readstr(offset, a, n, p->syscalltrace);
+ return n;
+
+.
+/KZERO/ s/KZERO/USTKTOP/
++2,/case .*:/-1c
+ error("no kernel memory access");
+.
diff --git a/src/9vx/a/devroot.c b/src/9vx/a/devroot.c
@@ -221,11 +221,11 @@ rootread(Chan *c, void *buf, long n, vlong off)
if(offset+n > d->length)
n = d->length - offset;
#ifdef asdf
-print("[%d] kaddr %.8ulx base %.8ulx offset %ld (%.8ulx), n %d %.8ux %.8ux %.8ux\n",
+print("[%d] kaddr %.8ulx base %.8ulx offset %ld (%.8ulx), n %d %.8ulx %.8ulx %.8ulx\n",
t, buf, data, offset, offset, n,
- ((uint32*)(data+offset))[0],
- ((uint32*)(data+offset))[1],
- ((uint32*)(data+offset))[2]);
+ ((ulong*)(data+offset))[0],
+ ((ulong*)(data+offset))[1],
+ ((ulong*)(data+offset))[2]);
#endif
memmove(buf, data+offset, n);
return n;
diff --git a/src/9vx/a/devroot.ed b/src/9vx/a/devroot.ed
@@ -2,4 +2,3 @@ g/^rootgen/ s/Dirtab\*, int/Dirtab *dt, int i/
g/^rootclose/ s/(Chan\*)/(Chan *c)/
,s/^#endif asdf/#endif/
g/^rootwrite/ s/(Chan\*, void\*, long, vlong)/(Chan *c, void *v, long l, vlong vl)/
-/^static uchar \*bootdata/ s/ =.*/;/
diff --git a/src/9vx/a/devsd.c b/src/9vx/a/devsd.c
@@ -135,19 +135,6 @@ sdaddpart(SDunit* unit, char* name, uvlong start, uvlong end)
pp->valid = 1;
}
-SDpart*
-sdfindpart(SDunit *unit, char *name)
-{
- int i;
-
- for(i=0; i<unit->npart; i++) {
- if(strcmp(unit->part[i].perm.name, name) == 0){
- return &unit->part[i];
- }
- }
- return nil;
-}
-
static void
sddelpart(SDunit* unit, char* name)
{
@@ -212,31 +199,6 @@ sdinitpart(SDunit* unit)
sdincvers(unit);
sdaddpart(unit, "data", 0, unit->sectors);
partition(unit);
-#if 0
- /*
- * Use partitions passed from boot program,
- * e.g.
- * sdC0part=dos 63 123123/plan9 123123 456456
- * This happens before /boot sets hostname so the
- * partitions will have the null-string for user.
- * The gen functions patch it up.
- */
- snprint(buf, sizeof buf, "%spart", unit->perm.name);
- for(p = getconf(buf); p != nil; p = q){
- if(q = strchr(p, '/'))
- *q++ = '\0';
- nf = tokenize(p, f, nelem(f));
- if(nf < 3)
- continue;
-
- start = strtoull(f[1], 0, 0);
- end = strtoull(f[2], 0, 0);
- if(!waserror()){
- sdaddpart(unit, f[0], start, end);
- poperror();
- }
- }
-#endif
}
return 1;
@@ -263,7 +225,7 @@ sdgetdev(int idno)
return nil;
qlock(&devslock);
- if((sdev = devs[i]))
+ if(sdev = devs[i])
incref(&sdev->r);
qunlock(&devslock);
return sdev;
@@ -1477,7 +1439,7 @@ unconfigure(char* spec)
sdev->ifc->disable(sdev);
for(i = 0; i != sdev->nunit; i++){
- if((unit = sdev->unit[i])){
+ if(unit = sdev->unit[i]){
free(unit->perm.name);
free(unit->perm.user);
free(unit);
@@ -1653,3 +1615,16 @@ legacytopctl(Cmdbuf *cb)
error(Ebadarg);
sdconfig(cd.on, cd.spec, &cd.cf);
}
+
+SDpart*
+sdfindpart(SDunit *unit, char *name)
+{
+ int i;
+
+ for(i=0; i<unit->npart; i++) {
+ if(strcmp(unit->part[i].perm.name, name) == 0){
+ return &unit->part[i];
+ }
+ }
+ return nil;
+}
diff --git a/src/9vx/a/devsd.ed b/src/9vx/a/devsd.ed
@@ -0,0 +1,28 @@
+/^sdaddpart/-1 s/static //
+,s/pp->perm/pp->perm.perm/g
+,s/pp->name/pp->perm.name/g
+,s/pp->user/pp->perm.user/g
+,s/unit->perm/unit->perm.perm/g
+,s/unit->name/unit->perm.name/g
+,s/unit->user/unit->perm.user/g
+,s/pp->SDperm/pp->perm/g
+/^sdgen/ s/char\*, Dirtab\*, int,/char *name, Dirtab *dt, int j,/
+/^sdinitpart/+2;/^$/d
+/sdaddpart/+1;/^ }/-1c
+ partition(unit);
+.
+$a
+
+SDpart*
+sdfindpart(SDunit *unit, char *name)
+{
+ int i;
+
+ for(i=0; i<unit->npart; i++) {
+ if(strcmp(unit->part[i].perm.name, name) == 0){
+ return &unit->part[i];
+ }
+ }
+ return nil;
+}
+.
diff --git a/src/9vx/makea b/src/9vx/makea
@@ -22,13 +22,13 @@ files=a/*.ed
if [ $# -gt 0 ]; then
files=$*
fi
-
+hfiles=a/*.h
for f in $files; do
name=`echo $f | sed 's,.*/,,;s,\.ed,,'`
ofile=`(ls $orig/port/$name.[ch] || ls $orig/pc/$name.[ch]) 2>/dev/null`
dfile=`echo $ofile | sed 's,.*/,a/,'`
echo -e ",p\nq" | cat $f - | ed -s $ofile | sed -r '
/^#include/s,../port/,,
-/^#include[ ]+<(libsec\.h|authsrv\.h|draw\.h|memdraw\.h|memlayer\.h|cursor\.h)>/s,[<>],",g
+/^#include[ ]+<('`echo $hfiles | sed 's,a/,,g; s/\./\\./g; s/ /|/g'`')>/s,[<>],",g
' > $dfile
done