Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


61a1a6fd7cc338abb649d9f762b5759394264b68
[palacios.git] / palacios / src / palacios / vmm_excp.c
1 /* 
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.  
5  *
6  * The V3VEE Project is a joint project between Northwestern University
7  * and the University of New Mexico.  You can find out more at 
8  * http://www.v3vee.org
9  *
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.
13  *
14  * Author: Jack Lange <jarusl@cs.northwestern.edu>
15  *
16  * This is free software.  You are permitted to use,
17  * redistribute, and modify it as specified in the file "V3VEE_LICENSE".
18  */
19
20 #include <palacios/vmm_excp.h>
21 #include <palacios/vmm.h>
22 #include <palacios/vmm_types.h>
23
24 void v3_init_exception_state(struct guest_info * info) {
25     info->excp_state.excp_pending = 0;
26     info->excp_state.excp_num = 0;
27     info->excp_state.excp_error_code = 0;
28
29 }
30
31
32
33 int v3_raise_exception_with_error(struct guest_info * info, uint_t excp, uint_t error_code) {
34     struct v3_excp_state * excp_state = &(info->excp_state);
35
36     if (excp_state->excp_pending == 0) {
37         excp_state->excp_pending = 1;
38         excp_state->excp_num = excp;
39         excp_state->excp_error_code = error_code;
40         excp_state->excp_error_code_valid = 1;
41         //      PrintDebug("[v3_raise_exception_with_error] error code: %x\n", error_code);
42     } else {
43         PrintError("Error injecting exception_w_error (excp=%d) (error=%d) -- Exception (%d) (error=%d) already pending\n",
44                    excp, error_code, excp_state->excp_num, excp_state->excp_error_code);
45         return -1;
46     }
47
48     return 0;
49 }
50
51 int v3_raise_exception(struct guest_info * info, uint_t excp) {
52     struct v3_excp_state * excp_state = &(info->excp_state);
53     //PrintDebug("[v3_raise_exception]\n");
54     if (excp_state->excp_pending == 0) {
55         excp_state->excp_pending = 1;
56         excp_state->excp_num = excp;
57         excp_state->excp_error_code = 0;
58         excp_state->excp_error_code_valid = 0;
59     } else {
60         PrintError("Error injecting exception (excp=%d) -- Exception (%d) (error=%d) already pending\n",
61                    excp, excp_state->excp_num, excp_state->excp_error_code);
62         return -1;
63     }
64
65     return 0;
66 }
67
68
69 int v3_excp_pending(struct guest_info * info) {
70     struct v3_excp_state * excp_state = &(info->excp_state);
71     
72     if (excp_state->excp_pending == 1) {
73         return 1;
74     }
75
76     return 0;
77 }
78
79
80 int v3_get_excp_number(struct guest_info * info) {
81     struct v3_excp_state * excp_state = &(info->excp_state);
82
83     if (excp_state->excp_pending == 1) {
84         return excp_state->excp_num;
85     }
86
87     return 0;
88 }
89
90
91 int v3_injecting_excp(struct guest_info * info, uint_t excp) {
92     struct v3_excp_state * excp_state = &(info->excp_state);
93     
94     excp_state->excp_pending = 0;
95     excp_state->excp_num = 0;
96     excp_state->excp_error_code = 0;
97     excp_state->excp_error_code_valid = 0;
98     
99     return 0;
100 }