Main Page | Modules | Data Structures | File List | Data Fields | Globals | Examples

loader.h

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

Generated on Wed Jul 6 01:18:59 2005 for Contiki/ESB by doxygen 1.3.6