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