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