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