xref: /kvmtool/x86/interrupt.c (revision 06f82371976121011b1626910c1dffeecb126f28)
1 #include "kvm/interrupt.h"
2 
3 #include "util.h"
4 
5 #include <string.h>
6 
7 static struct ivt_entry ivt_table[IVT_VECTORS];
8 
9 void ivt_reset(void)
10 {
11 	memset(ivt_table, 0x0, sizeof(ivt_table));
12 }
13 
14 void ivt_copy_table(void *dst, unsigned int size)
15 {
16 	if (size < sizeof(ivt_table))
17 		die("An attempt to overwrite host memory");
18 	memcpy(dst, ivt_table, sizeof(ivt_table));
19 }
20 
21 struct ivt_entry * const ivt_get_entry(unsigned int n)
22 {
23 	struct ivt_entry *v = NULL;
24 	if (n < IVT_VECTORS)
25 		v = &ivt_table[n];
26 	return (struct ivt_entry * const)v;
27 }
28 
29 void ivt_set_entry(struct ivt_entry e, unsigned int n)
30 {
31 	if (n < IVT_VECTORS)
32 		ivt_table[n] = e;
33 }
34 
35 void ivt_set_all(struct ivt_entry e)
36 {
37 	unsigned int i;
38 
39 	for (i = 0; i < IVT_VECTORS; i++)
40 		ivt_table[i] = e;
41 }
42