aboutsummaryrefslogtreecommitdiffstats
path: root/hw/mc146818rtc.c
AgeCommit message (Collapse)AuthorFilesLines
2012-02-24suspend: make rtc alarm wakeup the guest.Gerd Hoffmann1-0/+1
Make the rtc wake up the guest when the alarm fires. Add acpi windup to property support RTC_EN, so guests can enable and disable this. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-02-24suspend: switch acpi s3 to new infrastructure.Gerd Hoffmann1-0/+12
This patch switches pc s3 suspend over to the new infrastructure. The cmos_s3 qemu_irq is killed, the new notifier is used instead. The xen hack goes away with that too, the hypercall can simply be done in a notifier function now. This patch also makes the guest actually stay suspended instead of leaving suspend instantly, so it is useful for more than just testing whenever the suspend/resume cycle actually works. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-02-15qom: Unify type registrationAndreas Färber1-2/+3
Replace device_init() with generalized type_init(). While at it, unify naming convention: type_init([$prefix_]register_types) Also, type_init() is a function, so add preceding blank line where necessary and don't put a semicolon after the closing brace. Signed-off-by: Andreas Färber <afaerber@suse.de> Cc: Anthony Liguori <anthony@codemonkey.ws> Cc: malc <av1474@comtv.ru> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-02-03qom: move properties from qdev to objectAnthony Liguori1-4/+4
This is mostly code movement although not entirely. This makes properties part of the Object base class which means that we can now start using Object in a meaningful way outside of qdev. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-02-03qdev: register all types natively through QEMU Object ModelAnthony Liguori1-13/+17
This was done in a mostly automated fashion. I did it in three steps and then rebased it into a single step which avoids repeatedly touching every file in the tree. The first step was a sed-based addition of the parent type to the subclass registration functions. The second step was another sed-based removal of subclass registration functions while also adding virtual functions from the base class into a class_init function as appropriate. Finally, a python script was used to convert the DeviceInfo structures and qdev_register_subclass functions to TypeInfo structures, class_init functions, and type_register_static calls. We are almost fully converted to QOM after this commit. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-02-01mc146818rtc: Use lost_tick_policy propertyJan Kiszka1-7/+19
Allow to configure the MC146818 RTC via the new lost tick policy property and replace rtc_td_hack with this mechanism. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-01-27isa: pic: convert to QEMU Object ModelAnthony Liguori1-8/+14
This converts two devices at once because PIC subclasses ISA and converting subclasses independently is extremely hard. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-01-13rtc: clear non-PF bits when reinjecting on ackPaolo Bonzini1-3/+3
When an rtc interrupt is reinjected immediately after being acked, other interrupts should not be reinjected, so do clear their bits. Also, if the periodic interrupts have been disabled before acking, do not reinject, as the guest might get very confused! Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-01-13rtc: raise PF bit when the periodic timer triggers but PIE=0Paolo Bonzini1-1/+2
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-01-13rtc: raise AF bit when the alarm is encountered but AIE=0Paolo Bonzini1-9/+10
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-01-13rtc: fix 12-hour modePaolo Bonzini1-4/+7
Hours in 12-hour mode are in the 1-12 range, not 0-11. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-12-20isa: give ISABus/ISADevice to isa_create(), isa_bus_irqs() and isa_get_irq() ↵Hervé Poussineau1-2/+2
functions NULL is a valid bus/device, so there is no change in behaviour. Signed-off-by: Hervé Poussineau <hpoussin@reactos.org> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-12-15rtc: add a dynamic property for retrieving the dateAnthony Liguori1-0/+27
This really shows the power of dynamic object properties compared to qdev static properties. This property represents a complex structure who's format is preserved over the wire. This is enabled by visitors. It also shows an entirely synthetic property that is not tied to device state. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-10-11rtc: Convert to isa_register_ioportRichard Henderson1-3/+12
Signed-off-by: Richard Henderson <rth@twiddle.net> Signed-off-by: Avi Kivity <avi@redhat.com>
2011-07-23mc146818rtc: Handle host clock resetsJan Kiszka1-0/+20
Make use of the new clock reset notifier to update the RTC whenever rtc_clock is the host clock and that happens to jump backward. This avoids that the RTC stalls for the period the host clock was set back. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-03-21change all other clock references to use nanosecond resolution accessorsPaolo Bonzini1-8/+8
This was done with: sed -i 's/qemu_get_clock\>/qemu_get_clock_ns/' \ $(git grep -l 'qemu_get_clock\>' ) sed -i 's/qemu_new_timer\>/qemu_new_timer_ns/' \ $(git grep -l 'qemu_new_timer\>' ) after checking that get_clock and new_timer never occur twice on the same line. There were no missed occurrences; however, even if there had been, they would have been caught by the compiler. There was exactly one false positive in qemu_run_timers: - current_time = qemu_get_clock (clock); + current_time = qemu_get_clock_ns (clock); which is of course not in this patch. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2011-01-29mc146818rtc: update registers after a format changeAurelien Jarno1-1/+9
For some unknown reason, the MIPS kernel briefly changes the RTC to binary mode during boot, switch back to BCD mode and read the time. As the registers are updated only every second, they may still be in the old format when they are read. This patch forces a register update immediately after a format change (BCD/binary or 12/24H). This avoid long fsck during boot due to time wrap. Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2011-01-29mc146818rtc: constantifyAurelien Jarno1-2/+3
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2010-12-11Keep track of ISA ports ISA device is using in qdev.Gleb Natapov1-0/+1
Store all io ports used by device in ISADevice structure. Signed-off-by: Gleb Natapov <gleb@redhat.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-07-06make rtc alatm workGleb Natapov1-4/+3
Convert alarm time from BCD if needed before comparing with current time. Signed-off-by: Gleb Natapov <gleb@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-06-13hpet/rtc: Rework RTC IRQ replacement by HPETJan Kiszka1-34/+15
Allow the intercept the RTC IRQ for the HPET legacy mode. Then push routing to IRQ8 completely into the HPET. This allows to turn hpet_in_legacy_mode() into a private function. Furthermore, this stops the RTC from clearing IRQ8 even if the HPET is in control. This patch comes with a side effect: The RTC timers will no longer be stoppend when there is no IRQ consumer, possibly causing a minor performance degration. But as the guest may want to redirect the RTC to the SCI in that mode, it should normally disable unused IRQ source anyway. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-05-30mc146818rtc: improve debuggingBlue Swirl1-2/+20
Add a separate flag for debugging coalesced interrupts. Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-05-15mc146818rtc: remove #ifdef DEBUG_CMOS.Isaku Yamahata1-8/+10
remove #ifdef DEBUG_CMOS by using macro. Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp> Acked-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-05-15rtc: make rtc_xxx accept/return ISADevice instead of RTCState.Isaku Yamahata1-11/+15
To match rtc_xxx with qdev, make rtc_xxx accept and return ISADevice instead of RTCState. Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp> Acked-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-05-15mc146818rtc: Register vmstate via qdevJan Kiszka1-1/+2
After defining the required alias ID, we can push vmstate registration of mc146818rtc to qdev. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-03-21Move x86 specific PC declarations to a separate fileBlue Swirl1-0/+1
x86 definitions (especially CPUState uses) prevent many files from being compiled within libhw. Move x86 specific declarations (APIC stuff) to a separate file. Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-03-08QMP: Introduce RTC_CHANGE eventLuiz Capitulino1-0/+2
Emitted whenever the RTC time changes. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-01-20reduce number of reinjects on ACKGleb Natapov1-1/+1
Windows 7 BSODs under load with HAL_RTC_IRQF_WILL_NOT_CLEAR error. It happens here: hal!HalpRtcUnmaskClock: 8281b93a 8bff mov edi,edi 8281b93c 56 push esi 8281b93d 33f6 xor esi,esi 8281b93f 6a0c push 0Ch 8281b941 e8b2ffffff call hal!CMOS_READ (8281b8f8) 8281b946 84c0 test al,al 8281b948 7920 jns hal!HalpRtcUnmaskClock+0x30 (8281b96a) 8281b94a 6a0a push 0Ah 8281b94c 46 inc esi 8281b94d e854c8ffff call hal!KeStallExecutionProcessor (828181a6) 8281b952 83fe64 cmp esi,64h 8281b955 72e8 jb hal!HalpRtcUnmaskClock+0x5 (8281b93f) 8281b957 6a00 push 0 8281b959 6a00 push 0 8281b95b 6a00 push 0 8281b95d 680a010000 push 10Ah 8281b962 6a5c push 5Ch 8281b964 ff1500c38082 call dword ptr [hal!_imp__KeBugCheckEx (8280c300)] 8281b96a 5e pop esi 8281b96b c3 ret So it loops for 100(64h) times reading register C before BSOD. Lets reduce number of immediate reinjection well under this limit. Signed-off-by: Gleb Natapov <gleb@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-12fix rtc-td-hack on host without high-res timersGleb Natapov1-0/+17
On hosts without high-res timers it is impossible to inject rtc interrupt faster then 1kHz. Windows sometimes configures RTC to generate 1kHz interrupts, so we can't inject missed interrupts when running on such hosts. Always injecting an interrupt on REG_C read is also not an option since Windows wait for REG_C to become zero with interrupt disabled during boot. This patch uses mixed approach: accelerate timer + inject up to 1000 interrupts on REG_C read. Signed-off-by: Gleb Natapov <gleb@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-11-22BCD cleanupPaul Brook1-18/+18
Combine multiple BCD implementations. Signed-off-by: Paul Brook <paul@codesourcery.com>
2009-10-27mc146818rtc: remove rtc_mm_init()Juan Quintela1-105/+0
It was used for Acer Pica 61 emulation, removed in 2008 Signed-off-by: Juan Quintela <quintela@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-27mc146818rtc: fix indentationJuan Quintela1-1/+2
Signed-off-by: Juan Quintela <quintela@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-27mc146818rtc: port rtc to vmstateJuan Quintela1-53/+32
Signed-off-by: Juan Quintela <quintela@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-27mc145818rtc: fix saving of rtc-td hack properly upgrading the version numberJuan Quintela1-34/+13
Signed-off-by: Juan Quintela <quintela@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-12TARGET_I386 is always defined if TARGET_X86_64 is definedJuan Quintela1-2/+2
Patchworks-ID: 35378 Signed-off-by: Juan Quintela <quintela@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-07New qdev_init_nofail()Markus Armbruster1-1/+1
Like qdev_init(), but terminate program via hw_error() instead of returning an error value. Use it instead of qdev_init() where terminating the program on failure is okay, either because it's during machine construction, or because we know that failure can't happen. Because relying in the latter is somewhat unclean, and the former is not always obvious, it would be nice to go back to qdev_init() in the not-so-obvious cases, only with proper error handling. I'm leaving that for another day, because it involves making sure that error values are properly checked by all callers. Patchworks-ID: 35168 Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-05Enable host-clock-based RTCJan Kiszka1-20/+18
Switch RTC emulations to the new host_clock instead of vm_clock by default. This has the advantage that the emulated RTC will follow automatically the host time while it might be tuned via NTP. vm_clock can still be selected by passing '-rtc clock=vm' on the command line. Note that some RTC emulations (at least M48T59) already use the host time unconditionally while others (namely MC146818) do not. This patch introduces the required infrastructure for selecting the base clock but only converts MC146818 for now. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-01Revert "Get rid of _t suffix"Anthony Liguori1-7/+7
In the very least, a change like this requires discussion on the list. The naming convention is goofy and it causes a massive merge problem. Something like this _must_ be presented on the list first so people can provide input and cope with it. This reverts commit 99a0949b720a0936da2052cb9a46db04ffc6db29. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-01Get rid of _t suffixmalc1-7/+7
Some not so obvious bits, slirp and Xen were left alone for the time being. Signed-off-by: malc <av1474@comtv.ru>
2009-09-11Unexport ticks_per_sec variable. Create get_ticks_per_sec() functionJuan Quintela1-8/+8
Signed-off-by: Juan Quintela <quintela@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-09-10qdev/isa: convert real time clockGerd Hoffmann1-11/+32
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2009-09-09RTC polling mode brokenBernhard Kauer1-2/+3
The RTC emulation does not set the IRQ flags independent of the IRQ enable bits. The original MC146818A datasheet from 1984 notes: "flag bits in Register C [...] are set independent of the state of the corresponding enable bits in Register B" Similar sections can be found in newer documentation e.g. in rtc82885. Qemu and Bochs set the IRQ flags only if they are enabled, which breaks drivers polling on them. The following patch corrects this for the update-ended-flag in Qemu only. It does not fix the handling of the other flags. Signed-off-by: Bernhard Kauer <kauer@tudos.org> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-08-25Make CPURead/WriteFunc structure 'const'Blue Swirl1-2/+2
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2009-06-29Revert "Introduce reset notifier order"Jan Kiszka1-2/+2
This reverts commit 8217606e6edb49591b4a6fd5a0d1229cebe470a9 (and updates later added users of qemu_register_reset), we solved the problem it originally addressed less invasively. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-06-16Remove io_index argument from cpu_register_io_memory()Avi Kivity1-1/+1
The parameter is always zero except when registering the three internal io regions (ROM, unassigned, notdirty). Remove the parameter to reduce the API's power, thus facilitating future change. Signed-off-by: Avi Kivity <avi@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-06-15Incorporate changes from v2 of Gleb's RTC reset patchAnthony Liguori1-4/+8
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-06-14Add rtc reset function.Gleb Natapov1-0/+19
On reset: Periodic Interrupt Enable (PIE) bit is cleared to zero Alarm Interrupt Enable (AIE) bit is cleared to zero Update ended Interrupt Flag (UF) bit is cleared to zero Interrupt Request status Flag (IRQF) bit is cleared to zero Periodic Interrupt Flag (PF) bit is cleared to zero Alarm Interrupt Flag (AF) bit is cleared to zero Square Wave output Enable (SQWE) zero Signed-off-by: Gleb Natapov <gleb@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-04-22Change RTC time drift IRQ re-injection (Gleb Natapov)aliguori1-15/+47
Currently IRQ are reinjected as soon as they are acknowledged to the RTC, but Windows sometimes do acknowledgement in a loop with global interrupt disabled waiting for interrupt to be cleared and it does not mask RTC vector in PIC/APIC while doing this. In such situation interrupt injection always fails and RTC interrupt is never cleared. Instead of reinjecting coalesced IRQs on acknowledgement the patch below reinjects them by accelerating RTC clock a bit. This way RTC interrupt is not constantly raced after coalesced interrupt. Signed-off-by: Gleb Natapov <gleb@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7231 c046a42c-6fe2-441c-8c8c-71466251a162
2009-04-10Fix RTC breakage from r7031.pbrook1-1/+1
Signed-off-by: Paul Brook <paul@codesourcery.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7062 c046a42c-6fe2-441c-8c8c-71466251a162
2009-04-07mc146818: add square wave output supportaurel321-10/+29
This is necessary for es40 as the sqw output is directly connected to the core chipset. Signed-off-by: Tristan Gingold <gingold@adacore.com> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7031 c046a42c-6fe2-441c-8c8c-71466251a162