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