paul@0 | 1 | #pragma once |
paul@0 | 2 | |
paul@30 | 3 | #include <systypes/base.h> |
paul@30 | 4 | |
paul@0 | 5 | #include "types.h" |
paul@0 | 6 | |
paul@0 | 7 | |
paul@0 | 8 | |
paul@0 | 9 | /* Region-related state information. */ |
paul@0 | 10 | |
paul@0 | 11 | class RegionState |
paul@0 | 12 | { |
paul@0 | 13 | public: |
paul@0 | 14 | unsigned long size; |
paul@0 | 15 | fileid_t fileid; |
paul@0 | 16 | offset_t filepos; |
paul@0 | 17 | |
paul@0 | 18 | explicit RegionState(unsigned long size=0, fileid_t fileid=0, offset_t filepos=0); |
paul@0 | 19 | |
paul@0 | 20 | void fill(fileid_t fileid, offset_t filepos); |
paul@0 | 21 | |
paul@0 | 22 | bool valid() { return size != 0; } |
paul@0 | 23 | }; |
paul@0 | 24 | |
paul@0 | 25 | |
paul@0 | 26 | |
paul@0 | 27 | /* A memory region abstraction. */ |
paul@0 | 28 | |
paul@0 | 29 | class Region |
paul@0 | 30 | { |
paul@0 | 31 | public: |
paul@0 | 32 | offset_t start, end; |
paul@0 | 33 | |
paul@0 | 34 | /* Debugging information. */ |
paul@0 | 35 | |
paul@0 | 36 | RegionState state; |
paul@0 | 37 | |
paul@0 | 38 | /* Methods. */ |
paul@0 | 39 | |
paul@0 | 40 | explicit Region(offset_t start, offset_t end); |
paul@0 | 41 | |
paul@0 | 42 | virtual ~Region(); |
paul@0 | 43 | |
paul@0 | 44 | offset_t size(); |
paul@0 | 45 | |
paul@0 | 46 | int compare(Region *other); |
paul@0 | 47 | |
paul@0 | 48 | void fill(fileid_t fileid, offset_t filepos); |
paul@0 | 49 | |
paul@0 | 50 | void flush(); |
paul@0 | 51 | |
paul@0 | 52 | /* Simulation methods. */ |
paul@0 | 53 | |
paul@0 | 54 | char *read(offset_t offset=0); |
paul@0 | 55 | |
paul@0 | 56 | void write(const char *data, offset_t offset=0); |
paul@0 | 57 | }; |
paul@0 | 58 | |
paul@0 | 59 | // vim: tabstop=4 expandtab shiftwidth=4 |