From ec510cabb066488af6e05697c867f11652e96a58 Mon Sep 17 00:00:00 2001 From: Nate Williams Date: Tue, 28 Oct 1997 17:51:25 +0000 Subject: [PATCH] - Disable cards when doing a suspend by emulating that they have been removed. Add a new state 'suspend' so we 'fake' insertion events at resume time for the cards that have been suspended. [ The code still works if you remove the card during suspend, switch the card during suspend, or combinations of both. ] Reviewed by: frf@xocolatl.com --- sys/pccard/card.h | 2 +- sys/pccard/cardinfo.h | 2 +- sys/pccard/pccard.c | 19 +++++++++++-------- usr.sbin/pccard/pccardd/cardd.c | 5 ++++- 4 files changed, 17 insertions(+), 11 deletions(-) diff --git a/sys/pccard/card.h b/sys/pccard/card.h index 159a8e761761..91da7268af43 100644 --- a/sys/pccard/card.h +++ b/sys/pccard/card.h @@ -54,7 +54,7 @@ /* * Slot states for PIOCGSTATE */ -enum cardstate { noslot, empty, filled }; +enum cardstate { noslot, empty, suspend, filled }; /* * Descriptor structure for memory map. diff --git a/sys/pccard/cardinfo.h b/sys/pccard/cardinfo.h index 159a8e761761..91da7268af43 100644 --- a/sys/pccard/cardinfo.h +++ b/sys/pccard/cardinfo.h @@ -54,7 +54,7 @@ /* * Slot states for PIOCGSTATE */ -enum cardstate { noslot, empty, filled }; +enum cardstate { noslot, empty, suspend, filled }; /* * Descriptor structure for memory map. diff --git a/sys/pccard/pccard.c b/sys/pccard/pccard.c index 549f2155821b..d0507b3c23c4 100644 --- a/sys/pccard/pccard.c +++ b/sys/pccard/pccard.c @@ -372,6 +372,14 @@ slot_suspend(void *arg) { struct slot *slt = arg; + /* This code stolen from pccard_event:card_removed */ + if (slt->state == filled) { + int s = splhigh(); + disable_slot(slt); + slt->state = suspend; + splx(s); + printf("Card disabled, slot %d\n", slt->slotnum); + } slt->ctrl->disable(slt); return (0); } @@ -383,16 +391,11 @@ slot_resume(void *arg) if (pcic_resume_reset) slt->ctrl->resume(slt); - /* Fake card removal/insertion events */ - if (slt->state == filled) { - int s; - - s = splhigh(); - disable_slot(slt); + /* This code stolen from pccard_event:card_inserted */ + if (slt->state == suspend) { slt->state = empty; - splx(s); slt->insert_seq = 1; - slt->insert_ch = timeout(inserted, (void *)slt, hz); + slt->insert_ch = timeout(inserted, (void *)slt, hz/4); selwakeup(&slt->selp); } return (0); diff --git a/usr.sbin/pccard/pccardd/cardd.c b/usr.sbin/pccard/pccardd/cardd.c index e2237f3c6fd6..64c31a0feb9e 100644 --- a/usr.sbin/pccard/pccardd/cardd.c +++ b/usr.sbin/pccard/pccardd/cardd.c @@ -26,7 +26,7 @@ #ifndef lint static const char rcsid[] = - "$Id: cardd.c,v 1.18 1997/10/06 11:36:06 charnier Exp $"; + "$Id: cardd.c,v 1.19 1997/10/26 04:36:24 nate Exp $"; #endif /* not lint */ #include @@ -227,6 +227,9 @@ slot_change(struct slot *sp) case filled: card_inserted(sp); break; + case suspend: + /* ignored */ + break; } }