1 | /* |
---|
2 | * COPYRIGHT (c) 2013, 2018 Chris Johns <chrisj@rtems.org> |
---|
3 | * |
---|
4 | * The license and distribution terms for this file may be |
---|
5 | * found in the file LICENSE in this distribution or at |
---|
6 | * http://www.rtems.org/license/LICENSE. |
---|
7 | */ |
---|
8 | /** |
---|
9 | * @file |
---|
10 | * |
---|
11 | * @ingroup rtems_rap |
---|
12 | * |
---|
13 | * @brief RTEMS Application Loader |
---|
14 | * |
---|
15 | * This is the RTEMS Application loader for files in the RAP format. |
---|
16 | */ |
---|
17 | |
---|
18 | #if !defined (_RAP_H_) |
---|
19 | #define _RAP_H_ |
---|
20 | |
---|
21 | #include <rtems.h> |
---|
22 | #include <rtems/chain.h> |
---|
23 | |
---|
24 | #ifdef __cplusplus |
---|
25 | extern "C" { |
---|
26 | #endif /* __cplusplus */ |
---|
27 | |
---|
28 | /** |
---|
29 | * @defgroup rtems_rap RTEMS Application Loader |
---|
30 | * |
---|
31 | * The module implements an application loader for files in the RAP format. The |
---|
32 | * RAP format is: |
---|
33 | * |
---|
34 | * <header> |
---|
35 | * <compressed container> |
---|
36 | * |
---|
37 | * The compressed container is a stream of ELF relocatable object files. |
---|
38 | * |
---|
39 | * TBD. |
---|
40 | */ |
---|
41 | |
---|
42 | /** |
---|
43 | * The module iterator handle. |
---|
44 | */ |
---|
45 | typedef bool (*rtems_rap_iterator) (void* handle); |
---|
46 | |
---|
47 | /** |
---|
48 | * Load an application. |
---|
49 | * |
---|
50 | * @param name The name of the application file. |
---|
51 | * @return bool True if the module loads else an error. |
---|
52 | */ |
---|
53 | bool rtems_rap_load (const char* name, int mode, int argc, const char* argv[]); |
---|
54 | |
---|
55 | /** |
---|
56 | * Unload an application. |
---|
57 | * |
---|
58 | * @param obj The application descriptor. |
---|
59 | * @retval true The application file has been unloaded. |
---|
60 | * @retval false The application could not be unloaded. |
---|
61 | */ |
---|
62 | bool rtems_rap_unload (const char* name); |
---|
63 | |
---|
64 | /** |
---|
65 | * Find the application handle given a file name. |
---|
66 | * |
---|
67 | * @param name The name of the application file. It can be absolute or |
---|
68 | * relative. Relative names can the basename with an extension. |
---|
69 | * @retval NULL No application file with that name found. |
---|
70 | * @return void* The application descriptor. |
---|
71 | */ |
---|
72 | void* rtems_rap_find (const char* name); |
---|
73 | |
---|
74 | /** |
---|
75 | * Run an iterator over the modules calling the iterator function. |
---|
76 | * |
---|
77 | * @param iterator The iterator function. |
---|
78 | * @retval true The iterator function returned did not return false. |
---|
79 | * @retval false The iterator function returned false.. |
---|
80 | */ |
---|
81 | bool rtems_rap_iterate (rtems_rap_iterator iterator); |
---|
82 | |
---|
83 | /** |
---|
84 | * Return the name of the module given a handle. |
---|
85 | * |
---|
86 | * @param handle The module handle. |
---|
87 | * @return const char* The name of the module if the handle is valid else it |
---|
88 | * is NULL. |
---|
89 | */ |
---|
90 | const char* rtems_rap_name (void* handle); |
---|
91 | |
---|
92 | /** |
---|
93 | * Return the DL handle used to load the module given the RAP handle. |
---|
94 | * |
---|
95 | * @param handle The module handle. |
---|
96 | * @return void* The DL handle returned by the dlopen call. |
---|
97 | */ |
---|
98 | void* rtems_rap_dl_handle (void* handle); |
---|
99 | |
---|
100 | /** |
---|
101 | * Get the last error message clearing it. This call is not thread safe is |
---|
102 | * multiple threads are loading object files at the same time. This call |
---|
103 | * follows the model provided by the dlopen family of calls. |
---|
104 | * |
---|
105 | * @param message Pointer to a buffer to copy the message into. |
---|
106 | * @param max_message The maximum message that can be copied. |
---|
107 | * @return int The last error number. |
---|
108 | */ |
---|
109 | int rtems_rap_get_error (char* message, size_t max_message); |
---|
110 | |
---|
111 | #ifdef __cplusplus |
---|
112 | } |
---|
113 | #endif /* __cplusplus */ |
---|
114 | |
---|
115 | #endif |
---|