paul@355 | 1 | /* |
paul@431 | 2 | * Common system pager functionality. |
paul@355 | 3 | * |
paul@355 | 4 | * Copyright (C) 2022 Paul Boddie <paul@boddie.org.uk> |
paul@355 | 5 | * |
paul@355 | 6 | * This program is free software; you can redistribute it and/or |
paul@355 | 7 | * modify it under the terms of the GNU General Public License as |
paul@355 | 8 | * published by the Free Software Foundation; either version 2 of |
paul@355 | 9 | * the License, or (at your option) any later version. |
paul@355 | 10 | * |
paul@355 | 11 | * This program is distributed in the hope that it will be useful, |
paul@355 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
paul@355 | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
paul@355 | 14 | * GNU General Public License for more details. |
paul@355 | 15 | * |
paul@355 | 16 | * You should have received a copy of the GNU General Public License |
paul@355 | 17 | * along with this program; if not, write to the Free Software |
paul@355 | 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, |
paul@355 | 19 | * Boston, MA 02110-1301, USA |
paul@355 | 20 | */ |
paul@355 | 21 | |
paul@355 | 22 | #pragma once |
paul@355 | 23 | |
paul@431 | 24 | #include <map> |
paul@431 | 25 | |
paul@431 | 26 | #include <exec/mapped_region.h> |
paul@431 | 27 | |
paul@355 | 28 | |
paul@355 | 29 | |
paul@431 | 30 | /* Collection types. */ |
paul@431 | 31 | |
paul@431 | 32 | typedef std::map<l4_addr_t, MappedRegion> MappedRegions; |
paul@431 | 33 | |
paul@431 | 34 | |
paul@431 | 35 | |
paul@355 | 36 | /* A simple system pager also acting as a region mapper. */ |
paul@355 | 37 | |
paul@469 | 38 | class ExecPager |
paul@355 | 39 | { |
paul@431 | 40 | protected: |
paul@431 | 41 | address_t _start, _end; |
paul@431 | 42 | |
paul@431 | 43 | /* Region manager/mapper functionality. */ |
paul@431 | 44 | |
paul@431 | 45 | MappedRegions _regions; |
paul@431 | 46 | |
paul@431 | 47 | virtual long find(address_t *start, address_t *size, map_flags_t flags, |
paul@431 | 48 | address_t offset, unsigned char align); |
paul@431 | 49 | |
paul@355 | 50 | public: |
paul@431 | 51 | explicit ExecPager(address_t start = 0, address_t end = 0); |
paul@431 | 52 | |
paul@366 | 53 | virtual ~ExecPager(); |
paul@355 | 54 | |
paul@431 | 55 | virtual void add(MappedRegion ®ion); |
paul@431 | 56 | |
paul@355 | 57 | /* Notification methods. */ |
paul@355 | 58 | |
paul@355 | 59 | virtual long exception(l4_exc_regs_t regs, |
paul@366 | 60 | l4_snd_fpage_t *region) = 0; |
paul@355 | 61 | |
paul@355 | 62 | virtual long page_fault(l4_umword_t pfa, l4_umword_t pc, |
paul@431 | 63 | l4_snd_fpage_t *region) = 0; |
paul@355 | 64 | }; |
paul@355 | 65 | |
paul@355 | 66 | /* vim: tabstop=2 expandtab shiftwidth=2 |
paul@355 | 67 | */ |