paul@93 | 1 | /* |
paul@93 | 2 | * File-specific 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@8 | 22 | #include "file_pager.h" |
paul@10 | 23 | #include "mapped_file_object_server.h" |
paul@8 | 24 | |
paul@93 | 25 | |
paul@93 | 26 | |
paul@8 | 27 | /* Initialise a pager for a file with a unique file identifier and shared page |
paul@8 | 28 | mapper for moderating access to loaded pages. */ |
paul@8 | 29 | |
paul@79 | 30 | FilePager::FilePager(fileid_t fileid, PageMapper *mapper, flags_t flags, |
paul@81 | 31 | FilePaging *paging) |
paul@79 | 32 | : Pager(mapper, flags), _paging(paging), fileid(fileid) |
paul@8 | 33 | { |
paul@8 | 34 | } |
paul@8 | 35 | |
paul@10 | 36 | int FilePager::expected_items() |
paul@10 | 37 | { |
paul@10 | 38 | return MappedFileObject_expected_items; |
paul@10 | 39 | } |
paul@10 | 40 | |
paul@10 | 41 | ipc_server_handler_type FilePager::handler() |
paul@10 | 42 | { |
paul@10 | 43 | return (ipc_server_handler_type) handle_MappedFileObject; |
paul@10 | 44 | } |
paul@10 | 45 | |
paul@78 | 46 | |
paul@78 | 47 | |
paul@79 | 48 | /* Close the pager, removing the mapper from the paging registry if |
paul@79 | 49 | appropriate. */ |
paul@79 | 50 | |
paul@79 | 51 | void FilePager::close() |
paul@79 | 52 | { |
paul@79 | 53 | _paging->detach_pager(fileid, _mapper); |
paul@79 | 54 | } |
paul@79 | 55 | |
paul@79 | 56 | |
paul@79 | 57 | |
paul@78 | 58 | /* File-specific operations. */ |
paul@78 | 59 | |
paul@53 | 60 | long FilePager::flush(offset_t populated_size, offset_t *size) |
paul@53 | 61 | { |
paul@53 | 62 | return Pager::flush(populated_size, size); |
paul@53 | 63 | } |
paul@53 | 64 | |
paul@55 | 65 | long FilePager::resize(offset_t *size) |
paul@55 | 66 | { |
paul@55 | 67 | return Pager::resize(size); |
paul@55 | 68 | } |
paul@55 | 69 | |
paul@90 | 70 | long FilePager::mmap(offset_t position, offset_t length, offset_t *start_pos, |
paul@90 | 71 | offset_t *end_pos, offset_t *size) |
paul@8 | 72 | { |
paul@8 | 73 | /* Set the limits of the paged region. */ |
paul@8 | 74 | |
paul@90 | 75 | return Pager::mmap(position, length, start_pos, end_pos, size); |
paul@8 | 76 | } |
paul@8 | 77 | |
paul@78 | 78 | |
paul@78 | 79 | |
paul@78 | 80 | /* Generic pager operations. */ |
paul@78 | 81 | |
paul@92 | 82 | long FilePager::map(offset_t offset, address_t hot_spot, flags_t flags, l4_snd_fpage_t *region) |
paul@16 | 83 | { |
paul@16 | 84 | return Pager::map(offset, hot_spot, flags, region); |
paul@16 | 85 | } |
paul@16 | 86 | |
paul@8 | 87 | // vim: tabstop=4 expandtab shiftwidth=4 |