#!/bin/sh # suspend.sh copyright (c) 2002 by Charl P. Botha http://cpbotha.net/ # $Id: suspend.sh,v 1.16 2003/01/29 23:03:38 cpbotha Exp $ # shell script for suspending dri_resume/swsusp capable laptop PATH=/bin:/usr/bin:/sbin:/usr/sbin:$PATH OLDCON=`fgconsole` # make sure we are on a text VT chvt 1 # okay, store the time in the hardware clock echo "Storing time" hwclock --systohc # deactivate things which will stop us from suspending (or things that # get confused, like the mouse) # 1. 8139 eth (swsusp is supposed to handle this, but if you've been suspended # for a while, you may get "NETDEV WATCHDOG: eth0: transmit timed out" and # then no network. So, we play it safe... # because we now have wireless lan, we down all interfaces echo "Downing interfaces" ifdown -a # 2. pcmcia stuffies: with 0.15 of wlan-ng, it seems we don't have to do # this anymore. Let's keep it here just in case... #echo "Stopping PCMCIA" #/etc/init.d/pcmcia stop #rmmod ds # we remove the PCMCIA modules, else we get "cs: unable to map card memory" #rmmod yenta_socket # at resume (things did still work though) # 3. usb #echo "Stopping usb" /etc/hotplug/usb.rc stop # suspend... echo "Suspending" echo -n 4 > /proc/acpi/sleep # RESUME # put the time back hwclock --hctosys # restart usb /etc/hotplug/usb.rc start # and we restart the pcmcia #modprobe yenta_socket #modprobe ds #/etc/init.d/pcmcia start # let's not restart the PCMCIA, just get the wlan card going again # (if necessary) cd /etc/pcmcia ./wlan-ng start wlan0 # we don't start the network, because we could have moved the laptop # to somewhere without e.g. a DHCP server, thus resulting in an # unnecessary delay here... we make use of our cust scripts to perform # the location specific network/firewall/etc setup # ifup eth0 # go back to the VT we came from /usr/bin/chvt $OLDCON # and, just in case (this should be fixed in-code rather) install the MTRRs # that makes X go fast (my resume fixes don't do this, as I think swsusp # should be handling it) # update: it seems swsusp has been modified to handle this correctly now echo "base=0xf0000000 size=0x4000000 type=write-combining" >| /proc/mtrr echo "base=0xec000000 size=0x4000000 type=write-combining" >| /proc/mtrr # update2: just tested with swsusp16: it DOESN'T restore MTRRs # finally, re-do the hdparm setup: it seems that it retains its dma, # unmaskirq and 32-bit settings, but not the standby settings... # we make sure in anycase... hdparm -c1 -u1 -S 60 /dev/hda