Deleted Added
full compact
pmtimer.c (184386) pmtimer.c (247088)
1/*-
2 * Copyright (c) 2000 Mitsuru IWASAKI <iwasaki@FreeBSD.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 11 unchanged lines hidden (view full) ---

20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2000 Mitsuru IWASAKI <iwasaki@FreeBSD.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 11 unchanged lines hidden (view full) ---

20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#include <sys/cdefs.h>
28__FBSDID("$FreeBSD: head/sys/i386/isa/pmtimer.c 184386 2008-10-28 04:32:41Z imp $");
28__FBSDID("$FreeBSD: head/sys/i386/isa/pmtimer.c 247088 2013-02-21 07:16:40Z imp $");
29
30/*
31 * Timer device driver for power management events.
32 * The code for suspend/resume is derived from APM device driver.
33 */
34
35#include <sys/param.h>
36#include <sys/systm.h>

--- 40 unchanged lines hidden (view full) ---

77}
78
79static struct timeval suspend_time;
80static struct timeval diff_time;
81
82static int
83pmtimer_suspend(device_t dev)
84{
29
30/*
31 * Timer device driver for power management events.
32 * The code for suspend/resume is derived from APM device driver.
33 */
34
35#include <sys/param.h>
36#include <sys/systm.h>

--- 40 unchanged lines hidden (view full) ---

77}
78
79static struct timeval suspend_time;
80static struct timeval diff_time;
81
82static int
83pmtimer_suspend(device_t dev)
84{
85 int pl;
86
85
87 pl = splsoftclock();
88 microtime(&diff_time);
89 inittodr(0);
90 microtime(&suspend_time);
91 timevalsub(&diff_time, &suspend_time);
86 microtime(&diff_time);
87 inittodr(0);
88 microtime(&suspend_time);
89 timevalsub(&diff_time, &suspend_time);
92 splx(pl);
93 return (0);
94}
95
96static int
97pmtimer_resume(device_t dev)
98{
90 return (0);
91}
92
93static int
94pmtimer_resume(device_t dev)
95{
99 int pl;
100 u_int second, minute, hour;
101 struct timeval resume_time, tmp_time;
102
103 /* modified for adjkerntz */
96 u_int second, minute, hour;
97 struct timeval resume_time, tmp_time;
98
99 /* modified for adjkerntz */
104 pl = splsoftclock();
105 timer_restore(); /* restore the all timers */
106 inittodr(0); /* adjust time to RTC */
107 microtime(&resume_time);
108 getmicrotime(&tmp_time);
109 timevaladd(&tmp_time, &diff_time);
110
111#ifdef FIXME
112 /* XXX THIS DOESN'T WORK!!! */
113 time = tmp_time;
114#endif
115
116#ifdef PMTIMER_FIXUP_CALLTODO
117 /* Calculate the delta time suspended */
118 timevalsub(&resume_time, &suspend_time);
119 /* Fixup the calltodo list with the delta time. */
120 adjust_timeout_calltodo(&resume_time);
100 timer_restore(); /* restore the all timers */
101 inittodr(0); /* adjust time to RTC */
102 microtime(&resume_time);
103 getmicrotime(&tmp_time);
104 timevaladd(&tmp_time, &diff_time);
105
106#ifdef FIXME
107 /* XXX THIS DOESN'T WORK!!! */
108 time = tmp_time;
109#endif
110
111#ifdef PMTIMER_FIXUP_CALLTODO
112 /* Calculate the delta time suspended */
113 timevalsub(&resume_time, &suspend_time);
114 /* Fixup the calltodo list with the delta time. */
115 adjust_timeout_calltodo(&resume_time);
121#endif /* PMTIMER_FIXUP_CALLTODOK */
122 splx(pl);
123#ifndef PMTIMER_FIXUP_CALLTODO
124 second = resume_time.tv_sec - suspend_time.tv_sec;
125#else /* PMTIMER_FIXUP_CALLTODO */
126 /*
127 * We've already calculated resume_time to be the delta between
128 * the suspend and the resume.
129 */
130 second = resume_time.tv_sec;
116 /*
117 * We've already calculated resume_time to be the delta between
118 * the suspend and the resume.
119 */
120 second = resume_time.tv_sec;
121#else /* !PMTIMER_FIXUP_CALLTODO */
122 second = resume_time.tv_sec - suspend_time.tv_sec;
131#endif /* PMTIMER_FIXUP_CALLTODO */
132 hour = second / 3600;
133 second %= 3600;
134 minute = second / 60;
135 second %= 60;
136 log(LOG_NOTICE, "wakeup from sleeping state (slept %02d:%02d:%02d)\n",
137 hour, minute, second);
138 return (0);

--- 19 unchanged lines hidden ---
123#endif /* PMTIMER_FIXUP_CALLTODO */
124 hour = second / 3600;
125 second %= 3600;
126 minute = second / 60;
127 second %= 60;
128 log(LOG_NOTICE, "wakeup from sleeping state (slept %02d:%02d:%02d)\n",
129 hour, minute, second);
130 return (0);

--- 19 unchanged lines hidden ---