summaryrefslogtreecommitdiffstats
path: root/sys/amd64/include/clock.h
Commit message (Collapse)AuthorAgeFilesLines
* First part of a little cleanup in the calendar/timezone/RTC handling.phk2006-10-021-3/+0
| | | | | | Move relevant variables to <sys/clock.h> and fix #includes as necessary. Use libkern's much more time- & spamce-efficient BCD routines.
* Move clock_lock prototype into <machine/clock.h>, where it is moresobomax2006-05-191-0/+1
| | | | | | appropriate. Discussed with: jhb
* Tweak how the MD code calls the fooclock() methods some. Instead ofjhb2005-12-221-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | passing a pointer to an opaque clockframe structure and requiring the MD code to supply CLKF_FOO() macros to extract needed values out of the opaque structure, just pass the needed values directly. In practice this means passing the pair (usermode, pc) to hardclock() and profclock() and passing the boolean (usermode) to hardclock_cpu() and hardclock_process(). Other details: - Axe clockframe and CLKF_FOO() macros on all architectures. Basically, all the archs were taking a trapframe and converting it into a clockframe one way or another. Now they can just extract the PC and usermode values directly out of the trapframe and pass it to fooclock(). - Renamed hardclock_process() to hardclock_cpu() as the latter is more accurate. - On Alpha, we now run profclock() at hz (profhz == hz) rather than at the slower stathz. - On Alpha, for the TurboLaser machines that don't have an 8254 timecounter, call hardclock() directly. This removes an extra conditional check from every clock interrupt on Alpha on the BSP. There is probably room for even further pruning here by changing Alpha to use the simplified timecounter we use on x86 with the lapic timer since we don't get interrupts from the 8254 on Alpha anyway. - On x86, clkintr() shouldn't ever be called now unless using_lapic_timer is false, so add a KASSERT() to that affect and remove a condition to slightly optimize the non-lapic case. - Change prototypeof arm_handler_execute() so that it's first arg is a trapframe pointer rather than a void pointer for clarity. - Use KCOUNT macro in profclock() to lookup the kernel profiling bucket. Tested on: alpha, amd64, arm, i386, ia64, sparc64 Reviewed by: bde (mostly)
* Begin all license/copyright comments with /*-imp2005-01-051-1/+1
|
* Initial landing of SMP support for FreeBSD/amd64.peter2003-11-171-0/+1
| | | | | | | | | | | | | | | | - This is heavily derived from John Baldwin's apic/pci cleanup on i386. - I have completely rewritten or drastically cleaned up some other parts. (in particular, bootstrap) - This is still a WIP. It seems that there are some highly bogus bioses on nVidia nForce3-150 boards. I can't stress how broken these boards are. I have a workaround in mind, but right now the Asus SK8N is broken. The Gigabyte K8NPro (nVidia based) is also mind-numbingly hosed. - Most of my testing has been with SCHED_ULE. SCHED_4BSD works. - the apic and acpi components are 'standard'. - If you have an nVidia nForce3-150 board, you are stuck with 'device atpic' in addition, because they somehow managed to forget to connect the 8254 timer to the apic, even though its in the same silicon! ARGH! This directly violates the ACPI spec.
* Preemptively burn a bridges. The isa timer code is likely to bepeter2003-11-141-4/+0
| | | | | replaced by the HPET timer at some point, so dont even make a release with the aquire/release_timer0 functions.
* MFi386: BURN_BRIDGES around timer0 functionspeter2003-09-301-1/+3
|
* MFi386 machdep.c rev 1.201, clock.c 1.201, clock.h 1.45 by phk: Dontpeter2003-09-221-0/+1
| | | | | | | | | | | initialize a TSC timecounter until we know if it is broke or not. XXX I think there is a bug in the i386 code here. init_TSC_tc() comes after: if (statclock_disable) return; ie: if you turn off the statclock interrupt, you dont get the TSC either.
* Commit MD parts of a loosely functional AMD64 port. This is based onpeter2003-05-011-9/+0
| | | | | | | | | | | | | | | | | | | | | | a heavily stripped down FreeBSD/i386 (brutally stripped down actually) to attempt to get a stable base to start from. There is a lot missing still. Worth noting: - The kernel runs at 1GB in order to cheat with the pmap code. pmap uses a variation of the PAE code in order to avoid having to worry about 4 levels of page tables yet. - It boots in 64 bit "long mode" with a tiny trampoline embedded in the i386 loader. This simplifies locore.s greatly. - There are still quite a few fragments of i386-specific code that have not been translated yet, and some that I cheated and wrote dumb C versions of (bcopy etc). - It has both int 0x80 for syscalls (but using registers for argument passing, as is native on the amd64 ABI), and the 'syscall' instruction for syscalls. int 0x80 preserves all registers, 'syscall' does not. - I have tried to minimize looking at the NetBSD code, except in a couple of places (eg: to find which register they use to replace the trashed %rcx register in the syscall instruction). As a result, there is not a lot of similarity. I did look at NetBSD a few times while debugging to get some ideas about what I might have done wrong in my first attempt.
* i386/i386/tsc.c was repo-copied from i386/isa/clock.c.phk2003-02-051-0/+1
| | | | | | | | | | | | | | | | | | | | | | | Remove all the stuff that does not relate to the TSC. Change the calibration to use DELAY(1000000) rather than trying to check it against the CMOS RTC, this drastically increases precision: Using 25 samples on a Athlon 700MHz UP machine I find: stddev min max average CMOS 22200 Hz -74980 Hz 34301 Hz 704928721 Hz DELAY 1805 Hz -1984 Hz 2678 Hz 704937583 Hz (The difference between the two averages is not statistically significant.) expressed in PPM of the frequency: stddev min max CMOS 31.49 PPM -106.37 PPM 48.66 PPM DELAY 2.56 PPM 2.81 PPM 3.80 PPM This code will not be used until a followup commit to sys/isa/clock.c and sys/pc98/pc98/clock.c which will only happen after some field testing.
* Split statclock into statclock and profclock, and made the method for drivingjake2003-02-031-0/+2
| | | | | | | | | | | | | statclock based on profhz when profiling is enabled MD, since most platforms don't use this anyway. This removes the need for statclock_process, whose only purpose was to subdivide profhz, and gets the profiling clock running outside of sched_lock on platforms that implement suswintr. Also changed the interface for starting and stopping the profiling clock to do just that, instead of changing the rate of statclock, since they can now be separate. Reviewed by: jhb, tmm Tested on: i386, sparc64
* Make tsc_freq a 64bit quantity.phk2003-01-291-1/+1
| | | | Inspired by: http://www.theinquirer.net/?article=7481
* Remove __P.alfred2002-03-201-10/+9
|
* Reenable RTC interrupts after wakeup. Some laptops have a problemiwasaki2001-09-041-1/+1
| | | | | | | | | with system statistics monitoring tools (such as systat, vmstat...) because of stopping RTC interrupts generation. Restore all the timers (RTC and i8254) atomically. Reviewed by: bde MFC after: 1 week
* Move DELAY() from <machine/clock.h> to <sys/systm.h>phk2000-10-151-1/+0
|
* Change #ifdef KERNEL to #ifdef _KERNEL in the public headers. "KERNEL"peter1999-12-291-2/+2
| | | | | | is an application space macro and the applications are supposed to be free to use it as they please (but cannot). This is consistant with the other BSD's who made this change quite some time ago. More commits to come.
* i8254_restore is called from apm_default_resume() to reloadiwasaki1999-10-301-0/+1
| | | | | | | | | | | | the countdown register. this should not be necessary but there are broken laptops that do not restore the countdown register on resume. when it happnes, it messes up the hardclock interval and system clock, which leads to the infamous "calcru: negative time" problem. Submitted by: kjc, iwasaki Reviewed by: Steve O'Hara-Smith <steveo@eircom.net> and committers. Obtained from: PAO3
* $Id$ -> $FreeBSD$peter1999-08-281-1/+1
|
* Stop the TSC from being used as timecounter on K5/step0 machines.phk1999-05-291-1/+2
|
* Remove special handling for resuming clock interrupt when using APIC_IO.tegge1998-03-051-1/+4
| | | | The `generic' vector stubs do the right thing.
* Removed vestiges of previous microtime() implementation.bde1998-02-251-6/+2
|
* Replace TOD clock code with more systematic approach.phk1998-02-201-65/+1
| | | | | | | | | | | | | | | Highlights: * Simple model for underlying hardware. * Hardware basis for timekeeping can be changed on the fly. * Only one hardware clock responsible for TOD keeping. * Provides a real nanotime() function. * Time granularity: .232E-18 seconds. * Frequency granularity: .238E-12 s/s * Frequency adjustment is continuous in time. * Less overhead for frequency adjustment. * Improves xntpd performance. Reviewed by: bde, bde, bde
* Fixed a recently broken comment.bde1998-02-011-4/+4
|
* More cleanup relating to our use of the TSC.phk1997-12-281-13/+1
| | | | Look in the cpu_feature (CPUID output) to see if we have it.
* wash, sort and put in order various nits from the i586_ctr -> tscphk1997-12-281-11/+11
| | | | | | commit. Pointed out by: bde
* Rename "i586_ctr" to "tsc" (both upper and lower case instances).phk1997-12-261-13/+13
| | | | | | Fix a couple of printfs too. Warning: This changes the names of a couple of kernel options!
* correct the order of the variablespeter1997-05-051-3/+5
| | | | | | use #ifdef where possible instead of #if defined Submitted by: the KNF police, ie: bde :-)
* Don't remove i586_ctr_freq from scope, leave it defined as zero. Thispeter1997-05-041-3/+5
| | | | | | | simplifies some assumptions and stops some code compile problems. This should fix the compile hiccup in PR#3491, but smp kernel profiling isn't likely to be fixed by this.
* Man the liferafts! Here comes the long awaited SMP -> -current merge!peter1997-04-261-4/+4
| | | | | | | | | | | | | | | | There are various options documented in i386/conf/LINT, there is more to come over the next few days. The kernel should run pretty much "as before" without the options to activate SMP mode. There are a handful of known "loose ends" that need to be fixed, but have been put off since the SMP kernel is in a moderately good condition at the moment. This commit is the result of the tinkering and testing over the last 14 months by many people. A special thanks to Steve Passe for implementing the APIC code!
* Back out part 1 of the MCFH that changed $Id$ to $FreeBSD$. We are notpeter1997-02-221-1/+1
| | | | ready for it yet.
* Make the long-awaited change from $Id$ to $FreeBSD$jkh1997-01-141-1/+1
| | | | | | | | This will make a number of things easier in the future, as well as (finally!) avoiding the Id-smashing problem which has plagued developers for so long. Boy, I'm glad we're not using sup anymore. This update would have been insane otherwise.
* Staticize the functions rtc_inb, rtc_outb, rtc_serialcombit, andkato1997-01-101-4/+1
| | | | rtc_serialcom. These functions are only used by PC98.
* More merge and update.asami1996-10-301-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | (1) deleted #if 0 pc98/pc98/mse.c (2) hold per-unit I/O ports in ed_softc pc98/pc98/if_ed.c pc98/pc98/if_ed98.h (3) merge more files by segregating changes into headers. new file (moved from pc98/pc98): i386/isa/aic_98.h deleted: well, it's already in the commit message so I won't repeat the long list here ;) Submitted by: The FreeBSD(98) Development Team
* Improved biasing of i586 clock by adjusting for hardclock() latency.bde1996-10-251-51/+62
| | | | | | | | | | | | | | | | | | | | | I decided to do this for every hardclock() call instead of lazily in microtime(). The lazy method is simpler but has more overhead if microtime() is called a lot. CPU_THISTICKLEN() is now a no-op and should probably go away. Previously it did nothing directly but had the side effect of setting i586_last_tick for CPU_CLOCKUPDATE() and i586_avg_tick for debugging. CPU_CLOCKUPDATE() now uses a better method and i586_avg_tick is too much trouble to maintain. Reduced nesting of #includes in the usual case. Increased nesting of #includes when CLOCK_HAIR is defined. This is a kludge to get typedefs for inline functions only when the inline functions are used. Normally only kern_clock.c defines this. kern_clock.c can't include the i386 headers directly. Removed unused LOCORE support.
* Added missing extern declaration of timer_freq.bde1996-10-171-8/+7
| | | | Sorted declarations of scalars.
* Don't include "opt_cpu.h" in <machine/clock.h>, since this breaks lkm's.bde1996-10-101-3/+1
| | | | | The change breaks kern_clock.c; fix that temporarily by including "opt_cpu.h" there.
* Put I*86_CPU defines in opt_cpu.h.bde1996-10-091-1/+3
|
* Eliminated i586_ctr_rate. Use i586_ctr_freq instead.bde1996-08-021-8/+6
| | | | | | | Changed i586_ctr_bias from long long to u_int. Only the low 32 bits are used now that microtime uses a multiplication to do the scaling. Previously the high 32 bits had to match those of rdtsc() to prevent overflow traps and invalid timeval adjustments.
* Fixed the machdep.i8254_freq and machdep.i586_freq sysctls. Writes werebde1996-07-301-2/+6
| | | | | | | handled bogusly. Centralized the setting of all the frequency variables. Set these variables atomically. Some new ones aren't used yet.
* The Great PC98 Merge.asami1996-06-141-1/+9
| | | | | | | | All new code is "#ifdef PC98"ed so this should make no difference to PC/AT (and its clones) users. Ok'd by: core Submitted by: FreeBSD(98) development team
* Added calibration the i8254 and the i586 clocks agains the RTC at bootbde1996-05-011-9/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | time. The results are currently ignored unless certain temporary options are used. Added sysctls to support reading and writing the clock frequency variables (not the frequencies themselves). Writing is supposed to atomically adjust all related variables. machdep.c: Fixed spelling of a function name in a comment so that I can log this message which should have been with the previous commit. Initialize `cpu_class' earlier so that it can be used in startrtclock() instead of in calibrate_cyclecounter() (which no longer exists). Removed range checking of `cpu'. It is always initialized to CPU_XXX so it is less likely to be out of bounds than most variables. clock.h: Removed I586_CYCLECTR(). Use rdtsc() instead. clock.c: TIMER_FREQ is now a variable timer_freq that defaults to the old value of TIMER_FREQ. #define'ing TIMER_FREQ should still work and may be the best way of setting the frequency. Calibration involves counting cycles while watching the RTC for one second. This gives values correct to within (a few ppm) + (the innaccuracy of the RTC) on my systems.
* - add apm to the GENERIC kernel (disabled by default), and add some commentsnate1996-04-221-1/+2
| | | | | | | | | | | regarding apm to LINT - Disabled the statistics clock on machines which have an APM BIOS and have the options "APM_BROKEN_STATCLOCK" enabled (which is default in GENERIC now) - move around some of the code in clock.c dealing with the rtc to make it more obvios the effects of disabling the statistics clock Reviewed by: bde
* Add wall_cmos_clock sysctl variable, needed to manage adjkerntz even forache1996-04-051-1/+3
| | | | UTC cmos clocks (needed for Local Timezone FSes)
* Moved rtcin() to clock.c.bde1996-03-311-1/+2
| | | | | | | | Always delay using one inb(0x84) after each i/o in rtcin() - don't do this conditional on the bogus option DUMMY_NOPS not being defined. If you want an optionally slightly faster rtcin() again, then inline it and use a better named option or sysctl variable. It only needs to be fast in rtcintr().
* No longer use the cyclecounter to attempt to correct for late or missedwollman1996-01-301-6/+6
| | | | | | | | clock interrupts. Keep a 1-in-16 smoothed average of the length of each tick. If the CPU speed is correctly diagnosed, this should give experienced users enough information to figure out a more suitable value for `tick'.
* Add Pentium Pro CPU detection and special handling. For now, all thedg1995-12-241-5/+5
| | | | | optimizations we have for 586s also apply to 686s...this will be fine- tuned in the future as appropriate.
* Staticize and cleanup.phk1995-12-101-3/+1
|
* Fix Pentium CPU rate diagnosis:wollman1995-11-291-4/+9
| | | | | | | | | | | | - Don't print out meaningless iCOMP numbers, those are for droids. - Use a shorter wait to determine clock rate to avoid deficiencies in DELAY(). - Use a fixed-point representation with 8 bits of fraction to store the rate and rationalize the variable name. It would be possible to use even more fraction if it turns out to be worthwhile (I rather doubt it). The question of source code arrangement remains unaddressed.
* Reduce jitter of Pentium microtime() implementation by letting the counterwollman1995-10-121-23/+38
| | | | | | | free-run and doing a subtract in microtime() rather than resetting the counter to zero at every clock tick. In combination with the changes to kern_clock.c, this should eliminate all the immediately obvious sources of systematic jitter in timekeeping on Pentium machines.
* Add and move declarations to fix all of the warnings from `gcc -Wimplicit'bde1995-03-161-7/+0
| | | | | | (except in netccitt, netiso and netns) and most of the warnings from `gcc -Wnested-externs'. Fix all the bugs found. There were no serious ones.
OpenPOWER on IntegriCloud