paul@65 | 1 | #pragma once |
paul@65 | 2 | |
paul@65 | 3 | #include "page_mapper.h" |
paul@72 | 4 | #include "pages.h" |
paul@66 | 5 | #include "pipe_accessor.h" |
paul@65 | 6 | |
paul@65 | 7 | /* Pipe paging support, maintaining the sequence of active regions or sections |
paul@65 | 8 | in a pipe. */ |
paul@65 | 9 | |
paul@65 | 10 | class PipePaging |
paul@65 | 11 | { |
paul@65 | 12 | protected: |
paul@72 | 13 | Memory *_memory, *_memory_base; |
paul@72 | 14 | Pages *_pages; |
paul@72 | 15 | PageQueue *_queue; |
paul@66 | 16 | |
paul@66 | 17 | /* Regions acting as files with their own accessors. */ |
paul@66 | 18 | |
paul@72 | 19 | PageMapper *_regions[2]; |
paul@72 | 20 | PipeAccessor _accessors[2]; |
paul@72 | 21 | |
paul@72 | 22 | /* The first region is initially exposed to both reader and writer. */ |
paul@72 | 23 | |
paul@72 | 24 | int _reading = 0, _writing = 0; |
paul@66 | 25 | |
paul@66 | 26 | /* Pipe section/region size. */ |
paul@66 | 27 | |
paul@66 | 28 | offset_t _size; |
paul@65 | 29 | |
paul@67 | 30 | /* Endpoint status. */ |
paul@67 | 31 | |
paul@67 | 32 | unsigned int _endpoints = 2; |
paul@67 | 33 | |
paul@65 | 34 | public: |
paul@70 | 35 | explicit PipePaging(Memory *memory, offset_t size); |
paul@70 | 36 | |
paul@66 | 37 | explicit PipePaging(offset_t size); |
paul@65 | 38 | |
paul@67 | 39 | virtual void detach(); |
paul@67 | 40 | |
paul@67 | 41 | virtual offset_t region_size() |
paul@67 | 42 | { return _size; } |
paul@67 | 43 | |
paul@67 | 44 | /* Region management. */ |
paul@67 | 45 | |
paul@72 | 46 | virtual PageMapper *add_region(); |
paul@65 | 47 | |
paul@72 | 48 | virtual PageMapper *current_region(); |
paul@65 | 49 | |
paul@65 | 50 | virtual PageMapper *next_region(); |
paul@65 | 51 | }; |
paul@65 | 52 | |
paul@65 | 53 | // vim: tabstop=4 expandtab shiftwidth=4 |