Home | History | Annotate | Download | only in isa
History log of /src/sys/arch/x86/isa/clock.c
RevisionDateAuthorComments
 1.42  24-Feb-2025  imil Check for RTC presence to avoid hang with QEMU microvm and rtc=off
parameter.

Test bits 0-6 of MC146818's Register D, which must be 0 according to
the specification. This prevents a later hang in rtcget() when no RTC
is present.
 1.41  25-Jan-2023  riastradh x86/intr: Work around sleazy clockintr with a secret frame argument.

PR kern/57197
 1.40  24-Jan-2023  riastradh x86/isa/clock.c: Nix trailing whitespace.

No functional change intended.
 1.39  29-May-2020  rin branches: 1.39.20;
For struct timecounter, use C99 initializers.
Compile tested. No functional changes intended.
 1.38  02-May-2020  bouyer Introduce Xen PVH support in GENERIC.
This is compiled in with
options XENPVHVM
x86 changes:
- add Xen section and xen pvh entry points to locore.S. Set vm_guest
to VM_GUEST_XENPVH in this entry point.
Most of the boot procedure (especially page table setup and switch to
paged mode) is shared with native.
- change some x86_delay() to delay_func(), which points to x86_delay() for
native/HVM, and xen_delay() for PVH

Xen changes:
- remove Xen bits from init_x86_64_ksyms() and init386_ksyms()
and move to xen_init_ksyms(), used for both PV and PVH
- set ISA no-legacy-devices property for PVH
- factor out code from Xen's cpu_bootconf() to xen_bootconf()
in xen_machdep.c
- set up a specific pvh_consinit() which starts with printk()
(which uses a simple hypercall that is available early) and switch to
xencons when we can use pmap_kenter_pa().
 1.37  25-Apr-2020  bouyer Merge the bouyer-xenpvh branch, bringing in Xen PV drivers support under HVM
guests in GENERIC.
Xen support can be disabled at runtime with
boot -c
disable hypervisor
 1.36  16-Oct-2019  christos branches: 1.36.6;
Add and use __FPTRCAST, requested by uwe@
 1.35  16-Oct-2019  christos add void * casts for the clock interrupt handlers.
 1.34  15-Feb-2019  nonaka Added Microsoft Hyper-V support. It ported from OpenBSD and FreeBSD.

graphical console is not work on Gen.2 VM yet. To use the serial console,
enter "consdev com,0x3f8,115200" on efiboot.
 1.33  16-Jun-2009  bouyer branches: 1.33.56; 1.33.64;
Split mc146818-related functions from clock.c into rtc.c.
Call rtc_set_ymdhms() from xen/xen/clock.c:xen_rtc_set() for xen3 dom0
kernels as the Xen3 hypervisor doesn't write the new date/time to the CMOS
by itself.
Now a XEN3_DOM0 kernel properly updates the CMOS time.
 1.32  07-Apr-2009  dyoung Detach sysbeep0 at shutdown.
 1.31  16-Dec-2008  christos branches: 1.31.2;
replace bitmask_snprintf(9) with snprintb(3)
 1.30  11-May-2008  ad branches: 1.30.6; 1.30.8; 1.30.14;
Fix the qemu (?) problem.
 1.29  10-May-2008  ad Improve x86 tsc handling:

- Ditch the cross-CPU calibration stuff. It didn't work properly, and it's
near impossible to synchronize the CPUs in a running system, because bus
traffic will interfere with any calibration attempt, messing up the
timings.

- Only enable the TSC on CPUs where we are sure it does not drift. If we are
On a known good CPU, give the TSC high timecounter quality, making it the
default.

- When booting CPUs, detect TSC skew and account for it. Most Intel MP
systems have synchronized counters, but that need not be true if the
system has a complicated bus structure. As far as I know, AMD systems
do not have synchronized TSCs and so we need to handle skew.

- While an AP is waiting to be set running, try and make the TSC drift by
entering a reduced power state. If we detect drift, ensure that the TSC
does not get a high timecounter quality. This should not happen and is
only for safety.

- Make cpu_counter() stuff LKM safe.
 1.28  06-Apr-2008  cherry branches: 1.28.2; 1.28.4; 1.28.6;
