2 * This file is part of the Palacios Virtual Machine Monitor developed
3 * by the V3VEE Project with funding from the United States National
4 * Science Foundation and the Department of Energy.
6 * The V3VEE Project is a joint project between Northwestern University
7 * and the University of New Mexico. You can find out more at
10 * Copyright (c) 2008, Jack Lange <jarusl@cs.northwestern.edu>
11 * Copyright (c) 2008, The V3VEE Project <http://www.v3vee.org>
12 * All rights reserved.
14 * Author: Jack Lange <jarusl@cs.northwestern.edu>
16 * This is free software. You are permitted to use,
17 * redistribute, and modify it as specified in the file "V3VEE_LICENSE".
26 #include <palacios/vmm_types.h>
29 #define DE_EXCEPTION 0x00
30 #define DB_EXCEPTION 0x01
31 #define NMI_EXCEPTION 0x02
32 #define BP_EXCEPTION 0x03
33 #define OF_EXCEPTION 0x04
34 #define BR_EXCEPTION 0x05
35 #define UD_EXCEPTION 0x06
36 #define NM_EXCEPTION 0x07
37 #define DF_EXCEPTION 0x08
38 #define TS_EXCEPTION 0x0a
39 #define NP_EXCEPTION 0x0b
40 #define SS_EXCEPTION 0x0c
41 #define GPF_EXCEPTION 0x0d
42 #define PF_EXCEPTION 0x0e
43 #define MF_EXCEPTION 0x10
44 #define AC_EXCEPTION 0x11
45 #define MC_EXCEPTION 0x12
46 #define XF_EXCEPTION 0x13
47 #define SX_EXCEPTION 0x1e
50 typedef enum {INVALID_INTR, EXTERNAL_IRQ, NMI, EXCEPTION, SOFTWARE_INTR, VIRTUAL_INTR} intr_type_t;
55 /* We need a way to allow the APIC/PIC to decide when they are supposed to receive interrupts...
56 * Maybe a notification call when they have been turned on, to deliver irqs to them...
57 * We can rehook the guest raise_irq op, to the appropriate controller
62 int (*handler)(struct guest_info * info, struct v3_interrupt * intr, void * priv_data);
67 struct v3_intr_state {
69 /* We need to rework the exception state, to handle stacking */
72 uint_t excp_error_code_valid : 1;
73 uint_t excp_error_code;
75 struct intr_ctrl_ops * controller;
76 void * controller_state;
78 /* some way to get the [A]PIC intr */
80 struct v3_irq_hook * hooks[256];
86 void v3_init_interrupt_state(struct guest_info * info);
89 int v3_raise_irq(struct guest_info * info, int irq);
90 int v3_lower_irq(struct guest_info * info, int irq);
94 struct intr_ctrl_ops {
95 int (*intr_pending)(void * private_data);
96 int (*get_intr_number)(void * private_data);
97 int (*raise_intr)(void * private_data, int irq);
98 int (*lower_intr)(void * private_data, int irq);
99 int (*begin_irq)(void * private_data, int irq);
105 void v3_set_intr_controller(struct guest_info * info, struct intr_ctrl_ops * ops, void * state);
107 int v3_raise_exception(struct guest_info * info, uint_t excp);
108 int v3_raise_exception_with_error(struct guest_info * info, uint_t excp, uint_t error_code);
110 int v3_intr_pending(struct guest_info * info);
111 uint_t v3_get_intr_number(struct guest_info * info);
112 intr_type_t v3_get_intr_type(struct guest_info * info);
114 int v3_injecting_intr(struct guest_info * info, uint_t intr_num, intr_type_t type);
117 int start_irq(struct vm_intr * intr);
118 int end_irq(struct vm_intr * intr, int irq);
123 int v3_hook_irq(struct guest_info * info,
125 int (*handler)(struct guest_info * info, struct v3_interrupt * intr, void * priv_data),
128 int v3_hook_passthrough_irq(struct guest_info *info, uint_t irq);