summaryrefslogtreecommitdiffstats
path: root/sys/i386/isa/clock.c
Commit message (Collapse)AuthorAgeFilesLines
* Namespace cleanup. Remove some #includes in favour of an explicitmarkm2000-12-021-0/+5
| | | | | | declaration. Asked for by: bde
* Revert two experimental changes which escaped from my devel machine.phk2000-10-281-1/+1
|
* Convert all users of fldoff() to offsetof(). fldoff() is badphk2000-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
* - Overhaul the software interrupt code to use interrupt threads for eachjhb2000-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
* - machine/mutex.h -> sys/mutex.hjhb2000-10-201-3/+3
| | | | | - machine/ipl.h -> sys/ipl.h - Use MUTEX_DECLARE() for clock_lock
* - Change fast interrupts on x86 to push a full interrupt frame and tojhb2000-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())
* - Heavyweight interrupt threads on the alpha for device I/O interrupts.jhb2000-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
* - Remove the inthand2_t type and use the equivalent driver_intr_t type fromjhb2000-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.
* Major update to the way synchronization is done in the kernel. Highlightsjasone2000-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
* Allow use of TSC even if APM is compiled in but disabled.phk2000-07-301-1/+6
|
* Previous commit changing SYSCTL_HANDLER_ARGS violated KNF.phk2000-07-041-2/+2
| | | | Pointed out by: bde
* Style police catches up with rev 1.26 of src/sys/sys/sysctl.h:phk2000-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)
* Add PnP probe methods to some common AT hardware drivers. In each case,msmith2000-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.
* Add SWI_TQ_MASK to all interrupt masks except SWI_CLOCK_MASK. Use abde2000-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
* Isolate the Timecounter internals in their own two files.phk2000-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!)
* ISA device drivers use the ISA source interrupt number in locations wheretegge2000-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>
* Fixed races accessing the RTC. The races apparently causedbde1999-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
* Remove references to register_intr() etc in comments.peter1999-12-201-1/+1
|
* i8254_restore is called from apm_default_resume() to reloadiwasaki1999-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
* This adds the i386 specific support for systems with a MicroChannelmdodd1999-09-031-0/+10
| | | | | | Architecture bus. Reviewed by: msmith
* $Id$ -> $FreeBSD$peter1999-08-281-1/+1
|
* Merge the cons.c and cons.h to the best of my ability. alpha may orphk1999-08-091-2/+2
| | | | may not compile, I can't test it.
* Remove XXX from the headers (broke the build, I'm betting.)green1999-07-291-2/+1
|
* We're called too early to have any idea whether APM is going to bemsmith1999-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.
* Updated acquire_timer2()'s state machine to work when the i8254 isbde1999-07-181-23/+10
| | | | | | | being used for timecounting. Fixed a race or two in it. Undisabled it. PR: 10455
* Don't let the machdep.tsc_freq sysctl proceed if the TSC is presentbde1999-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
* Shut up gcc.peter1999-06-271-1/+3
|
* This commit gives support for the Rise mP6 CPU. It has two changes:green1999-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
* Remove fd driver from its old home and change files which include rtc.hdfr1999-05-311-2/+2
| | | | to account for its new location.
* Stop the TSC from being used as timecounter on K5/step0 machines.phk1999-05-291-2/+3
|
* Fixed glitches (jumps) of about 1/HZ seconds for the i8254 timecounter.bde1999-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
* For what it's worth, idelayed is declared as a volatile in the headers,peter1999-05-091-2/+2
| | | | and even though it's not used in this file make it a volatile here too.
* Make the machdep.i8254_freq and machdep.tsc_freq sysctls modify thephk1999-04-251-1/+3
| | | | | | timecounter as well Asked for by: bde, jhay
* oops, SMP was missing includes for a typedef.peter1999-04-211-2/+2
|
* Stage 1 of a cleanup of the i386 interrupt registration mechanism.peter1999-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.
* Fix tabs that should have been spaces. Some were in kernel error messages.mckay1998-12-141-22/+22
|
* Update timecounters to new interface.phk1998-10-231-11/+11
|
* Attempt to work around a bug in the previous commit related tobde1998-09-201-3/+3
| | | | | non-reentrancy of SMP clock locking. Depend on the giant lock protecting clkintr().
* Ensure that the i8254 timecounter doesn't go backards. It sometimesbde1998-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.
* Maintain a mapping from irq number to (ioapic number, int pin) tuple,tegge1998-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.
* Add a tc_ prefix to struct timecounter members.phk1998-06-091-6/+6
| | | | Urged by: bde
* Add a member function more to the timecounters, this one is for usephk1998-06-071-1/+3
| | | | | with latch based PPS implementations. The client that uses it will be committed after more testing.
* Add a "this" style argument and a "void *private" so timecounters canphk1998-06-071-5/+5
| | | | figure out which instance to wount with.
* Some cleanups related to timecounters and weird ifdefs in <sys/time.h>.phk1998-05-281-3/+3
| | | | | | | | | | | | | | | | | | | | Clean up (or if antipodic: down) some of the msgbuf stuff. Use an inline function rather than a macro for timecounter delta. Maintain process "on-cpu" time as 64 bits of microseconds to avoid needless second rollover overhead. Avoid calling microuptime the second time in mi_switch() if we do not pass through _idle in cpu_switch() This should reduce our context-switch overhead a bit, in particular on pre-P5 and SMP systems. WARNING: Programs which muck about with struct proc in userland will have to be fixed. Reviewed, but found imperfect by: bde
* Change a data type internal to the timecounters, and remove the "delta"phk1998-05-191-18/+9
| | | | | | function. Reviewed, but not entirely approved by: bde
* Remove some unneeded statements that enabled interrupts.tegge1998-04-051-3/+2
|
* Eradicate the variable "time" from the kernel, using various measures.phk1998-03-301-3/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | "time" wasn't a atomic variable, so splfoo() protection were needed around any access to it, unless you just wanted the seconds part. Most uses of time.tv_sec now uses the new variable time_second instead. gettime() changed to getmicrotime(0. Remove a couple of unneeded splfoo() protections, the new getmicrotime() is atomic, (until Bruce sets a breakpoint in it). A couple of places needed random data, so use read_random() instead of mucking about with time which isn't random. Add a new nfs_curusec() function. Mark a couple of bogosities involving the now disappeard time variable. Update ffs_update() to avoid the weird "== &time" checks, by fixing the one remaining call that passwd &time as args. Change profiling in ncr.c to use ticks instead of time. Resolution is the same. Add new function "tvtohz()" to avoid the bogus "splfoo(), add time, call hzto() which subtracts time" sequences. Reviewed by: bde
* Be less draconian about the TSC if APM is configured, use it forphk1998-03-161-8/+31
| | | | | timecounting if APM-BIOS isn't found. Be just as draconian about SMP as always, but explain it better.
* On SMP systems, initially follow the MP spec with regard to which pintegge1998-03-141-38/+90
| | | | | | on the IOAPIC being connected to the 8254 timer interrupt. Verify that timer interrupts are delivered. If they aren't, attempt a fallback to mixed mode (i.e. routing the timer interrupt via the 8259 PIC).
* Remove special handling for resuming clock interrupt when using APIC_IO.tegge1998-03-051-6/+6
| | | | The `generic' vector stubs do the right thing.
OpenPOWER on IntegriCloud