nvram-wakup-1.1/0000755000175000017500000000000011327032545013151 5ustar tobiastobiasnvram-wakup-1.1/set_timer0000755000175000017500000000614611112255100015063 0ustar tobiastobias#!/bin/bash # # $Id: set_timer 908 2008-11-23 13:29:13Z tiber $ # # This script was made by Hans-Hermann Redenius (redenius@gmx.de) # # This file is for bioses nvram-wakeup couldn't handle, because there is # no possibility to change the Wake on RTC time in the nvram # The wake up time must be set to 23:59:59 the day must be set to 31 # if your board supports a month setting for the wakeup, set it to July # # The System should not update the hardware clock in the shutdown process. # In Debian Woody set HWCLOCKACCESS=no in /etc/default/rcS # # in vdrshutdown replace: # # $NVRAMCMD -ls $1 # # by # # $PATH_TO_SET_TIMER/set_timer $1 $2 # # and add the following line to your start script before vdr is started # # $PATH_TO_SET_TIMER/set_timer # # The time command from nvram-wakeup is needed (set the path bwlow) # # Thanks to Sergei Haller for nvram-wakeup and the time and ideas to develop # this script # programs to use: HWCLOCK=/sbin/hwclock TIME=/usr/local/sbin/time # files to use: TIME_DIFF=/video/time_diff if [ ! -x $HWCLOCK ] ; then echo "$0 needs hwclock" exit 1 fi if [ ! -x $TIME ] ; then echo "$0 needs the time command from nvram-wakeup" exit 1 fi # current time cur_time=`date +%s` # how many seconds before the next event the system should be booted boot_time=300 # if a time_diff file exists the clock is set to the wakeup time and # must be fixed before any further action # if [ -f $TIME_DIFF ] ; then # the difference stored time_diff=`cat $TIME_DIFF` # add the difference to the curent time and change it in the date format set_time=$(( $cur_time + $time_diff )) set_date=`$TIME $set_time | grep "^(local" | cut -f2- -d')' ` # restore the correct time and if all is right remove the $TIME_DIFF file # because there is no longer a difference $HWCLOCK --set --date "$set_date" && $HWCLOCK --hctosys && rm $TIME_DIFF fi # if there is a parameter given, it is assumed the system schould boot # after $boot_time seconds if [ -n "$2" ] ; then if [ $1 -eq 0 ] ; then # no timer present sleep_time=$(( 61 * 24 * 60 * 60 - 1 + $boot_time )) # 61 days - 1s # + boot_time else # timer present if [ $2 -ge $(( $boot_time + 30 )) ] ; then # need 30 seconds for shutdown sleep_time=$2 else sleep_time=$(( $boot_time + 30 )) # or exit 1 so vdrshutdown would do nothing # because the next timer is less than boot_time + 30 seconds in the future # or currently recording # I suggest a short timeout, because the user really asked for it fi fi # wakeup time wake_time=996616799 # date -d "Jul 31 23:59:59 2001" +%s # calculate the right time and the time difference set_time=$(( $wake_time - $sleep_time + $boot_time )) time_diff=$(( $cur_time - $set_time )) # convert time to date format set_date=`$TIME $set_time | grep "^(local" | cut -f2- -d')' ` # set date and if it is correct write the time_diff file # date --set="$set_date" && \ # add this if a script updates the hwclock $HWCLOCK --set --date "$set_date" && echo $time_diff > $TIME_DIFF fi nvram-wakup-1.1/HISTORY0000644000175000017500000004540411327032316014240 0ustar tobiastobias NVRAM-WakeUp Revision History $Id: HISTORY 926 2010-01-24 11:53:49Z tiber $ + denotes a new feature * denotes a bugfix/some change - denotes a removed feature 2010-01-24: Version 1.1 * Some minor documentation tweaks (Closes http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=484929) * Check if ~/guess-nvram-module exists, before running guess in guess-helper (Closes http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=484929) + Added new boards - Gigabyte G31M-S2L (http://sourceforge.net/tracker/index.php?func=detail&aid=2810386&group_id=35022&atid=412959) - ASRock G31DE - ID: 2799023 (http://sourceforge.net/tracker/?func=detail&aid=2799023&group_id=35022&atid=412959) - GA-E7AUM-DS2H (http://sourceforge.net/tracker/?func=detail&aid=2794688&group_id=35022&atid=412959) - Gigabyte EX58-UD5 (http://sourceforge.net/tracker/?func=detail&aid=2834010&group_id=35022&atid=412959) - ASRock P45TS (http://sourceforge.net/tracker/?func=detail&aid=2826826&group_id=35022&atid=412959) - Leadtek WinFast nVidia CR18D/G (http://sourceforge.net/tracker/?func=detail&aid=2824513&group_id=35022&atid=412959) - ASUS P4P800-E Deluxe rv. 1009 (http://sourceforge.net/tracker/?func=detail&aid=2816578&group_id=35022&atid=412959) - Commell LV-676 (http://sourceforge.net/tracker/?func=detail&aid=2881988&group_id=35022&atid=412959) - MSI G31 M3-F (http://sourceforge.net/tracker/?func=detail&aid=2847240&group_id=35022&atid=412959) - ASRock N68-S (http://sourceforge.net/tracker/?func=detail&aid=2846328&group_id=35022&atid=412959) - ASRock K7VT4APro (http://sourceforge.net/tracker/?func=detail&aid=2834322&group_id=35022&atid=412959) - ASRock N68-S, Bios Version P2.00 (http://sourceforge.net/tracker/?func=detail&aid=2921130&group_id=35022&atid=412959) - ASUSTeK Computer INC. P5QC (http://sourceforge.net/tracker/?func=detail&aid=2920376&group_id=35022&atid=412959) - Shuttle Inc FN78S V10 (http://sourceforge.net/tracker/?func=detail&aid=2910300&group_id=35022&atid=412959) - ASRock G41M-GS (http://sourceforge.net/tracker/?func=detail&aid=2907630&group_id=35022&atid=412959) - VIA KM400-8237 (http://sourceforge.net/tracker/?func=detail&aid=2921850&group_id=35022&atid=412959) - ASUS P5LD2 Deluxe (http://sourceforge.net/tracker/?func=detail&aid=2923487&group_id=35022&atid=412959) - Biostar M7VIG-PRO (ok, no reboot needed) (http://sourceforge.net/tracker/?func=detail&aid=2924202&group_id=35022&atid=412959) 2008-11-23: Version 1.0 * Fixed a 1-byte buffer overflow in xxd() Patch provided by Kees Cook (Closes: http://sourceforge.net/tracker/?func=detail&aid=2782757&group_id=35022&atid=412755) (Closes: http://bugs.edge.launchpad.net/bugs/370261) (Closes: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=529074) + Added new boards - Shuttle FN45 (Shuttle XPC SN45G Barebone) (http://sourceforge.net/tracker/?func=detail&aid=2725339&group_id=35022&atid=412959) - Asus M3A78-EM (http://sourceforge.net/tracker/?func=detail&aid=2689458&group_id=35022&atid=412959) - ASUS M2N-SLI DELUXE (https://sourceforge.net/tracker/?func=detail&aid=2686287&group_id=35022&atid=412959) - Gigabyte GA-M68SM-S2L (http://sourceforge.net/tracker/?func=detail&aid=2635404&group_id=35022&atid=412959) (http://sourceforge.net/tracker/?func=detail&aid=2635295&group_id=35022&atid=412959) - MSI K8MM3-V (MS-7181) (http://sourceforge.net/tracker/index.php?func=detail&aid=2635366&group_id=35022&atid=412959) - AOpen i855GMEm-LFS (http://sourceforge.net/tracker/?func=detail&aid=2568568&group_id=35022&atid=412959) - Gigabyte EG45M-DS2H (http://sourceforge.net/tracker/?func=detail&aid=2564249&group_id=35022&atid=412959) - ASRock P43R1600Twins-WiFi P1.90 (http://sourceforge.net/tracker/?func=detail&aid=2482357&group_id=35022&atid=412959) - HP Vectra VL420 A06, A08 (https://sourceforge.net/tracker/?func=detail&aid=1728527&group_id=35022&atid=412959) 2008-11-23: Version 0.99 (beta) * Dropped -march=i686 CFLAG, so that nvram-wakeup compiles on AMD64 out of the box * Use boards.yaml to manage all board configurations and just generate the C code formerly used in nvram-wakeup-mb.c from this file + Added new boards: - Dell OptiPlex GX260 as provided by Petter Reinholdtsen (http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=484680) - MSI MS-6734 09/03/2004 (http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=433929) - Micro Star MS-7125 (http://sourceforge.net/tracker/index.php?func=detail&aid=1564608&group_id=35022&atid=412959) - Gigabyte GA-M55PLUS-S3G (http://sourceforge.net/tracker/index.php?func=detail&aid=1591669&group_id=35022&atid=412959) - AOpen EA65-II (http://sourceforge.net/tracker/index.php?func=detail&aid=1604006&group_id=35022&atid=412959) - ASUS A8N-VM CSM (config file only - no autodetect due to duplicate DMI entries!) (http://sourceforge.net/tracker/index.php?func=detail&aid=1539163&group_id=35022&atid=412959) - ASUS A8N-E 2.XX (http://sourceforge.net/tracker/index.php?func=detail&aid=1604940&group_id=35022&atid=412959) - Micro Star MS-7204 (http://sourceforge.net/tracker/index.php?func=detail&aid=1628899&group_id=35022&atid=412959) - ASRock ALiveNF7G-FullHD (http://sourceforge.net/tracker/index.php?func=detail&aid=2043063&group_id=35022&atid=412959) - Gigabyte GA-K8NF9 (http://sourceforge.net/tracker/index.php?func=detail&aid=1982502&group_id=35022&atid=412959) - PCChips m748lmrt (http://sourceforge.net/tracker/index.php?func=detail&aid=1913268&group_id=35022&atid=412959) - Gigabyte P35-DS3 (http://sourceforge.net/tracker/index.php?func=detail&aid=1911833&group_id=35022&atid=412959) - Asrock 4Core1333-eSATA2 BIOS P1.30 (http://sourceforge.net/tracker/index.php?func=detail&aid=1900791&group_id=35022&atid=412959) - AOpen i945GMt-FSA (http://sourceforge.net/tracker/index.php?func=detail&aid=1875412&group_id=35022&atid=412959) - Asrock AM2NF3-VSTA P2.30 (http://sourceforge.net/tracker/index.php?func=detail&aid=1848862&group_id=35022&atid=412959) - MICRO-STAR MS-6728 (http://sourceforge.net/tracker/index.php?func=detail&aid=1821547&group_id=35022&atid=412959) - AsRock ConRoeXFire-eSATA2 (http://sourceforge.net/tracker/index.php?func=detail&aid=1805113&group_id=35022&atid=412959) - AsRock AM2NF3-VSTA P2.00 (http://sourceforge.net/tracker/index.php?func=detail&aid=1804477&group_id=35022&atid=412959) - MSI K8N Neo4-F MS7125 (http://sourceforge.net/tracker/index.php?func=detail&aid=1782399&group_id=35022&atid=412959) - DFI NF4 Lanparty Ultra-D (http://sourceforge.net/tracker/index.php?func=detail&aid=1782397&group_id=35022&atid=412959) - Asrock 775Dual-VSTA with BIOS versions 2.10 and 2.90 (http://sourceforge.net/tracker/index.php?func=detail&aid=1765755&group_id=35022&atid=412959) - DFI Infinity Ultra-U (http://sourceforge.net/tracker/index.php?func=detail&aid=1682947&group_id=35022&atid=412959) - ECS M830LR (http://sourceforge.net/tracker/index.php?func=detail&aid=1766813&group_id=35022&atid=412959) - HP Vectra VL420 (http://sourceforge.net/tracker/index.php?func=detail&aid=1728527&group_id=35022&atid=412959) - Asrock 4CoreDual-VSTA (http://sourceforge.net/tracker/index.php?func=detail&aid=1721485&group_id=35022&atid=412959) - Gigabyte 8I945GZME-RH (http://sourceforge.net/tracker/index.php?func=detail&aid=1666781&group_id=35022&atid=412959) - FX43G with 03/17/2005 BIOS update (http://sourceforge.net/tracker/index.php?func=detail&aid=1664911&group_id=35022&atid=412959) - ASUS P5LD2 (http://sourceforge.net/tracker/index.php?func=detail&aid=1640421&group_id=35022&atid=412959) - K7NF2-RAID (L1.12 and P1.30) (http://sourceforge.net/tracker/index.php?func=detail&aid=1634632&group_id=35022&atid=412959) (http://www.vdr-portal.de/board/thread.php?postid=466399#post466399) - ASUS P5PE-VM (http://sourceforge.net/tracker/index.php?func=detail&aid=1634627&group_id=35022&atid=412959) - Shuttle XPC SB83G5M (http://sourceforge.net/tracker/index.php?func=detail&aid=1534740&group_id=35022&atid=412756) - ASRock AM2NF3-VSTA Bios P2.40 (http://sourceforge.net/tracker/index.php?func=detail&aid=1886735&group_id=35022&atid=412959) - Gigabyte M61P-S3 (http://sourceforge.net/tracker/index.php?func=detail&aid=2253979&group_id=35022&atid=412959) - ASROCK K8NF4G-SATA2 v1.00 / BIOS v P1.70 (http://sourceforge.net/tracker/index.php?func=detail&aid=2124432&group_id=35022&atid=412755) + Added option -n / --nocheck to disable checking if the time is at least 10 minutes in the future. This option maybe especially useful, when testing nvram-wakeup. Suggested by Holger Kubiak - closes (http://sourceforge.net/tracker/index.php?func=detail&aid=1502552&group_id=35022&atid=412757) + Added option -w to allow to configure the wake up ahead time span via the command line * Dropped debian/ dir (Please use the Debian sources instead!) 2005-??-??: Version 0.98 (beta) + Added several new mainboards. See CVS logs for details and credits. Thanks to everyone who sent me his/her board configuration. + Small change in guess-helper: Step4-file (01.00.00.00-) will not be overwritten, when guess-helper is called again after the last step. 2004-07-21: Version 0.97 (beta) + Added support for upper nvram on boards with VIA's VT8233 south bridges. + Added two new configuration file options: chk_method and day_no_bcd (see 'man nvram-wakeup.conf' for more information) + Added man pages for all helper programs and scripts. * Renamed guess-helper.sh to guess-helper. * Fixed a minor bug in the time helper command. + Added several new mainboards. See CVS logs for details and credits. Thanks to everyone who sent me his/her board configuration. 2004-05-22: Version 0.96 (beta) + Added support for upper nvram on boards with VIA's VT8235/37 south bridges. + Added support for upper nvram on boards with nVidia nForce2 chipset. + Added support for upper nvram on boards with ATI RADEON 9100 IGP (=RS300) chipset. + Added several new mainboards. See CVS logs for details and credits. Thanks to everyone who sent me his/her board configuration. + Added a few more examples to be used by hand in the man page. 2004-04-06: Version 0.95a (beta) * two small bugs in guess and guess-helper were fixed. + Added several new mainboards. See CVS logs for details and credits. Thanks to everyone who sent me his/her board configuration. 2004-02-29: Version 0.95 (beta) "Feb 29th - release" * IMPORTANT: the various _date fields changed to _day. _date configuration options are accepted but will be removed in one of the next versions. * IMPORTANT: need_reboot=ALWAYS was changed to need_reboot=ON_ANY_CHANGE since it produced some confusion on the meaning. The value ALWAYS is still accepted but will be removed in one of the next versions. + Added a new option --directisa. This is an alternative for using /dev/nvram See man page for more information. + Added support for upper nvram on boards with Intel's ICH* south bridges, VIA's VT82C686A, VT82C686B, VT82C596 and south bridges with Dallas Semiconductor's DS1685/1687. + Added a LOT of new mainboards and updated/added a LOT of new autodetection strings. See CVS logs for details and credits. Thanks to everyone who sent me his/her board configuration. + Added guess-helper script (by Tobias Grimm), see README.mb for more details. 2003-08-07: Version 0.91 (beta) * IMPORTANT: the option --iwstring is now called --iwname. * Changed `guess' to produce output in configuration file format. + Added a LOT of new mainboards and updated/added a LOT of new autodetection strings. See CVS logs for details and credits. Thanks to everyone who sent me his/her board configuration. * Updated man pages, preventing triggering a bug in troff 1.17.2 + Added some debug output here and there * The vdrshutdown script now supports checks for non-shotdown-conditions like - users are logged in - some process (like movie conversion) is running - whatever else. This conditions are freely configurable. look into the script vdrshutdown for more info. * the reboot images and patches are moved to a separate "package" -- just a tar file 2003-03-04: Version 0.90 (beta) "Birthday release" + Added support for configuration files. (option -C|--configfile) + Added a manual page for the configuration file. + Added support for mainboard autodetection (contributed by Bernhard "Bero" Rosenkraenzer ) this feature uses code from the dmidecode program (https://savannah.nongnu.org/projects/dmidecode/) - got rid of ACTUALLY_WRITE + now write by default. A new option (-N/--nowrite) emulates the old ACTUALLY_WRITE=OFF behaviour. 2003-03-04: Version 0.05 (stable) "Birthday release" + Added several new mainboards. See nvram-wakeup-mb.h for details and credits. Thanks to everyone who sent me his/her board configuration. 2002-04-14: Version 0.04b (beta) + Added several new mainboards. See nvram-wakeup-mb.h for details and credits. Thanks to everyone who sent me his/her board configuration. + Added a new configuration option ADDR_WDAYS to nvram-wakeup-mb.h. It seems that there are boards storing the weekday instead of a date. * Now really fixed the problem with the daylight savings. (I should have read ftp://ftp.gnu.org/pub/gnu/Manuals/glibc/pdf/libc.pdf earlier) 2002-04-03: Version 0.04a (beta) * Fixed the problem with the daylight savings. * Some mainboard updates. See nvram-wakeup-mb.h for details and credits. Thanks to everyone who sent me his/her board configuration. 2002-03-24: Version 0.04 (beta) * IMPORTANT: It turned out that not only the MSI boards need to be rebooted after making a change, but also some other boards in special cases. Therefore the exit states are changed. Now we have: 0 - successful, everything is set properly. don't need to reboot. 1 - successful, everything is set properly. must reboot the changes to take effect. 2 - error occurred. something went wrong. the script vdrshutdown is changed accordingly, but if you're using your own script, you have to look at it. * Completely rewritten many parts of the main program. + We can handle the case now where more than one information (e.g. date and status) is stored in the same byte at different bits. + Started using debug mode for printing debug messages. * Added/Removed/Changed several options in nvram-wakeup-mb.h and added a more detailed documentation of them at the beginning of the file. (See into nvram-wakeup-mb.h for more information.) + Added some more intelligence to `guess'. (still consider `guess' alpha quality) + Added a new rule `devices' to Makefile. It creates /dev/nvram and /dev/rtc if they are missing. + Print rtc time before setting it. (was just forgotten in ver. 0.03) + Added several new mainboards. See nvram-wakeup-mb.h for details and credits. Thanks to everyone who sent me his/her board configuration. + Added support for storing month. (only for the boards with a BIOS which supports it) * Replaced RUN_BEFORE by NEED_TO_SHTDWN, which has a slightly different meaning (see README or nvram-wakeup.h for more details). + Added a new rule to Makefile: install. (The user has to adjust paths in Makefile before installing) * /dev/nvram and /dev/rtc are never opened at the same time now, (this prevented some machines from halting by `halt -p') Thanks to Dr. Werner Fink for the hint. * Don't need write permissions for /dev/nvram if no -s/-d parameter was specified or ACTUALLY_WRITE==OFF 2002-02-04: BUGFIX * Fixed the BCD bug introduced in Version 0.03 2002-02-01: Version 0.03 (beta) * Moved the ACTUALLY_WRITE from nvram-wakeup.h to Makefile + Added a bunch of new boards. See nvram-wakeup-mb.h for details and credits. Thanks to everyone who sent me his/her board configuration. + Added new mb parameters NEED_RTC, RESET_DATE, BCD + Adapted nvram-wakeup to use the BCD notation used on some boards. + README.mb is a new document containing information about how to figure out the addresses of the stored values. + Autodetecting if CMOS clock runs at GMT or local time. Thanks to Dr. Werner Fink * Now we require both nvram and rtc drivers (we need the latter one for detecting if the rtc clock is running in localtime or UTC/GMT) + Added a new command line option: -D (--debug). It enables printing of debug messages. (not many of them now) + New command line option -l (--syslog) to pass all output to syslog. + The vdrshutdown script now makes use of the new -l (--syslog) command line option. + Introduced the variable RUN_BEFORE to use instead of 2*WAKEUP_BEFORE in several places. Now the two things are independant. + Now I tested boot.diff on a SuSE 7.2 system. + If there wouldn't be changed anything in nvram, don't write into it. * Now the exit status is always one of the following: 0 - Successfully finished 1 - We had to set (disable/enable) the wakeup date and time, but they were already set to proper values. We didn't write them again. 2 - Some error occurred. + Modified the script vdrshutdown to take advantage of the new exit status of nvram-wakeup. Especially useful on MSI MS-6351, where you have to reboot after changing nvram. + Added a new program `guess', which should help to retrieve the addresses in nvram guessing them from four given states. Consider this program to be alpha quality. + Added a new program `rtc', the only thing it does: It prints the currently set RTC alarm time. + Added a man page and a new `man' rule in the Makefile + Added a HISTORY file (actually, you are reading it at the moment). 2001-10-17: Version 0.02 (never released). + Added support for clocks running in UTC/GMT time. + Added some new motherboards. * rewritten calculate_read and calculate_write to be more human readable Thanks to Leiser for the idea. 2001-10-10: Version 0.01 (Initial revision). + Could read/write wakeup time via /dev/nvram. + Predefined configurations for two motherboards: MSI MS-6351 and Biostar M6VCG + Accepts command line options -s (--settime), -d (--disable), -h (--help), -v (--version). 2001-08-17: The idea was born + There was a discussion on the linux-dvb mailinglist about ways to poweron a PC automatically. + The message by Frank Klingenhoefer : http://linuxtv.org/mailinglists/linux-dvb/2001/08-2001/msg00457.html (and a following off-list discussion with him and Hans-Hermann Redenius ) gave me the idea to write some small program for setting the Wakeup feature. nvram-wakup-1.1/nvram-wakeup.c0000644000175000017500000012342311112233333015725 0ustar tobiastobias/* * NVRAM WakeUp * Copyright (C) 2001-2005, Sergei Haller. * * $Id: nvram-wakeup.c 902 2008-09-19 20:29:46Z tiber $ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ #define CVSREV_nvram_wakeup_c \ "$Id: nvram-wakeup.c 902 2008-09-19 20:29:46Z tiber $" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "nvram-wakeup.h" /* Use bcd2bin if necessary... */ #define FROMBCD(x) (b.bcd ? bcd2bin(x) : x) #define TOBCD(x) (b.bcd ? bin2bcd(x) : x) /* this one is special for the addr_day ... */ #define FROM_D_BCD(x) (b.bcd & !b.day_no_bcd ? bcd2bin(x) : x) #define TO_D_BCD(x) (b.bcd & !b.day_no_bcd ? bin2bcd(x) : x) #include "cvs_revs.h" static int handle_cmdline(int *argc, char ***argv); static time_t vdr_abs_time_t = -1; unsigned char oBytes[MAXNVRAMSIZE]; unsigned char nBytes[MAXNVRAMSIZE]; int nvramSize = 0; /* the real size of nvram (will become 114 in most cases) */ long int wakeupbefore = WAKEUP_BEFORE; char * _config_file = NULL; char * _iw_string = NULL; int _nowrite = OFF; int _directisa = OFF; int _check_time = ON; struct biosinfo b; int assign_byte( unsigned char **oPtr, unsigned char **nPtr, const unsigned int addr, const char *str) { if (addr < nvramSize) { *oPtr = &oBytes[addr]; *nPtr = &nBytes[addr]; nvprintf(LOG_DEBUG, "value of the %-12s byte is: 0x%02X.\n", str, **oPtr); return 0; } else { nvprintf(LOG_ERR, "%s (0x%02X) is beyond the end of nvram\n", str, addr); if (_directisa == OFF) nvprintf(LOG_ERR, "You might want to use the --directisa command line option.\n"); return 1; } } int main(int argc, char **argv) { int retval; int addr, changed = 0, need_reboot = 0; unsigned char *oChkH, *oChkL; unsigned char *nChkH, *nChkL; unsigned int oChk=0, nChk=0; unsigned char *oChkH2, *oChkL2; unsigned char *nChkH2, *nChkL2; unsigned int oChk2=0, nChk2=0; unsigned char *oStat, *nStat; unsigned char *oMon, *nMon; unsigned char *oDay, *nDay; unsigned char *oWdays, *nWdays; unsigned char *oHour, *nHour; unsigned char *oMin, *nMin; unsigned char *oSec, *nSec; unsigned char *oRtcDay, *nRtcDay; unsigned char *oRtcMon, *nRtcMon; struct rtc_time oRtc_tm, nRtc_tm; struct tm vdr_abs_tm; struct tm *(*get_the_time)(const time_t *); time_t now; /* learn who we really are */ set_progname(argv[0]); /* handle the commandline */ handle_cmdline(&argc, &argv); /* get bios info first... */ if (_config_file) { /* read config file */ if (!readconf(&b, _config_file)) { nvprintf(LOG_ERR, "Reading configuration file returned with errors.\n"); exit(2); } } else if (_iw_string) { /* get corresponding config */ if (!get_bios_info_by_iw(&b, _iw_string)) { nvprintf(LOG_ERR, "Infowriter '%s' not found.\n", _iw_string); exit(2); } } else { switch (get_bios_info_by_dmi(&b)) { case -1: /* all errors already printed */ exit(2); break; case 0: nvprintf(LOG_ERR, "Your mainboard is currently not supported.\n" ); nvprintf(LOG_ERR, "Please try determining the addresses and sending the following\n"); nvprintf(LOG_ERR, "information back to the maintainers:\n" ); nvprintf(LOG_ERR, " - The addresses you found out (read README.mb)\n" ); nvprintf(LOG_ERR, " - Mainboard vendor: %s%s%s\n", QUOTE(board_vendor() ), VALUE(board_vendor() ), QUOTE(board_vendor() ) ); nvprintf(LOG_ERR, " - Mainboard type: %s%s%s\n", QUOTE(board_type() ), VALUE(board_type() ), QUOTE(board_type() ) ); nvprintf(LOG_ERR, " - Mainboard revision: %s%s%s\n", QUOTE(board_version()), VALUE(board_version()), QUOTE(board_version()) ); nvprintf(LOG_ERR, " - BIOS vendor: %s%s%s\n", QUOTE(bios_vendor() ), VALUE(bios_vendor() ), QUOTE(bios_vendor() ) ); nvprintf(LOG_ERR, " - BIOS version: %s%s%s\n", QUOTE(bios_version() ), VALUE(bios_version() ), QUOTE(bios_version() ) ); nvprintf(LOG_ERR, " - BIOS release: %s%s%s\n", QUOTE(bios_release() ), VALUE(bios_release() ), QUOTE(bios_release() ) ); exit(2); break; case 1: break; /* everything is ok. doing nothing */ } } nvprintf(LOG_DEBUG, "Using following bios info:\n" ); nvprintf(LOG_DEBUG, " need_reboot = %d\n", b.need_reboot ); nvprintf(LOG_DEBUG, " addr_chk_h = 0x%02X\n", b.addr_chk_h ); nvprintf(LOG_DEBUG, " addr_chk_l = 0x%02X\n", b.addr_chk_l ); nvprintf(LOG_DEBUG, " addr_chk_h2 = 0x%02X\n", b.addr_chk_h2 ); nvprintf(LOG_DEBUG, " addr_chk_l2 = 0x%02X\n", b.addr_chk_l2 ); nvprintf(LOG_DEBUG, " addr_stat = 0x%02X\n", b.addr_stat ); nvprintf(LOG_DEBUG, " addr_mon = 0x%02X\n", b.addr_mon ); nvprintf(LOG_DEBUG, " addr_day = 0x%02X\n", b.addr_day ); nvprintf(LOG_DEBUG, " addr_wdays = 0x%02X\n", b.addr_wdays ); nvprintf(LOG_DEBUG, " addr_hour = 0x%02X\n", b.addr_hour ); nvprintf(LOG_DEBUG, " addr_min = 0x%02X\n", b.addr_min ); nvprintf(LOG_DEBUG, " addr_sec = 0x%02X\n", b.addr_sec ); nvprintf(LOG_DEBUG, " shift_stat = %d\n", b.shift_stat ); nvprintf(LOG_DEBUG, " shift_mon = %d\n", b.shift_mon ); nvprintf(LOG_DEBUG, " shift_day = %d\n", b.shift_day ); nvprintf(LOG_DEBUG, " shift_wdays = %d\n", b.shift_wdays ); nvprintf(LOG_DEBUG, " shift_hour = %d\n", b.shift_hour ); nvprintf(LOG_DEBUG, " shift_min = %d\n", b.shift_min ); nvprintf(LOG_DEBUG, " shift_sec = %d\n", b.shift_sec ); nvprintf(LOG_DEBUG, " rtc_time = %d\n", b.rtc_time ); nvprintf(LOG_DEBUG, " rtc_day = 0x%02X\n", b.rtc_day ); nvprintf(LOG_DEBUG, " rtc_mon = 0x%02X\n", b.rtc_mon ); nvprintf(LOG_DEBUG, " rtc_day_0_is_c0 = %d\n", b.rtc_day_0_is_c0 ); nvprintf(LOG_DEBUG, " rtc_mon_0_is_c0 = %d\n", b.rtc_mon_0_is_c0 ); nvprintf(LOG_DEBUG, " reset_day = %d\n", b.reset_day ); nvprintf(LOG_DEBUG, " reset_mon = %d\n", b.reset_mon ); nvprintf(LOG_DEBUG, " nr_stat = %d\n", b.nr_stat ); nvprintf(LOG_DEBUG, " nr_mon = %d\n", b.nr_mon ); nvprintf(LOG_DEBUG, " nr_day = %d\n", b.nr_day ); nvprintf(LOG_DEBUG, " nr_hour = %d\n", b.nr_hour ); nvprintf(LOG_DEBUG, " nr_min = %d\n", b.nr_min ); nvprintf(LOG_DEBUG, " nr_sec = %d\n", b.nr_sec ); nvprintf(LOG_DEBUG, " nr_rtc_day = %d\n", b.nr_rtc_day ); nvprintf(LOG_DEBUG, " nr_rtc_mon = %d\n", b.nr_rtc_mon ); nvprintf(LOG_DEBUG, " nr_wdays = %d\n", b.nr_wdays ); nvprintf(LOG_DEBUG, " bcd = %d\n", b.bcd ); nvprintf(LOG_DEBUG, " day_hack = %d\n", b.day_hack ); nvprintf(LOG_DEBUG, " upper_method = %d\n", b.upper_method ); nvprintf(LOG_DEBUG, " chk_method = %d\n", b.chk_method ); if (b.chk_method == FSC) { nvprintf(LOG_ERR, "Checksum algorithm by FSC is unsupported!\n"); exit(2); } /* open the rtc device */ nvprintf(LOG_DEBUG, "Opening %s in O_RDONLY mode...\n", RTC_DEV); fd_rtc = open(RTC_DEV, O_RDONLY); if (fd_rtc == -1) { nvprintf(LOG_ERR, "%s: %m\n", RTC_DEV); exit(2); } /* First, we have to know if the hardware clock runs local or UTC/GMT time */ switch (compare_ltm_rtc()) { case -1: get_the_time = NULL; nvprintf(LOG_ERR, "RTC is not synchronously with system time!\n"); nvprintf(LOG_ERR, "RTC isn't running in localtime nor in UTC/GMT time!\n"); exit(2); break; case 0: get_the_time = localtime; nvprintf(LOG_DEBUG, "RTC is running in localtime!\n"); break; case 1: get_the_time = gmtime; nvprintf(LOG_DEBUG, "RTC is running in UTC/GMT!\n"); break; default: get_the_time = NULL; exit(2); break; } now = time(NULL); nvprintf(LOG_DEBUG, "Test (this should be the current time of the hardware clock): %s", asctime((*get_the_time)(&now))); /* close the rtc device again */ close(fd_rtc); /* Fill oBytes with 0s */ memset(oBytes, 0, sizeof(oBytes)); /* Now we read whole nvram ... */ open_nvram(_directisa, O_RDONLY); nvramSize = read_whole_nvram(_directisa, b.upper_method, oBytes); close_nvram(_directisa); /* print a nice xxd-like table of nvram */ xxd(oBytes, nvramSize, LOG_DEBUG); /* Copy whole contents of oBytes to nBytes */ memcpy(nBytes, oBytes, sizeof(oBytes)); if (b.addr_stat && assign_byte(&oStat, &nStat, b.addr_stat, "addr_stat" )) exit(2); if (b.addr_mon && assign_byte(&oMon, &nMon, b.addr_mon, "addr_mon" )) exit(2); if (b.addr_day && assign_byte(&oDay, &nDay, b.addr_day, "addr_day" )) exit(2); if (b.addr_wdays && assign_byte(&oWdays, &nWdays, b.addr_wdays, "addr_wdays" )) exit(2); if (b.addr_hour && assign_byte(&oHour, &nHour, b.addr_hour, "addr_hour" )) exit(2); if (b.addr_min && assign_byte(&oMin, &nMin, b.addr_min, "addr_min" )) exit(2); if (b.addr_sec && assign_byte(&oSec, &nSec, b.addr_sec, "addr_sec" )) exit(2); if (b.rtc_day && assign_byte(&oRtcDay, &nRtcDay, b.rtc_day, "rtc_day" )) exit(2); if (b.rtc_mon && assign_byte(&oRtcMon, &nRtcMon, b.rtc_mon, "rtc_mon" )) exit(2); if (b.addr_chk_h && assign_byte(&oChkH, &nChkH, b.addr_chk_h, "addr_chk_h" )) exit(2); if (b.addr_chk_l && assign_byte(&oChkL, &nChkL, b.addr_chk_l, "addr_chk_l" )) exit(2); if (b.addr_chk_h2 && assign_byte(&oChkH2, &nChkH2, b.addr_chk_h2, "addr_chk_h2")) exit(2); if (b.addr_chk_l2 && assign_byte(&oChkL2, &nChkL2, b.addr_chk_l2, "addr_chk_l2")) exit(2); if (b.rtc_time == ON) { /* open the rtc device */ nvprintf(LOG_DEBUG, "Opening %s in O_RDONLY mode...\n", RTC_DEV); fd_rtc = open( RTC_DEV, O_RDONLY ); if (fd_rtc == -1) { nvprintf(LOG_ERR, "%s: %m\n", RTC_DEV); exit(2); } /* we read rtc alarm in this case */ retval = ioctl(fd_rtc, RTC_ALM_READ, &oRtc_tm); if (retval == -1) { nvprintf(LOG_ERR, "%s: %m\n", "ioctl RTC_ALM_READ"); exit(2); } /* close the rtc device again */ close(fd_rtc); } /* now put the two checksum bytes into one checksum */ if (b.addr_chk_h && b.addr_chk_l) { oChk = (*oChkH << 8) | *oChkL; nvprintf(LOG_DEBUG, "Checksum is: 0x%04X.\n", oChk); } if(b.addr_chk_h2) { oChk2 = (*oChkH2 << 8) | *oChkL2; nvprintf(LOG_DEBUG, "Checksum2 is: 0x%04X.\n", oChk2); } /* Now we will check all values for their correctness / plausibility... */ if (b.addr_mon && FROMBCD(calculate_read(*oMon, b.nr_mon, b.shift_mon)) > 12) { nvprintf(LOG_ERR, "WakeUp Month value (%02u) not correct.\n", FROMBCD(calculate_read(*oMon, b.nr_mon, b.shift_mon))); exit(2); } if (b.addr_day) { int day = 0; if (b.day_hack) /* on this boards the day is split over the day byte and the stat byte */ day = calculate_read(*oStat, b.day_hack, 8-b.day_hack ) | calculate_read(*oDay, b.nr_day-b.day_hack, 0 )< 31) { nvprintf(LOG_ERR, "WakeUp Day value (%02u) not correct.\n", day); exit(2); } } if (b.addr_wdays) { /* I think, there's nothing to check - every bit could be set */ /* or not. The only thing I could think of is that at least */ /* one bit has to be set. But I don't really know... */ } if (b.addr_hour && FROMBCD(calculate_read(*oHour, b.nr_hour, b.shift_hour)) > 23) { nvprintf(LOG_ERR, "WakeUp Hour value (%02u) not correct.\n", FROMBCD(calculate_read(*oHour, b.nr_hour, b.shift_hour))); exit(2); } if (b.addr_min && FROMBCD(calculate_read(*oMin, b.nr_min, b.shift_min)) > 59) { nvprintf(LOG_ERR, "WakeUp Minute value (%02u) not correct.\n", FROMBCD(calculate_read(*oMin, b.nr_min, b.shift_min))); exit(2); } if (b.addr_sec && FROMBCD(calculate_read(*oSec, b.nr_sec, b.shift_sec)) > 59) { nvprintf(LOG_ERR, "WakeUp Second value (%02u) not correct.\n", FROMBCD(calculate_read(*oSec, b.nr_sec, b.shift_sec))); exit(2); } if(b.rtc_day) { int day = calculate_read(*oRtcDay, b.nr_rtc_day, 0); if (b.rtc_day_0_is_c0 && day == 0xC0) day=0; day = bcd2bin(day); if (day > 31) { nvprintf(LOG_ERR, "WakeUp rtcDay value (%02u) not correct.\n", day); exit(2); } } if(b.rtc_mon) { int mon = calculate_read(*oRtcMon, b.nr_rtc_mon, 0); if (b.rtc_mon_0_is_c0 && mon == 0xC0) mon = 0; mon = bcd2bin(mon); if (mon > 12) { nvprintf(LOG_ERR, "WakeUp rtcMon value (%02u) not correct.\n", mon); exit(2); } } /* we should compare both values in case they are */ /* stored in both places. */ /* for now we will just output both values below */ if (b.addr_day && b.rtc_day ) {} if (b.addr_mon && b.rtc_mon ) {} /* we should compare the values with those from nvram */ /* in case they are stored in both places. */ /* for now we will just output both values below */ if(b.rtc_time == ON) {} /* Output stored values */ nvprintf(LOG_NOTICE, "\n"); nvprintf(LOG_NOTICE, "All values are displayed as they are stored in the nvram/rtc.\n"); nvprintf(LOG_NOTICE, "(and do not correspond necessarily to the system date/time)\n"); nvprintf(LOG_NOTICE, "\n"); nvprintf(LOG_NOTICE, "WakeUp : %s (0x%02X)\n", calculate_read(*oStat, b.nr_stat, b.shift_stat) ? "Enabled" : "Disabled", *oStat); if (b.addr_mon) nvprintf(LOG_NOTICE, "Month : %02u (0x%02X)\n", FROMBCD(calculate_read(*oMon, b.nr_mon, b.shift_mon)), *oMon); if (b.addr_day) { int d, od; if (b.day_hack) { d = calculate_read(*oStat, b.day_hack, 8-b.day_hack) | calculate_read(*oDay, b.nr_day-b.day_hack, 0 )<> (4-b.day_hack)), b.day_hack, 8-b.day_hack); *nDay = calculate_write(*nDay, vdr_abs_tm.tm_mday >> b.day_hack, b.nr_day-b.day_hack, 0 ); } } else { if (FROM_D_BCD(calculate_read(*nDay, b.nr_day, b.shift_day)) != vdr_abs_tm.tm_mday) *nDay = calculate_write(*nDay, TO_D_BCD(vdr_abs_tm.tm_mday), b.nr_day, b.shift_day); } } if (b.addr_wdays) { unsigned char weekday = 1 << vdr_abs_tm.tm_wday; nvprintf(LOG_DEBUG, "vdr_abs_tm.tm_wday = %d\n", vdr_abs_tm.tm_wday); if (calculate_read(*nWdays, b.nr_wdays, b.shift_wdays) != weekday) *nWdays = calculate_write(*nWdays, weekday, b.nr_wdays, b.shift_wdays); } if (b.addr_hour) { if ( FROMBCD(calculate_read(*nHour, b.nr_hour, b.shift_hour)) != vdr_abs_tm.tm_hour) *nHour = calculate_write(*nHour, TOBCD(vdr_abs_tm.tm_hour), b.nr_hour, b.shift_hour); } if (b.addr_min) { if ( FROMBCD(calculate_read(*nMin, b.nr_min, b.shift_min)) != vdr_abs_tm.tm_min) *nMin = calculate_write(*nMin, TOBCD(vdr_abs_tm.tm_min), b.nr_min, b.shift_min); } if (b.addr_sec) { if ( FROMBCD(calculate_read(*nSec, b.nr_sec, b.shift_sec)) != vdr_abs_tm.tm_sec) *nSec = calculate_write(*nSec, TOBCD(vdr_abs_tm.tm_sec % 60), b.nr_sec, b.shift_sec); } if (b.rtc_mon) { if ( bcd2bin(calculate_read(*nRtcMon, b.nr_rtc_mon, 0)) != (vdr_abs_tm.tm_mon+1)) *nRtcMon = calculate_write(*nRtcMon, bin2bcd(vdr_abs_tm.tm_mon+1), b.nr_rtc_mon, 0); } if (b.rtc_day) { if ( bcd2bin(calculate_read(*nRtcDay, b.nr_rtc_day, 0)) != vdr_abs_tm.tm_mday) *nRtcDay = calculate_write(*nRtcDay, bin2bcd(vdr_abs_tm.tm_mday), b.nr_rtc_day, 0); } if (b.rtc_time==ON) { nRtc_tm.tm_sec = vdr_abs_tm.tm_sec ; nRtc_tm.tm_min = vdr_abs_tm.tm_min ; nRtc_tm.tm_hour = vdr_abs_tm.tm_hour ; /* we shouldn't need the following lines ... * nRtc_tm.tm_mday = vdr_abs_tm.tm_mday ; * nRtc_tm.tm_mon = vdr_abs_tm.tm_mon ; * nRtc_tm.tm_year = vdr_abs_tm.tm_year ; * nRtc_tm.tm_wday = vdr_abs_tm.tm_wday ; * nRtc_tm.tm_yday = vdr_abs_tm.tm_yday ; * nRtc_tm.tm_isdst = vdr_abs_tm.tm_isdst; */ } nvprintf(LOG_NOTICE, "Enabling (0x%02X) WakeUp-on-RTC in nvram.\n", *nStat); if (b.addr_mon) nvprintf(LOG_NOTICE, "New Month : %02u (0x%02X)\n", FROMBCD(calculate_read(*nMon, b.nr_mon, b.shift_mon)), *nMon); if (b.addr_day) { int d, nd; if (b.day_hack) { d = calculate_read(*nStat, b.day_hack, 8-b.day_hack) | calculate_read(*nDay, b.nr_day-b.day_hack, 0 )<> 8; /* in the case of an overflow we just throw away * the bits higher than the 16 bits we could store */ } if (b.addr_chk_h2 && b.addr_chk_l2) { *nChkL2 = nChk2 & 0x00FF; *nChkH2 = (nChk2 & 0xFF00) >> 8; } if (b.addr_chk_h && b.addr_chk_l) nvprintf(LOG_NOTICE, "New Checksum: 0x%02X%02X\n", *nChkH, *nChkL); if (b.addr_chk_h2 && b.addr_chk_l2) nvprintf(LOG_NOTICE, "New Checksum2: 0x%02X%02X\n", *nChkH2, *nChkL2); nvprintf(LOG_NOTICE, "\n"); /* Check if something changed and write the values back, if needed ... */ for (addr=0; addr < nvramSize ; addr++) if (oBytes[addr] - nBytes[addr]) { nvprintf(LOG_DEBUG, "Byte 0x%02X is changed: 0x%02X -> 0x%02X\n", addr, oBytes[addr], nBytes[addr]); /* Now really WRITING into /dev/nvram */ if (!changed) { if (! _nowrite) { nvprintf(LOG_NOTICE, "Now really WRITING into %s...\n", NVRAM_DEV); open_nvram( _directisa, O_WRONLY ); } changed = 1; } if (! _nowrite) { write_back(_directisa, b.upper_method, addr, nBytes); } } if (! _nowrite) { /* close the nvram device again */ if (changed) close_nvram(_directisa); } if (b.rtc_time == ON) { if (vdr_abs_time_t != 0 && (nRtc_tm.tm_sec != oRtc_tm.tm_sec || nRtc_tm.tm_min != oRtc_tm.tm_min || nRtc_tm.tm_hour != oRtc_tm.tm_hour ) ) { nvprintf(LOG_DEBUG, "RTC time is changed. Setting RTC alarm into %s\n", RTC_DEV); /* Setting RTC alarm into /dev/rtc */ if (!changed) { if (! _nowrite) nvprintf(LOG_NOTICE, "Setting RTC alarm into %s...\n", RTC_DEV); changed = 1; } else { if (! _nowrite) nvprintf(LOG_NOTICE, "And setting RTC alarm into %s...\n", RTC_DEV); } if (! _nowrite) { nvprintf(LOG_NOTICE, "\n"); /* open the rtc device */ nvprintf(LOG_DEBUG, "Opening %s in O_RDONLY mode...\n", RTC_DEV); fd_rtc = open( RTC_DEV, O_RDONLY ); if (fd_rtc == -1) { nvprintf(LOG_ERR, "%s: %m\n", RTC_DEV); exit(2); } retval = ioctl(fd_rtc, RTC_ALM_SET, &nRtc_tm); if (retval == -1) { nvprintf(LOG_CRIT, "Ioctl RTC_ALM_SET failed: %m\n"); exit(2); } /* Enable alarm interrupts */ /* Do we need this? */ /* * retval = ioctl(fd_rtc, RTC_AIE_ON, 0); * if (retval == -1) { * nvprintf(LOG_CRIT, "ioctl RTC_AIE_ON: %m\n"); * exit(2); * } */ /* close the rtc device again */ close(fd_rtc); } } } nvprintf(LOG_DEBUG, "need_reboot: %d\n", need_reboot); if (!changed) /* there was nothing to do: all values were already correct */ exit(0); else { if (_nowrite) { nvprintf(LOG_NOTICE, " Actually, nothing was written into %s nor into %s.\n", NVRAM_DEV, RTC_DEV); nvprintf(LOG_NOTICE, " (since --nowrite option was used).\n"); nvprintf(LOG_NOTICE, " \n"); exit(2); } else { if (need_reboot) { nvprintf(LOG_NOTICE, " The changes to take effect, you must reboot your computer now.\n"); nvprintf(LOG_NOTICE, " \n"); exit(1); } else { /* don't need to reboot. */ exit(0); } } } } /* end main */ /* * Parse command line arguments */ struct option opts[] = { {"settime", 1, 0, 's'}, {"disable", 0, 0, 'd'}, {"configfile", 1, 0, 'C'}, {"iwname", 1, 0, 'I'}, {"directisa", 0, 0, 'A'}, {"nowrite", 0, 0, 'N'}, {"debug", 0, 0, 'D'}, {"syslog", 0, 0, 'l'}, {"wakeupbefore", 1, 0, 'w'}, {"version", 0, 0, 'v'}, {"help", 0, 0, 'h'}, {"nocheck", 0, 0, 'n'}, {NULL, 0, 0, 0 }, }; const char *optstring = "s:dC:I:ANDlw:vhn"; const char *opts_help[] = { "Set the given wakeup date/time (given as a time_t value).", /* settime */ "Disable WakeUp. Equivalent to --settime=0.", /* disable */ "Read board configuration from specified configuration file.", /* configfile */ "Specify the IW (infowriter) name.", /* iwname */ "Use direct ISA access to read/write nvram instead of /dev/nvram.", /* directisa */ "Don't write any values (in /dev/nvram or /dev/rtc). For testing.", /* nowrite */ "Enable printing debug messages.", /* debug */ "Log all output via syslogd instead of stdout/stderr.", /* syslog */ "Start that many minutes before the wakeuptime (default is 5).", /* wakeupbefore */ "Print version information.", /* version */ "Print this message (always to stderr, regardless of --syslog).", /* help */ "Don't check if the time argument is in the future", /* nocheck */ }; void print_usage(void) { int max, size; struct option *opt; const char **hlp; nvprintf(LOG_INFO, "\n"); nvprintf(LOG_INFO, "Usage: %s [OPTIONS]\n", get_progname()); max = 0; for (opt = opts; opt->name; opt++) { size = strlen(opt->name); if (size > max) max = size; } for (opt = opts, hlp = opts_help; opt->name; opt++, hlp++) nvprintf(LOG_INFO, " -%c, --%-*s%s\n", opt->val, max+2, opt->name, *hlp); nvprintf(LOG_INFO, "\n"); nvprintf(LOG_INFO, " All specified wakeup times are times at which the PC should be up and running.\n"); nvprintf(LOG_INFO, "\n"); exit(2); } /* * opterr = 0; */ static int handle_cmdline(int *argc, char ***argv) { for (;;) { int i = getopt_long(*argc, *argv, optstring, opts, NULL); if (i == -1) break; switch (i) { /* * case '?': * nvprintf(LOG_ERR, "invalid option: %d,%s,%c\n", optind, (*argv)[optind-1], optopt); * print_usage(); * break; */ case 's': if ( strlen(optarg) > strspn(optarg, "0123456789") ) { /* if the time is not a number */ nvprintf(LOG_ERR, "\"%s\" is not a number\n", optarg); print_usage(); } else if ( vdr_abs_time_t >= 0 && strtol(optarg, NULL, 10) != vdr_abs_time_t ) { /* if two different times specified at the same time */ nvprintf(LOG_ERR, "two different times specified at the same time\n"); print_usage(); } else { vdr_abs_time_t = strtol(optarg, NULL, 10); } break; case 'd': if (vdr_abs_time_t > 0) { /* if -s positivetime and -d options given at the same time */ nvprintf(LOG_ERR, "-s %u and -d specified at the same time\n", (unsigned int)vdr_abs_time_t); print_usage(); } else { vdr_abs_time_t = 0; } break; case 'C': if (_config_file && strcmp(_config_file, optarg)) { nvprintf(LOG_ERR, "Two different configuration files specified.\n"); print_usage(); } _config_file = optarg; break; case 'I': if (_iw_string && strcmp(_iw_string, optarg)) { nvprintf(LOG_ERR, "Two different infowriter strings specified.\n"); print_usage(); } _iw_string = optarg; break; case 'D': enable_debug(); nvprintf(LOG_DEBUG, "Printing debug messages enbled.\n"); for(i=0; CVS_ALL[i]; i++) nvprintf(LOG_DEBUG, "%s\n", CVS_ALL[i]); nvprintf(LOG_DEBUG, "Built at: " __DATE__ " " __TIME__ "\n"); break; case 'A': nvprintf(LOG_DEBUG, "Direct ISA access enabled.\n"); _directisa = ON; break; case 'N': _nowrite = ON; break; case 'n': _check_time = OFF; break; case 'l': enable_syslog(); openlog( get_progname(), LOG_CONS || LOG_PID, LOG_USER ); fprintf(stderr, "--syslog parameter specified. All output goes to the syslog\n"); break; case 'v': nvprintf(LOG_NOTICE, "NVRAM WakeUp - Copyright (C) 2001-2005, Sergei Haller.\n"); nvprintf(LOG_NOTICE, PACKAGE "-" VERSION "\n"); exit(0); case 'w': if ( strlen(optarg) > strspn(optarg, "0123456789") ) { /* if the argument is not a number */ nvprintf(LOG_ERR, "\"%s\" is not a number\n", optarg); print_usage(); } else if ( strtol(optarg, NULL, 10) < 0 ) { /* argument must be >= 0 */ nvprintf(LOG_ERR, "wakeupbefore must be bigger or equal 0.\n"); print_usage(); } else { wakeupbefore = strtol(optarg, NULL, 10); } break; case 'h': default: print_usage(); break; } } *argc -= optind; *argv += optind; if (*argc > 0) { nvprintf(LOG_ERR, "invalid parameter: %s\n", *argv[0]); print_usage(); } if (_config_file && _iw_string) nvprintf(LOG_WARNING, "Configuration file and IW name specified at command line -- ignoring IW name\n"); return 0; } nvram-wakup-1.1/nvram-wakeup-mb.c0000644000175000017500000001264711112233333016326 0ustar tobiastobias/* * NVRAM WakeUp * Copyright (C) 2001-2005, Sergei Haller. * Copyright (C) 2002 Bernhard "Bero" Rosenkraenzer * * $Id: nvram-wakeup-mb.c 870 2008-09-06 20:48:34Z tiber $ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ #define CVSREV_nvram_wakeup_mb_c \ "$Id: nvram-wakeup-mb.c 870 2008-09-06 20:48:34Z tiber $" #include #include #include #include "nvram-wakeup.h" /* * If you can't find your motherboard here, try at the MB tracker * http://sourceforge.net/tracker/index.php?group_id=35022&atid=412959 * or the latest SVN revision of this file * http://nvram-wakeup.svn.sourceforge.net/viewvc/nvram-wakeup/trunk/nvram-wakeup/boards/boards.yaml * or * read README.mb. */ typedef void (*info_writer)(struct biosinfo *b); struct mainboard { info_writer infowriter; char *iw_name; /* the function name of the infowriter */ char *vendor; char *type; char *version; char *biosvendor; char *biosversion; char *biosrelease; }; /* * look into nvram-wakeup.conf(5) for the documentation of the options */ /* * By far the most common way of storing the timing information is having * it in subsequent bytes in the day-hour-min-sec order. #define this * here to save code later on */ #define TIMEREGS(b, base) b->addr_day = base; \ b->addr_hour = base+1;\ b->addr_min = base+2;\ b->addr_sec = base+3 /* * Virtually every board keeps the low and high bytes of the checksum in * subsequent bytes - save some more code */ #define CHECKSUM(b, base) b->addr_chk_h = base;\ b->addr_chk_l = base+1 #define BCD(b) b->nr_mon = 5;\ b->nr_day = 6;\ b->nr_hour = 6;\ b->nr_min = 7;\ b->nr_sec = 7;\ b->nr_rtc_mon = 5;\ b->nr_rtc_day = 6;\ b->nr_wdays = 7;\ b->bcd = ON #define NOBCD(b) b->nr_mon = 4;\ b->nr_day = 5;\ b->nr_hour = 5;\ b->nr_min = 6;\ b->nr_sec = 6;\ b->nr_rtc_day = 6;\ b->nr_rtc_mon = 5;\ b->nr_wdays = 7 #include "infowriters.c.inc" #define IW(x) x, #x /* * Definitions of the mainboards below are in the format * * { infowriter, iwname, boardvendor, boardtype, boardversion, biosvendor, biosversion, biosrelease } * * Where NULL means "Don't care" and "" is a real empty field. */ #include "boards.c.inc" int set_biosinfo_defaults(struct biosinfo *b) { if (b) { memset(b, 0, sizeof(struct biosinfo)); b->nr_stat = 1; b->addr_stat = -1; NOBCD(b); return 1; } else return 0; } int get_bios_info_by_dmi(struct biosinfo *b) { int i; /* Set defaults... */ if (!set_biosinfo_defaults(b)) return 0; if (!__dmi_probe()) return -1; /* Check if we know the mainboard... */ for(i=0; boards[i].infowriter; i++) { if (boards[i].vendor && (!board_vendor() || strcmp(boards[i].vendor, board_vendor() ))) continue; if (boards[i].type && (!board_type() || strcmp(boards[i].type, board_type() ))) continue; if (boards[i].version && (!board_version() || strcmp(boards[i].version, board_version()))) continue; if (boards[i].biosvendor && (!bios_vendor() || strcmp(boards[i].biosvendor, bios_vendor() ))) continue; if (boards[i].biosversion && (!bios_version() || strcmp(boards[i].biosversion, bios_version() ))) continue; if (boards[i].biosrelease && (!bios_release() || strcmp(boards[i].biosrelease, bios_release() ))) continue; /* This is our board... */ nvprintf(LOG_DEBUG, "Using infowriter \"%s\" (automatically detected)\n", boards[i].iw_name); boards[i].infowriter(b); return 1; } return 0; } int get_bios_info_by_iw(struct biosinfo *b, const char * iw_name) { int i; /* Set defaults... */ if (!set_biosinfo_defaults(b)) return 0; /* Check if we know that infowriter... */ for(i=0; boards[i].infowriter; i++) { if ( strcmp( boards[i].iw_name, iw_name ) ) continue; /* This is our board... */ nvprintf(LOG_DEBUG, "Using infowriter \"%s\" (manually choosen)\n", boards[i].iw_name); boards[i].infowriter(b); return 1; } return 0; } nvram-wakup-1.1/biosinfo.c0000644000175000017500000000254211044374410015124 0ustar tobiastobias/* * Mainboard and BIOS identification * * (c) 2002 Bernhard "Bero" Rosenkraenzer * (c) 2003-5 Sergei Haller. * * $Id: biosinfo.c 835 2005-03-16 22:43:39Z bistr-o-math $ * * Released under the terms of the GPL version 2 or if, and only if, * the GPL version 2 is ruled invalid in a court of law, any later * version of the GPL. */ #include #include #include "nvram-wakeup.h" int main(int argc, char **argv) { set_progname("biosinfo"); if ( argc > 1 && strcmp((char *)argv[1], "--debug") == 0) enable_debug(); printf("Following DMI entries found:\n"); printf(" - Mainboard vendor: %s%s%s\n", QUOTE(board_vendor() ), VALUE(board_vendor() ), QUOTE(board_vendor() ) ); printf(" - Mainboard type: %s%s%s\n", QUOTE(board_type() ), VALUE(board_type() ), QUOTE(board_type() ) ); printf(" - Mainboard revision: %s%s%s\n", QUOTE(board_version()), VALUE(board_version()), QUOTE(board_version()) ); printf(" - BIOS vendor: %s%s%s\n", QUOTE(bios_vendor() ), VALUE(bios_vendor() ), QUOTE(bios_vendor() ) ); printf(" - BIOS version: %s%s%s\n", QUOTE(bios_version() ), VALUE(bios_version() ), QUOTE(bios_version() ) ); printf(" - BIOS release: %s%s%s\n", QUOTE(bios_release() ), VALUE(bios_release() ), QUOTE(bios_release() ) ); return 0; } nvram-wakup-1.1/nvramops.c0000644000175000017500000001443211044374410015162 0ustar tobiastobias/* * NVRAM WakeUp * Copyright (C) 2001-2004, Sergei Haller. * * $Id: nvramops.c 682 2004-05-03 22:40:13Z bistr-o-math $ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ #include #include #include #include #include #include #include #include "nvram-wakeup.h" int fd_rtc, fd_nvram; void open_nvram(int _directisa, int mode) { if (_directisa == OFF) { char mode_str[10]; switch (mode) { case O_RDONLY: sprintf(mode_str, "O_RDONLY"); break; case O_WRONLY: sprintf(mode_str, "O_WRONLY"); break; default: sprintf(mode_str, "%d", mode); break; } /* open the nvram device */ nvprintf(LOG_DEBUG, "Opening %s in %s mode...\n", NVRAM_DEV, mode_str); fd_nvram = open(NVRAM_DEV, mode); if (fd_nvram == -1) { nvprintf(LOG_ERR, "%s: %m\n", NVRAM_DEV); exit(2); } } else { /* get permission */ nvprintf(LOG_DEBUG, "Requesting permissions for io ports 0x70...0x75\n"); if (ioperm(0x70, 6, 1) == -1) { nvprintf(LOG_ERR, "An error occurred while requesting permissions: %m\n"); exit(2); } } } void close_nvram(int _directisa) { if (_directisa == OFF) { /* close the nvram device again */ close(fd_nvram); } else { /* release ports */ ioperm( 0x70, 4, 0 ); } } int read_whole_nvram(int _directisa, int upper_method, unsigned char * bytes) { int addr; char reg_A; int nvramSize = 0; if (_directisa == OFF) { /* Now we read whole nvram ... */ lseek(fd_nvram, 0, SEEK_SET); /* just to be sure we are at the beginning */ nvramSize = read(fd_nvram, bytes, MAXNVRAMSIZE); if (nvramSize < 0) { nvprintf(LOG_ERR, "An error occurred while reading nvram: %m\n"); exit(2); } } else /* if (_directisa == ON) */ { for(addr=0;addr<=13;addr++) { outb(addr, 0x70); bytes[addr+114] = inb(0x71); } for(addr=14;addr<=127;addr++) { outb(addr, 0x70); bytes[addr-14] = inb(0x71); } switch (upper_method) { case OFF: nvramSize = 128; break; case INTEL: for(addr=0;addr<=127;addr++) { outb(addr, 0x72); bytes[addr+128] = inb(0x73); } nvramSize = 256; break; case DS1685: reg_A = bytes[0xA+114]; outb(0xA, 0x70); outb(reg_A | 0x10, 0x71); /* set bit 4 of register A and enable upper nvram access */ for(addr=0;addr<=127;addr++) { outb(addr, 0x70); bytes[addr+128] = inb(0x71); } outb(0xA, 0x70); outb(reg_A, 0x71); /* restore contents of register A */ nvramSize = 256; break; case VT82Cxxx: for(addr=128;addr<=255;addr++) { outb(addr, 0x72); bytes[addr] = inb(0x73); } nvramSize = 256; break; case VT8235_37: for(addr=128;addr<=255;addr++) { outb(addr, 0x74); bytes[addr] = inb(0x75); } nvramSize = 256; break; default: nvramSize = 128; break; } } nvprintf(LOG_DEBUG, "The size of NVRAM is %u bytes.\n", nvramSize); return nvramSize; } void write_back(int _directisa, int upper_method, int addr, unsigned char * bytes) { int retval; char reg_A = bytes[0xA+114]; nvprintf(LOG_DEBUG, "Writing value 0x%02X into byte 0x%02X of NVRAM\n", bytes[addr], addr); if (_directisa == OFF) { lseek(fd_nvram, addr, SEEK_SET); retval = write(fd_nvram, &bytes[addr], 1); if (retval != 1) { nvprintf(LOG_CRIT, "Error occurred while writing byte 0x%02X of %s: %m\n", addr, NVRAM_DEV); exit(2); } } else /* _directisa == ON */ { if (addr<114) { outb(addr+14, 0x70); outb(bytes[addr], 0x71); } else if (addr<128) { outb(addr-114, 0x70); outb(bytes[addr], 0x71); } /* upper nvram needs special treatment */ else switch (upper_method) { case INTEL: outb(addr-128, 0x72); outb(bytes[addr], 0x73); break; case DS1685: outb(0xA, 0x70); outb(reg_A | 0x10, 0x71); /* set bit 4 of register A and enable upper nvram access */ outb(addr-128, 0x70); outb(bytes[addr], 0x71); outb(0xA, 0x70); outb(reg_A, 0x71); /* restore contents of register A */ break; case VT82Cxxx: outb(addr, 0x72); outb(bytes[addr], 0x73); break; case VT8235_37: outb(addr, 0x74); outb(bytes[addr], 0x75); break; } } } nvram-wakup-1.1/VDR/0000755000175000017500000000000011044374410013600 5ustar tobiastobiasnvram-wakup-1.1/VDR/vdrshutdown0000755000175000017500000000523711044374410016124 0ustar tobiastobias#!/bin/bash # $Id: vdrshutdown 773 2004-08-23 01:22:35Z bistr-o-math $ NVRAMCMD=/usr/local/bin/nvram-wakeup SVDRPCMD=/usr/local/src/VDR/svdrpsend.pl LOGGER=/bin/logger CHECKSCRIPT=/path/to/the/script ################# ## if the script $CHECKSCRIPT thinks that we should shutdown, ## it must not print anything on stdout. ## if it thinks that we should NOT shutdown, ## it must print a one-line message on stdout describing the reason. ## ## note that all parameters passed to vdrshutdown will also be passed to $CHECKSCRIPT ## so it might use them (e.g. $5 -eq 0 below) ## ## it might look like this: ## -------------------------- ## #!/bin/bash ## ## pgrep 2divx >/dev/null 2>&1 && { echo Divx-Conversion is still running; exit; } ## ## test -a /some/file && { echo /some/file exists; exit; } ## ## USERCOUNT=`who | wc -l`; ## test $5 -eq 0 -a $USERCOUNT -gt 0 && { echo "$USERCOUNT users are logged in."; exit; } ## ## -------------------------- ## ## now if $CHECKSCRIPT exists and is executable, the message will be passed through ## SVDRP to the tv screen. ## test -x $CHECKSCRIPT && { msg=`$CHECKSCRIPT "$@"` test "$msg" != "" && { $SVDRPCMD MESG $msg & $LOGGER -t `basename $0` "shutdown aborted: $msg" exit 1 } } ################# # Add here needed options like --configfile=... # (read 'man nvram-wakeup' and 'man nvram-wakeup.conf' for more details) $NVRAMCMD --syslog --settime $1 # if you are going to use the set_timer script instead of nvram-wakeup, # comment out the line above and uncomment the following line. # (read the comments inside the script for more details) # $PATH_TO_SET_TIMER/set_timer $1 $2 case $PIPESTATUS in 0) # all went ok - new date and time set shutdown -h now EXITSTATUS=0 ;; 1) # all went ok - new date and time set. # # *** but we need to reboot. *** # # for some boards this is needed after every change. # # for some other boards, we only need this after changing the # status flag, i.e. from enabled to disabled or the other way. # For plan A - (Plan A is not supported anymore---see README) # # For plan B - (don't forget to install the modified kernel image first) # lilo -R PowerOff shutdown -r now EXITSTATUS=0 ;; 2) # something went wrong # don't do anything - just exit with status 1 EXITSTATUS=1 ;; esac # exit with 0 if everything went ok. # exit with 1 if something went wrong. exit $EXITSTATUS nvram-wakup-1.1/guess-helper0000755000175000017500000001542511327030667015514 0ustar tobiastobias#!/bin/sh # # guess-helper # Copyright (C) 2004 Tobias Grimm # # $Id: guess-helper 925 2010-01-24 11:40:38Z tiber $ # # prepare to use gettext, if installed: if [ -x /usr/bin/gettext ] then export TEXTDOMAIN=guess-helper echo="gettext -s" else echo="echo" fi # clear console window and print header line ClearScreen () { clear echo echo guess-helper echo ------------ echo } # AskQuestion "Do you like Debian?" Y n > Do you like Debian? [Y/n] AskQuestion () { if [ -x /usr/bin/gettext ] then question=`gettext "$1"` else question=$1 fi shift answers="" for answer in $* do if [ -x /usr/bin/gettext ] then answer=`gettext "$answer"` fi answers="$answers $answer" done choices="" for answer in $answers do if [ "$choices" = "" ] then choices="[$answer" else choices="$choices/$answer" fi done choices="$choices]" answers=`$echo $answers | tr '[:lower:]' '[:upper:]'` result=0 while [ $result -eq 0 ] do echo -n "$question" "$choices " read input if [ "$input" = "" ] then result=1 else input=`echo $input | tr '[:lower:]' '[:upper:]'` i=1 for answer in $answers do if [ "$answer" = "$input" ] then result=$i fi i=`expr $i + 1` done fi done return $result } # Translate and print text lines EchoTextLines () { textLines="" while [ "$1" ] do textLines="$textLines$1" shift done $echo -ne "$textLines" } # show next wakeup time settings and ask for reboot ShowBiosSettings () { ClearScreen EchoTextLines \ "On the next reboot, please enter the BIOS settings and change\n" \ "the wakeup time settings to the following values:\n" echo $echo -n "Day = " ; echo "$1" $echo -n "Hour = " ; echo "$2" $echo -n "Minute = " ; echo "$3" $echo -n "Second = " ; echo "$4" if [ $5 -eq 1 ] then $echo "Enabled = Yes" else $echo "Enabled = No" fi echo AskQuestion "Restart or Abort?" "A" "r" if [ $? -eq 2 ] then echo EchoTextLines \ "After changing the wakeup time in the BIOS settings and rebooting the PC,\n"\ "please run this script again (PC will reboot in 10 seconds...)\n" sleep 10 shutdown -r now exit 0 else echo $echo "Script aborted !!!" echo exit 0 fi } ReadNvram () { cat_nvram $catOptions > ~/guess-directisa/$1 2>~/guess-directisa/cat_nvram.log [ -c /dev/nvram ] && \ cat /dev/nvram > ~/guess-nvram-module/$1 2>~/guess-nvram-module/cat.log if [ ! -s ~/guess-directisa/$1 ] && [ ! -s ~/guess-nvram-module/$1 ] ; then EchoTextLines\ "cat_nvram and cat /dev/nvram failed.\n" "Please check the cat_nvram.log for the details, fix the errors and run\n" "guess-helper again.\n" # if they exist, they are empty. Remove them. rm -fr ~/guess-directisa/$1 ~/guess-nvram-module/$1 exit 1 fi } step0file=guess-helper.conf step1file=31.23.59.59+ step2file=11.12.13.14+ step3file=01.00.00.00+ step4file=01.00.00.00- # check for needed binaries if ! (which cat_nvram >/dev/null && \ which cat >/dev/null && \ which guess >/dev/null ) ; then EchoTextLines \ "Please check that the tools cat_nvram, cat and guess are installed.\n\n"\ "guess-helper aborted!\n" exit 1 fi if [ ! -f ~/guess-directisa/$step0file ] then ClearScreen EchoTextLines \ "The aim of this script is to help you figuring out the addresses of the\n"\ "wakeup time in the NVRAM of your PC. You will have to do this only,\n"\ "if your mainboard couldn't be detected by nvram-wakeup.\n"\ "\n"\ "In several steps it will be necessary to reboot the PC, change the\n"\ "wakeup time in the BIOS and then run guess-helper again.\n"\ "\n"\ "This script will create several temporary files and a config file for\n"\ "nvram-wakeup. This will be done in your home directory.\n" echo AskQuestion "Continue with the first step of the nvram-wakeup address detection?" "N" "y" [ $? -eq 1 ] && exit ClearScreen mkdir -p ~/guess-directisa EchoTextLines \ "Please select the chipset of your Board -\n"\ " [U] Unknown (i.e, disable access to upper nvram);\n"\ " [I] Intel;\n"\ " [V] VIA VT82Cxxx (xxx=686A,686B,596,...), nVidia nForce2, ATI RADEON 9100 IGP; \n"\ " [3] VIA VT8233/35/37;\n"\ " [D] DS1685\n" AskQuestion "Select one of the above:" "U" "i" "v" "3" "d" case $? in 2) catOptions="INTEL" ;; 3) catOptions="VT82Cxxx" ;; 4) catOptions="VT8235_37" ;; 5) catOptions="DS1685" ;; esac echo catOptions=\"$catOptions\" >~/guess-directisa/$step0file ShowBiosSettings 31 23 59 59 1 else . ~/guess-directisa/$step0file if [ ! -f ~/guess-directisa/$step1file ] then [ -c /dev/nvram ] && mkdir -p ~/guess-nvram-module ReadNvram $step1file ShowBiosSettings 11 12 13 14 1 else if [ ! -f ~/guess-directisa/$step2file ] then ReadNvram $step2file ShowBiosSettings 01 00 00 00 1 else if [ ! -f ~/guess-directisa/$step3file ] then ReadNvram $step3file ShowBiosSettings 01 00 00 00 0 else if [ ! -f ~/guess-directisa/$step4file ] then ReadNvram $step4file fi ClearScreen cd ~/guess-directisa guess > nvram-wakeup.conf 2> guess-error.log [ "$catOptions" = "" ] || echo upper_method = $catOptions >> nvram-wakeup.conf if [ -d ~/guess-nvram-module ] ; then cd ~/guess-nvram-module guess > nvram-wakeup.conf 2> guess-error.log cd .. fi EchoTextLines \ "The nvram-wakeup address detection is finished now.\n"\ "If everything went well, you will find the detected nvram-wakeup\n"\ "settings in the file ~/guess-directisa/nvram-wakeup.conf. This file\n"\ "has been generated using the 'directisa' access method.\n" [ -c /dev/nvram ] && EchoTextLines \ "In the directory ~/guess-nvram-module you will find the results using\n"\ "the 'nvram-kernel-module' access method. It's up to you to decide,\n"\ "what access method worked.\n" EchoTextLines \ "Check the files nvram-wakeup.conf and guess-error.log to see if\n"\ "everything went well. In order to use the generated conf file, you\n"\ "have to pass it as a command line parameter with the option -C to\n"\ "nvram-wakeup. Before doing this, you should copy it to /etc.\n"\ "If the settings in your nvram-wakup.conf seem to work, please submit\n"\ "this file to the mainboard tracker:\n" echo echo "https://sourceforge.net/tracker/?group_id=35022&atid=412959" echo $echo "By doing so, you are helping to keep nvram-wakeup support more boards." fi fi fi fi nvram-wakup-1.1/time.c0000644000175000017500000000313211044374410014246 0ustar tobiastobias/* * NVRAM WakeUp * Copyright (C) 2001-2002, Sergei Haller. * * $Id: time.c 727 2004-06-26 07:21:23Z bistr-o-math $ * * Contributed by Dr. Werner Fink * Added some changes/speedups by Dr. Werner Fink and me. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ #define CVSREV_time_c \ "$Id: time.c 727 2004-06-26 07:21:23Z bistr-o-math $" #include #include #include int main(int argc, char **argv) { time_t vdr_abs_time_t; if (argc != 2) { printf("Usage: %s