paul@93 | 1 | /* |
paul@93 | 2 | * Generic pager functionality. |
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@6 | 22 | #pragma once |
paul@6 | 23 | |
paul@30 | 24 | #include <systypes/base.h> |
paul@30 | 25 | |
paul@94 | 26 | #include <fsserver/page_mapper.h> |
paul@94 | 27 | #include <fsserver/resource.h> |
paul@6 | 28 | |
paul@6 | 29 | |
paul@6 | 30 | |
paul@6 | 31 | /* A pager exposing a dataspace. */ |
paul@6 | 32 | |
paul@7 | 33 | class Pager : public Resource |
paul@6 | 34 | { |
paul@6 | 35 | protected: |
paul@6 | 36 | offset_t _start, _size; |
paul@6 | 37 | PageMapper *_mapper; |
paul@54 | 38 | flags_t _flags; |
paul@6 | 39 | |
paul@6 | 40 | public: |
paul@54 | 41 | explicit Pager(PageMapper *mapper, flags_t flags); |
paul@6 | 42 | |
paul@24 | 43 | virtual void close(); |
paul@6 | 44 | |
paul@6 | 45 | /* Paging methods. */ |
paul@6 | 46 | |
paul@92 | 47 | virtual long map(offset_t offset, address_t hot_spot, flags_t flags, |
paul@90 | 48 | l4_snd_fpage_t *region); |
paul@6 | 49 | |
paul@6 | 50 | /* Limit methods. */ |
paul@6 | 51 | |
paul@6 | 52 | offset_t get_data_size(); |
paul@6 | 53 | |
paul@53 | 54 | /* File methods. */ |
paul@53 | 55 | |
paul@53 | 56 | virtual long flush(offset_t populated_size, offset_t *size); |
paul@53 | 57 | |
paul@55 | 58 | virtual long resize(offset_t *size); |
paul@55 | 59 | |
paul@7 | 60 | /* Mapped file methods. */ |
paul@7 | 61 | |
paul@90 | 62 | virtual long mmap(offset_t position, offset_t length, offset_t *start_pos, |
paul@90 | 63 | offset_t *end_pos, offset_t *size); |
paul@6 | 64 | }; |
paul@6 | 65 | |
paul@6 | 66 | // vim: tabstop=4 expandtab shiftwidth=4 |