Correct comment about struct timecounter field
 1.27  05-Mar-2008  cube Cosmetics: use device_t and cfdata_t.
 1.26  04-Mar-2008  cube sysbeep has no softc, use CFATTACH_DECL_NEW.
 1.25  19-Jan-2008  kardel branches: 1.25.2; 1.25.6;
unbreak i8254_get_timecount() in environments where the
clock interrupt is derived from other sources (e.g. lapic)
and the i8254 timer is running the full cycle without
being used as clock interrupt source.
 1.24  17-Jan-2008  lukem Remove unnecessary references to config_time.h.
 1.23  16-Jan-2008  chuck fix clock accounting problem in i8254_get_timecount that caused
the auich auich_calibrate() function to get the wrong ac97 freq
(may cause audio to play at wrong speed on some systems). this
error was inadvertently introduced in rev 1.98 of the old
src/sys/arch/i386/isa/clock.c (2006/09/03) and manifests itself
on systems that do not use an alternate timecounter (e.g. ACPI-Fast).

the basic problem is that the code that handled when the i8254
counter wrapped was firing in cases when it shouldn't have,
causing the counter to run fast. a more detailed discussion
can be found here:
http://mail-index.netbsd.org/tech-kern/2008/01/15/0001.html
http://mail-index.netbsd.org/tech-kern/2008/01/16/0000.html
 1.22  04-Jan-2008  dyoung Remove superfluous #if (NPCPPI > 0).
 1.21  04-Jan-2008  dyoung Move #endif to the place where it belongs. Thanks, Chavdar Ivanov,
for noticing this.
 1.20  04-Jan-2008  ad Start detangling lock.h from intr.h. This is likely to cause short term
breakage, but the mess of dependencies has been regularly breaking the
build recently anyhow.
 1.19  04-Jan-2008  christos add missing includes
 1.18  03-Jan-2008  he Declare sysbeepdetach(), and protect a small additional section
with #if (NPCPPI > 0).
 1.17  03-Jan-2008  dyoung Support detachment of pchb(4) and sysbeep(4).
 1.16  28-Dec-2007  joerg Remove delaytab and just compute the reminder directly. This requires
two muls and a shift, which needs at most 2ms on a 25MHz i386 and should
end up as fast as delay(1) was before due to using a reminder of 2.
Discussed with ad@.
 1.15  09-Dec-2007  jmcneill branches: 1.15.2;
Merge jmcneill-pm branch.
 1.14  04-Dec-2007  ad branches: 1.14.2;
- Fix the locking around the i8254. Values for the TSC clock and lapic
delay function were wildly inaccurate due to multiple CPUs competing
in DELAY() during calibration, confusing the clock chip.
- Use i8254_delay() explictly in a few more places.
 1.13  14-Nov-2007  ad branches: 1.13.2;
- Remove I486_CPU, I586_CPU, I686_CPU options. They buy us nothing and
clutter the code significantly.
- Remove pccons.
 1.12  26-Oct-2007  joerg branches: 1.12.2;
Match delay/DELAY on x86 with delay(9). It takes an unsigned int as
argument. Use this and replace the inline assembly (mul + div using the
64bit intermediate result) with normal 32bit multiplication and
division. The compiler can turn the division into a multiplication and
shift, making it even cheaper then the original assembly. For extreme
long delays, just use 64bit arithmetic.
 1.11  17-Oct-2007  garbled Merge the ppcoea-renovation branch to HEAD.

This branch was a major cleanup and rototill of many of the various OEA
cpu based PPC ports that focused on sharing as much code as possible
between the various ports to eliminate near-identical copies of files in
every tree. Additionally there is a new PIC system that unifies the
interface to interrupt code for all different OEA ppc arches. The work
for this branch was done by a variety of people, too long to list here.

TODO:
bebox still needs work to complete the transition to -renovation.
ofppc still needs a bunch of work, which I will be looking at.
ev64260 still needs to be renovated
amigappc was not attempted.

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
 1.10  26-Sep-2007  ad branches: 1.10.2;
x86 changes for pcc and LKMs.

- Replace most inline assembly with proper functions. As a side effect
this reduces the size of amd64 GENERIC by about 120kB, and i386 by a
smaller amount. Nearly all of the inlines did something slow, or something
that does not need to be fast.
- Make curcpu() and curlwp functions proper, unless __GNUC__ && _KERNEL.
In that case make them inlines. Makes curlwp LKM and preemption safe.
- Make bus_space and bus_dma more LKM friendly.
- Share a few more files between the ports.
- Other minor changes.
 1.9  09-Jul-2007  ad branches: 1.9.8; 1.9.10; 1.9.12;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
 1.8  08-Dec-2006  yamt branches: 1.8.2; 1.8.8; 1.8.10; 1.8.16;
