paul@366 | 1 | /* |
paul@366 | 2 | * A system pager implementation residing in a separate task. |
paul@366 | 3 | * |
paul@480 | 4 | * Copyright (C) 2022, 2023 Paul Boddie <paul@boddie.org.uk> |
paul@366 | 5 | * |
paul@366 | 6 | * This program is free software; you can redistribute it and/or |
paul@366 | 7 | * modify it under the terms of the GNU General Public License as |
paul@366 | 8 | * published by the Free Software Foundation; either version 2 of |
paul@366 | 9 | * the License, or (at your option) any later version. |
paul@366 | 10 | * |
paul@366 | 11 | * This program is distributed in the hope that it will be useful, |
paul@366 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
paul@366 | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
paul@366 | 14 | * GNU General Public License for more details. |
paul@366 | 15 | * |
paul@366 | 16 | * You should have received a copy of the GNU General Public License |
paul@366 | 17 | * along with this program; if not, write to the Free Software |
paul@366 | 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, |
paul@366 | 19 | * Boston, MA 02110-1301, USA |
paul@366 | 20 | */ |
paul@366 | 21 | |
paul@366 | 22 | #pragma once |
paul@366 | 23 | |
paul@499 | 24 | #include <vector> |
paul@499 | 25 | |
paul@366 | 26 | #include <exec/pager.h> |
paul@484 | 27 | #include <fsserver/notification.h> |
paul@489 | 28 | #include <fsserver/resource.h> |
paul@366 | 29 | |
paul@480 | 30 | #include "notifier_interface.h" |
paul@469 | 31 | #include "parent_pager_object_interface.h" |
paul@469 | 32 | |
paul@366 | 33 | |
paul@366 | 34 | |
paul@366 | 35 | /* A simple system pager also acting as a region mapper. */ |
paul@366 | 36 | |
paul@484 | 37 | class ExternalPager : public ExecPager, public ParentPagerObject, |
paul@489 | 38 | public NotificationSupport, public Resource |
paul@366 | 39 | { |
paul@492 | 40 | protected: |
paul@501 | 41 | l4_cap_idx_t _task, _rtask, _parent, _rparent, _pager, _rpager, _ipc_gate; |
paul@499 | 42 | std::vector<l4_cap_idx_t> _threads, _rthreads; |
paul@492 | 43 | |
paul@366 | 44 | public: |
paul@431 | 45 | explicit ExternalPager(address_t start = 0, address_t end = 0); |
paul@366 | 46 | |
paul@489 | 47 | /* Server details. */ |
paul@489 | 48 | |
paul@489 | 49 | virtual ipc_server_default_config_type config(); |
paul@489 | 50 | |
paul@489 | 51 | virtual void *interface() |
paul@489 | 52 | { return static_cast<ParentPagerObject *>(this); } |
paul@489 | 53 | |
paul@492 | 54 | /* Task and thread management. */ |
paul@492 | 55 | |
paul@499 | 56 | virtual void add_thread(l4_cap_idx_t cap, l4_cap_idx_t rcap); |
paul@499 | 57 | virtual void set_gate(l4_cap_idx_t cap); |
paul@499 | 58 | virtual void set_pager(l4_cap_idx_t cap, l4_cap_idx_t rcap); |
paul@499 | 59 | virtual void set_parent(l4_cap_idx_t cap, l4_cap_idx_t rcap); |
paul@501 | 60 | virtual void set_task(l4_cap_idx_t cap, l4_cap_idx_t rcap); |
paul@492 | 61 | |
paul@492 | 62 | /* Resource methods. */ |
paul@492 | 63 | |
paul@492 | 64 | virtual void close(); |
paul@492 | 65 | |
paul@366 | 66 | /* Notification methods, implementing PagerObject. */ |
paul@366 | 67 | |
paul@366 | 68 | virtual long exception(l4_exc_regs_t regs, |
paul@366 | 69 | l4_snd_fpage_t *region); |
paul@366 | 70 | |
paul@366 | 71 | virtual long page_fault(l4_umword_t pfa, l4_umword_t pc, |
paul@366 | 72 | l4_snd_fpage_t *region); |
paul@366 | 73 | |
paul@366 | 74 | /* Region manager/mapper methods. */ |
paul@366 | 75 | |
paul@419 | 76 | virtual long attach(address_t *start, address_t size, map_flags_t flags, |
paul@366 | 77 | l4_cap_idx_t ds, address_t offset, unsigned char align); |
paul@469 | 78 | |
paul@469 | 79 | /* Parent methods. */ |
paul@469 | 80 | |
paul@469 | 81 | virtual long signal(unsigned long sig, unsigned long val); |
paul@480 | 82 | |
paul@480 | 83 | /* Notification methods. */ |
paul@480 | 84 | |
paul@485 | 85 | virtual long subscribe(l4_cap_idx_t notifier, notify_flags_t flags); |
paul@484 | 86 | |
paul@488 | 87 | virtual long unsubscribe(l4_cap_idx_t notifier); |
paul@366 | 88 | }; |
paul@366 | 89 | |
paul@366 | 90 | /* vim: tabstop=2 expandtab shiftwidth=2 |
paul@366 | 91 | */ |