summaryrefslogtreecommitdiff
path: root/sys/amd64/isa/clock.c
Commit message (Collapse)AuthorAgeFilesLines
* Catch up to header include changes:John Baldwin2001-03-281-3/+1
| | | | | | | | - <sys/mutex.h> now requires <sys/systm.h> - <sys/mutex.h> and <sys/sx.h> now require <sys/lock.h> Notes: svn path=/head/; revision=74914
* Fixed style bugs in clock.c rev.1.164 and cpu.h rev.1.52-1.53 -- declareBruce Evans2001-02-191-6/+1
| | | | | | | | | tsc_present in the right places (together with other variables of the same linkage), and don't use messy ifdefs just to avoid exporting it in some cases. Notes: svn path=/head/; revision=72678
* Catch up to changes to inthand_add().John Baldwin2001-02-091-8/+8
| | | | Notes: svn path=/head/; revision=72240
* Change and clean the mutex lock interface.Bosko Milekic2001-02-091-16/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | mtx_enter(lock, type) becomes: mtx_lock(lock) for sleep locks (MTX_DEF-initialized locks) mtx_lock_spin(lock) for spin locks (MTX_SPIN-initialized) similarily, for releasing a lock, we now have: mtx_unlock(lock) for MTX_DEF and mtx_unlock_spin(lock) for MTX_SPIN. We change the caller interface for the two different types of locks because the semantics are entirely different for each case, and this makes it explicitly clear and, at the same time, it rids us of the extra `type' argument. The enter->lock and exit->unlock change has been made with the idea that we're "locking data" and not "entering locked code" in mind. Further, remove all additional "flags" previously passed to the lock acquire/release routines with the exception of two: MTX_QUIET and MTX_NOSWITCH The functionality of these flags is preserved and they can be passed to the lock/unlock routines by calling the corresponding wrappers: mtx_{lock, unlock}_flags(lock, flag(s)) and mtx_{lock, unlock}_spin_flags(lock, flag(s)) for MTX_DEF and MTX_SPIN locks, respectively. Re-inline some lock acq/rel code; in the sleep lock case, we only inline the _obtain_lock()s in order to ensure that the inlined code fits into a cache line. In the spin lock case, we inline recursion and actually only perform a function call if we need to spin. This change has been made with the idea that we generally tend to avoid spin locks and that also the spin locks that we do have and are heavily used (i.e. sched_lock) do recurse, and therefore in an effort to reduce function call overhead for some architectures (such as alpha), we inline recursion for this case. Create a new malloc type for the witness code and retire from using the M_DEV type. The new type is called M_WITNESS and is only declared if WITNESS is enabled. Begin cleaning up some machdep/mutex.h code - specifically updated the "optimized" inlined code in alpha/mutex.h and wrote MTX_LOCK_SPIN and MTX_UNLOCK_SPIN asm macros for the i386/mutex.h as we presently need those. Finally, caught up to the interface changes in all sys code. Contributors: jake, jhb, jasone (in no particular order) Notes: svn path=/head/; revision=72200
* Convert mca (microchannel bus support) from something that we countPeter Wemm2001-01-291-3/+3
| | | | | | | (bogus) to something that we test for the presence of. Notes: svn path=/head/; revision=71797
* Remove MUTEX_DECLARE() and MTX_COLD. Instead, postpone full mutexJason Evans2001-01-211-1/+1
| | | | | | | | | | | initialization until after malloc() is safe to call, then iterate through all mutexes and complete their initialization. This change is necessary in order to avoid some circular bootstrapping dependencies. Notes: svn path=/head/; revision=71320
* Convert apm from a bogus 'count' into a plain option. Clean out somePeter Wemm2001-01-191-3/+3
| | | | | | | other cruft from the files.alpha and files.ia64 that were related to this. Notes: svn path=/head/; revision=71262
* Namespace cleanup. Remove some #includes in favour of an explicitMark Murray2000-12-021-0/+5
| | | | | | | | | declaration. Asked for by: bde Notes: svn path=/head/; revision=69521
* Revert two experimental changes which escaped from my devel machine.Poul-Henning Kamp2000-10-281-1/+1
| | | | Notes: svn path=/head/; revision=67759
* Convert all users of fldoff() to offsetof(). fldoff() is badPoul-Henning Kamp2000-10-271-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | because it only takes a struct tag which makes it impossible to use unions, typedefs etc. Define __offsetof() in <machine/ansi.h> Define offsetof() in terms of __offsetof() in <stddef.h> and <sys/types.h> Remove myriad of local offsetof() definitions. Remove includes of <stddef.h> in kernel code. NB: Kernelcode should *never* include from /usr/include ! Make <sys/queue.h> include <machine/ansi.h> to avoid polluting the API. Deprecate <struct.h> with a warning. The warning turns into an error on 01-12-2000 and the file gets removed entirely on 01-01-2001. Paritials reviews by: various. Significant brucifications by: bde Notes: svn path=/head/; revision=67708
* - Overhaul the software interrupt code to use interrupt threads for eachJohn Baldwin2000-10-251-5/+1
| | | | | | | | | | | | | | | | | | | | | | type of software interrupt. Roughly, what used to be a bit in spending now maps to a swi thread. Each thread can have multiple handlers, just like a hardware interrupt thread. - Instead of using a bitmask of pending interrupts, we schedule the specific software interrupt thread to run, so spending, NSWI, and the shandlers array are no longer needed. We can now have an arbitrary number of software interrupt threads. When you register a software interrupt thread via sinthand_add(), you get back a struct intrhand that you pass to sched_swi() when you wish to schedule your swi thread to run. - Convert the name of 'struct intrec' to 'struct intrhand' as it is a bit more intuitive. Also, prefix all the members of struct intrhand with 'ih_'. - Make swi_net() a MI function since there is now no point in it being MD. Submitted by: cp Notes: svn path=/head/; revision=67551
* - machine/mutex.h -> sys/mutex.hJohn Baldwin2000-10-201-3/+3
| | | | | | | | - machine/ipl.h -> sys/ipl.h - Use MUTEX_DECLARE() for clock_lock Notes: svn path=/head/; revision=67356
* - Change fast interrupts on x86 to push a full interrupt frame and toJohn Baldwin2000-10-061-106/+51
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | return through doreti to handle ast's. This is necessary for the clock interrupts to work properly. - Change the clock interrupts on the x86 to be fast instead of threaded. This is needed because both hardclock() and statclock() need to run in the context of the current process, not in a separate thread context. - Kill the prevproc hack as it is no longer needed. - We really need Giant when we call psignal(), but we don't want to block during the clock interrupt. Instead, use two p_flag's in the proc struct to mark the current process as having a pending SIGVTALRM or a SIGPROF and let them be delivered during ast() when hardclock() has finished running. - Remove CLKF_BASEPRI, which was #ifdef'd out on the x86 anyways. It was broken on the x86 if it was turned on since cpl is gone. It's only use was to bogusly run softclock() directly during hardclock() rather than scheduling an SWI. - Remove the COM_LOCK simplelock and replace it with a clock_lock spin mutex. Since the spin mutex already handles disabling/restoring interrupts appropriately, this also lets us axe all the *_intr() fu. - Back out the hacks in the APIC_IO x86 cpu_initclocks() code to use temporary fast interrupts for the APIC trial. - Add two new process flags P_ALRMPEND and P_PROFPEND to mark the pending signals in hardclock() that are to be delivered in ast(). Submitted by: jakeb (making statclock safe in a fast interrupt) Submitted by: cp (concept of delaying signals until ast()) Notes: svn path=/head/; revision=66716
* - Heavyweight interrupt threads on the alpha for device I/O interrupts.John Baldwin2000-10-051-6/+0
| | | | | | | | | | | | | | - Make softinterrupts (SWI's) almost completely MI, and divorce them completely from the x86 hardware interrupt code. - The ihandlers array is now gone. Instead, there is a MI shandlers array that just contains SWI handlers. - Most of the former machine/ipl.h files have moved to a new sys/ipl.h. - Stub out all the spl*() functions on all architectures. Submitted by: dfr Notes: svn path=/head/; revision=66698
* - Remove the inthand2_t type and use the equivalent driver_intr_t type fromJohn Baldwin2000-09-131-7/+7
| | | | | | | | | | | | | | | | newbus for referencing device interrupt handlers. - Move the 'struct intrec' type which describes interrupt sources into sys/interrupt.h instead of making it just be a x86 structure. - Don't create 'ithd' and 'intrec' typedefs, instead, just use 'struct ithd' and 'struct intrec' - Move the code to translate new-bus interrupt flags into an interrupt thread priority out of the x86 nexus code and into a MI ithread_priority() function in sys/kern/kern_intr.c. - Remove now-uneeded x86-specific headers from sys/dev/ata/ata-all.c and sys/pci/pci_compat.c. Notes: svn path=/head/; revision=65822
* Major update to the way synchronization is done in the kernel. HighlightsJason Evans2000-09-071-52/+103
| | | | | | | | | | | | | | | | | | include: * Mutual exclusion is used instead of spl*(). See mutex(9). (Note: The alpha port is still in transition and currently uses both.) * Per-CPU idle processes. * Interrupts are run in their own separate kernel threads and can be preempted (i386 only). Partially contributed by: BSDi (BSD/OS) Submissions by (at least): cp, dfr, dillon, grog, jake, jhb, sheldonh Notes: svn path=/head/; revision=65557
* Allow use of TSC even if APM is compiled in but disabled.Poul-Henning Kamp2000-07-301-1/+6
| | | | Notes: svn path=/head/; revision=64031
* Previous commit changing SYSCTL_HANDLER_ARGS violated KNF.Poul-Henning Kamp2000-07-041-2/+2
| | | | | | | Pointed out by: bde Notes: svn path=/head/; revision=62573
* Style police catches up with rev 1.26 of src/sys/sys/sysctl.h:Poul-Henning Kamp2000-07-031-2/+2
| | | | | | | | | | | Sanitize SYSCTL_HANDLER_ARGS so that simplistic tools can grog our sources: -sysctl_vm_zone SYSCTL_HANDLER_ARGS +sysctl_vm_zone (SYSCTL_HANDLER_ARGS) Notes: svn path=/head/; revision=62454
* Add PnP probe methods to some common AT hardware drivers. In each case,Mike Smith2000-06-231-0/+48
| | | | | | | | | | | | the PnP probe is merely a stub as we make assumptions about some of this hardware before we have probed it. Since these devices (with the exception of the speaker) are 'standard', suppress output in the !bootverbose case to clean up the probe messages somewhat. Notes: svn path=/head/; revision=61994
* Add SWI_TQ_MASK to all interrupt masks except SWI_CLOCK_MASK. Use aBruce Evans2000-05-311-1/+1
| | | | | | | | | | new macro SWI_LOW_MASK to give the mask for low priority SWIs instead of hard-coding this mask as SWI_CLOCK_MASK. Reviewed by: dfr Notes: svn path=/head/; revision=61126
* Isolate the Timecounter internals in their own two files.Poul-Henning Kamp2000-03-201-6/+7
| | | | | | | | | | | | | | | | | | Make the public interface more systematically named. Remove the alternate method, it doesn't do any good, only ruins performance. Add counters to profile the usage of the 8 access functions. Apply the beer-ware to my code. The weird +/- counts are caused by two repocopies behind the scenes: kern/kern_clock.c -> kern/kern_tc.c sys/time.h -> sys/timetc.h (thanks peter!) Notes: svn path=/head/; revision=58377
* ISA device drivers use the ISA source interrupt number in locations whereTor Egge2000-01-041-9/+27
| | | | | | | | | | | | | | | | | the low level interrupt handler number should be used. Change setup_apic_irq_mapping() to allocate low level interrupt handler X (Xintr${X}) for any ISA interrupt X mentioned in the MP table. Remove an assumption in the driver for the system clock (clock.c) that interrupts mentioned in the MP table as delivered to IOAPIC #0 intpin Y is handled by low level interrupt handler Y (Xintr${Y}) but don't assume that low level interrupt handler 0 (Xintr0) is used. Don't allocate two low level interrupt handlers for the system clock. Reviewed by: NOKUBI Hirotaka <hnokubi@yyy.or.jp> Notes: svn path=/head/; revision=55420
* Fixed races accessing the RTC. The races apparently causedBruce Evans1999-12-251-4/+16
| | | | | | | | | | | | | | | | | | apm_default_resume() to sometimes set a very wrong time. (1) Accesses to the RTC index and data registers were not atomic enough. Interrupts were not masked. This was only good enough until an interrupt handler (rtcintr()) started accessing the RTC in FreeBSD-2.0. (2) Access to the block of time registers in inittodr() was not atomic enough. inittodr() has 244us to read the time registers. Interrupts were not masked. This was only good enough until something (apm) started calling inittodr() after boot time in FreeBSD-2.0. The fix for (2) also makes the timecounter update more atomic, although this is currently unimportant due to the low resolution of the RTC. Problem reported by: mckay Notes: svn path=/head/; revision=55098
* Remove references to register_intr() etc in comments.Peter Wemm1999-12-201-1/+1
| | | | Notes: svn path=/head/; revision=54890
* i8254_restore is called from apm_default_resume() to reloadMitsuru IWASAKI1999-10-301-0/+22
| | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=52669
* This adds the i386 specific support for systems with a MicroChannelMatthew N. Dodd1999-09-031-0/+10
| | | | | | | | | Architecture bus. Reviewed by: msmith Notes: svn path=/head/; revision=50823
* $Id$ -> $FreeBSD$Peter Wemm1999-08-281-1/+1
| | | | Notes: svn path=/head/; revision=50477
* Merge the cons.c and cons.h to the best of my ability. alpha may orPoul-Henning Kamp1999-08-091-2/+2
| | | | | | | may not compile, I can't test it. Notes: svn path=/head/; revision=49558
* Remove XXX from the headers (broke the build, I'm betting.)Brian Feldman1999-07-291-2/+1
| | | | Notes: svn path=/head/; revision=49196
* We're called too early to have any idea whether APM is going to beMike Smith1999-07-281-11/+7
| | | | | | | | | | | | | | active or not. The only sane thing we can do here is assume that if APM is supported it might be active at some point, and bail. In reality, even this isn't good enough; regardless of whether we support APM or not, the system may well futz with the CPU's clock speed and throw the TSC off. We need to stop using it for timekeeping except under controlled circumstances. Curse the lack of a dependable high-resolution timer. Notes: svn path=/head/; revision=49186
* Updated acquire_timer2()'s state machine to work when the i8254 isBruce Evans1999-07-181-23/+10
| | | | | | | | | | being used for timecounting. Fixed a race or two in it. Undisabled it. PR: 10455 Notes: svn path=/head/; revision=48889
* Don't let the machdep.tsc_freq sysctl proceed if the TSC is presentBruce Evans1999-07-181-6/+6
| | | | | | | | | | | | | but broken, since tsc_timecounter is not initialised in that case, and updating an uninitialised timecounter is fatal. Fixed style bugs in the machdep.i8254_freq and machdep.tsc_freq sysctls. Reviewed by: phk Notes: svn path=/head/; revision=48888
* Shut up gcc.Peter Wemm1999-06-271-1/+3
| | | | Notes: svn path=/head/; revision=48266
* This commit gives support for the Rise mP6 CPU. It has two changes:Brian Feldman1999-06-241-5/+7
| | | | | | | | | | | | | | | | 1. Rise is recognized in identdcpu.c. 2. The TSC is not written to. A workaround for the CPU bug is being applied to clock.c (the bug being that the mP6 has TSC enabled in its CPUID-capabilities, but it only supports reading it. If we try to write to it (MSR 16), a GPF occurs.) The new behavior is that FreeBSD will _not_ zero the TSC. Instead, we do a bit of 64-bit arithmetic. Reviewed by: msmith Obtained from: unfurl & msmith Notes: svn path=/head/; revision=48160
* Remove fd driver from its old home and change files which include rtc.hDoug Rabson1999-05-311-2/+2
| | | | | | | to account for its new location. Notes: svn path=/head/; revision=47642
* Stop the TSC from being used as timecounter on K5/step0 machines.Poul-Henning Kamp1999-05-291-2/+3
| | | | Notes: svn path=/head/; revision=47592
* Fixed glitches (jumps) of about 1/HZ seconds for the i8254 timecounter.Bruce Evans1999-05-281-20/+21
| | | | | | | | | | | | | | | | | | | The old version only worked right when the time was read strictly more often than every 1/HZ seconds, but we only guarantee reading it every (1/HZ + epsilon) seconds. Part of rev.1.126-1.127 attempted to fix this but didn't succeed. Detect counter rollover using the heuristic from the old version of microtime() with additional complications for supporting calls from fast interrupt handlers. This works provided i8254 interrupts are not delayed by more than 1/(2*HZ) seconds. This needs more comments, and cleanups for the SMP case, and more testing of the SMP case before it is merged into RELENG_3. Tested by: jhay Notes: svn path=/head/; revision=47588
* For what it's worth, idelayed is declared as a volatile in the headers,Peter Wemm1999-05-091-2/+2
| | | | | | | and even though it's not used in this file make it a volatile here too. Notes: svn path=/head/; revision=46847
* Make the machdep.i8254_freq and machdep.tsc_freq sysctls modify thePoul-Henning Kamp1999-04-251-1/+3
| | | | | | | | | timecounter as well Asked for by: bde, jhay Notes: svn path=/head/; revision=46054
* oops, SMP was missing includes for a typedef.Peter Wemm1999-04-211-2/+2
| | | | Notes: svn path=/head/; revision=45900
* Stage 1 of a cleanup of the i386 interrupt registration mechanism.Peter Wemm1999-04-211-16/+12
| | | | | | | | | | Interrupts under the new scheme are managed by the i386 nexus with the awareness of the resource manager. There is further room for optimizing the interfaces still. All the users of register_intr()/intr_create() should be gone, with the exception of pcic and i386/isa/clock.c. Notes: svn path=/head/; revision=45897
* Fix tabs that should have been spaces. Some were in kernel error messages.Stephen McKay1998-12-141-22/+22
| | | | Notes: svn path=/head/; revision=41787
* Update timecounters to new interface.Poul-Henning Kamp1998-10-231-11/+11
| | | | Notes: svn path=/head/; revision=40610
* Attempt to work around a bug in the previous commit related toBruce Evans1998-09-201-3/+3
| | | | | | | | non-reentrancy of SMP clock locking. Depend on the giant lock protecting clkintr(). Notes: svn path=/head/; revision=39526
* Ensure that the i8254 timecounter doesn't go backards. It sometimesBruce Evans1998-09-201-6/+21
| | | | | | | | | | | | | went backwards when interrupts were masked for more than one i8254 interrupt period. It sometimes went backwards when the i8254 counter was reprogrammed. Neither of these should happen in normal operation. Update the i8254 timecounter support variables atomically. Calling timecounter functions from fast interrupt handlers may actually work in all cases now. Notes: svn path=/head/; revision=39503
* Maintain a mapping from irq number to (ioapic number, int pin) tuple,Tor Egge1998-09-061-3/+3
| | | | | | | | | | | | | | | and use this when masking/unmasking interrupts. Maintain a mapping from (iopaic number, int pin) tuple to irq number, and use this when configuring devices and programming the ioapics. Previous code assumed that irq number was equal to int pin number, and that the ioapic number was 0. Don't let an AP enter _cpu_switch before all local apics are initialized. Notes: svn path=/head/; revision=38888
* Add a tc_ prefix to struct timecounter members.Poul-Henning Kamp1998-06-091-6/+6
| | | | | | | Urged by: bde Notes: svn path=/head/; revision=36810
* Add a member function more to the timecounters, this one is for usePoul-Henning Kamp1998-06-071-1/+3
| | | | | | | | with latch based PPS implementations. The client that uses it will be committed after more testing. Notes: svn path=/head/; revision=36741
* Add a "this" style argument and a "void *private" so timecounters canPoul-Henning Kamp1998-06-071-5/+5
| | | | | | | figure out which instance to wount with. Notes: svn path=/head/; revision=36719