]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/l4re/include/elf_aux.h
update
[l4.git] / l4 / pkg / l4re / include / elf_aux.h
1 /**
2  * \file
3  * \brief Auxiliary information for binaries
4  */
5 /*
6  * (c) 2009 Alexander Warg <warg@os.inf.tu-dresden.de>
7  *     economic rights: Technische Universität Dresden (Germany)
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 #pragma once
23
24 #include <l4/sys/types.h>
25
26
27 /**
28  * \defgroup api_l4re_elf_aux L4Re ELF Auxiliary Information
29  * \ingroup api_l4re
30  * \brief API for embedding auxiliary information into
31  *        binary programs.
32  *
33  * This API allows information for the binary loader to be embedded into a
34  * binary application.  This information can be reserved areas in the virtual
35  * memory of an application and things such as the stack size to be allocated
36  * for the first application thread.
37  */
38 /*@{*/
39
40 /**
41  * \brief Define an auxiliary vector element.
42  *
43  * This is the generic method for defining auxiliary vector elements.
44  * A more convenient way is to use L4RE_ELF_AUX_ELEM_T.
45  *
46  * Usage:
47  * \code
48  * L4RE_ELF_AUX_ELEM l4re_elf_aux_vma_t decl_name =
49  *   { L4RE_ELF_AUX_T_VMA, sizeof(l4re_elf_aux_vma_t), 0x2000, 0x4000 };
50  * \endcode
51  */
52 #define L4RE_ELF_AUX_ELEM const __attribute__((used, section(".rol4re_elf_aux")))
53
54 /**
55  * \brief Define an auxiliary vector element.
56  * \param type is the data type for the element (e.g., l4re_elf_aux_vma_t)
57  * \param id is the identifier (variable name) for the declaration (the
58  *           variable is defined with \c static storage class)
59  * \param tag is the tag value for the element e.g., #L4RE_ELF_AUX_T_VMA
60  * \param val are the values to be set in the descriptor
61  *
62  * Usage:
63  * \code
64  * L4RE_ELF_AUX_ELEM_T(l4re_elf_aux_vma_t, decl_name, L4RE_ELF_AUX_T_VMA, 0x2000, 0x4000 };
65  * \endcode
66  */
67 #define L4RE_ELF_AUX_ELEM_T(type, id, tag, val...) \
68   static const __attribute__((used, section(".rol4re_elf_aux"))) \
69   type id = {tag, sizeof(type), val}
70
71 enum
72 {
73   /**
74    * \brief Tag for an invalid element in the auxiliary vector
75    */
76   L4RE_ELF_AUX_T_NONE = 0,
77
78   /**
79    * \brief Tag for descriptor for a reserved virtual memory area.
80    */
81   L4RE_ELF_AUX_T_VMA,
82
83   /**
84    * \brief Tag for descriptor that defines the stack size for
85    *        the first application thread.
86    */
87   L4RE_ELF_AUX_T_STACK_SIZE,
88
89   /**
90    * \brief Tag for descriptor that defines the stack address
91    *        for the first application thread.
92    */
93   L4RE_ELF_AUX_T_STACK_ADDR,
94
95   /**
96    * \brief Tag for descriptor that defines the KIP address
97    *        for the binaries address space.
98    */
99   L4RE_ELF_AUX_T_KIP_ADDR,
100 };
101
102 /**
103  * \brief Generic header for each auxiliary vector element.
104  */
105 typedef struct l4re_elf_aux_t
106 {
107   l4_umword_t type;
108   l4_umword_t length;
109 } l4re_elf_aux_t;
110
111 /**
112  * \brief Auxiliary vector element for a reserved virtual memory area.
113  */
114 typedef struct l4re_elf_aux_vma_t
115 {
116   l4_umword_t type;
117   l4_umword_t length;
118   l4_umword_t start;
119   l4_umword_t end;
120 } l4re_elf_aux_vma_t;
121
122 /**
123  * \brief Auxiliary vector element for a single unsigned data word.
124  */
125 typedef struct l4re_elf_aux_mword_t
126 {
127   l4_umword_t type;
128   l4_umword_t length;
129   l4_umword_t value;
130 } l4re_elf_aux_mword_t;
131
132 /*@}*/