summaryrefslogtreecommitdiff
path: root/hw/mc146818rtc.c
AgeCommit message (Collapse)AuthorFilesLines
2013-01-10Make all static TypeInfos constAndreas Färber1-1/+1
Since 39bffca2030950ef6efe57c2fac8327a45ae1015 (qdev: register all types natively through QEMU Object Model), TypeInfo as used in the common, non-iterative pattern is no longer amended with information and should therefore be const. Fix the documented QOM examples: sed -i 's/static TypeInfo/static const TypeInfo/g' include/qom/object.h Since frequently the wrong examples are being copied by contributors of new devices, fix all types in the tree: sed -i 's/^static TypeInfo/static const TypeInfo/g' */*.c sed -i 's/^static TypeInfo/static const TypeInfo/g' */*/*.c This also avoids to piggy-back these changes onto real functional changes or other refactorings. Signed-off-by: Andreas Färber <afaerber@suse.de> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-12-19softmmu: move include files to include/sysemu/Paolo Bonzini1-1/+1
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-12-19misc: move include files to include/qemu/Paolo Bonzini1-1/+1
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-12-19qapi: move include files to include/qobject/Paolo Bonzini1-1/+1
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-11-27rtc: Only call rtc_set_cmos when Register B SET flag is disabled.Alex Horn1-1/+5
This bug occurs when the SET flag of Register B is enabled. When an RTC data register (i.e. any of the ten time/calender CMOS bytes) is set, the data is (as expected) correctly stored in the cmos_data array. However, since the SET flag is enabled, the function rtc_set_time is not invoked. As a result, the field base_rtc in RTCState remains uninitialized. This causes a problem on subsequent writes which can end up overwriting data. To see this, consider writing data to Register A after having written data to any of the RTC data registers; the following figure illustrates the call stack for the Register A write operation: +- cmos_io_port_write +-- check_update_timer +---- get_next_alarm +------ rtc_update_time In rtc_update_time, get_guest_rtc calculates the wrong time and overwrites the previously written RTC data register values. Signed-off-by: Alex Horn <alex.horn@cs.ox.ac.uk> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-11-15qdev: Split up header so it can be used in cpu.hAnthony Liguori1-0/+1
Header file dependency is a frickin' nightmare right now. cpu.h tends to get included in our 'include everything' header files but qdev also needs to include those headers mainly for qdev-properties since it knows about CharDriverState and friends. We can solve this for now by splitting out qdev.h along the same lines that we previously split the C file. Then cpu.h just needs to include qdev-core.h. hw/qdev.h is split into following new headers: hw/qdev-core.h hw/qdev-properties.h hw/qdev-monitor.h Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> [ehabkost: re-add DEFINE_PROP_PCI_HOST_DEVADDR, that was removed on the original patch (by mistake, I guess)] [ehabkost: kill qdev_prop_set_vlan() declaration] [ehabkost: moved get_fw_dev_path() comment to the original location (I don't know why it was moved)] [ehabkost: removed qdev_exists() declaration] [ehabkost: keep using 'QemuOpts' instead of 'struct QemuOpts', as qdev-core.h includes qemu-option.h] Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> Signed-off-by: Andreas Färber <afaerber@suse.de>
2012-10-29mc146818rtc: convert PIO to new memory api read/writeAlexander Graf1-8/+11
Signed-off-by: Alexander Graf <agraf@suse.de>
2012-10-05rtc: implement century bytePaolo Bonzini1-9/+18
Implement the century byte in the RTC emulation, and test that it works. This leads to some annoying compatibility code because we need to treat a value of 2000 for the base_year property as "use the century byte properly" (which would be a value of 0). The century byte will now be always-zero, rather than always-20, for the MIPS Magnum machine whose base_year is 1980. Commit 42fc73a (Support epoch of 1980 in RTC emulation for MIPS Magnum, 2009-01-24) correctly said: With an epoch of 1980 and a year of 2009, one could argue that [the century byte] should hold either 0, 1, 19 or 20. NT 3.50 on MIPS does not read the century byte. so I picked the simplest and most sensible implementation which is to return 0 for 1980-2079, 1 for 2080-2179 and so on. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-10-05rtc: map CMOS index 0x37 to 0x32 on read and writesPaolo Bonzini1-6/+9
QEMU's attempt to implement the century byte cover two possible places for the byte. A common one on modern chipsets is 0x32, but QEMU also stores the value in 0x37 (apparently for IBM PS/2 compatibility---it's only been 25 years). To simplify the implementation of the century byte, store it only at 0x32 but remap transparently 0x37 to 0x32 when reading and writing from CMOS. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-09-10RTC: Remove the current_tm fieldPaolo Bonzini1-11/+1
This is not used anymore and only written to. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-09-10RTC: Get and set time without going through s->current_tmPaolo Bonzini1-16/+22
This patch makes rtc_set_time and rtc_set_cmos work without reading s->current_tm. In the case of rtc_set_time I introduce a new function that retrieves the time and stores into a given struct tm (not hard-coded to s->current_tm). In the case of rtc_set_cmos, the current time is similarly taken from a struct tm rather than s->current_tm. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-09-10RTC: Do not fire timer periodically to catch next alarmPaolo Bonzini1-14/+103
This patch limits further the usage of a periodic timer. It computes the time of the next alarm, and uses it to skip all intermediate occurrences of the timer. Cc: Yang Zhang <yang.z.zhang@intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-09-10RTC: Add divider reset supportYang Zhang1-9/+41
The first update cycle begins one-half seconds after divider reset is removed. This feature is useful for testing. Signed-off-by: Yang Zhang <yang.z.zhang@intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-09-10RTC: Update the RTC clock only when reading itYang Zhang1-135/+194
Calculate guest RTC based on the time of the last update, instead of using timers. The formula is (base_rtc + guest_time_now - guest_time_last_update + offset) Base_rtc is the RTC value when the RTC was last updated. Guest_time_now is the guest time when the access happens. Guest_time_last_update was the guest time when the RTC was last updated. Offset is used when divider reset happens or the set bit is toggled. The timer is kept in order to signal interrupts, but it only needs to run when either UF or AF is cleared. When the bits are both set, the timer does not run. UIP is now synthesized when reading register A. If the timer is not set, or if there is more than one second before it (as is the case at the end of this series), the leading edge of UIP is computed and the rising edge occurs 220us later. If the update timer occurs within one second, however, the rising edge of the AF and UF bits should coincide withe the falling edge of UIP. We do not know exactly when this will happen because there could be delays in the servicing of the timer. Hence, in this case reading register A only computes for the rising edge of UIP, and latches the bit until the timer is fired and clears it. Signed-off-by: Yang Zhang <yang.z.zhang@intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-09-10RTC: Update interrupt state when interrupts are masked/unmaskedYang Zhang1-0/+9
If an interrupt flag is already set when the interrupt becomes enabled, raise an interrupt immediately, and vice versa if interrupts become disabled. Signed-off-by: Yang Zhang <yang.z.zhang@intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-09-10RTC: introduce RTC_CLOCK_RATEPaolo Bonzini1-4/+5
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-09-10RTC: Rename rtc_timer_updateYang Zhang1-5/+5
Signed-off-by: Yang Zhang <yang.z.zhang@intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-09-10RTC: Remove the logic to update time format when DM bit changedYang Zhang1-9/+1
Changing the DM (binary/BCD) and 24/12 control bit doesn't affect the internal registers. It only indicates what format is used for those registers. Signed-off-by: Yang Zhang <yang.z.zhang@intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-06-08qapi: Add Visitor interfaces for uint*_t and int*_tMichael Roth1-7/+0
This adds visitor interfaces for fixed-width integers types. Implementing these in visitors is optional, otherwise we fall back to visit_type_int() (int64_t) with some additional bounds checking to avoid integer overflows for cases where the value fetched exceeds the bounds of our target C type. Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> [LE: exclude negative values in uint*_t Visitor interfaces] Signed-off-by: Laszlo Ersek <lersek@redhat.com> [AF: Merged fix by Laszlo] Signed-off-by: Andreas Färber <afaerber@suse.de>
2012-03-30rtc: split out macros into a header file and use in test caseAnthony Liguori1-33/+0
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-03-14hw/mc146818: Drop unneeded #includesAndreas Färber1-2/+0
pc.h and apic.h are not needed; apic.h would drag in x86 CPUState and is now included directly for TARGET_I386. isa.h is already #included from mc146818rtc.h. Signed-off-by: Andreas Färber <afaerber@suse.de> Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
2012-03-01Merge remote-tracking branch 'qemu-kvm/uq/master' into stagingAnthony Liguori1-1/+4
* qemu-kvm/uq/master: pc-bios: update kvmvapic.bin kvmvapic: Use optionrom helpers optionsrom: Reserve space for checksum kvmvapic: Simplify mp/up_set_tpr kvmvapic: Introduce TPR access optimization for Windows guests kvmvapic: Add option ROM target-i386: Add infrastructure for reporting TPR MMIO accesses Allow to use pause_all_vcpus from VCPU context Process pending work while waiting for initial kick-off in TCG mode Remove useless casts from cpu iterators kvm: Set cpu_single_env only once kvm: Synchronize cpu state in kvm_arch_stop_on_emulation_error()
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-18target-i386: Add infrastructure for reporting TPR MMIO accessesJan Kiszka1-1/+4
This will allow the APIC core to file a TPR access report. Depending on the accelerator and kernel irqchip mode, it will either be delivered right away or queued for later reporting. In TCG mode, we can restart the triggering instruction and can therefore forward the event directly. KVM does not allows us to restart, so we postpone the delivery of events recording in the user space APIC until the current instruction is completed. Note that KVM without in-kernel irqchip will report the address after the instruction that triggered the access. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Avi Kivity <avi@redhat.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>