]>
Commit | Line | Data |
---|---|---|
8046f374 DH |
1 | /* |
2 | * TOD (Time Of Day) clock | |
3 | * | |
4 | * Copyright 2018 Red Hat, Inc. | |
5 | * Author(s): David Hildenbrand <david@redhat.com> | |
6 | * | |
7 | * This work is licensed under the terms of the GNU GPL, version 2 or later. | |
8 | * See the COPYING file in the top-level directory. | |
9 | */ | |
10 | ||
11 | #ifndef HW_S390_TOD_H | |
12 | #define HW_S390_TOD_H | |
13 | ||
a27bd6c7 | 14 | #include "hw/qdev-core.h" |
ec150c7e | 15 | #include "target/s390x/s390-tod.h" |
db1015e9 | 16 | #include "qom/object.h" |
8046f374 DH |
17 | |
18 | typedef struct S390TOD { | |
19 | uint8_t high; | |
20 | uint64_t low; | |
21 | } S390TOD; | |
22 | ||
23 | #define TYPE_S390_TOD "s390-tod" | |
db1015e9 EH |
24 | typedef struct S390TODClass S390TODClass; |
25 | typedef struct S390TODState S390TODState; | |
8046f374 DH |
26 | #define S390_TOD(obj) OBJECT_CHECK(S390TODState, (obj), TYPE_S390_TOD) |
27 | #define S390_TOD_CLASS(oc) OBJECT_CLASS_CHECK(S390TODClass, (oc), \ | |
28 | TYPE_S390_TOD) | |
29 | #define S390_TOD_GET_CLASS(obj) OBJECT_GET_CLASS(S390TODClass, (obj), \ | |
30 | TYPE_S390_TOD) | |
31 | #define TYPE_KVM_S390_TOD TYPE_S390_TOD "-kvm" | |
32 | #define TYPE_QEMU_S390_TOD TYPE_S390_TOD "-qemu" | |
33 | ||
db1015e9 | 34 | struct S390TODState { |
8046f374 DH |
35 | /* private */ |
36 | DeviceState parent_obj; | |
7de3b1cd | 37 | |
9bc9d3d1 DH |
38 | /* |
39 | * Used by TCG to remember the time base. Used by KVM to backup the TOD | |
40 | * while the TOD is stopped. | |
41 | */ | |
7de3b1cd | 42 | S390TOD base; |
9bc9d3d1 DH |
43 | /* Used by KVM to remember if the TOD is stopped and base is valid. */ |
44 | bool stopped; | |
db1015e9 | 45 | }; |
8046f374 | 46 | |
db1015e9 | 47 | struct S390TODClass { |
8046f374 DH |
48 | /* private */ |
49 | DeviceClass parent_class; | |
9bc9d3d1 | 50 | void (*parent_realize)(DeviceState *dev, Error **errp); |
8046f374 DH |
51 | |
52 | /* public */ | |
53 | void (*get)(const S390TODState *td, S390TOD *tod, Error **errp); | |
54 | void (*set)(S390TODState *td, const S390TOD *tod, Error **errp); | |
db1015e9 | 55 | }; |
8046f374 DH |
56 | |
57 | void s390_init_tod(void); | |
7de3b1cd | 58 | S390TODState *s390_get_todstate(void); |
8046f374 DH |
59 | |
60 | #endif |