]> git.lizzy.rs Git - plan9front.git/blobdiff - sys/src/9/pc64/main.c
pc64: print "Plan 9" on boot, cleanup pccpu64 files
[plan9front.git] / sys / src / 9 / pc64 / main.c
index 0464bad6ba5b46ee838d20ba752f5a67f29c24a2..63dce3934a8f7fe4a9cacee0620df82f8864fc72 100644 (file)
@@ -199,21 +199,6 @@ confinit(void)
                if(userpcnt < 10)
                        userpcnt = 70;
                kpages = conf.npage - (conf.npage*userpcnt)/100;
-
-               /*
-                * Hack for the big boys. Only good while physmem < 4GB.
-                * Give the kernel fixed max + enough to allocate the
-                * page pool.
-                * This is an overestimate as conf.upages < conf.npages.
-                * The patch of nimage is a band-aid, scanning the whole
-                * page list in imagereclaim just takes too long.
-                */
-               if(getconf("*imagemaxmb") == 0)
-               if(kpages > (64*MB + conf.npage*sizeof(Page))/BY2PG){
-                       kpages = (64*MB + conf.npage*sizeof(Page))/BY2PG;
-                       conf.nimage = 2000;
-                       kpages += (conf.nproc*KSTACK)/BY2PG;
-               }
        } else {
                if(userpcnt < 10) {
                        if(conf.npage*BY2PG < 16*MB)
@@ -246,8 +231,7 @@ confinit(void)
         * (probably ~300KB).
         */
        kpages *= BY2PG;
-       kpages -= conf.upages*sizeof(Page)
-               + conf.nproc*sizeof(Proc)
+       kpages -= conf.nproc*sizeof(Proc)
                + conf.nimage*sizeof(Image)
                + conf.nswap
                + conf.nswppo*sizeof(Page*);
@@ -265,6 +249,44 @@ confinit(void)
        }
 }
 
+/*
+ * The palloc.pages array can be a large chunk out of the 2GB
+ * window above KZERO, so we allocate the array from
+ * upages and map in the VMAP window before pageinit()
+ */
+static void
+preallocpages(void)
+{
+       Pallocmem *pm;
+       uintptr va, base, top;
+       vlong size;
+       ulong np;
+       int i;
+
+       np = 0;
+       for(i=0; i<nelem(palloc.mem); i++){
+               pm = &palloc.mem[i];
+               np += pm->npage;
+       }
+       size = (uvlong)np * BY2PG;
+       size += sizeof(Page) + BY2PG;   /* round up */
+       size = (size / (sizeof(Page) + BY2PG)) * sizeof(Page);
+       size = ROUND(size, PGLSZ(1));
+
+       for(i=0; i<nelem(palloc.mem); i++){
+               pm = &palloc.mem[i];
+               base = ROUND(pm->base, PGLSZ(1));
+               top = pm->base + (uvlong)pm->npage * BY2PG;
+               if((base + size) <= VMAPSIZE && (vlong)(top - base) >= size){
+                       va = base + VMAP;
+                       pmap(m->pml4, base | PTEGLOBAL|PTEWRITE|PTEVALID, va, size);
+                       palloc.pages = (Page*)va;
+                       pm->base = base + size;
+                       pm->npage = (top - pm->base)/BY2PG;
+                       break;
+               }
+       }
+}
 
 void
 machinit(void)
@@ -306,7 +328,6 @@ mach0init(void)
 
        active.machs = 1;
        active.exiting = 0;
-       active.rebooting = 0;
 }
 
 
@@ -478,6 +499,7 @@ main()
        i8250console();
        quotefmtinstall();
        screeninit();
+       print("\nPlan 9\n");
        trapinit0();
        kbdinit();
        i8253init();
@@ -508,6 +530,7 @@ main()
                links();
        conf.monitor = 1;
        chandevreset();
+       preallocpages();
        pageinit();
        swapinit();
        userinit();
@@ -583,21 +606,8 @@ reboot(void *entry, void *code, ulong size)
                procwired(up, 0);
                sched();
        }
-
-       lock(&active);
-       active.rebooting = 1;
-       unlock(&active);
-
        shutdown(0);
 
-       /*
-        * should be the only processor running now
-        */
-       if (m->machno != 0)
-               iprint("on cpu%d (not 0)!\n", m->machno);
-       if (active.machs)
-               iprint("still have active ap processors!\n");
-
        iprint("shutting down...\n");
        delay(200);