- pass intrframe by-pointer, not by-value.
- make i386 and xen use per-cpu interrupt stack.

xen part is reviewed by Manuel Bouyer.
 1.7  16-Nov-2006  christos branches: 1.7.2; 1.7.4;
__unused removal on arguments; approved by core.
 1.6  13-Oct-2006  hannken More __unused (NPCPPI == 0 case).
 1.5  12-Oct-2006  christos - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
 1.4  07-Sep-2006  gdamore branches: 1.4.2; 1.4.4; 1.4.6; 1.4.8;
Use common todr_settime_ymdhms/gettime_ymdhms.
While here, fix an incorrect test for timeset (that's in kern_todr already),
and an incorrect to time_second (instead of using the date passed in).
 1.3  04-Sep-2006  gdamore Remove unused todr_setcal/todr_getcal and all the assorted stub
implementations.
 1.2  04-Sep-2006  perry Undo static declaration on gettick -- lapic.c uses it.
Pointed out by Geoff Wing (mason at primenet.com.au)
 1.1  04-Sep-2006  perry switch to a common clock.c
 1.4.8.2  10-Dec-2006  yamt sync with head.
 1.4.8.1  22-Oct-2006  yamt sync with head
 1.4.6.2  14-Sep-2006  yamt sync with head.
 1.4.6.1  07-Sep-2006  yamt file clock.c was added on branch yamt-pdpolicy on 2006-09-14 12:31:22 +0000
 1.4.4.2  09-Sep-2006  rpaulo sync with head
 1.4.4.1  07-Sep-2006  rpaulo file clock.c was added on branch rpaulo-netinet-merge-pcb on 2006-09-09 02:44:49 +0000
 1.4.2.2  12-Jan-2007  ad Sync with head.
 1.4.2.1  18-Nov-2006  ad Sync with head.
 1.7.4.1  03-Jun-2008  skrll Sync with netbsd-4.
 1.7.2.2  17-May-2008  bouyer Pull up following revision(s) (requested by kardel in ticket #1058):
sys/arch/x86/isa/clock.c: revision 1.25 via patch
unbreak i8254_get_timecount() in environments where the
clock interrupt is derived from other sources (e.g. lapic)
and the i8254 timer is running the full cycle without
being used as clock interrupt source.
 1.7.2.1  21-Jan-2008  bouyer Pull up following revision(s) (requested by chuck in ticket #1049):
src/sys/arch/x86/isa/clock.c 1.23 via patch
fixes clock accounting problem in i8254_get_timecount that caused
the auich auich_calibrate() function to get the wrong ac97 freq
(may cause audio to play at wrong speed on some systems).
 1.8.16.1  03-Oct-2007  garbled Sync with HEAD
 1.8.10.1  11-Jul-2007  mjf Sync with head.
 1.8.8.3  03-Dec-2007  ad Sync with HEAD.
 1.8.8.2  09-Oct-2007  ad Sync with head.
 1.8.8.1  10-Apr-2007  ad Replace some more locks.
 1.8.2.8  17-Mar-2008  yamt sync with head.
 1.8.2.7  21-Jan-2008  yamt sync with head
 1.8.2.6  07-Dec-2007  yamt sync with head
 1.8.2.5  15-Nov-2007  yamt sync with head.
 1.8.2.4  27-Oct-2007  yamt sync with head.
 1.8.2.3  03-Sep-2007  yamt sync with head.
 1.8.2.2  30-Dec-2006  yamt sync with head.
 1.8.2.1  08-Dec-2006  yamt file clock.c was added on branch yamt-lazymbuf on 2006-12-30 20:47:22 +0000
 1.9.12.1  06-Oct-2007  yamt sync with head.
 1.9.10.3  23-Mar-2008  matt sync with HEAD
 1.9.10.2  09-Jan-2008  matt sync with HEAD
 1.9.10.1  06-Nov-2007  matt sync with HEAD
 1.9.8.6  09-Dec-2007  jmcneill Sync with HEAD.
 1.9.8.5  08-Dec-2007  jmcneill Rename pnp(9) -> pmf(9), as requested by many.
 1.9.8.4  28-Nov-2007  jmcneill Register with power management framework.
 1.9.8.3  21-Nov-2007  joerg Sync with HEAD.
 1.9.8.2  28-Oct-2007  joerg Sync with HEAD.
 1.9.8.1  02-Oct-2007  joerg Sync with HEAD.
 1.10.2.2  18-Nov-2007  bouyer Sync with HEAD
 1.10.2.1  13-Nov-2007  bouyer Sync with HEAD
 1.12.2.4  18-Feb-2008  mjf Sync with HEAD.
 1.12.2.3  27-Dec-2007  mjf Sync with HEAD.
 1.12.2.2  08-Dec-2007  mjf Sync with HEAD.
 1.12.2.1  19-Nov-2007  mjf Sync with HEAD.
 1.13.2.2  26-Dec-2007  ad Sync with head.
 1.13.2.1  08-Dec-2007  ad Sync with head.
 1.14.2.1  11-Dec-2007  yamt sync with head.
 1.15.2.4  20-Jan-2008  bouyer Sync with HEAD
 1.15.2.3  19-Jan-2008  bouyer Sync with HEAD
 1.15.2.2  08-Jan-2008  bouyer Sync with HEAD
 1.15.2.1  02-Jan-2008  bouyer Sync with HEAD
 1.25.6.3  17-Jan-2009  mjf Sync with HEAD.
 1.25.6.2  02-Jun-2008  mjf Sync with HEAD.
 1.25.6.1  03-Apr-2008  mjf Sync with HEAD.
 1.25.2.1  24-Mar-2008  keiichi sync with head.
 1.28.6.1  23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.28.4.3  20-Jun-2009  yamt sync with head
 1.28.4.2  04-May-2009  yamt sync with head.
 1.28.4.1  16-May-2008  yamt sync with head.
 1.28.2.1  18-May-2008  yamt sync with head.
 1.30.14.1  21-Apr-2010  matt sync to netbsd-5
 1.30.8.1  19-Jun-2009  snj Pull up following revision(s) (requested by bouyer in ticket #816):
sys/arch/amd64/conf/files.amd64: revision 1.68
sys/arch/i386/conf/files.i386: revision 1.350
sys/arch/x86/include/rtc.h: revision 1.1
sys/arch/x86/isa/clock.c: revision 1.33
sys/arch/x86/isa/rtc.c: revision 1.1
sys/arch/xen/conf/files.xen: revision 1.100
sys/arch/xen/xen/clock.c: revision 1.50 via patch
Split mc146818-related functions from clock.c into rtc.c.
Call rtc_set_ymdhms() from xen/xen/clock.c:xen_rtc_set() for xen3 dom0
kernels as the Xen3 hypervisor doesn't write the new date/time to the CMOS
by itself.
Now a XEN3_DOM0 kernel properly updates the CMOS time.
 1.30.6.2  28-Apr-2009  skrll Sync with HEAD.
 1.30.6.1  19-Jan-2009  skrll Sync with HEAD.
 1.31.2.3  01-Nov-2009  jym Sync with HEAD.
 1.31.2.2  23-Jul-2009  jym Sync with HEAD.
 1.31.2.1  13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.33.64.2  13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.33.64.1  10-Jun-2019  christos Sync with HEAD
 1.33.56.1  09-Mar-2019  martin Pull up following revision(s) via patch (requested by nonaka in ticket #1210):

sys/dev/hyperv/vmbusvar.h: revision 1.1
sys/dev/hyperv/hvs.c: revision 1.1
sys/dev/hyperv/if_hvn.c: revision 1.1
sys/dev/hyperv/vmbusic.c: revision 1.1
sys/arch/x86/x86/lapic.c: revision 1.69
sys/arch/x86/isa/clock.c: revision 1.34
sys/arch/x86/include/intrdefs.h: revision 1.22
sys/arch/i386/conf/GENERIC: revision 1.1201
sys/arch/x86/x86/hyperv.c: revision 1.1
sys/arch/x86/include/cpu.h: revision 1.105
sys/arch/x86/x86/x86_machdep.c: revision 1.124
sys/arch/i386/conf/GENERIC: revision 1.1203
sys/arch/amd64/amd64/genassym.cf: revision 1.74
sys/arch/i386/conf/GENERIC: revision 1.1204
sys/arch/amd64/conf/GENERIC: revision 1.520
sys/arch/x86/x86/hypervreg.h: revision 1.1
sys/arch/amd64/amd64/vector.S: revision 1.69
sys/dev/hyperv/hvshutdown.c: revision 1.1
sys/dev/hyperv/hvshutdown.c: revision 1.2
sys/dev/usb/if_urndisreg.h: file removal
sys/arch/x86/x86/cpu.c: revision 1.167
sys/arch/x86/conf/files.x86: revision 1.107
sys/dev/usb/if_urndis.c: revision 1.20
sys/dev/hyperv/vmbusicreg.h: revision 1.1
sys/dev/hyperv/hvheartbeat.c: revision 1.1
sys/dev/hyperv/vmbusicreg.h: revision 1.2
sys/dev/hyperv/hvheartbeat.c: revision 1.2
sys/dev/hyperv/files.hyperv: revision 1.1
sys/dev/ic/rndisreg.h: revision 1.1
sys/arch/i386/i386/genassym.cf: revision 1.111
sys/dev/ic/rndisreg.h: revision 1.2
sys/dev/hyperv/hyperv_common.c: revision 1.1
sys/dev/hyperv/hvtimesync.c: revision 1.1
sys/dev/hyperv/hypervreg.h: revision 1.1
sys/dev/hyperv/hvtimesync.c: revision 1.2
sys/dev/hyperv/vmbusicvar.h: revision 1.1
sys/dev/hyperv/if_hvnreg.h: revision 1.1
sys/arch/x86/x86/lapic.c: revision 1.70
sys/arch/amd64/amd64/vector.S: revision 1.70
sys/dev/ic/ndisreg.h: revision 1.1
sys/arch/amd64/conf/GENERIC: revision 1.516
sys/dev/hyperv/hypervvar.h: revision 1.1
sys/arch/amd64/conf/GENERIC: revision 1.518
sys/arch/amd64/conf/GENERIC: revision 1.519
sys/arch/i386/conf/files.i386: revision 1.400
sys/dev/acpi/vmbus_acpi.c: revision 1.1
sys/dev/hyperv/vmbus.c: revision 1.1
sys/dev/hyperv/vmbus.c: revision 1.2
sys/arch/x86/x86/intr.c: revision 1.144
sys/arch/i386/i386/vector.S: revision 1.83
sys/arch/amd64/conf/files.amd64: revision 1.112

separate RNDIS definitions from urndis(4) for use with Hyper-V NetVSC.

-

Added Microsoft Hyper-V support. It ported from OpenBSD and FreeBSD.
graphical console is not work on Gen.2 VM yet. To use the serial console,
enter "consdev com,0x3f8,115200" on efiboot.

-

Add __diagused.

-

PR/53984: Partial revert of modify lapic_calibrate_timer() in lapic.c r1.69.

-

Update Hyper-V related drivers description.

-

Remove unused definition.

-

Rename the MODULE_*_HOOK() macros to MODULE_HOOK_*() as briefly
discussed on irc.
NFCI intended.

-

commented out hvkvp entry.

-

fix typo. pointed out by pgoyette@n.o.

-

Use IDTVEC instead of NENTRY for handle_hyperv_hypercall.

-

Rename the MODULE_*_HOOK() macros to MODULE_HOOK_*() as briefly
discussed on irc.
 1.36.6.1  18-Apr-2020  bouyer Centralize initialisations of delay_func and initclock_func
in x86_machdep.c and export from <x86/machdep.h>
Introduce a x86_dummy_initclock() and a x86_cpu_initclock_func pointer,
to be used later for Xen HVM native clock support.
rename rtclock_tval to x86_rtclock_tval and export from <x86/machdep.h>,
for the benefit of lapic.c
 1.39.20.1  01-Apr-2023  martin Pull up following revision(s) (requested by riastradh in ticket #136):

sys/arch/x86/x86/intr.c: revision 1.164
sys/arch/x86/isa/clock.c: revision 1.41
sys/arch/x86/include/intr_private.h: revision 1.1

x86/intr: Work around sleazy clockintr with a secret frame argument.
PR kern/57197

RSS XML Feed