PATCH. apm/pty updates, credits.

C. Scott Ananian (cananian@lcs.mit.edu)
Sat, 21 Feb 1998 17:08:16 -0500 (EST)


Attached is a patch to 2.1.88 completing the APM 1.2 updates.
An early version of the APM patch got merged into 2.1.88; the attachment
brings the source tree up to date with the final version of apm_bios and
friends, including support for certain Thinkpad models by Dean Gaudet.
[This support has been well-tested in 2.0.xx kernels; I have brought the
changes forward to the 2.1 series.]

The attached patch also stomps on a warning message in tty_io.c when
CONFIG_VT is not defined. This was reported to the list a couple of days
ago.

This patch should go into 2.1.89.
--Scott
@ @
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-oOO-(_)-OOo-=-=-=-=-=
C. Scott Ananian: cananian@lcs.mit.edu / Declare the Truth boldly and
Laboratory for Computer Science/Crypto / without hindrance.
Massachusetts Institute of Technology /META-PARRESIAS AKOLUTOS:Acts 28:31
-.-. .-.. .. ..-. ..-. --- .-. -.. ... -.-. --- - - .- -. .- -. .. .- -.
PGP key available via finger and from http://www.pdos.lcs.mit.edu/~cananian

diff -ruHp -X badboys linux-2.1.88-orig/CREDITS linux-2.1.88/CREDITS
--- linux-2.1.88-orig/CREDITS Sat Feb 21 15:54:18 1998
+++ linux-2.1.88/CREDITS Sat Feb 21 16:23:40 1998
@@ -37,7 +37,8 @@ N: C. Scott Ananian
E: cananian@alumni.princeton.edu
W: http://www.pdos.lcs.mit.edu/~cananian
P: 1024/85AD9EED AD C0 49 08 91 67 DF D7 FA 04 1A EE 09 E8 44 B0
-D: pty improvements.
+D: Unix98 pty support.
+D: APM update to 1.2 spec.

N: Erik Andersen
E: andersee@debian.org
diff -ruHp -X badboys linux-2.1.88-orig/Documentation/Configure.help linux-2.1.88/Documentation/Configure.help
--- linux-2.1.88-orig/Documentation/Configure.help Thu Feb 12 15:14:14 1998
+++ linux-2.1.88/Documentation/Configure.help Sat Feb 21 16:24:01 1998
@@ -6509,6 +6509,13 @@ CONFIG_APM_POWER_OFF
powers off the computer). As with the other APM options, this
option may not work reliably with some APM BIOS implementations.

+Ignore multiple suspend/standby events
+CONFIG_APM_IGNORE_MULTIPLE_SUSPEND
+ This option is necessary on the Thinkpad 560, but should work on all
+ other laptops. When the APM BIOS returns multiple suspend or standby
+ events while one is already being processed they will be ignored.
+ Without this the Thinkpad 560 has troubles with apmd, and pcmcia-cs.
+
Watchdog Timer Support
CONFIG_WATCHDOG
If you say Y here (and to one of the following options) and create a
diff -ruHp -X badboys linux-2.1.88-orig/drivers/char/Config.in linux-2.1.88/drivers/char/Config.in
--- linux-2.1.88-orig/drivers/char/Config.in Thu Feb 12 15:11:56 1998
+++ linux-2.1.88/drivers/char/Config.in Sat Feb 21 16:02:38 1998
@@ -89,6 +89,7 @@ if [ "$CONFIG_APM" = "y" ]; then
bool ' Make CPU Idle calls when idle' CONFIG_APM_CPU_IDLE
bool ' Enable console blanking using APM' CONFIG_APM_DISPLAY_BLANK
bool ' Power off on shutdown' CONFIG_APM_POWER_OFF
+ bool ' Ignore multiple suspend' CONFIG_APM_IGNORE_MULTIPLE_SUSPEND
fi
bool 'Watchdog Timer Support' CONFIG_WATCHDOG
if [ "$CONFIG_WATCHDOG" != "n" ]; then
diff -ruHp -X badboys linux-2.1.88-orig/drivers/char/apm_bios.c linux-2.1.88/drivers/char/apm_bios.c
--- linux-2.1.88-orig/drivers/char/apm_bios.c Sat Feb 21 15:54:44 1998
+++ linux-2.1.88/drivers/char/apm_bios.c Sat Feb 21 16:18:16 1998
@@ -27,6 +27,7 @@
* Version 1.0 and 1.1
* May 1996, Version 1.2
* Feb 1998, Version 1.3
+ * Feb 1998, Version 1.4
*
* History:
* 0.6b: first version in official kernel, Linux 1.3.46
@@ -46,8 +47,11 @@
* The new replacment for it is, but Linux doesn't yet support this.
* Alan Cox Linux 2.1.55
* 1.3: Set up a valid data descriptor 0x40 for buggy BIOS's
+ * 1.4: Upgraded to support APM 1.2. Integrated ThinkPad suspend patch by
+ * Dean Gaudet <dgaudet@arctic.org>.
+ * C. Scott Ananian <cananian@alumni.princeton.edu> Linux 2.1.87
*
- * Reference:
+ * APM 1.1 Reference:
*
* Intel Corporation, Microsoft Corporation. Advanced Power Management
* (APM) BIOS Interface Specification, Revision 1.1, September 1993.
@@ -58,6 +62,15 @@
* ftp://ftp.intel.com/pub/IAL/software_specs/apmv11.doc. It is also
* available from Microsoft by calling 206.882.8080.]
*
+ * APM 1.2 Reference:
+ * Intel Corporation, Microsoft Corporation. Advanced Power Management
+ * (APM) BIOS Interface Specification, Revision 1.2, February 1996.
+ *
+ * [This document is available from Intel at:
+ * http://www.intel.com/IAL/powermgm
+ * or Microsoft at
+ * http://www.microsoft.com/windows/thirdparty/hardware/pcfuture.htm
+ * ]
*/

