Disable recv notifications until avail buffers exhausted
[qemu-kvm/fedora.git] / hw / i8254-kvm.c
blob127b34736196f90a0901cbbbf3a4e16cca3b5690
1 /*
2 * QEMU 8253/8254 interval timer emulation
4 * Copyright (c) 2003-2004 Fabrice Bellard
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 * THE SOFTWARE.
24 #include "hw.h"
25 #include "pc.h"
26 #include "isa.h"
27 #include "qemu-timer.h"
28 #include "i8254.h"
29 #include "qemu-kvm.h"
31 static PITState pit_state;
33 static void kvm_pit_save(QEMUFile *f, void *opaque)
35 PITState *s = opaque;
36 struct kvm_pit_state pit;
37 struct kvm_pit_channel_state *c;
38 struct PITChannelState *sc;
39 int i;
41 kvm_get_pit(kvm_context, &pit);
43 for (i = 0; i < 3; i++) {
44 c = &pit.channels[i];
45 sc = &s->channels[i];
46 sc->count = c->count;
47 sc->latched_count = c->latched_count;
48 sc->count_latched = c->count_latched;
49 sc->status_latched = c->status_latched;
50 sc->status = c->status;
51 sc->read_state = c->read_state;
52 sc->write_state = c->write_state;
53 sc->write_latch = c->write_latch;
54 sc->rw_mode = c->rw_mode;
55 sc->mode = c->mode;
56 sc->bcd = c->bcd;
57 sc->gate = c->gate;
58 sc->count_load_time = c->count_load_time;
61 pit_save(f, s);
64 static int kvm_pit_load(QEMUFile *f, void *opaque, int version_id)
66 PITState *s = opaque;
67 struct kvm_pit_state pit;
68 struct kvm_pit_channel_state *c;
69 struct PITChannelState *sc;
70 int i;
72 pit_load(f, s, version_id);
74 for (i = 0; i < 3; i++) {
75 c = &pit.channels[i];
76 sc = &s->channels[i];
77 c->count = sc->count;
78 c->latched_count = sc->latched_count;
79 c->count_latched = sc->count_latched;
80 c->status_latched = sc->status_latched;
81 c->status = sc->status;
82 c->read_state = sc->read_state;
83 c->write_state = sc->write_state;
84 c->write_latch = sc->write_latch;
85 c->rw_mode = sc->rw_mode;
86 c->mode = sc->mode;
87 c->bcd = sc->bcd;
88 c->gate = sc->gate;
89 c->count_load_time = sc->count_load_time;
92 kvm_set_pit(kvm_context, &pit);
94 return 0;
97 PITState *kvm_pit_init(int base, qemu_irq irq)
99 PITState *pit = &pit_state;
101 register_savevm(PIT_SAVEVM_NAME, base, PIT_SAVEVM_VERSION,
102 kvm_pit_save, kvm_pit_load, pit);
104 qemu_register_reset(pit_reset, pit);
105 pit_reset(pit);
107 return pit;