allow nvr to be in the dos active partition so the fs can be booted without a floppy drive. the changes work like this 1. make sure _sdinit() is always called before we try to look up a drive. 2. make sure that _sdinit actually sees the drives available. perhaps the check to make sure drives are not added twice should be moved to _sdinit from *pnpsd. this would make drive deconfiguration and reconfiguration easier. 3. noisy debugging changes. sorry. Reference: /n/sources/patch/sorry/fs-nvr-hd1 Date: Thu Aug 17 20:27:04 CES 2006 Signed-off-by: quanstro@quanstro.net --- /sys/src/fs/pc/sdata.c Thu Aug 17 20:16:29 2006 +++ /sys/src/fs/pc/sdata.c Thu Aug 17 20:16:00 2006 @@ -859,6 +859,8 @@ | (drive->info[Ilba48+1]<<16) | ((Devsize)drive->info[Ilba48+2]<<32); drive->flags |= Lba48; + if(DEBUG & Dbg48BIT) + print("LLBA48 drive @%.2x:%.3x\n", dev, cmdport); }else drive->sectors = (drive->info[Ilba+1]<<16) |drive->info[Ilba]; @@ -2002,6 +2004,8 @@ } } +static SDev *pnpsdev; + static SDev* atapnp(void) { @@ -2220,10 +2224,22 @@ ctlr->bmiba = (p->mem[4].bar & ~0x01) + channel*8; } } + pnpsdev = head; return head; } static SDev* +atapnpsd(void) +{ + static int once; + + if(once) + return 0; + once = 1; + return pnpsdev; +} + +static SDev* atalegacy(int port, int irq) { return ataprobe(port, port+Ctl2cmd, irq); @@ -2431,7 +2447,7 @@ SDifc sdataifc = { "ata", /* name */ - atapnp, /* pnp */ + atapnpsd, /* pnp */ atalegacy, /* legacy */ ataid, /* id */ ataenable, /* enable */ @@ -2598,7 +2614,7 @@ SDunit *unit = sdgetunit(sdevs[driveno/NCtlrdrv], driveno%NCtlrdrv); if (unit == nil) { - print("mvsataxfer: nil unit\n"); + print("ataxfer: nil unit h%d\n", driveno); return -1; } if (dp->driveno == -1) --- /sys/src/fs/pc/sdmv50xx.c Thu Aug 17 20:17:09 2006 +++ /sys/src/fs/pc/sdmv50xx.c Thu Aug 17 20:16:50 2006 @@ -27,9 +27,6 @@ #endif enum { - DEBUGPR = 0, - IDEBUG = 0, - /* old stuff carried forward */ NCtlr= 8, NCtlrdrv= 8, @@ -43,8 +40,8 @@ Ctlrmagic = 0xfeedfaceUL, }; -#define DPRINT if(DEBUGPR)print -#define IDPRINT if(IDEBUG)print +#define DPRINT(...) print(__VA_ARGS__) +#define IDPRINT(...) /*print(__VA_ARGS__) */ enum { SrbRing = 32, @@ -932,6 +929,8 @@ /* * Device discovery */ +static SDev *pnpsdev; + static SDev* mv50pnp(void) { @@ -1030,6 +1029,17 @@ return head; } +static SDev* +mv50pnpsd(void) +{ + static int once; + + if(once) + return 0; + once = 1; + return pnpsdev; +} + /* * Enable the controller. Each disk has its own interrupt mask, * and those get enabled as the disks are brought online. @@ -1469,7 +1479,7 @@ SDifc sdmv50xxifc = { "mv50xx", /* name */ - mv50pnp, /* pnp */ + mv50pnpsd, /* pnp */ nil, /* legacy */ #ifdef FS nil, /* id */ --- /sys/src/fs/port/devsd.c Thu Aug 17 20:17:39 2006 +++ /sys/src/fs/port/devsd.c Thu Aug 17 20:17:30 2006 @@ -10,7 +10,7 @@ #include "compat.h" #undef error -#define parttrace 0 +#define parttrace(...) print(__VA_ARGS__) extern SDifc sdataifc, sdmv50xxifc; @@ -34,14 +34,16 @@ Rawstatus, }; +// didn't want to confuse the diff. +static int _sdinit(void); + void sdaddpart(SDunit* unit, char* name, Devsize start, Devsize end) { SDpart *pp; int i, partno; - if(parttrace) - print("add %d %s %s %lld %lld\n", unit->npart, unit->name, + parttrace("add %d %s %s %lld %lld\n", unit->npart, unit->name, name, start, end); /* * Check name not already used @@ -58,16 +60,14 @@ } if(strcmp(name, pp->name) == 0){ if(pp->start == start && pp->end == end){ - if(parttrace) - print("already present\n"); + parttrace("already present\n"); return; } } } }else{ if((unit->part = malloc(sizeof(SDpart)*SDnpart)) == nil){ - if(parttrace) - print("malloc failed\n"); + parttrace("malloc failed\n"); return; } partno = 0; @@ -97,8 +97,7 @@ int i; SDpart *pp; - if(parttrace) - print("del %d %s %s\n", unit->npart, unit->name, name); + parttrace("del %d %s %s\n", unit->npart, unit->name, name); /* * Look for the partition to delete. * Can't delete if someone still has it open. @@ -132,6 +131,7 @@ unit->part = nil; } + parttrace("sdinitpart\n"); if(unit->inquiry[0] & 0xC0) return 0; switch(unit->inquiry[0] & 0x1F){ @@ -141,11 +141,15 @@ case 0x07: /* MO */ break; default: + parttrace("unknown device type: %x\n", unit->inquiry[0] & 0x1F); return 0; } - if(unit->dev->ifc->online == nil || unit->dev->ifc->online(unit) == 0) + if(unit->dev->ifc->online == nil || unit->dev->ifc->online(unit) == 0){ + parttrace("offline\n"); return 0; + } + parttrace("calling sdaddpart\n"); sdaddpart(unit, "data", 0, unit->sectors); return 1; } @@ -156,6 +160,12 @@ int index; SDunit *unit; + if(sdlist == nil) + _sdinit(); + if(subno >= sdnunit){ + parttrace("sdgetunit: partition out-of-range %d >= %d\n", subno, sdnunit); + return nil; + } /* * Associate a unit with a given device and sub-unit * number on that device. @@ -240,8 +250,10 @@ * of units attached and marking each device with an index * into the linear top-level directory array of units. */ + parttrace("_sdinit()\n"); tail = nil; for(i = 0; sdifc[i] != nil; i++){ + parttrace("probe %s\n", sdifc[i]->name); if((sdev = sdifc[i]->pnp()) == nil) continue; if(sdlist != nil) @@ -249,9 +261,11 @@ else sdlist = sdev; for(tail = sdev; tail->next != nil; tail = tail->next){ + parttrace("\t" "[%2d.%2d]", sdnunit, sdnunit+tail->nunit-1); sdev->index = sdnunit; sdnunit += tail->nunit; } + parttrace("\t" "[%2d.%2d]\n", sdnunit, sdnunit+tail->nunit-1); tail->index = sdnunit; sdnunit += tail->nunit; } @@ -345,19 +359,15 @@ { int i; - if(parttrace) - print("findpart %d %s %s\t\n", unit->npart, unit->name, name); + parttrace("findpart %d %s %s\t\n", unit->npart, unit->name, name); for(i=0; inpart; i++) { - if(parttrace) - print("%s...", unit->part[i].name); + parttrace("%s...", unit->part[i].name); if(strcmp(unit->part[i].name, name) == 0){ - if(parttrace) - print("\n"); + parttrace("\n"); return &unit->part[i]; } } - if(parttrace) - print("not found\n"); + parttrace("not found\n"); return nil; }