1 | |
---|
2 | /* -*- Mode:C; c-basic-offset:4; tab-width:4; indent-tabs-mode:nil -*- */ |
---|
3 | /* |
---|
4 | * vtm.h: virtual timer head file. |
---|
5 | * Copyright (c) 2004, Intel Corporation. |
---|
6 | * |
---|
7 | * This program is free software; you can redistribute it and/or modify it |
---|
8 | * under the terms and conditions of the GNU General Public License, |
---|
9 | * version 2, as published by the Free Software Foundation. |
---|
10 | * |
---|
11 | * This program is distributed in the hope it will be useful, but WITHOUT |
---|
12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
---|
13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
---|
14 | * more details. |
---|
15 | * |
---|
16 | * You should have received a copy of the GNU General Public License along with |
---|
17 | * this program; if not, write to the Free Software Foundation, Inc., 59 Temple |
---|
18 | * Place - Suite 330, Boston, MA 02111-1307 USA. |
---|
19 | * |
---|
20 | * Yaozu Dong (Eddie Dong) (Eddie.dong@intel.com) |
---|
21 | */ |
---|
22 | |
---|
23 | #ifndef _VTM_H_ |
---|
24 | #define _VTM_H_ |
---|
25 | |
---|
26 | #include <xen/timer.h> |
---|
27 | #include <xen/types.h> |
---|
28 | |
---|
29 | #define MAX_JUMP_STEP (5000) /* 500ms, max jump step */ |
---|
30 | #define MIN_GUEST_RUNNING_TIME (0) /* 10ms for guest os to run */ |
---|
31 | #define ITV_VECTOR_MASK (0xff) |
---|
32 | |
---|
33 | typedef struct vtime { |
---|
34 | long vtm_offset; // guest ITC = host ITC + vtm_offset |
---|
35 | uint64_t vtm_local_drift; |
---|
36 | uint64_t last_itc; |
---|
37 | uint64_t pending; |
---|
38 | /* |
---|
39 | * Local drift (temporary) after guest suspension |
---|
40 | * In case of long jump amount of ITC after suspension, |
---|
41 | * guest ITC = host ITC + vtm_offset - vtm_local_drift; |
---|
42 | * so that the duration passed saw in guest ITC is limited to |
---|
43 | * cfg_max_jump that will make all kind of device driver happy. |
---|
44 | */ |
---|
45 | |
---|
46 | // next all uses ITC tick as unit |
---|
47 | uint64_t cfg_max_jump; // max jump within one time suspendsion |
---|
48 | uint64_t cfg_min_grun; // min guest running time since last jump |
---|
49 | // uint64_t latest_read_itc; // latest guest read ITC |
---|
50 | struct timer vtm_timer; |
---|
51 | // int triggered; |
---|
52 | |
---|
53 | |
---|
54 | uint64_t guest_running_time; // guest running time since last switch |
---|
55 | //uint64_t vtm_last_suspending_time; |
---|
56 | //uint64_t switch_in_time; |
---|
57 | //uint64_t switch_out_time; |
---|
58 | //uint64_t itc_freq; |
---|
59 | |
---|
60 | } vtime_t; |
---|
61 | |
---|
62 | #define ITV_VECTOR(itv) (itv&0xff) |
---|
63 | #define ITV_IRQ_MASK(itv) (itv&(1<<16)) |
---|
64 | |
---|
65 | #define VTM_FIRED(vtm) ((vtm)->triggered) |
---|
66 | |
---|
67 | #endif /* _STATS_H_ */ |
---|