paul@93 | 1 | /* |
paul@93 | 2 | * A pipe pager providing access to pipe content and navigation support. |
paul@93 | 3 | * |
paul@93 | 4 | * Copyright (C) 2021 Paul Boddie <paul@boddie.org.uk> |
paul@93 | 5 | * |
paul@93 | 6 | * This program is free software; you can redistribute it and/or |
paul@93 | 7 | * modify it under the terms of the GNU General Public License as |
paul@93 | 8 | * published by the Free Software Foundation; either version 2 of |
paul@93 | 9 | * the License, or (at your option) any later version. |
paul@93 | 10 | * |
paul@93 | 11 | * This program is distributed in the hope that it will be useful, |
paul@93 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
paul@93 | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
paul@93 | 14 | * GNU General Public License for more details. |
paul@93 | 15 | * |
paul@93 | 16 | * You should have received a copy of the GNU General Public License |
paul@93 | 17 | * along with this program; if not, write to the Free Software |
paul@93 | 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, |
paul@93 | 19 | * Boston, MA 02110-1301, USA |
paul@93 | 20 | */ |
paul@93 | 21 | |
paul@65 | 22 | #pragma once |
paul@65 | 23 | |
paul@65 | 24 | #include "pipe_accessor.h" |
paul@65 | 25 | #include "pipe_object_interface.h" |
paul@65 | 26 | #include "pipe_paging.h" |
paul@65 | 27 | #include "pager.h" |
paul@65 | 28 | |
paul@93 | 29 | |
paul@93 | 30 | |
paul@65 | 31 | /* A pager abstraction for a pipe. */ |
paul@65 | 32 | |
paul@65 | 33 | class PipePager : public Pager, public PipeObject |
paul@65 | 34 | { |
paul@65 | 35 | protected: |
paul@65 | 36 | PipePaging *_paging; |
paul@66 | 37 | bool _writing; |
paul@65 | 38 | |
paul@65 | 39 | /* Helper methods. */ |
paul@65 | 40 | |
paul@65 | 41 | virtual long next_region_for_reader(offset_t *populated_size, offset_t *size); |
paul@65 | 42 | |
paul@65 | 43 | virtual long next_region_for_writer(offset_t *populated_size, offset_t *size); |
paul@65 | 44 | |
paul@65 | 45 | public: |
paul@66 | 46 | explicit PipePager(PipePaging *paging, bool writer); |
paul@65 | 47 | |
paul@67 | 48 | virtual void close(); |
paul@67 | 49 | |
paul@65 | 50 | /* Server details. */ |
paul@65 | 51 | |
paul@65 | 52 | int expected_items(); |
paul@65 | 53 | |
paul@65 | 54 | ipc_server_handler_type handler(); |
paul@65 | 55 | |
paul@65 | 56 | void *interface() |
paul@65 | 57 | { return static_cast<PipeObject *>(this); } |
paul@65 | 58 | |
paul@65 | 59 | /* Pager methods. */ |
paul@65 | 60 | |
paul@92 | 61 | virtual long map(offset_t offset, address_t hot_spot, flags_t flags, l4_snd_fpage_t *region); |
paul@65 | 62 | |
paul@65 | 63 | /* Pipe methods. */ |
paul@65 | 64 | |
paul@65 | 65 | virtual long current_region(offset_t *populated_size, offset_t *size); |
paul@65 | 66 | |
paul@65 | 67 | virtual long next_region(offset_t *populated_size, offset_t *size); |
paul@65 | 68 | }; |
paul@65 | 69 | |
paul@65 | 70 | // vim: tabstop=4 expandtab shiftwidth=4 |