L4Re - L4 Runtime Environment
pager
Go to the documentation of this file.
1 // vi:set ft=cpp: -*- Mode: C++ -*-
2 /**
3  * \file
4  * Pager and Io_pager C++ interface.
5  */
6 /*
7  * (c) 2014 Alexander Warg <alexander.warg@kernkonzept.com>
8  *
9  * This file is part of TUD:OS and distributed under the terms of the
10  * GNU General Public License 2.
11  * Please see the COPYING-GPL-2 file for details.
12  *
13  * As a special exception, you may use this file as part of a free software
14  * library without restriction. Specifically, if other files instantiate
15  * templates or use macros or inline functions from this file, or you compile
16  * this file and link it with other files to produce an executable, this
17  * file does not by itself cause the resulting executable to be covered by
18  * the GNU General Public License. This exception does not however
19  * invalidate any other reasons why the executable file might be covered by
20  * the GNU General Public License.
21  */
22 
23 #pragma once
24 
25 #include <l4/sys/capability>
26 #include <l4/sys/types.h>
27 #include <l4/sys/cxx/ipc_types>
28 #include <l4/sys/cxx/ipc_iface>
29 
30 namespace L4 {
31 
32 /**
33  * Io_pager interface.
34  */
35 class L4_EXPORT Io_pager :
36  public Kobject_0t<Io_pager, L4_PROTO_IO_PAGE_FAULT>
37 {
38 public:
39  /**
40  * IO page fault protocol message.
41  *
42  * \param io_pfa Flex-page describing the faulting IO-port.
43  * \param pc Faulting program counter.
44  * \param[out] result Optional: handling result value.
45  * \param rwin The receive window for a flex-page mapping.
46  * \param[out] fp Optional: flex-page descriptor to send to the task
47  * raising the page fault.
48  *
49  * \return System call message tag; use l4_error() to check for errors.
50  *
51  * IO-port fault messages are usually generated by the kernel and an
52  * IO-page-fault handler needs to be in place to handle such faults
53  * and generate a reply by filling in `result` and / or `fp`.
54  */
55  L4_INLINE_RPC(
56  l4_msgtag_t, io_page_fault, (l4_fpage_t io_pfa, l4_umword_t pc,
57  L4::Ipc::Opt<l4_mword_t &> result,
58  L4::Ipc::Rcv_fpage rwin,
59  L4::Ipc::Opt<L4::Ipc::Snd_fpage &> fp));
60 
61  typedef L4::Typeid::Rpc_nocode<io_page_fault_t> Rpcs;
62 };
63 
64 /**
65  * Pager interface including the Io_pager interface.
66  */
67 class L4_EXPORT Pager :
68  public Kobject_t<Pager, Io_pager, L4_PROTO_PAGE_FAULT>
69 {
70 public:
71  /**
72  * Page-fault protocol message.
73  *
74  * \param pfa Faulting address including failure reason: bits [0:2]
75  * \param pc Faulting program counter.
76  * \param[out] result Optional: handling result value.
77  * \param rwin Receive window for a flex-page mapping resolving the
78  * page fault
79  * \param[out] fp Optional: flex-page descriptor to send to the task
80  * raising the page fault.
81  *
82  * \return System call message tag; use l4_error() to check for errors.
83  *
84  * Page-fault messages are usually generated by the kernel and need to
85  * be handled by an appropriate handler funtion that fills in `result`
86  * and / or `fp` for the reply.
87  *
88  * `pfa` encoding is as shown:
89  *
90  * | [63/31 .. 3] | 2 | 1 | 0 |
91  * |:------------------------:|:-:|:-:|:-:|
92  * | PFA | X | W | T |
93  *
94  * - __PFA__ Bits 63/31..3 of `pfa` are the page fault address bits 63/31
95  * to 3, bits 2..0 are masked.
96  * - __X__ Bit 2 of `pfa` is set to 1 for a page fault during instruction
97  * fetch.
98  * - __W__ Bit 1 of `pfa` is set to 1 for a page fault due to a write
99  * operation.
100  * - __T__ Bit 0 of `pfa` is set for translation faults (no mapping
101  * was present).
102  */
103  L4_INLINE_RPC(
104  l4_msgtag_t, page_fault, (l4_umword_t pfa, l4_umword_t pc,
105  L4::Ipc::Opt<l4_mword_t &> result,
106  L4::Ipc::Rcv_fpage rwin,
107  L4::Ipc::Opt<L4::Ipc::Snd_fpage &> fp));
108 
109  typedef L4::Typeid::Rpc_nocode<page_fault_t> Rpcs;
110 };
111 
112 }