[PATCH 5/5] qemu-kvm: i8254: Reorganize i8254-kvm code

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Include i8254-kvm.c instead of building it as a separate module. This
allows to reduce the diff to upstream and will help with merging the
latter.

Signed-off-by: Jan Kiszka <jan.kiszka@xxxxxxxxxxx>
---
 Makefile.target |    1 -
 hw/i8254-kvm.c  |   12 ++++--------
 hw/i8254.c      |   43 +++++++++++++++++++++++++++++++++++++++++--
 hw/i8254.h      |   49 ++-----------------------------------------------
 4 files changed, 47 insertions(+), 58 deletions(-)

diff --git a/Makefile.target b/Makefile.target
index 5f6b963..24386a4 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -251,7 +251,6 @@ obj-i386-y += testdev.o
 obj-i386-y += acpi.o acpi_piix4.o
 
 obj-i386-y += i8254.o
-obj-i386-$(CONFIG_KVM_PIT) += i8254-kvm.o
 obj-i386-$(CONFIG_KVM_DEVICE_ASSIGNMENT) += device-assignment.o
 
 # shared objects
diff --git a/hw/i8254-kvm.c b/hw/i8254-kvm.c
index 7316111..e2aa4d6 100644
--- a/hw/i8254-kvm.c
+++ b/hw/i8254-kvm.c
@@ -21,14 +21,8 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  * THE SOFTWARE.
  */
-#include "hw.h"
-#include "pc.h"
-#include "isa.h"
-#include "qemu-timer.h"
-#include "i8254.h"
-#include "qemu-kvm.h"
 
-extern VMStateDescription vmstate_pit;
+#ifdef CONFIG_KVM_PIT
 
 static void kvm_pit_pre_save(void *opaque)
 {
@@ -103,7 +97,7 @@ static void dummy_timer(void *opaque)
 {
 }
 
-void kvm_pit_init(PITState *pit)
+static void qemu_kvm_pit_init(PITState *pit)
 {
     PITChannelState *s;
 
@@ -116,3 +110,5 @@ void kvm_pit_init(PITState *pit)
     vmstate_pit.post_load = kvm_pit_post_load;
     return;
 }
+
+#endif
diff --git a/hw/i8254.c b/hw/i8254.c
index ca24ab9..a8e20cb 100644
--- a/hw/i8254.c
+++ b/hw/i8254.c
@@ -30,8 +30,45 @@
 
 //#define DEBUG_PIT
 
+#define RW_STATE_LSB 1
+#define RW_STATE_MSB 2
+#define RW_STATE_WORD0 3
+#define RW_STATE_WORD1 4
+
+typedef struct PITChannelState {
+    int count; /* can be 65536 */
+    uint16_t latched_count;
+    uint8_t count_latched;
+    uint8_t status_latched;
+    uint8_t status;
+    uint8_t read_state;
+    uint8_t write_state;
+    uint8_t write_latch;
+    uint8_t rw_mode;
+    uint8_t mode;
+    uint8_t bcd; /* not supported */
+    uint8_t gate; /* timer start */
+    int64_t count_load_time;
+    /* irq handling */
+    int64_t next_transition_time;
+    QEMUTimer *irq_timer;
+    qemu_irq irq;
+    uint32_t irq_disabled;
+} PITChannelState;
+
+typedef struct PITState {
+    ISADevice dev;
+    MemoryRegion ioports;
+    uint32_t iobase;
+    PITChannelState channels[3];
+} PITState;
+
 static void pit_irq_timer_update(PITChannelState *s, int64_t current_time);
 
+#ifdef CONFIG_KVM_PIT
+static void qemu_kvm_pit_init(PITState *pit);
+#endif
+
 static int pit_get_count(PITChannelState *s)
 {
     uint64_t d;
@@ -412,7 +449,7 @@ static int pit_load_old(QEMUFile *f, void *opaque, int version_id)
     return 0;
 }
 
-VMStateDescription vmstate_pit = {
+static VMStateDescription vmstate_pit = {
     .name = "i8254",
     .version_id = 3,
     .minimum_version_id = 2,
@@ -482,7 +519,7 @@ static int pit_initfn(ISADevice *dev)
 
 #ifdef CONFIG_KVM_PIT
     if (kvm_enabled() && kvm_irqchip_in_kernel()) {
-        kvm_pit_init(pit);
+        qemu_kvm_pit_init(pit);
         return 0;
     }
 #endif
@@ -531,3 +568,5 @@ static void pit_register_types(void)
 }
 
 type_init(pit_register_types)
+
+#include "i8254-kvm.c"
diff --git a/hw/i8254.h b/hw/i8254.h
index 3313662..47b2570 100644
--- a/hw/i8254.h
+++ b/hw/i8254.h
@@ -25,55 +25,10 @@
 #ifndef HW_I8254_H
 #define HW_I8254_H
 
+#include "hw.h"
+#include "isa.h"
 #include "kvm.h"
 
-#define PIT_SAVEVM_NAME "i8254"
-#define PIT_SAVEVM_VERSION 2
-
-#define RW_STATE_LSB 1
-#define RW_STATE_MSB 2
-#define RW_STATE_WORD0 3
-#define RW_STATE_WORD1 4
-
-#define PIT_FLAGS_HPET_LEGACY  1
-
-typedef struct PITChannelState {
-    int count; /* can be 65536 */
-    uint16_t latched_count;
-    uint8_t count_latched;
-    uint8_t status_latched;
-    uint8_t status;
-    uint8_t read_state;
-    uint8_t write_state;
-    uint8_t write_latch;
-    uint8_t rw_mode;
-    uint8_t mode;
-    uint8_t bcd; /* not supported */
-    uint8_t gate; /* timer start */
-    int64_t count_load_time;
-    /* irq handling */
-    int64_t next_transition_time;
-    QEMUTimer *irq_timer;
-    qemu_irq irq;
-    uint32_t irq_disabled;
-} PITChannelState;
-
-struct PITState {
-    ISADevice dev;
-    MemoryRegion ioports;
-    uint32_t iobase;
-    PITChannelState channels[3];
-};
-
-void pit_save(QEMUFile *f, void *opaque);
-
-int pit_load(QEMUFile *f, void *opaque, int version_id);
-
-typedef struct PITState PITState;
-
-/* i8254-kvm.c */
-void kvm_pit_init(PITState *pit);
-
 #define PIT_FREQ 1193182
 
 typedef struct PITChannelInfo {
-- 
1.7.3.4

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux