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