mirror of
https://github.com/clearlinux/kvmtool.git
synced 2026-09-04 04:31:27 +00:00
kvm: Introduce IVT handling
Introduce procedures for handling IVT (Interrupt Vector Table) to be used int real mode bootstrap procedure. Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com> Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
This commit is contained in:
committed by
Will Deacon
parent
6d1f350d0f
commit
b1b71cd91a
@@ -4,6 +4,7 @@ OBJS += cpu.o
|
||||
OBJS += kvm.o
|
||||
OBJS += main.o
|
||||
OBJS += util.o
|
||||
OBJS += ivt.o
|
||||
|
||||
CFLAGS += $(CPPFLAGS) -Iinclude
|
||||
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
#include <stdbool.h>
|
||||
#include <limits.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "util.h"
|
||||
#include "ivt.h"
|
||||
|
||||
static struct ivt_entry ivt_table[IVT_VECTORS];
|
||||
|
||||
void ivt_reset(void)
|
||||
{
|
||||
memset(ivt_table, 0x0, sizeof(ivt_table));
|
||||
}
|
||||
|
||||
void ivt_copy_table(void *dst, unsigned int size)
|
||||
{
|
||||
if (size < sizeof(ivt_table))
|
||||
die("An attempt to overwrite host memory");
|
||||
memcpy(dst, ivt_table, sizeof(ivt_table));
|
||||
}
|
||||
|
||||
struct ivt_entry * const ivt_get_entry(unsigned int n)
|
||||
{
|
||||
struct ivt_entry *v = NULL;
|
||||
if (n < IVT_VECTORS)
|
||||
v = &ivt_table[n];
|
||||
return (struct ivt_entry * const)v;
|
||||
}
|
||||
|
||||
void ivt_set_entry(struct ivt_entry e, unsigned int n)
|
||||
{
|
||||
if (n < IVT_VECTORS)
|
||||
ivt_table[n] = e;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
#include <inttypes.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#define IVT_BASE 0x0000
|
||||
#define IVT_VECTORS 256
|
||||
|
||||
struct ivt_entry {
|
||||
uint16_t segment;
|
||||
uint16_t offset;
|
||||
} __attribute__((packed));
|
||||
|
||||
void ivt_reset(void);
|
||||
void ivt_copy_table(void *dst, unsigned int size);
|
||||
struct ivt_entry * const ivt_get_entry(unsigned int n);
|
||||
void ivt_set_entry(struct ivt_entry e, unsigned int n);
|
||||
Reference in New Issue
Block a user