summaryrefslogtreecommitdiff
path: root/os/boot/pc/load.c
diff options
context:
space:
mode:
Diffstat (limited to 'os/boot/pc/load.c')
-rw-r--r--os/boot/pc/load.c110
1 files changed, 87 insertions, 23 deletions
diff --git a/os/boot/pc/load.c b/os/boot/pc/load.c
index 575c1205..5d071f59 100644
--- a/os/boot/pc/load.c
+++ b/os/boot/pc/load.c
@@ -4,10 +4,23 @@
#include "dat.h"
#include "fns.h"
#include "io.h"
-
+#include "sd.h"
#include "fs.h"
-static char *diskparts[] = { "dos", "9fat", "fs", "data", "cdboot", 0 };
+#ifndef VERBOSE
+#define VERBOSE 0
+#endif
+
+/*
+ * "cache" must be in this list so that 9load will pass the definition of
+ * the cache partition into the kernel so that the disk named by the `cfs'
+ * variable in plan9.ini can be seen in all circumstances before termrc
+ * sets up all the disk partitions. In particular, if it's on an odd-ball
+ * disk like sd10 rather than sdC0, this is needed.
+ */
+static char *diskparts[] = {
+ "dos", "9fat", "fs", "data", "cdboot", "cache", 0
+};
static char *etherparts[] = { "*", 0 };
static char *diskinis[] = {
@@ -20,6 +33,7 @@ static char *etherinis[] = {
0
};
+/* ordering: devbios must be called before devsd calls sdbios */
Type types[] = {
{ Tfloppy,
Fini|Ffs,
@@ -29,14 +43,6 @@ Type types[] = {
diskparts,
diskinis,
},
- { Tcd,
- Fini|Ffs,
- cdinit, sdinitdev,
- sdgetfspart, sdaddconf, sdboot,
- sdprintdevs,
- diskparts,
- diskinis,
- },
{ Tether,
Fini|Fbootp,
etherinit, etherinitdev,
@@ -45,6 +51,22 @@ Type types[] = {
etherparts,
etherinis,
},
+ { Tbios,
+ Fini|Ffs,
+ biosinit, biosinitdev,
+ biosgetfspart, nil, biosboot,
+ biosprintdevs,
+ diskparts,
+ diskinis,
+ },
+ { Tcd,
+ Fini|Ffs,
+ cdinit, sdinitdev,
+ sdgetfspart, sdaddconf, sdboot,
+ sdprintdevs,
+ diskparts,
+ diskinis,
+ },
{ Tsd,
Fini|Ffs,
sdinit, sdinitdev,
@@ -63,14 +85,35 @@ Type types[] = {
},
};
-#include "sd.h"
+static char *typenm[] = {
+ [Tnil] "nil",
+ [Tfloppy] "floppy",
+ [Tsd] "sd",
+ [Tether] "ether",
+ [Tcd] "cd",
+ [Tbios] "bios",
+};
+
+static char *
+typename(int type)
+{
+ if (type < 0 || type >= nelem(typenm) || typenm[type] == nil)
+ return "**gok**";
+ return typenm[type];
+}
extern SDifc sdataifc;
+extern SDifc sdiahciifc;
+extern SDifc sdaoeifc;
+extern SDifc sdbiosifc;
#ifdef NOSCSI
SDifc* sdifc[] = {
&sdataifc,
+ &sdiahciifc,
+ &sdbiosifc,
+ &sdaoeifc,
nil,
};
@@ -78,10 +121,14 @@ SDifc* sdifc[] = {
extern SDifc sdmylexifc;
extern SDifc sd53c8xxifc;
+
SDifc* sdifc[] = {
&sdataifc,
+ &sdiahciifc,
&sdmylexifc,
&sd53c8xxifc,
+ &sdbiosifc,
+ &sdaoeifc,
nil,
};
@@ -137,6 +184,8 @@ int scsi0port;
char *defaultpartition;
int iniread;
+int debugload;
+
static Medium*
parse(char *line, char **file)
{
@@ -179,6 +228,7 @@ boot(Medium *mp, char *file)
}
sprint(BOOTLINE, "%s!%s", mp->name, file);
+ print("booting %s!%s\n", mp->name, file);
return (*mp->type->boot)(mp->dev, file, &b);
}
@@ -216,7 +266,8 @@ probe(int type, int flag, int dev)
return mp;
}
}
-
+ if (debugload)
+ print("probing %s...", typename(tp->type));
if((tp->flag & Fprobe) == 0){
tp->flag |= Fprobe;
tp->mask = (*tp->init)();
@@ -276,25 +327,33 @@ main(void)
alarminit();
meminit(0);
spllo();
+ consinit("0", "9600");
kbdinit();
-
if((ulong)&end > (KZERO|(640*1024)))
panic("i'm too big\n");
readlsconf();
+ print("initial probe, to find plan9.ini...");
+ /* find and read plan9.ini, setting configuration variables */
for(tp = types; tp->type != Tnil; tp++){
- //if(tp->type == Tether)
- // continue;
+ /* skip bios until we have read plan9.ini */
+ if(!pxe && tp->type == Tether || tp->type == Tbios)
+ continue;
+ if (VERBOSE)
+ print("probing %s...", typename(tp->type));
if((mp = probe(tp->type, Fini, Dany)) && (mp->flag & Fini)){
print("using %s!%s!%s\n", mp->name, mp->part, mp->ini);
iniread = !dotini(mp->inifs);
break;
}
}
+ print("\n");
apminit();
+ debugload = getconf("*debugload") != nil;
if((p = getconf("console")) != nil)
consinit(p, getconf("baud"));
+
devpccardlink();
devi82365link();
@@ -304,9 +363,11 @@ main(void)
* have boot devices for parse.
*/
probe(Tany, Fnone, Dany);
+ if (debugload)
+ print("end disk probe\n");
tried = 0;
mode = Mauto;
-
+
p = getconf("bootfile");
if(p != 0) {
@@ -330,10 +391,14 @@ done:
flag &= ~Fbootp;
if((mp = probe(Tany, flag, Dany)) && mp->type->type != Tfloppy)
boot(mp, "");
+ if (debugload)
+ print("end auto probe\n");
}
def[0] = 0;
probe(Tany, Fnone, Dany);
+ if (debugload)
+ print("end final probe\n");
if(p = getconf("bootdef"))
strcpy(def, p);
@@ -386,7 +451,7 @@ cistrcmp(char *a, char *b)
for(;;){
ac = *a++;
bc = *b++;
-
+
if(ac >= 'A' && ac <= 'Z')
ac = 'a' + (ac - 'A');
if(bc >= 'A' && bc <= 'Z')
@@ -425,7 +490,7 @@ cistrncmp(char *a, char *b, int n)
return 0;
}
-#define PSTART (12*1024*1024)
+#define PSTART ( 8*1024*1024)
#define PEND (16*1024*1024)
ulong palloc = PSTART;
@@ -447,7 +512,7 @@ ialloc(ulong n, int align)
palloc = p+n;
if(palloc > PEND)
- panic("ialloc(%lud, %d) called from 0x%lux\n",
+ panic("ialloc(%lud, %d) called from %#p\n",
n, align, getcallerpc(&n));
return memset((void*)(p|KZERO), 0, n);
}
@@ -458,7 +523,7 @@ xspanalloc(ulong size, int align, ulong span)
ulong a, v;
if((palloc + (size+align+span)) > PEND)
- panic("xspanalloc(%lud, %d, 0x%lux) called from 0x%lux\n",
+ panic("xspanalloc(%lud, %d, 0x%lux) called from %#p\n",
size, align, span, getcallerpc(&size));
a = (ulong)ialloc(size+align+span, 0);
@@ -492,7 +557,7 @@ allocb(int size)
}
if(bp == 0){
if((palloc + (sizeof(Block)+size+64)) > PEND)
- panic("allocb(%d) called from 0x%lux\n",
+ panic("allocb(%d) called from %#p\n",
size, getcallerpc(&size));
bp = ialloc(sizeof(Block)+size+64, 0);
addr = (ulong)bp;
@@ -546,9 +611,8 @@ warp9(ulong entry)
floppydetach();
if(sddetach)
sddetach();
-
consdrain();
-
+
splhi();
trapdisable();