Contiki 3.x
loader.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2003, Adam Dunkels.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above
11  * copyright notice, this list of conditions and the following
12  * disclaimer in the documentation and/or other materials provided
13  * with the distribution.
14  * 3. The name of the author may not be used to endorse or promote
15  * products derived from this software without specific prior
16  * written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
19  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
22  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
24  * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  *
30  * This file is part of the Contiki desktop OS
31  *
32  *
33  */
34 
35 /**
36  * \file
37  * Default definitions and error values for the Contiki program loader.
38  * \author Adam Dunkels <adam@dunkels.com>
39  *
40  */
41 
42 /** \addtogroup sys
43  * @{
44  */
45 
46 /**
47  * \defgroup loader The Contiki program loader
48  *
49  * The Contiki program loader is an abstract interface for loading and
50  * starting programs.
51  *
52  * @{
53  */
54 
55 #ifndef LOADER_H_
56 #define LOADER_H_
57 
58 /* Errors that the LOADER_LOAD() function may return: */
59 
60 #define LOADER_OK 0 /**< No error. */
61 #define LOADER_ERR_READ 1 /**< Read error. */
62 #define LOADER_ERR_HDR 2 /**< Header error. */
63 #define LOADER_ERR_OS 3 /**< Wrong OS. */
64 #define LOADER_ERR_FMT 4 /**< Data format error. */
65 #define LOADER_ERR_MEM 5 /**< Not enough memory. */
66 #define LOADER_ERR_OPEN 6 /**< Could not open file. */
67 #define LOADER_ERR_ARCH 7 /**< Wrong architecture. */
68 #define LOADER_ERR_VERSION 8 /**< Wrong OS version. */
69 #define LOADER_ERR_NOLOADER 9 /**< Program loading not supported. */
70 
71 #ifdef LOADER_CONF_ARCH
72 #include LOADER_CONF_ARCH
73 #endif /* LOADER_CONF_ARCH */
74 
75 /**
76  * Load and execute a program.
77  *
78  * This macro is used for loading and executing a program, and
79  * requires support from the architecture dependent code. The actual
80  * program loading is made by architecture specific functions.
81  *
82  * \note A program loaded with LOADER_LOAD() must call the
83  * LOADER_UNLOAD() function to unload itself.
84  *
85  * \param name The name of the program to be loaded.
86  *
87  * \param arg A pointer argument that is passed to the program.
88  *
89  * \return A loader error, or LOADER_OK if loading was successful.
90  */
91 #ifndef LOADER_LOAD
92 #define LOADER_LOAD(name, arg) LOADER_ERR_NOLOADER
93 #endif /* LOADER_LOAD */
94 
95 /**
96  * Unload a program from memory.
97  *
98  * This macro is used for unloading a program and deallocating any
99  * memory that was allocated during the loading of the program. This
100  * function must be called by the program itself.
101  *
102  */
103 #ifndef LOADER_UNLOAD
104 #define LOADER_UNLOAD()
105 #endif /* LOADER_UNLOAD */
106 
107 /**
108  * Load a DSC (program description).
109  *
110  * Loads a DSC (program description) into memory and returns a pointer
111  * to the dsc.
112  *
113  * \return A pointer to the DSC or NULL if it could not be loaded.
114  */
115 #ifndef LOADER_LOAD_DSC
116 #define LOADER_LOAD_DSC(name) NULL
117 #endif /* LOADER_LOAD_DSC */
118 
119 /**
120  * Unload a DSC (program description).
121  *
122  * Unload a DSC from memory and deallocate any memory that was
123  * allocated when it was loaded.
124  */
125 #ifndef LOADER_UNLOAD_DSC
126 #define LOADER_UNLOAD_DSC(dsc)
127 #endif /* LOADER_UNLOAD */
128 
129 #endif /* LOADER_H_ */
130 
131 /** @} */
132 /** @} */