diff options
author | cinap_lenrek <cinap_lenrek@localhost> | 2011-06-16 17:33:26 +0200 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@localhost> | 2011-06-16 17:33:26 +0200 |
commit | 7cd1b102ee03d676b050319eaaefe73309b9b01c (patch) | |
tree | 325686092892be6bd2370643e69fb08b3729e665 | |
parent | fcf30f314b4c4157b536647a09a214576711ad16 (diff) | |
download | plan9front-7cd1b102ee03d676b050319eaaefe73309b9b01c.tar.xz |
remove mconf cruft
-rw-r--r-- | sys/src/cmd/cwfs/9netics32.16k/dat.h | 15 | ||||
-rw-r--r-- | sys/src/cmd/cwfs/9netics64.8k/dat.h | 16 | ||||
-rw-r--r-- | sys/src/cmd/cwfs/choline/dat.h | 15 | ||||
-rw-r--r-- | sys/src/cmd/cwfs/cwfs/dat.h | 15 | ||||
-rw-r--r-- | sys/src/cmd/cwfs/cwfs64/dat.h | 15 | ||||
-rw-r--r-- | sys/src/cmd/cwfs/cwfs64x/dat.h | 15 | ||||
-rw-r--r-- | sys/src/cmd/cwfs/emelie/dat.h | 15 | ||||
-rw-r--r-- | sys/src/cmd/cwfs/fs/dat.h | 15 | ||||
-rw-r--r-- | sys/src/cmd/cwfs/fs64/dat.h | 15 | ||||
-rw-r--r-- | sys/src/cmd/cwfs/main.c | 2 | ||||
-rw-r--r-- | sys/src/cmd/cwfs/malloc.c | 74 | ||||
-rw-r--r-- | sys/src/cmd/cwfs/pc.c | 92 | ||||
-rw-r--r-- | sys/src/cmd/cwfs/portdat.h | 1 | ||||
-rw-r--r-- | sys/src/cmd/cwfs/portfns.h | 1 | ||||
-rw-r--r-- | sys/src/cmd/cwfs/portmkfile | 2 | ||||
-rw-r--r-- | sys/src/cmd/cwfs/proc.c | 41 |
16 files changed, 78 insertions, 271 deletions
diff --git a/sys/src/cmd/cwfs/9netics32.16k/dat.h b/sys/src/cmd/cwfs/9netics32.16k/dat.h index da14c8cf5..958bbb075 100644 --- a/sys/src/cmd/cwfs/9netics32.16k/dat.h +++ b/sys/src/cmd/cwfs/9netics32.16k/dat.h @@ -19,18 +19,3 @@ enum { FIXEDSIZE = 1 }; #include "portdat.h" - -enum { MAXBANK = 2 }; - -typedef struct Mbank { - ulong base; - ulong limit; -} Mbank; - -typedef struct Mconf { - Lock; - Mbank bank[MAXBANK]; - int nbank; - ulong memsize; -} Mconf; -extern Mconf mconf; diff --git a/sys/src/cmd/cwfs/9netics64.8k/dat.h b/sys/src/cmd/cwfs/9netics64.8k/dat.h index 8b48c5d14..fc0386f68 100644 --- a/sys/src/cmd/cwfs/9netics64.8k/dat.h +++ b/sys/src/cmd/cwfs/9netics64.8k/dat.h @@ -17,20 +17,4 @@ */ enum { FIXEDSIZE = 1 }; - #include "portdat.h" - -enum { MAXBANK = 2 }; - -typedef struct Mbank { - ulong base; - ulong limit; -} Mbank; - -typedef struct Mconf { - Lock; - Mbank bank[MAXBANK]; - int nbank; - ulong memsize; -} Mconf; -extern Mconf mconf; diff --git a/sys/src/cmd/cwfs/choline/dat.h b/sys/src/cmd/cwfs/choline/dat.h index b35a3c601..5baf712e0 100644 --- a/sys/src/cmd/cwfs/choline/dat.h +++ b/sys/src/cmd/cwfs/choline/dat.h @@ -19,18 +19,3 @@ enum { FIXEDSIZE = 1 }; #include "portdat.h" - -enum { MAXBANK = 2 }; - -typedef struct Mbank { - ulong base; - ulong limit; -} Mbank; - -typedef struct Mconf { - Lock; - Mbank bank[MAXBANK]; - int nbank; - ulong memsize; -} Mconf; -extern Mconf mconf; diff --git a/sys/src/cmd/cwfs/cwfs/dat.h b/sys/src/cmd/cwfs/cwfs/dat.h index a332d0cb2..9d5684e49 100644 --- a/sys/src/cmd/cwfs/cwfs/dat.h +++ b/sys/src/cmd/cwfs/cwfs/dat.h @@ -19,18 +19,3 @@ enum { FIXEDSIZE = 1 }; #include "portdat.h" - -enum { MAXBANK = 2 }; - -typedef struct Mbank { - ulong base; - ulong limit; -} Mbank; - -typedef struct Mconf { - Lock; - Mbank bank[MAXBANK]; - int nbank; - ulong memsize; -} Mconf; -extern Mconf mconf; diff --git a/sys/src/cmd/cwfs/cwfs64/dat.h b/sys/src/cmd/cwfs/cwfs64/dat.h index 4c63315ca..978c95e44 100644 --- a/sys/src/cmd/cwfs/cwfs64/dat.h +++ b/sys/src/cmd/cwfs/cwfs64/dat.h @@ -19,18 +19,3 @@ enum { FIXEDSIZE = 1 }; #include "portdat.h" - -enum { MAXBANK = 2 }; - -typedef struct Mbank { - ulong base; - ulong limit; -} Mbank; - -typedef struct Mconf { - Lock; - Mbank bank[MAXBANK]; - int nbank; - ulong memsize; -} Mconf; -extern Mconf mconf; diff --git a/sys/src/cmd/cwfs/cwfs64x/dat.h b/sys/src/cmd/cwfs/cwfs64x/dat.h index e14371d43..379de9929 100644 --- a/sys/src/cmd/cwfs/cwfs64x/dat.h +++ b/sys/src/cmd/cwfs/cwfs64x/dat.h @@ -19,18 +19,3 @@ enum { FIXEDSIZE = 1 }; #include "portdat.h" - -enum { MAXBANK = 2 }; - -typedef struct Mbank { - ulong base; - ulong limit; -} Mbank; - -typedef struct Mconf { - Lock; - Mbank bank[MAXBANK]; - int nbank; - ulong memsize; -} Mconf; -extern Mconf mconf; diff --git a/sys/src/cmd/cwfs/emelie/dat.h b/sys/src/cmd/cwfs/emelie/dat.h index 7610ea993..449ef2793 100644 --- a/sys/src/cmd/cwfs/emelie/dat.h +++ b/sys/src/cmd/cwfs/emelie/dat.h @@ -19,18 +19,3 @@ enum { FIXEDSIZE = 1 }; #include "portdat.h" - -enum { MAXBANK = 2 }; - -typedef struct Mbank { - ulong base; - ulong limit; -} Mbank; - -typedef struct Mconf { - Lock; - Mbank bank[MAXBANK]; - int nbank; - ulong memsize; -} Mconf; -extern Mconf mconf; diff --git a/sys/src/cmd/cwfs/fs/dat.h b/sys/src/cmd/cwfs/fs/dat.h index 48f9ef0c5..6efbd76f7 100644 --- a/sys/src/cmd/cwfs/fs/dat.h +++ b/sys/src/cmd/cwfs/fs/dat.h @@ -19,18 +19,3 @@ enum { FIXEDSIZE = 1 }; #include "portdat.h" - -enum { MAXBANK = 2 }; - -typedef struct Mbank { - ulong base; - ulong limit; -} Mbank; - -typedef struct Mconf { - Lock; - Mbank bank[MAXBANK]; - int nbank; - ulong memsize; -} Mconf; -extern Mconf mconf; diff --git a/sys/src/cmd/cwfs/fs64/dat.h b/sys/src/cmd/cwfs/fs64/dat.h index b2ddd1c82..6f42fa46c 100644 --- a/sys/src/cmd/cwfs/fs64/dat.h +++ b/sys/src/cmd/cwfs/fs64/dat.h @@ -19,18 +19,3 @@ enum { FIXEDSIZE = 1 }; #include "portdat.h" - -enum { MAXBANK = 2 }; - -typedef struct Mbank { - ulong base; - ulong limit; -} Mbank; - -typedef struct Mconf { - Lock; - Mbank bank[MAXBANK]; - int nbank; - ulong memsize; -} Mconf; -extern Mconf mconf; diff --git a/sys/src/cmd/cwfs/main.c b/sys/src/cmd/cwfs/main.c index 5a6f8186b..de545a71b 100644 --- a/sys/src/cmd/cwfs/main.c +++ b/sys/src/cmd/cwfs/main.c @@ -128,8 +128,6 @@ confinit(void) { conf.nmach = 1; - conf.mem = meminit(); - conf.nuid = 1000; conf.nserve = 15; /* tunable */ conf.nfile = 30000; diff --git a/sys/src/cmd/cwfs/malloc.c b/sys/src/cmd/cwfs/malloc.c index 369ae4ab5..048a81209 100644 --- a/sys/src/cmd/cwfs/malloc.c +++ b/sys/src/cmd/cwfs/malloc.c @@ -1,6 +1,40 @@ #include "all.h" #include "io.h" +static ulong +memsize(void) +{ + int nf, pgsize = 0; + ulong userpgs = 0, userused = 0; + char *ln, *sl; + char *fields[2]; + Biobuf *bp; + + bp = Bopen("#c/swap", OREAD); + if (bp != nil) { + while ((ln = Brdline(bp, '\n')) != nil) { + ln[Blinelen(bp)-1] = '\0'; + nf = tokenize(ln, fields, nelem(fields)); + if (nf != 2) + continue; + if (strcmp(fields[1], "pagesize") == 0) + pgsize = atoi(fields[0]); + else if (strcmp(fields[1], "user") == 0) { + sl = strchr(fields[0], '/'); + if (sl == nil) + continue; + userpgs = atol(sl+1); + userused = atol(fields[0]); + } + } + Bterm(bp); + if (pgsize > 0 && userused > userpgs) + return (userpgs - userused)*pgsize; + } + return 64*MB; +} + + long niob; long nhiob; Hiob *hiob; @@ -17,27 +51,11 @@ ialloc(ulong n, int align) if (p == nil) panic("ialloc: out of memory"); + setmalloctag(p, getcallerpc(&n)); memset(p, 0, n); return p; } -void -prbanks(void) -{ - Mbank *mbp; - - for(mbp = mconf.bank; mbp < &mconf.bank[mconf.nbank]; mbp++) - print("bank[%ld]: base 0x%8.8lux, limit 0x%8.8lux (%.0fMB)\n", - mbp - mconf.bank, mbp->base, mbp->limit, - (mbp->limit - mbp->base)/(double)MB); -} - -static void -cmd_memory(int, char *[]) -{ - prbanks(); -} - enum { HWIDTH = 8 }; /* buffers per hash */ /* @@ -52,18 +70,11 @@ iobufinit(void) char *xiop; Iobuf *p, *q; Hiob *hp; - Mbank *mbp; wlock(&mainlock); /* init */ wunlock(&mainlock); - if(chatty) - prbanks(); - - m = 0; - for(mbp = mconf.bank; mbp < &mconf.bank[mconf.nbank]; mbp++) - m += mbp->limit - mbp->base; - + m = memsize() / 4; niob = m / (sizeof(Iobuf) + RBUFSIZE + sizeof(Hiob)/HWIDTH); nhiob = niob / HWIDTH; while(!prime(nhiob)) @@ -104,19 +115,6 @@ iobufinit(void) p++; xiop += RBUFSIZE; } - - /* - * Make sure that no more of bank[0] can be used. - */ - mconf.bank[0].base = mconf.bank[0].limit; - - i = 0; - for(mbp = mconf.bank; mbp < &mconf.bank[mconf.nbank]; mbp++) - i += mbp->limit - mbp->base; - if(chatty) - print("\tmem left = %,d, out of %,ld\n", i, conf.mem); - /* paranoia: add this command as late as is easy */ - cmd_install("memory", "-- print ranges of memory banks", cmd_memory); } void* diff --git a/sys/src/cmd/cwfs/pc.c b/sys/src/cmd/cwfs/pc.c deleted file mode 100644 index ea817c8f7..000000000 --- a/sys/src/cmd/cwfs/pc.c +++ /dev/null @@ -1,92 +0,0 @@ -#include "all.h" -#include "io.h" - -Mconf mconf; - -static void -mconfinit(void) -{ - int nf, pgsize = 0; - ulong size, userpgs = 0, userused = 0; - char *ln, *sl; - char *fields[2]; - Biobuf *bp; - Mbank *mbp; - - size = 64*MB; - bp = Bopen("#c/swap", OREAD); - if (bp != nil) { - while ((ln = Brdline(bp, '\n')) != nil) { - ln[Blinelen(bp)-1] = '\0'; - nf = tokenize(ln, fields, nelem(fields)); - if (nf != 2) - continue; - if (strcmp(fields[1], "pagesize") == 0) - pgsize = atoi(fields[0]); - else if (strcmp(fields[1], "user") == 0) { - sl = strchr(fields[0], '/'); - if (sl == nil) - continue; - userpgs = atol(sl+1); - userused = atol(fields[0]); - } - } - Bterm(bp); - if (pgsize > 0 && userpgs > 0) - size = (((userpgs - userused)*1LL)/4)*pgsize; - } - mconf.memsize = size; - mbp = mconf.bank; - mbp->base = 0x10000000; /* fake addresses */ - mbp->limit = mbp->base + size; - mbp++; - - mconf.nbank = mbp - mconf.bank; -} - -ulong -meminit(void) -{ - conf.nmach = 1; - mconfinit(); - return mconf.memsize; -} - -/* - * based on libthread's threadsetname, but drags in less library code. - * actually just sets the arguments displayed. - */ -void -procsetname(char *fmt, ...) -{ - int fd; - char *cmdname; - char buf[128]; - va_list arg; - - va_start(arg, fmt); - cmdname = vsmprint(fmt, arg); - va_end(arg); - if (cmdname == nil) - return; - snprint(buf, sizeof buf, "#p/%d/args", getpid()); - if((fd = open(buf, OWRITE)) >= 0){ - write(fd, cmdname, strlen(cmdname)+1); - close(fd); - } - free(cmdname); -} - -void -newproc(void (*f)(void *), void *arg, char *text) -{ - int kid = rfork(RFPROC|RFMEM|RFNOWAIT); - - if (kid < 0) - sysfatal("can't fork: %r"); - if (kid == 0) { - procsetname("%s", text); - (*f)(arg); - exits("child returned"); - } -} diff --git a/sys/src/cmd/cwfs/portdat.h b/sys/src/cmd/cwfs/portdat.h index 1904fc86d..3b17db295 100644 --- a/sys/src/cmd/cwfs/portdat.h +++ b/sys/src/cmd/cwfs/portdat.h @@ -415,7 +415,6 @@ struct Superb struct Conf { ulong nmach; /* processors */ - ulong mem; /* total physical bytes of memory */ ulong nuid; /* distinct uids */ ulong nserve; /* server processes */ ulong nfile; /* number of fid -- system wide */ diff --git a/sys/src/cmd/cwfs/portfns.h b/sys/src/cmd/cwfs/portfns.h index 7790b70e5..5f5cda257 100644 --- a/sys/src/cmd/cwfs/portfns.h +++ b/sys/src/cmd/cwfs/portfns.h @@ -131,7 +131,6 @@ void machinit(void); Msgbuf* mballoc(int, Chan*, int); void mbinit(void); void mbfree(Msgbuf*); -ulong meminit(void); Iobuf* movebuf(Iobuf*); void mcatinit(Device*); int mcatread(Device*, Off, void*); diff --git a/sys/src/cmd/cwfs/portmkfile b/sys/src/cmd/cwfs/portmkfile index 0bc734183..c49e23f22 100644 --- a/sys/src/cmd/cwfs/portmkfile +++ b/sys/src/cmd/cwfs/portmkfile @@ -21,7 +21,7 @@ OFILES=\ malloc.$O\ mworm.$O\ net.$O\ - pc.$O\ + proc.$O\ scsi.$O\ sub.$O\ time.$O\ diff --git a/sys/src/cmd/cwfs/proc.c b/sys/src/cmd/cwfs/proc.c new file mode 100644 index 000000000..22ac02e60 --- /dev/null +++ b/sys/src/cmd/cwfs/proc.c @@ -0,0 +1,41 @@ +#include "all.h" +#include "io.h" + +/* + * based on libthread's threadsetname, but drags in less library code. + * actually just sets the arguments displayed. + */ +void +procsetname(char *fmt, ...) +{ + int fd; + char *cmdname; + char buf[128]; + va_list arg; + + va_start(arg, fmt); + cmdname = vsmprint(fmt, arg); + va_end(arg); + if (cmdname == nil) + return; + snprint(buf, sizeof buf, "#p/%d/args", getpid()); + if((fd = open(buf, OWRITE)) >= 0){ + write(fd, cmdname, strlen(cmdname)+1); + close(fd); + } + free(cmdname); +} + +void +newproc(void (*f)(void *), void *arg, char *text) +{ + int kid = rfork(RFPROC|RFMEM|RFNOWAIT); + + if (kid < 0) + sysfatal("can't fork: %r"); + if (kid == 0) { + procsetname("%s", text); + (*f)(arg); + exits("child returned"); + } +} |