paul@93 | 1 | /* |
paul@93 | 2 | * A pipe pager providing access to pipe content and navigation support. |
paul@93 | 3 | * |
paul@672 | 4 | * Copyright (C) 2021, 2022, 2023, 2024 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@94 | 24 | #include <fsserver/pipe_accessor.h> |
paul@94 | 25 | #include <fsserver/pipe_object_interface.h> |
paul@94 | 26 | #include <fsserver/pipe_paging.h> |
paul@94 | 27 | #include <fsserver/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@665 | 38 | offset_t _data_current; |
paul@485 | 39 | l4_cap_idx_t _notifier = L4_INVALID_CAP; |
paul@65 | 40 | |
paul@65 | 41 | /* Helper methods. */ |
paul@65 | 42 | |
paul@65 | 43 | virtual long next_region_for_reader(offset_t *populated_size, offset_t *size); |
paul@65 | 44 | |
paul@65 | 45 | virtual long next_region_for_writer(offset_t *populated_size, offset_t *size); |
paul@65 | 46 | |
paul@114 | 47 | virtual long pipe_error(); |
paul@114 | 48 | |
paul@65 | 49 | public: |
paul@66 | 50 | explicit PipePager(PipePaging *paging, bool writer); |
paul@65 | 51 | |
paul@67 | 52 | virtual void close(); |
paul@67 | 53 | |
paul@65 | 54 | /* Server details. */ |
paul@65 | 55 | |
paul@459 | 56 | ipc_server_default_config_type config(); |
paul@65 | 57 | |
paul@65 | 58 | void *interface() |
paul@65 | 59 | { return static_cast<PipeObject *>(this); } |
paul@65 | 60 | |
paul@65 | 61 | /* Pager methods. */ |
paul@65 | 62 | |
paul@675 | 63 | virtual long map(offset_t offset, map_address_t hot_spot, map_flags_t flags, |
paul@675 | 64 | l4_snd_fpage_t *region); |
paul@65 | 65 | |
paul@65 | 66 | /* Pipe methods. */ |
paul@65 | 67 | |
paul@117 | 68 | virtual long closed(int *closed); |
paul@117 | 69 | |
paul@65 | 70 | virtual long next_region(offset_t *populated_size, offset_t *size); |
paul@117 | 71 | |
paul@117 | 72 | /* Flushing/synchronisation. */ |
paul@117 | 73 | |
paul@665 | 74 | virtual long flush(offset_t position, offset_t *size); |
paul@117 | 75 | |
paul@675 | 76 | virtual long refresh(offset_t *position, offset_t *start_pos, |
paul@675 | 77 | offset_t *end_pos, offset_t *size, |
paul@675 | 78 | object_flags_t *object_flags); |
paul@672 | 79 | |
paul@117 | 80 | /* Notification methods. */ |
paul@117 | 81 | |
paul@290 | 82 | virtual long subscribe(l4_cap_idx_t notifier, notify_flags_t flags); |
paul@290 | 83 | |
paul@548 | 84 | virtual long unsubscribe(); |
paul@65 | 85 | }; |
paul@65 | 86 | |
paul@65 | 87 | // vim: tabstop=4 expandtab shiftwidth=4 |