M bitsy/devether.c => bitsy/devether.c +1 -1
@@ 36,7 36,7 @@ etherpower(int on)
Ether *ether;
/* Power all ether cards on or off */
-print("etherpower %d\n", on);
+iprint("etherpower %d\n", on);
for (i = 0; i < MaxEther; i++){
if ((ether = etherxx[i]) == nil)
continue;
M bitsy/devpcmcia.c => bitsy/devpcmcia.c +56 -53
@@ 106,57 106,6 @@ bitno(ulong x)
}
/*
- * power up/down pcmcia
- */
-void
-pcmciapower(int on)
-{
- PCMslot *sp;
-
- /* if there's no pcmcia sleave, no interrupts */
- if(gpioregs->level & GPIO_OPT_IND_i)
- return;
- if (on){
- /* set timing to the default, 300 */
- slottiming(0, 300, 300, 300, 0);
- slottiming(1, 300, 300, 300, 0);
-
- /* if there's no pcmcia sleave, no interrupts */
- if(gpioregs->level & GPIO_OPT_IND_i)
- return;
-
- egpiobits(EGPIO_exp_nvram_power|EGPIO_exp_full_power, 1);
- delay(200);
- egpiobits(EGPIO_pcmcia_reset, 1);
- delay(100);
- egpiobits(EGPIO_pcmcia_reset, 0);
- delay(500);
-
- slotinfo(nil, nil); // See what's there
- for (sp = slot; sp < slot + nslot; sp++){
- if (sp->occupied == 0)
- continue;
- if(sp->cisread == 0)
- pcmcisread(sp);
- if (sp->dev){
-// if (sp->dev->power)
-// sp->dev->power(on);
- }
- }
- }else{
- for (sp = slot; sp < slot + nslot; sp++){
- if (sp->occupied == 0)
- continue;
- if (sp->dev){
- if (sp->dev->power)
- sp->dev->power(on);
- }
- }
- egpiobits(EGPIO_exp_nvram_power|EGPIO_exp_full_power, 0);
- }
-}
-
-/*
* set up the cards, default timing is 300 ns
*/
static void
@@ 448,6 397,55 @@ pcmciawrite(Chan *c, void *a, long n, vlong off)
return -1; /* not reached */
}
+/*
+ * power up/down pcmcia
+ */
+void
+pcmciapower(int on)
+{
+ PCMslot *sp;
+
+ /* if there's no pcmcia sleave, no interrupts */
+iprint("pcmciapower %d\n", on);
+
+ if (on){
+ /* set timing to the default, 300 */
+ slottiming(0, 300, 300, 300, 0);
+ slottiming(1, 300, 300, 300, 0);
+
+ /* if there's no pcmcia sleave, no interrupts */
+ if(gpioregs->level & GPIO_OPT_IND_i){
+ iprint("pcmciapower: no sleeve\n");
+ return;
+ }
+
+ for (sp = slot; sp < slot + nslot; sp++){
+ if (sp->dev){
+ increfp(sp);
+ iprint("pcmciapower: %s\n", sp->verstr);
+ if (sp->dev->power)
+ sp->dev->power(on);
+ }
+ }
+ }else{
+ if(gpioregs->level & GPIO_OPT_IND_i){
+ iprint("pcmciapower: no sleeve\n");
+ return;
+ }
+
+ for (sp = slot; sp < slot + nslot; sp++){
+ if (sp->dev){
+ if (sp->dev->power)
+ sp->dev->power(on);
+ decrefp(sp);
+ }
+ sp->occupied = 0;
+ sp->cisread = 0;
+ }
+ egpiobits(EGPIO_exp_nvram_power|EGPIO_exp_full_power, 0);
+ }
+}
+
Dev pcmciadevtab = {
'y',
"pcmcia",
@@ 510,7 508,9 @@ increfp(PCMslot *sp)
nexterror();
}
+iprint("increfp %ld\n", sp - slot);
if(incref(&pcmcia) == 1){
+iprint("increfp full power\n");
egpiobits(EGPIO_exp_nvram_power|EGPIO_exp_full_power, 1);
delay(200);
egpiobits(EGPIO_pcmcia_reset, 1);
@@ 531,13 531,16 @@ increfp(PCMslot *sp)
static void
decrefp(PCMslot *sp)
{
+iprint("decrefp %ld\n", sp - slot);
decref(&sp->ref);
- if(decref(&pcmcia) == 0)
+ if(decref(&pcmcia) == 0){
+iprint("increfp power down\n");
egpiobits(EGPIO_exp_nvram_power|EGPIO_exp_full_power, 0);
+ }
}
/*
- * the regions are staticly masped
+ * the regions are staticly mapped
*/
static void
slotmap(int slotno, ulong regs, ulong attr, ulong mem)
M bitsy/power.c => bitsy/power.c +1 -1
@@ 212,7 212,7 @@ deepsleep(void) {
audiopower(1);
µcpower(1);
screenpower(1);
- // pcmciapower(1);
+ pcmciapower(1);
splx(power_pl);
return;
}
M pc/ether8139.c => pc/ether8139.c +1 -1
@@ 73,7 73,7 @@ enum { /* Imr/Isr */
PunLc = 0x0020, /* Packet Underrun or Link Change */
Fovw = 0x0040, /* Receive FIFO Overflow */
Clc = 0x2000, /* Cable Length Change */
- Timerbit = 0x4000, /* Timer */
+ Timerbit = 0x4000, /* Timer */
Serr = 0x8000, /* System Error */
};
M pc/wavelan.c => pc/wavelan.c +21 -11
@@ 471,7 471,7 @@ w_txstart(Ether* ether)
Block *bp;
int len, off;
- if((ctlr = ether->ctlr) == nil || (ctlr->state & (Attached|Power)) == 0 || ctlr->txbusy)
+ if((ctlr = ether->ctlr) == nil || (ctlr->state & (Attached|Power)) != (Attached|Power) || ctlr->txbusy)
return;
if((bp = qget(ether->oq)) == nil)
@@ 618,7 618,7 @@ w_timer(void* arg)
ctlr = (Ctlr*)ether->ctlr;
if(ctlr == 0)
break;
- if((ctlr->state & Attached) == 0)
+ if((ctlr->state & (Attached|Power)) != (Attached|Power))
continue;
ctlr->ticks++;
@@ 698,7 698,7 @@ w_detach(Ether* ether)
Ctlr* ctlr;
char name[64];
- if(ether->ctlr == 0)
+ if(ether->ctlr == nil)
return;
snprint(name, sizeof(name), "#l%dtimer", ether->ctlrno);
@@ 714,6 714,7 @@ w_detach(Ether* ether)
ctlr->state &= ~Attached;
iunlock(ctlr);
}
+ ether->ctlr = nil;
}
void
@@ 723,8 724,16 @@ w_power(Ether* ether, int on)
ctlr = (Ctlr*) ether->ctlr;
ilock(ctlr);
+iprint("w_power %d\n", on);
if(on){
if((ctlr->state & Power) == 0){
+ if (wavelanreset(ether, ctlr) < 0){
+ iprint("w_power: reset failed\n");
+ iunlock(ctlr);
+ w_detach(ether);
+ free(ctlr);
+ return;
+ }
if(ctlr->state & Attached)
w_enable(ether);
ctlr->state |= Power;
@@ 1055,9 1064,10 @@ wavelanreset(Ether* ether, Ctlr *ctlr)
{
Wltv ltv;
+ iprint("wavelanreset, iob 0x%ux\n", ctlr->iob);
w_intdis(ctlr);
if(w_cmd(ctlr,WCmdIni,0)){
- print("#l%d: init failed\n", ether->ctlrno);
+ iprint("#l%d: init failed\n", ether->ctlrno);
return -1;
}
w_intdis(ctlr);
@@ 1081,7 1091,7 @@ wavelanreset(Ether* ether, Ctlr *ctlr)
ltv.type = WTyp_Mac;
ltv.len = 4;
if(w_inltv(ctlr, <v)){
- print("#l%d: unable to read mac addr\n",
+ iprint("#l%d: unable to read mac addr\n",
ether->ctlrno);
return -1;
}
@@ 1100,7 1110,7 @@ wavelanreset(Ether* ether, Ctlr *ctlr)
ctlr->state |= Power;
// free old Ctlr struct if resetting after suspend
- if(ether->ctlr)
+ if(ether->ctlr && ether->ctlr != ctlr)
free(ether->ctlr);
// link to ether
@@ 1117,11 1127,11 @@ wavelanreset(Ether* ether, Ctlr *ctlr)
ether->multicast = w_multicast;
ether->arg = ether;
-// DEBUG("#l%d: irq %ld port %lx type %s",
-// ether->ctlrno, ether->irq, ether->port, ether->type);
-// DEBUG(" %2.2uX%2.2uX%2.2uX%2.2uX%2.2uX%2.2uX\n",
-// ether->ea[0], ether->ea[1], ether->ea[2],
-// ether->ea[3], ether->ea[4], ether->ea[5]);
+ DEBUG("#l%d: intnum %ld port %lx type %s",
+ ether->ctlrno, ether->intnum, ether->port, ether->type);
+ DEBUG(" %2.2uX%2.2uX%2.2uX%2.2uX%2.2uX%2.2uX\n",
+ ether->ea[0], ether->ea[1], ether->ea[2],
+ ether->ea[3], ether->ea[4], ether->ea[5]);
return 0;
}
M port/portdat.h => port/portdat.h +1 -0
@@ 639,6 639,7 @@ struct Proc
Lock *lockwait;
Lock *lastlock; /* debugging */
+ Lock *lastilock; /* debugging */
Mach *wired;
Mach *mp; /* machine this process last ran on */
M port/proc.c => port/proc.c +3 -1
@@ 88,7 88,9 @@ void
sched(void)
{
if(m->ilockdepth)
- panic("ilockdepth %d", m->ilockdepth);
+ panic("ilockdepth %d, last lock 0x%p at 0x%lux",
+ m->ilockdepth, up?up->lastilock:nil,
+ (up && up->lastilock)?up->lastilock->pc:0);
if(up){
if(up->nlocks && up->state != Moribund){
M port/taslock.c => port/taslock.c +2 -2
@@ 99,7 99,7 @@ ilock(Lock *l)
if(tas(&l->key) == 0){
m->ilockdepth++;
if(up)
- up->lastlock = l;
+ up->lastilock = l;
l->sr = x;
l->pc = pc;
l->p = up;
@@ 122,7 122,7 @@ ilock(Lock *l)
if(tas(&l->key) == 0){
m->ilockdepth++;
if(up)
- up->lastlock = l;
+ up->lastilock = l;
l->sr = x;
l->pc = pc;
l->p = up;