00001 /** \addtogroup sys 00002 * @{ 00003 */ 00004 00005 /** 00006 * \defgroup loader The Contiki program loader 00007 * 00008 * The Contiki program loader is an abstract interface for loading and 00009 * starting programs. 00010 * 00011 * @{ 00012 */ 00013 00014 /** 00015 * \file 00016 * Default definitions and error values for the Contiki program loader. 00017 * \author Adam Dunkels <adam@dunkels.com> 00018 * 00019 */ 00020 00021 /* 00022 * Copyright (c) 2003, Adam Dunkels. 00023 * All rights reserved. 00024 * 00025 * Redistribution and use in source and binary forms, with or without 00026 * modification, are permitted provided that the following conditions 00027 * are met: 00028 * 1. Redistributions of source code must retain the above copyright 00029 * notice, this list of conditions and the following disclaimer. 00030 * 2. Redistributions in binary form must reproduce the above 00031 * copyright notice, this list of conditions and the following 00032 * disclaimer in the documentation and/or other materials provided 00033 * with the distribution. 00034 * 3. The name of the author may not be used to endorse or promote 00035 * products derived from this software without specific prior 00036 * written permission. 00037 * 00038 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 00039 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 00040 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00041 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 00042 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00043 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 00044 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00045 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 00046 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 00047 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00048 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00049 * 00050 * This file is part of the Contiki desktop OS 00051 * 00052 * $Id: loader.h,v 1.2 2008/10/14 12:46:39 nvt-se Exp $ 00053 * 00054 */ 00055 #ifndef __LOADER_H__ 00056 #define __LOADER_H__ 00057 00058 /* Errors that the LOADER_LOAD() function may return: */ 00059 00060 #define LOADER_OK 0 /**< No error. */ 00061 #define LOADER_ERR_READ 1 /**< Read error. */ 00062 #define LOADER_ERR_HDR 2 /**< Header error. */ 00063 #define LOADER_ERR_OS 3 /**< Wrong OS. */ 00064 #define LOADER_ERR_FMT 4 /**< Data format error. */ 00065 #define LOADER_ERR_MEM 5 /**< Not enough memory. */ 00066 #define LOADER_ERR_OPEN 6 /**< Could not open file. */ 00067 #define LOADER_ERR_ARCH 7 /**< Wrong architecture. */ 00068 #define LOADER_ERR_VERSION 8 /**< Wrong OS version. */ 00069 #define LOADER_ERR_NOLOADER 9 /**< Program loading not supported. */ 00070 00071 #ifdef LOADER_CONF_ARCH 00072 #include LOADER_CONF_ARCH 00073 #endif /* LOADER_CONF_ARCH */ 00074 00075 /** 00076 * Load and execute a program. 00077 * 00078 * This macro is used for loading and executing a program, and 00079 * requires support from the architecture dependent code. The actual 00080 * program loading is made by architecture specific functions. 00081 * 00082 * \note A program loaded with LOADER_LOAD() must call the 00083 * LOADER_UNLOAD() function to unload itself. 00084 * 00085 * \param name The name of the program to be loaded. 00086 * 00087 * \param arg A pointer argument that is passed to the program. 00088 * 00089 * \return A loader error, or LOADER_OK if loading was successful. 00090 */ 00091 #ifndef LOADER_LOAD 00092 #define LOADER_LOAD(name, arg) LOADER_ERR_NOLOADER 00093 #endif /* LOADER_LOAD */ 00094 00095 /** 00096 * Unload a program from memory. 00097 * 00098 * This macro is used for unloading a program and deallocating any 00099 * memory that was allocated during the loading of the program. This 00100 * function must be called by the program itself. 00101 * 00102 */ 00103 #ifndef LOADER_UNLOAD 00104 #define LOADER_UNLOAD() 00105 #endif /* LOADER_UNLOAD */ 00106 00107 /** 00108 * Load a DSC (program description). 00109 * 00110 * Loads a DSC (program description) into memory and returns a pointer 00111 * to the dsc. 00112 * 00113 * \return A pointer to the DSC or NULL if it could not be loaded. 00114 */ 00115 #ifndef LOADER_LOAD_DSC 00116 #define LOADER_LOAD_DSC(name) NULL 00117 #endif /* LOADER_LOAD_DSC */ 00118 00119 /** 00120 * Unload a DSC (program description). 00121 * 00122 * Unload a DSC from memory and deallocate any memory that was 00123 * allocated when it was loaded. 00124 */ 00125 #ifndef LOADER_UNLOAD_DSC 00126 #define LOADER_UNLOAD_DSC(dsc) 00127 #endif /* LOADER_UNLOAD */ 00128 00129 #endif /* __LOADER_H__ */ 00130 00131 /** @} */ 00132 /** @} */