paul@355 | 1 | /* |
paul@431 | 2 | * Common system pager functionality. |
paul@355 | 3 | * |
paul@504 | 4 | * Copyright (C) 2022, 2023 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@431 | 22 | #include <l4/re/env.h> |
paul@431 | 23 | |
paul@431 | 24 | #include <mem/memory_utils.h> |
paul@431 | 25 | |
paul@355 | 26 | #include "pager.h" |
paul@355 | 27 | |
paul@355 | 28 | |
paul@355 | 29 | |
paul@431 | 30 | /* Initialise common functionality. */ |
paul@431 | 31 | |
paul@431 | 32 | ExecPager::ExecPager(address_t start, address_t end) |
paul@515 | 33 | : _area(start, end) |
paul@431 | 34 | { |
paul@431 | 35 | } |
paul@431 | 36 | |
paul@366 | 37 | /* Necessary virtual destructor. */ |
paul@355 | 38 | |
paul@366 | 39 | ExecPager::~ExecPager() |
paul@355 | 40 | { |
paul@355 | 41 | } |
paul@355 | 42 | |
paul@504 | 43 | |
paul@504 | 44 | |
paul@515 | 45 | /* Add an area to the pager. */ |
paul@431 | 46 | |
paul@515 | 47 | void ExecPager::add(MemoryArea &area) |
paul@431 | 48 | { |
paul@515 | 49 | _area.add(area); |
paul@431 | 50 | } |
paul@431 | 51 | |
paul@515 | 52 | /* Remove an area from the pager. */ |
paul@504 | 53 | |
paul@515 | 54 | void ExecPager::remove(MemoryArea &area) |
paul@504 | 55 | { |
paul@515 | 56 | _area.remove(area); |
paul@504 | 57 | } |
paul@504 | 58 | |
paul@504 | 59 | |
paul@504 | 60 | |
paul@515 | 61 | /* Find an area suitable for attaching a memory region. */ |
paul@431 | 62 | |
paul@431 | 63 | long ExecPager::find(address_t *start, address_t *size, map_flags_t flags, |
paul@515 | 64 | unsigned char align, MemoryArea **area) |
paul@431 | 65 | { |
paul@431 | 66 | if (align < L4_PAGESHIFT) |
paul@431 | 67 | align = L4_PAGESHIFT; |
paul@431 | 68 | |
paul@515 | 69 | /* Attempt to find an address for the specified region, starting from |
paul@431 | 70 | any indicated address. */ |
paul@431 | 71 | |
paul@515 | 72 | return _area.find(start, size, flags, align, area); |
paul@431 | 73 | } |
paul@431 | 74 | |
paul@355 | 75 | /* vim: tabstop=2 expandtab shiftwidth=2 |
paul@355 | 76 | */ |