ref: 7cd1b102ee03d676b050319eaaefe73309b9b01c
parent: fcf30f314b4c4157b536647a09a214576711ad16
author: cinap_lenrek <cinap_lenrek@localhost>
date: Thu Jun 16 13:33:26 EDT 2011
remove mconf cruft
--- a/sys/src/cmd/cwfs/9netics32.16k/dat.h
+++ b/sys/src/cmd/cwfs/9netics32.16k/dat.h
@@ -19,18 +19,3 @@
#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;
--- 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;
--- a/sys/src/cmd/cwfs/choline/dat.h
+++ b/sys/src/cmd/cwfs/choline/dat.h
@@ -19,18 +19,3 @@
#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;
--- a/sys/src/cmd/cwfs/cwfs/dat.h
+++ b/sys/src/cmd/cwfs/cwfs/dat.h
@@ -19,18 +19,3 @@
#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;
--- a/sys/src/cmd/cwfs/cwfs64/dat.h
+++ b/sys/src/cmd/cwfs/cwfs64/dat.h
@@ -19,18 +19,3 @@
#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;
--- a/sys/src/cmd/cwfs/cwfs64x/dat.h
+++ b/sys/src/cmd/cwfs/cwfs64x/dat.h
@@ -19,18 +19,3 @@
#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;
--- a/sys/src/cmd/cwfs/emelie/dat.h
+++ b/sys/src/cmd/cwfs/emelie/dat.h
@@ -19,18 +19,3 @@
#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;
--- a/sys/src/cmd/cwfs/fs/dat.h
+++ b/sys/src/cmd/cwfs/fs/dat.h
@@ -19,18 +19,3 @@
#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;
--- a/sys/src/cmd/cwfs/fs64/dat.h
+++ b/sys/src/cmd/cwfs/fs64/dat.h
@@ -19,18 +19,3 @@
#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;
--- a/sys/src/cmd/cwfs/main.c
+++ b/sys/src/cmd/cwfs/main.c
@@ -128,8 +128,6 @@
{
conf.nmach = 1;
- conf.mem = meminit();
-
conf.nuid = 1000;
conf.nserve = 15; /* tunable */
conf.nfile = 30000;
--- 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 @@
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 @@
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 @@
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*
--- a/sys/src/cmd/cwfs/pc.c
+++ /dev/null
@@ -1,92 +1,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");
- }
-}
--- a/sys/src/cmd/cwfs/portdat.h
+++ b/sys/src/cmd/cwfs/portdat.h
@@ -415,7 +415,6 @@
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 */
--- a/sys/src/cmd/cwfs/portfns.h
+++ b/sys/src/cmd/cwfs/portfns.h
@@ -131,7 +131,6 @@
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*);
--- a/sys/src/cmd/cwfs/portmkfile
+++ b/sys/src/cmd/cwfs/portmkfile
@@ -21,7 +21,7 @@
malloc.$O\
mworm.$O\
net.$O\
- pc.$O\
+ proc.$O\
scsi.$O\
sub.$O\
time.$O\
--- /dev/null
+++ b/sys/src/cmd/cwfs/proc.c
@@ -1,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");
+ }
+}