Date: Tue, 7 May 1996 15:48:38 +0900 From: hosokawa@mt.cs.keio.ac.jp (HOSOKAWA Tatsumi) To: nate@sri.MT.net Cc: freebsd-mobile@freebsd.org, freebsd-hackers@freebsd.org, hosokawa@mt.cs.keio.ac.jp Subject: Re: [PCMCIA] pccard-test-960506 is now available! Message-ID: <199605070648.PAA23261@frig.mt.cs.keio.ac.jp> In-Reply-To: Your message of Mon, 6 May 1996 13:50:59 -0600. <199605061950.NAA18490@rocky.sri.MT.net>
next in thread | previous in thread | raw e-mail | index | archive | help
In article <199605061950.NAA18490@rocky.sri.MT.net>
nate@sri.MT.net writes:
>> This is helpful, thanks!
>>
>> However, I don't think there is any need for some (all) of the patches
>> you've made to apm.c now. Based on feedback I've got from some testers,
>> there machines no work fine w/out *any* of the patches you've added back
>> in, so it would be nice to see if you could get the Nomad testers to
>> test apm.c as it appears stock in the new SNAP. Also, some of the
>> patches you add in are completely redundant due to the changes Bruce and
>> I have made to 'apm_int()' (most noted are the cli/sti changes).
>>
>> Also, most of the changes you made to /sys/pccard.c are a step
>> backwards. I fixed them to be correct, and your patches back out my
>> fixes (slot_suspend/resume need to have void parameters for
>> timeout/untimeout, format changes, etc..).
Thank you.
Okay, I'll release bug-fix patch soon.
This is a quick-hack patch.
hosokawa
diff -crN sys.pccard-960506/i386/apm/apm.c sys/i386/apm/apm.c
*** sys.pccard-960506/i386/apm/apm.c Tue May 7 15:27:39 1996
--- sys/i386/apm/apm.c Tue May 7 12:11:52 1996
***************
*** 40,46 ****
#include <machine/apm_bios.h>
#include <machine/segments.h>
#include <machine/clock.h>
- #include <machine/laptops.h>
#include <vm/vm.h>
#include <vm/vm_param.h>
#include <vm/pmap.h>
--- 40,45 ----
***************
*** 52,63 ****
static int apm_int __P((u_long *eax, u_long *ebx, u_long *ecx));
static void apm_resume __P((void));
- #define APM_FORCE_APM10_FLAG 0x01
- #define APM_COMPAT_APM10_FLAG 0x02
- #define APM_SUSPEND_POSTPONE_FLAG 0x04
- #define APM_SUSPEND_DELAY_FLAG 0x08
- #define APM_DSVALUE_BUG_FLAG 0x10
-
/* static data */
struct apm_softc {
int initialized, active;
--- 51,56 ----
***************
*** 68,77 ****
u_int cs_limit, ds_limit;
u_int cs_entry;
u_int intversion;
- int force_apm10;
- int compat_apm10;
- int suspend_postpone;
- int suspend_delay;
struct apmhook sc_suspend;
struct apmhook sc_resume;
#ifdef DEVFS
--- 61,66 ----
***************
*** 116,122 ****
if (kdc_apm.kdc_isa)
return;
kdc_apm.kdc_state = DC_UNCONFIGURED;
- kdc_apm.kdc_description = "Advanced Power Management BIOS";
kdc_apm.kdc_unit = 0;
kdc_apm.kdc_isa = id;
dev_attach(&kdc_apm);
--- 105,110 ----
***************
*** 244,257 ****
ebx = PMDV_ALLDEV;
ecx = PMST_SUSPEND;
- __asm("cli");
if (apm_int(&eax, &ebx, &ecx)) {
- __asm("sti");
printf("Entire system suspend failure: errcode = %ld\n",
0xff & (eax >> 8));
return 1;
}
- __asm("sti");
return 0;
}
--- 232,242 ----
***************
*** 426,438 ****
static void apm_processevent(struct apm_softc *);
- static void
- apm_suspend_bug(void *dummy)
- {
- apm_resume();
- }
-
-
/*
* Public interface to the suspend/resume:
*
--- 411,416 ----
***************
*** 451,473 ****
if (sc->initialized) {
apm_execute_hook(hook[APM_HOOK_SUSPEND]);
apm_suspend_system(sc);
! /*
! * Some APM implementations needs extra delay here.
! * If the problem of your machine can be solved
! * with APM_SUSPEND_POSTPONE, please do not use
! * APM_SUSPEND_DELAY.
! *
! * HOSOKAWA, Tatsumi <hosokawa@mt.cs.keio.ac.jp>
! */
! if (sc->suspend_delay) {
! DELAY(100000);
! }
! if (!sc->suspend_postpone) {
! apm_processevent(sc);
! }
! else {
! timeout(apm_suspend_bug, NULL, 5 * hz);
! }
}
}
--- 429,435 ----
if (sc->initialized) {
apm_execute_hook(hook[APM_HOOK_SUSPEND]);
apm_suspend_system(sc);
! apm_processevent(sc);
}
}
***************
*** 677,685 ****
apm_event = apm_getevent(sc);
switch (apm_event) {
OPMEV_DEBUGMESSAGE(PMEV_STANDBYREQ);
- #ifndef APM_IGNORE_STANDBYREQ
apm_suspend();
- #endif /* !APM_IGNORE_STANDBYREQ */
break;
OPMEV_DEBUGMESSAGE(PMEV_SUSPENDREQ);
apm_suspend();
--- 639,645 ----
***************
*** 728,745 ****
{
#define APM_KERNBASE KERNBASE
struct apm_softc *sc = &apm_softc;
! caddr_t apm_bios_work = 0;
! #ifdef APM_DSVALUE_BUG
! dvp->id_flags |= APM_DSVALUE_BUG_FLAG;
! #endif /* APM_DSVALUE_BUG */
!
! if (dvp->id_flags & APM_DSVALUE_BUG_FLAG) {
! apm_bios_work = (caddr_t)malloc(apm_ds_limit, M_DEVBUF,
! M_NOWAIT);
! bcopy((caddr_t)((apm_ds_base << 4) + APM_KERNBASE),
! apm_bios_work, apm_ds_limit);
! }
sc->initialized = 0;
--- 688,700 ----
{
#define APM_KERNBASE KERNBASE
struct apm_softc *sc = &apm_softc;
! #ifdef APM_DSVALUE_BUG
! caddr_t apm_bios_work;
! apm_bioswork = (caddr_t)malloc(apm_ds_limit, M_DEVBUG, M_NOWAIT);
! bcopy((caddr_t)((apm_ds_base << 4) + APM_KERNBASE), apm_bios_work,
! apm_ds_limit);
! #endif /* APM_DSVALUE_BUG */
sc->initialized = 0;
***************
*** 754,765 ****
sc->ds_limit = apm_ds_limit;
sc->cs_entry = apm_cs_entry;
! if (!(dvp->id_flags & APM_DSVALUE_BUG_FLAG)) {
! sc->ds_base = (apm_ds_base << 4) + APM_KERNBASE;
! }
! else {
! sc->ds_base = (u_int)apm_bios_work;
! }
/* Always call HLT in idle loop */
sc->always_halt_cpu = 1;
--- 709,717 ----
sc->ds_limit = apm_ds_limit;
sc->cs_entry = apm_cs_entry;
! #ifdef APM_DSVALUE_BUG
! sc->ds_base = (u_int)apm_bios_work;
! #endif /* APM_DSVALUE_BUG */
/* Always call HLT in idle loop */
sc->always_halt_cpu = 1;
***************
*** 767,799 ****
sc->slow_idle_cpu = ((apm_flags & APM_CPUIDLE_SLOW) != 0);
sc->disabled = ((apm_flags & APM_DISABLED) != 0);
sc->disengaged = ((apm_flags & APM_DISENGAGED) != 0);
- #ifdef COMPAT_APM10
- sc->compat_apm10 = 1;
- #else /* COMPAT_APM10 */
- sc->compat_apm10 = (dvp->id_flags & APM_COMPAT_APM10_FLAG);
- #endif /* COMPAT_APM10 */
- #ifdef FORCE_APM10
- sc->force_apm10 = 1;
- #else /* FORCE_APM10 */
- sc->force_apm10 = (dvp->id_flags & APM_COMPAT_APM10_FLAG);
- if (sc->force_apm10) {
- sc->compat_apm10 = 1;
- }
- #endif /* FORCE_APM10 */
- #ifdef APM_SUSPEND_POSTPONE
- sc->suspend_postpone = 1;
- #else /* APM_SUSPEND_POSTPONE */
- sc->suspend_postpone = (dvp->id_flags & APM_SUSPEND_POSTPONE_FLAG);
- #endif /* APM_SUSPEND_POSTPONE */
- #ifdef APM_SUSPEND_DELAY
- sc->suspend_delay = 1;
- #else /* APM_SUSPEND_DELAY */
- sc->suspend_delay = (dvp->id_flags & APM_SUSPEND_DELAY_FLAG);
- #endif /* APM_SUSPEND_DELAY */
-
- if (sc->force_apm10) {
- apm_version = 0x100;
- }
/* print bootstrap messages */
#ifdef APM_DEBUG
--- 719,724 ----
***************
*** 820,884 ****
apm_addr.segment = GSEL(GAPMCODE32_SEL, SEL_KPL);
apm_addr.offset = sc->cs_entry;
! if (!sc->compat_apm10) {
! /* Try to kick bios into 1.1 mode */
! apm_driver_version();
! }
!
! if (sc->force_apm10) {
! sc->majorversion = 1;
! sc->minorversion = 0;
! }
! else {
! sc->minorversion = ((apm_version & 0x00f0) >> 4) * 10 +
! ((apm_version & 0x000f) >> 0);
! sc->majorversion = ((apm_version & 0xf000) >> 12) * 10 +
! ((apm_version & 0x0f00) >> 8);
! if (sc->majorversion > 10) { /* maybe buggy APM 1.1 */
! sc->force_apm10 = sc->compat_apm10 = 1;
! sc->majorversion = 1;
! sc->minorversion = 0;
! }
! }
sc->intversion = INTVERSION(sc->majorversion, sc->minorversion);
! if (!sc->compat_apm10) {
! if (sc->intversion >= INTVERSION(1, 1)) {
! printf("apm: Engaged control %s\n",
! is_enabled(!sc->disengaged));
! }
}
! if (sc->compat_apm10) {
! printf(" found APM BIOS version %d.%d",
! sc->majorversion, sc->minorversion);
! {
! static char string[100];
! sprintf(string, "Advanced Power Management BIOS %d.%d",
! sc->majorversion, sc->minorversion);
! if (sc->intversion >= INTVERSION(1, 1)) {
! strcat(string, " (compat-1.0 mode)");
! }
! kdc_apm.kdc_description = string;
! }
! printf("\n");
! }
! else {
! printf(" found APM BIOS version %d.%d\n",
! sc->majorversion, sc->minorversion);
! {
! static char string[100];
! sprintf(string, "Advanced Power Management BIOS %d.%d",
! sc->majorversion, sc->minorversion);
! kdc_apm.kdc_description = string;
! }
! }
! printf("apm: Slow Idling CPU %s\n", is_enabled(sc->slow_idle_cpu));
! #ifdef APM_DISABLE_BUG
! sc->disabled = 1;
! #endif /* APM_DISABLE_BUG */
/* enable power management */
if (sc->disabled) {
--- 745,781 ----
apm_addr.segment = GSEL(GAPMCODE32_SEL, SEL_KPL);
apm_addr.offset = sc->cs_entry;
! #ifdef FORCE_APM10
! apm_version = 0x100;
! sc->majorversion = 1;
! sc->minorversion = 0;
! sc->intversion = INTVERSION(sc->majorversion, sc->minorversion);
! printf("apm: running in APM 1.0 compatible mode\n");
! kcd_apm.kdc_description =
! "Advanced Power Management BIOS (1.0 compatability mode)",
! #else
! /* Try to kick bios into 1.1 or greater mode */
! apm_driver_version();
! sc->minorversion = ((apm_version & 0x00f0) >> 4) * 10 +
! ((apm_version & 0x000f) >> 0);
! sc->majorversion = ((apm_version & 0xf000) >> 12) * 10 +
! ((apm_version & 0x0f00) >> 8);
sc->intversion = INTVERSION(sc->majorversion, sc->minorversion);
! if (sc->intversion >= INTVERSION(1, 1)) {
! #ifdef APM_DEBUG
! printf("apm: Engaged control %s\n", is_enabled(!sc->disengaged));
! #endif
}
! printf("apm: found APM BIOS version %d.%d\n",
! sc->majorversion, sc->minorversion);
! #endif /* FORCE_APM10 */
! #ifdef APM_DEBUG
! printf("apm: Slow Idling CPU %s\n", is_enabled(sc->slow_idle_cpu));
! #endif
/* enable power management */
if (sc->disabled) {
***************
*** 890,896 ****
}
}
- #ifndef APM_NO_ENGAGE
/* engage power managment (APM 1.1 or later) */
if (sc->intversion >= INTVERSION(1, 1) && sc->disengaged) {
if (apm_engage_disengage_pm(sc, 1)) {
--- 787,792 ----
***************
*** 901,907 ****
#endif
}
}
- #endif /* APM_NO_ENGAGE */
/* default suspend hook */
sc->sc_suspend.ah_fun = apm_default_suspend;
--- 797,802 ----
diff -crN sys.pccard-960506/pccard/pccard.c sys/pccard/pccard.c
*** sys.pccard-960506/pccard/pccard.c Tue May 7 15:27:50 1996
--- sys/pccard/pccard.c Tue May 7 14:18:31 1996
***************
*** 56,67 ****
#include <machine/apm_bios.h>
#endif /* NAPM > 0 */
- #include <machine/pccard.h>
-
#include <pccard/card.h>
#include <pccard/driver.h>
#include <pccard/slot.h>
#include <machine/laptops.h>
extern struct kern_devconf kdc_cpu0;
--- 56,67 ----
#include <machine/apm_bios.h>
#endif /* NAPM > 0 */
#include <pccard/card.h>
#include <pccard/driver.h>
#include <pccard/slot.h>
+ #include <machine/clock.h>
+ #include <machine/pccard.h>
#include <machine/laptops.h>
extern struct kern_devconf kdc_cpu0;
***************
*** 97,104 ****
* drivers do not need to know about the hooks (or the
* data structures).
*/
! static int slot_suspend(struct slot * sp);
! static int slot_resume(struct slot * sp);
static struct apmhook s_hook[MAXSLOT]; /* APM suspend */
static struct apmhook r_hook[MAXSLOT]; /* APM resume */
#endif /* NAPM > 0 */
--- 97,104 ----
* drivers do not need to know about the hooks (or the
* data structures).
*/
! static int slot_suspend(void *sp);
! static int slot_resume(void *sp);
static struct apmhook s_hook[MAXSLOT]; /* APM suspend */
static struct apmhook r_hook[MAXSLOT]; /* APM resume */
#endif /* NAPM > 0 */
***************
*** 351,376 ****
*/
#if NAPM > 0
static int
! slot_suspend(struct slot * sp)
{
struct pccard_dev *dp;
! for (dp = sp->devices; dp; dp = dp->next) {
(void) dp->drv->suspend(dp);
! }
! if (!sp->susp_keep_pwr) {
sp->ctrl->disable(sp);
- }
return (0);
}
static int
! slot_resume(struct slot * sp)
{
#if 1
int s;
! if (sp->devices) {
s = splhigh();
disable_slot(sp);
sp->state = empty;
--- 351,376 ----
*/
#if NAPM > 0
static int
! slot_suspend(void *arg)
{
+ struct slot *sp = arg;
struct pccard_dev *dp;
! for (dp = sp->devices; dp; dp = dp->next)
(void) dp->drv->suspend(dp);
! if (!sp->susp_keep_pwr)
sp->ctrl->disable(sp);
return (0);
}
static int
! slot_resume(void *arg)
{
+ struct slot *sp = arg;
#if 1
int s;
! if (sp->state == filled) {
s = splhigh();
disable_slot(sp);
sp->state = empty;
***************
*** 454,467 ****
struct apmhook *ap;
ap = &s_hook[sp->slot];
! ap->ah_fun = (int (*)(void *))slot_suspend;
! ap->ah_arg = (void *) sp;
ap->ah_name = cp->name;
ap->ah_order = APM_MID_ORDER;
apm_hook_establish(APM_HOOK_SUSPEND, ap);
ap = &r_hook[sp->slot];
! ap->ah_fun = (int (*)(void *))slot_resume;
! ap->ah_arg = (void *) sp;
ap->ah_name = cp->name;
ap->ah_order = APM_MID_ORDER;
apm_hook_establish(APM_HOOK_RESUME, ap);
--- 454,467 ----
struct apmhook *ap;
ap = &s_hook[sp->slot];
! ap->ah_fun = slot_suspend;
! ap->ah_arg = (void *)sp;
ap->ah_name = cp->name;
ap->ah_order = APM_MID_ORDER;
apm_hook_establish(APM_HOOK_SUSPEND, ap);
ap = &r_hook[sp->slot];
! ap->ah_fun = slot_resume;
! ap->ah_arg = (void *)sp;
ap->ah_name = cp->name;
ap->ah_order = APM_MID_ORDER;
apm_hook_establish(APM_HOOK_RESUME, ap);
***************
*** 623,628 ****
--- 623,642 ----
/*
* Remove from device list on this slot.
*/
+ #if 1
+ if (sp->devices == devp) {
+ sp->devices = devp->next;
+ printf("Remove 0x%x (sp->devices = 0x%x)\n", devp, sp->devices);
+ }
+ else {
+ for (list = sp->devices; list->next; list = list->next)
+ if (list->next == devp) {
+ list->next = devp->next;
+ break;
+ }
+ printf("Remove 0x%x from chain\n", devp);
+ }
+ #else
if (sp->devices == devp)
sp->devices = devp->next;
else
***************
*** 631,636 ****
--- 645,651 ----
list->next = devp->next;
break;
}
+ #endif
/*
* Finally, free the memory space.
*/
diff -crN sys.pccard-960506/pccard/pcic.c sys/pccard/pcic.c
*** sys.pccard-960506/pccard/pcic.c Tue May 7 15:27:50 1996
--- sys/pccard/pcic.c Tue May 7 12:09:54 1996
***************
*** 86,92 ****
--- 86,94 ----
static void pcic_disable __P((struct slot *));
static void pcic_mapirq __P((struct slot *, int));
static timeout_t pcictimeout;
+ #ifdef LKM
static int pcic_handle __P((struct lkm_table *lkmtp, int cmd));
+ #endif /* LKM */
static int pcic_memory(struct slot *, int);
static int pcic_io(struct slot *, int);
***************
*** 631,637 ****
printf("pcic: failed to allocate IRQ\n");
else
printf("pcic: controller irq %d\n", pcic_irq);
-
}
/*
* Check for a card in this slot.
--- 633,638 ----
***************
*** 798,812 ****
}
slotp->insert_seq = 0;
if (sp->controller == PCIC_PD672X || sp->controller == PCIC_PD6710) {
- /*
- * OS and values of timing registers.
- *
- * SETUP0 CMD0 RECOV0 SETUP1 CMD1 RECOV1
- * Linux 0x1 0x6, 0x0, 0x1, 0xf, 0x0
- * DHU BIOS? 0x41 0x6, 0x0, 0x1, 0xf, 0x0
- * Original 0x1 0x6, 0x0, 0x1, 0x5f, 0x0
- */
-
putb(sp, PCIC_TIME_SETUP0, 0x1);
putb(sp, PCIC_TIME_CMD0, 0x6);
putb(sp, PCIC_TIME_RECOV0, 0x0);
--- 799,804 ----
diff -crN sys.pccard-960506/pccard/slot.h sys/pccard/slot.h
*** sys.pccard-960506/pccard/slot.h Tue May 7 15:27:51 1996
--- sys/pccard/slot.h Tue May 7 14:05:53 1996
***************
*** 106,118 ****
* Per-slot structure.
*/
struct slot {
! struct slot *next; /* Master list */
! int slot; /* Slot number */
! int flags; /* Slot flags (see below) */
! int rwmem; /* Read/write flags */
! int ex_sel; /* PID for select */
! int irq; /* IRQ allocated (0 = none) */
! int irqref; /* Reference count of driver IRQs */
struct pccard_dev *devices; /* List of drivers attached */
/*
* flags.
--- 106,118 ----
* Per-slot structure.
*/
struct slot {
! struct slot *next; /* Master list */
! int slot; /* Slot number */
! int flags; /* Slot flags (see below) */
! int rwmem; /* Read/write flags */
! int ex_sel; /* PID for select */
! int irq; /* IRQ allocated (0 = none) */
! int irqref; /* Reference count of driver IRQs */
struct pccard_dev *devices; /* List of drivers attached */
/*
* flags.
--
HOSOKAWA, Tatsumi E-mail: hosokawa@mt.cs.keio.ac.jp
WWW homepage: http://www.mt.cs.keio.ac.jp/person/hosokawa.html
Department of Computer Science, Keio University, Yokohama, Japan
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199605070648.PAA23261>
