1 #pragma once 2 3 #include <sstream> 4 5 #include "memory_utils.h" 6 #include "region.h" 7 #include "send_flexpage.h" 8 9 10 11 /* A flexpage abstraction. */ 12 13 class Flexpage 14 { 15 protected: 16 unsigned int _counter; 17 unsigned long _flags; 18 19 public: 20 Region *region; 21 22 /* General flexpage characteristics. */ 23 24 offset_t base_addr, size; 25 offset_t base_offset; 26 27 /* Transient debugging information. */ 28 29 offset_t page_addr, page_offset; 30 31 /* Associate a flexpage with a memory 'region'. */ 32 33 explicit Flexpage(Region *region) : region(region) 34 { 35 } 36 37 void reset(offset_t offset); 38 39 bool decrement(); 40 41 void increment(); 42 43 void invalidate(); 44 45 bool valid(); 46 47 bool supports_position(offset_t position); 48 49 void upgrade(unsigned long flags); 50 51 SendFlexpage to_send(offset_t offset, offset_t hot_spot, offset_t max_offset=0); 52 53 SendFlexpage to_unmap(); 54 55 /* Debugging methods. */ 56 57 void show(std::ostringstream &buffer); 58 }; 59 60 // vim: tabstop=4 expandtab shiftwidth=4