#include <linux/config.h>
@@ -128,6 +141,11 @@ extern unsigned long get_cmos_time(void)
* problems have been reported when using this option with gpm (if you'd
* like to debug this, please do so).
*
+ * CONFIG_APM_IGNORE_MULTIPLE_SUSPEND: The IBM TP560 bios seems to insist
+ * on returning multiple suspend/standby events whenever one occurs. We
+ * really only need one at a time, so just ignore any beyond the first.
+ * This is probably safe on most laptops.
+ *
* If you are debugging the APM support for your laptop, note that code for
* all of these options is contained in this file, so you can #define or
* #undef these on the next line to avoid recompiling the whole kernel.
@@ -341,6 +359,9 @@ static int clock_slowed = 0;
#endif
static int suspends_pending = 0;
static int standbys_pending = 0;
+#ifdef CONFIG_APM_IGNORE_MULTIPLE_SUSPEND
+static int waiting_for_resume = 0;
+#endif

static long clock_cmos_diff;
static int got_clock_diff = 0;
@@ -350,7 +371,7 @@ static struct apm_bios_struct * user_lis

static struct timer_list apm_timer;

-static char driver_version[] = "1.3"; /* no spaces */
+static char driver_version[] = "1.4"; /* no spaces */

#ifdef APM_DEBUG
static char * apm_event_name[] = {
@@ -614,8 +635,15 @@ static int queue_event(apm_event_t event
if (as == sender)
continue;
as->event_head = (as->event_head + 1) % APM_MAX_EVENTS;
- if (as->event_head == as->event_tail)
+ if (as->event_head == as->event_tail) {
+ static int notified;
+
+ if (notified == 0) {
+ printk( "apm_bios: an event queue overflowed\n" );
+ notified = 1;
+ }
as->event_tail = (as->event_tail + 1) % APM_MAX_EVENTS;
+ }
as->events[as->event_head] = event;
if (!as->suser)
continue;
@@ -722,9 +750,23 @@ static void check_events(void)
apm_event_t event;

while ((event = get_event()) != 0) {
+#ifdef APM_DEBUG
+ if (event <= NR_APM_EVENT_NAME)
+ printk(KERN_DEBUG "APM BIOS received %s notify\n",
+ apm_event_name[event - 1]);
+ else
+ printk(KERN_DEBUG "APM BIOS received unknown "
+ "event 0x%02x\n", event);
+#endif
switch (event) {
case APM_SYS_STANDBY:
case APM_USER_STANDBY:
+#ifdef CONFIG_APM_IGNORE_MULTIPLE_SUSPEND
+ if (waiting_for_resume) {
+ return;
+ }
+ waiting_for_resume = 1;
+#endif
send_event(event, APM_STANDBY_RESUME, NULL);
if (standbys_pending <= 0)
standby();
@@ -737,6 +779,12 @@ static void check_events(void)
break;
#endif
case APM_SYS_SUSPEND:
+#ifdef CONFIG_APM_IGNORE_MULTIPLE_SUSPEND
+ if (waiting_for_resume) {
+ return;
+ }
+ waiting_for_resume = 1;
+#endif
send_event(event, APM_NORMAL_RESUME, NULL);
if (suspends_pending <= 0)
suspend();
@@ -745,6 +793,9 @@ static void check_events(void)
case APM_NORMAL_RESUME:
case APM_CRITICAL_RESUME:
case APM_STANDBY_RESUME:
+#ifdef CONFIG_APM_IGNORE_MULTIPLE_SUSPEND
+ waiting_for_resume = 0;
+#endif
set_time();
send_event(event, 0, NULL);
break;
@@ -763,14 +814,6 @@ static void check_events(void)
suspend();
break;
}
-#ifdef APM_DEBUG
- if (event <= NR_APM_EVENT_NAME)
- printk(KERN_DEBUG "APM BIOS received %s notify\n",
- apm_event_name[event - 1]);
- else
- printk(KERN_DEBUG "APM BIOS received unknown event 0x%02x\n",
- event);
-#endif
}
}

diff -ruHp -X badboys linux-2.1.88-orig/drivers/char/tty_io.c linux-2.1.88/drivers/char/tty_io.c
--- linux-2.1.88-orig/drivers/char/tty_io.c Sat Feb 21 15:09:31 1998
+++ linux-2.1.88/drivers/char/tty_io.c Sat Feb 21 16:12:53 1998
@@ -1961,8 +1961,10 @@ long console_init(long kmem_start, long
return kmem_start;
}

-static struct tty_driver dev_tty_driver, dev_console_driver,
- dev_syscons_driver, dev_ptmx_driver;
+static struct tty_driver dev_tty_driver, dev_syscons_driver, dev_ptmx_driver;
+#ifdef CONFIG_VT
+static struct tty_driver dev_console_driver;
+#endif

/*
* Ok, now we can initialize the rest of the tty devices and can count

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu