]> rtime.felk.cvut.cz Git - l4.git/blob - kernel/fiasco/src/abi/l4_buf_desc.cpp
b157a4ff1db3ae8329f14fb2e190e04756fc5e7b
[l4.git] / kernel / fiasco / src / abi / l4_buf_desc.cpp
1 INTERFACE:
2
3 #include "types.h"
4 #include <bitfield>
5
6 /**
7  * Description of the mapping buffer registers contained in the UTCB 
8  * (used e.g. during IPC).
9  * The utcb can contain buffers that describe memory regions, bits in the
10  * I/O bitmap or capabilities. The buffer description is used to find the
11  * first buffer for each type.
12  * Additionally, the buffer description contains a flag to specify the
13  * willingness to receive FPU state in an IPC operation.
14  *
15  * Note that a single buffer might occupy more than one word in the buffer-
16  * registers array in the UTCB. The L4_buf_iter class can be used to iterate
17  * over buffers.
18  */
19 class L4_buf_desc
20 {
21 public:
22   enum Flags
23   {
24     /**
25      * \brief Flag the willingness to receive FPU state during IPC.
26      *
27      * If this flag is set, the receiving thread in an IPC is willing
28      * to receive the status of the floating point unit (FPU) from its partner
29      * as part of an IPC. Conceptually, this flag adds the FPU of the
30      * receiver as an additional message receiver buffer.
31      * The sender must set the corresponding flag L4_msg_tag::Transfer_fpu.
32      */
33     Inherit_fpu = (1UL << 24)
34   };
35
36   /**
37    * Create an uninitialized buffer descriptor.
38    * \note The value of the buffer descriptor is unpredictable.
39    */
40   L4_buf_desc() {}
41
42   /**
43    * Create a buffer descriptor with given values.
44    * \param mem the BR index for the first memory buffer item.
45    * \param io the BR index for the first I/O-port buffer item.
46    * \param obj the BR index for the first object/capability buffer item.
47    * \param flags the flags, such as, Inherit_fpu.
48    *
49    * The buffer registers must contain blocks of buffers of identical
50    * type (memory, caps, I/O-ports) starting at the given index. The first
51    * non-matching item terminates the items of the particular type.
52    * \see Utcb and L4_msg_tag
53    */
54   L4_buf_desc(unsigned mem, unsigned io, unsigned obj,
55               unsigned flags = 0)
56   : _raw(  mem_bfm_t::val_dirty(mem)
57          | io_bfm_t::val_dirty(io)
58          | obj_bfm_t::val_dirty(obj)
59          | flags)
60   {}
61
62   /**
63    * The flags of the BDR.
64    * \return flags encoded in the BDR, see #Inherit_fpu, L4_buf_desc::Flags.
65    * \note The return value may have reserved bits set.
66    */
67   Mword flags() const { return _raw; }
68
69   /**
70    * Get the raw binary representation of the buffer descriptor.
71    * \return binary representation of the buffer descriptor.
72    */
73   Mword raw() const { return _raw; }
74
75 private:
76   /**
77    * A single machine word that describes the buffers that follow:
78    * - Bits 0..4: The index of the first memory buffer.
79    * - Bits 5..9: The index of the first io buffer.
80    * - Bits 10..14: The index of the first capability buffer.
81    * - Bits 15..23: Unused
82    * - Bits 24..31: Flags as defined above (only #Inherit_fpu is in use).
83    */
84   Mword _raw;
85
86 public:
87   /** \name Index of the first memory receive buffer
88    *
89    * The memory receive items use two BRs each.
90    * \see L4_fpage, L4_msg_item
91    */
92   CXX_BITFIELD_MEMBER( 0,  4, mem, _raw);
93
94   /** \name Index of the first IO-port receive buffer
95    *
96    * The I/O-port buffer items use two BRs each.
97    * \see L4_fpage, L4_msg_item.
98    */
99   CXX_BITFIELD_MEMBER( 5,  9, io, _raw);
100
101   /** \name Index of the first object receive buffer
102    *
103    * An object receive buffer may use one or two BRs depending on the
104    * value in the L4_msg_item in the first BR.
105    * \see L4_msg_item, L4_fpage.
106    */
107   CXX_BITFIELD_MEMBER(10, 14, obj, _raw);
108
109 };