1 /* 2 * File-specific pager functionality. 3 * 4 * Copyright (C) 2021 Paul Boddie <paul@boddie.org.uk> 5 * 6 * This program is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU General Public License as 8 * published by the Free Software Foundation; either version 2 of 9 * the License, or (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, 19 * Boston, MA 02110-1301, USA 20 */ 21 22 #include "file_pager.h" 23 #include "mapped_file_object_server.h" 24 25 26 27 /* Initialise a pager for a file with a unique file identifier and shared page 28 mapper for moderating access to loaded pages. */ 29 30 FilePager::FilePager(fileid_t fileid, PageMapper *mapper, map_flags_t flags, 31 FilePaging *paging) 32 : Pager(mapper, flags), _paging(paging), fileid(fileid) 33 { 34 } 35 36 int FilePager::expected_items() 37 { 38 return MappedFileObject_expected_items; 39 } 40 41 ipc_server_handler_type FilePager::handler() 42 { 43 return (ipc_server_handler_type) handle_MappedFileObject; 44 } 45 46 47 48 /* Close the pager, removing the mapper from the paging registry if 49 appropriate. */ 50 51 void FilePager::close() 52 { 53 _paging->detach_pager(fileid, _mapper); 54 } 55 56 57 58 /* File-specific operations. */ 59 60 long FilePager::flush(offset_t populated_size, offset_t *size) 61 { 62 return Pager::flush(populated_size, size); 63 } 64 65 long FilePager::resize(offset_t *size) 66 { 67 return Pager::resize(size); 68 } 69 70 long FilePager::mmap(offset_t position, offset_t length, offset_t *start_pos, 71 offset_t *end_pos, offset_t *size) 72 { 73 /* Set the limits of the paged region. */ 74 75 return Pager::mmap(position, length, start_pos, end_pos, size); 76 } 77 78 79 80 /* Generic pager operations. */ 81 82 long FilePager::map(offset_t offset, address_t hot_spot, map_flags_t flags, l4_snd_fpage_t *region) 83 { 84 return Pager::map(offset, hot_spot, flags, region); 85 } 86 87 // vim: tabstop=4 expandtab shiftwidth=4