Skip to content

Commit b5f7707

Browse files
peterfangwenlingz
authored andcommitted
dm: vpit: add vPIT support
vPIT is used as a source of system timer by UEFI (e.g. OVMF). This is ported from Bhyve, with a few changes: - move to user space, using POSIX timer - support timer mode 3 - improve the emulation of OUT and STATUS byte - improve the emulation of counter behavior - improve the emulation of CE update in periodic mode - treat CR == 0 as 0x10000 Origin: FreeBSD License: BSD-3-Clause URL: https://svnweb.freebsd.org/ commit: 283291 Purpose: Adding vPIT support. Maintained-by: External Tracked-On: #1392 Signed-off-by: Peter Fang <peter.fang@intel.com> Acked-by: Yin Fengwei <fengwei.yin@intel.com>
1 parent 0359bd0 commit b5f7707

File tree

6 files changed

+803
-3
lines changed

6 files changed

+803
-3
lines changed

devicemodel/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ SRCS += hw/platform/usb_pmapper.c
6868
SRCS += hw/platform/atkbdc.c
6969
SRCS += hw/platform/ps2mouse.c
7070
SRCS += hw/platform/rtc.c
71+
SRCS += hw/platform/pit.c
7172
SRCS += hw/platform/ps2kbd.c
7273
SRCS += hw/platform/ioapic.c
7374
SRCS += hw/platform/cmos_io.c

devicemodel/core/main.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
#include "lpc.h"
5656
#include "smbiostbl.h"
5757
#include "rtc.h"
58+
#include "pit.h"
5859
#include "version.h"
5960
#include "sw_load.h"
6061
#include "monitor.h"
@@ -430,6 +431,10 @@ vm_init_vdevs(struct vmctx *ctx)
430431
if (ret < 0)
431432
goto vrtc_fail;
432433

434+
ret = vpit_init(ctx);
435+
if (ret < 0)
436+
goto vpit_fail;
437+
433438
sci_init(ctx);
434439
init_bvmcons();
435440

@@ -442,10 +447,13 @@ vm_init_vdevs(struct vmctx *ctx)
442447
goto pci_fail;
443448

444449
return 0;
450+
445451
pci_fail:
446452
monitor_close();
447453
monitor_fail:
448454
deinit_bvmcons();
455+
vpit_deinit(ctx);
456+
vpit_fail:
449457
vrtc_deinit(ctx);
450458
vrtc_fail:
451459
ioc_deinit(ctx);
@@ -461,6 +469,7 @@ vm_deinit_vdevs(struct vmctx *ctx)
461469
deinit_pci(ctx);
462470
monitor_close();
463471
deinit_bvmcons();
472+
vpit_deinit(ctx);
464473
vrtc_deinit(ctx);
465474
ioc_deinit(ctx);
466475
atkbdc_deinit(ctx);
@@ -483,6 +492,7 @@ vm_reset_vdevs(struct vmctx *ctx)
483492
* could be assigned with different number after reset.
484493
*/
485494
atkbdc_deinit(ctx);
495+
vpit_deinit(ctx);
486496
vrtc_deinit(ctx);
487497

488498
deinit_pci(ctx);
@@ -491,6 +501,7 @@ vm_reset_vdevs(struct vmctx *ctx)
491501

492502
atkbdc_init(ctx);
493503
vrtc_init(ctx);
504+
vpit_init(ctx);
494505

495506
ioapic_init(ctx);
496507
pci_irq_init(ctx);

0 commit comments

Comments
 (0)