xref: /qemu/include/hw/s390x/tod.h (revision c9274b6b)
18046f374SDavid Hildenbrand /*
28046f374SDavid Hildenbrand  * TOD (Time Of Day) clock
38046f374SDavid Hildenbrand  *
48046f374SDavid Hildenbrand  * Copyright 2018 Red Hat, Inc.
58046f374SDavid Hildenbrand  * Author(s): David Hildenbrand <david@redhat.com>
68046f374SDavid Hildenbrand  *
78046f374SDavid Hildenbrand  * This work is licensed under the terms of the GNU GPL, version 2 or later.
88046f374SDavid Hildenbrand  * See the COPYING file in the top-level directory.
98046f374SDavid Hildenbrand  */
108046f374SDavid Hildenbrand 
118046f374SDavid Hildenbrand #ifndef HW_S390_TOD_H
128046f374SDavid Hildenbrand #define HW_S390_TOD_H
138046f374SDavid Hildenbrand 
14a27bd6c7SMarkus Armbruster #include "hw/qdev-core.h"
15*c9274b6bSCho, Yu-Chen #include "tcg/s390-tod.h"
16db1015e9SEduardo Habkost #include "qom/object.h"
178046f374SDavid Hildenbrand 
188046f374SDavid Hildenbrand typedef struct S390TOD {
198046f374SDavid Hildenbrand     uint8_t high;
208046f374SDavid Hildenbrand     uint64_t low;
218046f374SDavid Hildenbrand } S390TOD;
228046f374SDavid Hildenbrand 
238046f374SDavid Hildenbrand #define TYPE_S390_TOD "s390-tod"
24a489d195SEduardo Habkost OBJECT_DECLARE_TYPE(S390TODState, S390TODClass, S390_TOD)
258046f374SDavid Hildenbrand #define TYPE_KVM_S390_TOD TYPE_S390_TOD "-kvm"
268046f374SDavid Hildenbrand #define TYPE_QEMU_S390_TOD TYPE_S390_TOD "-qemu"
278046f374SDavid Hildenbrand 
28db1015e9SEduardo Habkost struct S390TODState {
298046f374SDavid Hildenbrand     /* private */
308046f374SDavid Hildenbrand     DeviceState parent_obj;
317de3b1cdSDavid Hildenbrand 
329bc9d3d1SDavid Hildenbrand     /*
339bc9d3d1SDavid Hildenbrand      * Used by TCG to remember the time base. Used by KVM to backup the TOD
349bc9d3d1SDavid Hildenbrand      * while the TOD is stopped.
359bc9d3d1SDavid Hildenbrand      */
367de3b1cdSDavid Hildenbrand     S390TOD base;
379bc9d3d1SDavid Hildenbrand     /* Used by KVM to remember if the TOD is stopped and base is valid. */
389bc9d3d1SDavid Hildenbrand     bool stopped;
39db1015e9SEduardo Habkost };
408046f374SDavid Hildenbrand 
41db1015e9SEduardo Habkost struct S390TODClass {
428046f374SDavid Hildenbrand     /* private */
438046f374SDavid Hildenbrand     DeviceClass parent_class;
449bc9d3d1SDavid Hildenbrand     void (*parent_realize)(DeviceState *dev, Error **errp);
458046f374SDavid Hildenbrand 
468046f374SDavid Hildenbrand     /* public */
478046f374SDavid Hildenbrand     void (*get)(const S390TODState *td, S390TOD *tod, Error **errp);
488046f374SDavid Hildenbrand     void (*set)(S390TODState *td, const S390TOD *tod, Error **errp);
49db1015e9SEduardo Habkost };
508046f374SDavid Hildenbrand 
518046f374SDavid Hildenbrand void s390_init_tod(void);
527de3b1cdSDavid Hildenbrand S390TODState *s390_get_todstate(void);
538046f374SDavid Hildenbrand 
548046f374SDavid Hildenbrand #endif
55