Can associate multiple CVs with spinlocks
[akaros.git] / kern / include / colored_caches.h
index 3510f95..3616515 100644 (file)
@@ -9,8 +9,8 @@
 #define ROS_KERN_COLORED_CACHES_H
 
 #include <ros/common.h>
-#include <ros/error.h>
-#include <process.h>
+#include <error.h>
+#include <atomic.h>
 
 /****************** Cache Structures ********************/
 typedef struct Cache {
@@ -39,13 +39,21 @@ void cache_init();
 void cache_color_alloc_init();
 void init_cache_properties(cache_t RO*c, size_t sz_k, size_t wa, size_t clsz);
 void init_free_cache_colors_map(cache_t* c);
-size_t get_page_color(uintptr_t page, cache_t RO*c);
 size_t get_offset_in_cache_line(uintptr_t addr, cache_t RO*c);
 void print_cache_properties(char *NT lstring, cache_t RO*c);
-error_t cache_color_alloc(cache_t* c, struct proc* p);
-error_t cache_color_alloc_specific(size_t color, cache_t* c, struct proc* p);
-void cache_color_free(cache_t* c, struct proc* p);
-void cache_color_free_specific(size_t color, cache_t* c, struct proc* p);
+
+static inline size_t get_page_color(uintptr_t page, cache_t *c) {
+    return (page & (c->num_colors-1));
+}
+
+
+uint8_t* cache_colors_map_alloc();
+void cache_colors_map_free(uint8_t* colors_map);
+error_t cache_color_alloc(cache_t* c, uint8_t* colors_map);
+error_t cache_color_alloc_specific(size_t color, cache_t* c, 
+                                         uint8_t* colors_map);
+void cache_color_free(cache_t* c, uint8_t* colors_map);
+void cache_color_free_specific(size_t color, cache_t* c, uint8_t* colors_map);
 
 /****************** Cache Properties *********************/
 inline size_t get_cache_ways_associative(cache_t RO*c);