Deleted Added
full compact
timer.c (263007) timer.c (263008)
1/*-
2 * Copyright (c) 2009 Adrian Chadd
3 * Copyright (c) 2012 Spectra Logic Corporation
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 18 unchanged lines hidden (view full) ---

27 */
28
29/**
30 * \file dev/xen/timer/timer.c
31 * \brief A timer driver for the Xen hypervisor's PV clock.
32 */
33
34#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2009 Adrian Chadd
3 * Copyright (c) 2012 Spectra Logic Corporation
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 18 unchanged lines hidden (view full) ---

27 */
28
29/**
30 * \file dev/xen/timer/timer.c
31 * \brief A timer driver for the Xen hypervisor's PV clock.
32 */
33
34#include <sys/cdefs.h>
35__FBSDID("$FreeBSD: head/sys/dev/xen/timer/timer.c 263007 2014-03-11 10:16:17Z royger $");
35__FBSDID("$FreeBSD: head/sys/dev/xen/timer/timer.c 263008 2014-03-11 10:20:42Z royger $");
36
37#include <sys/param.h>
38#include <sys/systm.h>
39#include <sys/bus.h>
40#include <sys/kernel.h>
41#include <sys/module.h>
42#include <sys/time.h>
43#include <sys/timetc.h>

--- 11 unchanged lines hidden (view full) ---

55#include <xen/interface/vcpu.h>
56
57#include <machine/cpu.h>
58#include <machine/cpufunc.h>
59#include <machine/clock.h>
60#include <machine/_inttypes.h>
61#include <machine/smp.h>
62
36
37#include <sys/param.h>
38#include <sys/systm.h>
39#include <sys/bus.h>
40#include <sys/kernel.h>
41#include <sys/module.h>
42#include <sys/time.h>
43#include <sys/timetc.h>

--- 11 unchanged lines hidden (view full) ---

55#include <xen/interface/vcpu.h>
56
57#include <machine/cpu.h>
58#include <machine/cpufunc.h>
59#include <machine/clock.h>
60#include <machine/_inttypes.h>
61#include <machine/smp.h>
62
63#include <dev/xen/timer/timer.h>
64
63#include "clock_if.h"
64
65static devclass_t xentimer_devclass;
66
67#define NSEC_IN_SEC 1000000000ULL
68#define NSEC_IN_USEC 1000ULL
69/* 18446744073 = int(2^64 / NSEC_IN_SC) = 1 ns in 64-bit fractions */
70#define FRAC_IN_NSEC 18446744073LL

--- 516 unchanged lines hidden (view full) ---

587}
588
589static int
590xentimer_suspend(device_t dev)
591{
592 return (0);
593}
594
65#include "clock_if.h"
66
67static devclass_t xentimer_devclass;
68
69#define NSEC_IN_SEC 1000000000ULL
70#define NSEC_IN_USEC 1000ULL
71/* 18446744073 = int(2^64 / NSEC_IN_SC) = 1 ns in 64-bit fractions */
72#define FRAC_IN_NSEC 18446744073LL

--- 516 unchanged lines hidden (view full) ---

589}
590
591static int
592xentimer_suspend(device_t dev)
593{
594 return (0);
595}
596
597/*
598 * Xen early clock init
599 */
600void
601xen_clock_init(void)
602{
603}
604
605/*
606 * Xen PV DELAY function
607 *
608 * When running on PVH mode we don't have an emulated i8524, so
609 * make use of the Xen time info in order to code a simple DELAY
610 * function that can be used during early boot.
611 */
612void
613xen_delay(int n)
614{
615 struct vcpu_info *vcpu = &HYPERVISOR_shared_info->vcpu_info[0];
616 uint64_t end_ns;
617 uint64_t current;
618
619 end_ns = xen_fetch_vcpu_time(vcpu);
620 end_ns += n * NSEC_IN_USEC;
621
622 for (;;) {
623 current = xen_fetch_vcpu_time(vcpu);
624 if (current >= end_ns)
625 break;
626 }
627}
628
595static device_method_t xentimer_methods[] = {
596 DEVMETHOD(device_identify, xentimer_identify),
597 DEVMETHOD(device_probe, xentimer_probe),
598 DEVMETHOD(device_attach, xentimer_attach),
599 DEVMETHOD(device_detach, xentimer_detach),
600 DEVMETHOD(device_suspend, xentimer_suspend),
601 DEVMETHOD(device_resume, xentimer_resume),
602 /* clock interface */

--- 13 unchanged lines hidden ---
629static device_method_t xentimer_methods[] = {
630 DEVMETHOD(device_identify, xentimer_identify),
631 DEVMETHOD(device_probe, xentimer_probe),
632 DEVMETHOD(device_attach, xentimer_attach),
633 DEVMETHOD(device_detach, xentimer_detach),
634 DEVMETHOD(device_suspend, xentimer_suspend),
635 DEVMETHOD(device_resume, xentimer_resume),
636 /* clock interface */

--- 13 unchanged lines hidden ---