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.


Assorted minor fixes to the transactional memory code
[palacios.git] / palacios / include / extensions / tm_util.h
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) 2012, NWU EECS 441 Transactional Memory Team  
11  * Copyright (c) 2012, The V3VEE Project <http://www.v3vee.org> 
12  * All rights reserved.
13  *
14  * Author:  Maciek Swiech <dotpyfe@u.northwestern.edu>
15  *          Marcel Flores <marcel-flores@u.northwestern.edu>
16  *          Zachary Bischof <zbischof@u.northwestern.edu>
17  *          Kyle C. Hale <kh@u.northwestern.edu>
18  *
19  * This is free software.  You are permitted to use,
20  * redistribute, and modify it as specified in the file "V3VEE_LICENSE".
21  */
22
23 #ifndef __TM_UTIL_H
24 #define __TM_UTIL_H
25
26 // new printing macros
27 // used like TM_ERR(core, ABORT, "couldnt wangle the dangle");
28
29 #define TM_ERR(core, label, msg, ...) \
30     do {                              \
31         typeof (core) _core = (core);  \
32         PrintError(_core->vm_info, _core, "TM %10s | " msg , #label, ##__VA_ARGS__); \
33     } while (0);
34
35 #ifdef V3_CONFIG_DEBUG_TM_FUNC
36 #define TM_DBG(core, label, msg, ...) \
37     do {                              \
38         typeof (core) _core = (core);  \
39         PrintDebug(_core->vm_info, _core, "TM %10s | " msg , #label, ##__VA_ARGS__); \
40     } while (0);
41 #else
42 #define TM_DBG(cor, label, msg, ...) 
43 #endif
44
45 struct mem_op {
46     addr_t   guest_addr;
47     uint64_t data;
48     int      current;
49
50     struct list_head op_node;
51 };
52
53 void v3_clear_tm_lists(struct v3_trans_mem * tm);
54
55 // note memory location touched in the list, avoids duplicate creation
56 int add_mem_op_to_list(struct list_head * list, addr_t guest_addr);
57
58 // searches for address in the list, returns pointer to elt if found, null
59 struct mem_op * list_contains_guest_addr(struct list_head * list, addr_t guest_addr);
60
61 // checks for current = 0 in list, updates to new value from staging page
62 int update_list(struct v3_trans_mem * tm, struct list_head * list);
63
64 // writes value to staging page, sets current = 0
65 int stage_entry(struct v3_trans_mem * tm, struct list_head * list, addr_t guest_addr);
66
67 // adds entry to list if it doesnt exist, used in copying
68 int copy_add_entry(struct list_head * list, addr_t guest_addr, uint64_t data);
69
70 // if TM block succesfully finishes, commits the list
71 int commit_list(struct guest_info * core, struct v3_trans_mem * tm);
72
73 // copy other lists to core's global lists
74 int v3_copy_lists(struct guest_info *core);
75
76 // set TM_MODE to TM_ON
77 int v3_set_tm(struct v3_trans_mem * tm);
78
79 // set TM_MODE to TM_OFF, clear data structures
80 int v3_clr_tm(struct v3_trans_mem * tm);
81
82 // clear the vtlb on a core
83 int v3_clr_vtlb(struct guest_info *core);
84
85 // set TM_STATE to TM_ABORT
86 int v3_tm_set_abrt(struct v3_trans_mem * tm);
87
88 // free the staging page of the core
89 int v3_free_staging_page(struct v3_trans_mem * tm);
90
91 #endif