elfloader-arch.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2005, Swedish Institute of Computer Science
00003  * All rights reserved.
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions
00007  * are met:
00008  * 1. Redistributions of source code must retain the above copyright
00009  *    notice, this list of conditions and the following disclaimer.
00010  * 2. Redistributions in binary form must reproduce the above copyright
00011  *    notice, this list of conditions and the following disclaimer in the
00012  *    documentation and/or other materials provided with the distribution.
00013  * 3. Neither the name of the Institute nor the names of its contributors
00014  *    may be used to endorse or promote products derived from this software
00015  *    without specific prior written permission.
00016  *
00017  * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
00018  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00019  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00020  * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
00021  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00022  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
00023  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00024  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00025  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
00026  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00027  * SUCH DAMAGE.
00028  *
00029  * This file is part of the Contiki operating system.
00030  *
00031  * @(#)$Id: elfloader-arch.h,v 1.4 2007/03/24 15:21:34 oliverschmidt Exp $
00032  */
00033 /**
00034  * \addtogroup elfloader
00035  * @{
00036  */
00037 
00038 /**
00039  * \defgroup elfloaderarch Architecture specific functionality for the ELF loader.
00040  *
00041  * The architecture specific functionality for the Contiki ELF loader
00042  * has to be implemented for each processor type Contiki runs on.
00043  *
00044  * Since the ELF format is slightly different for different processor
00045  * types, the Contiki ELF loader is divided into two parts: the
00046  * generic ELF loader module (\ref elfloader) and the architecture
00047  * specific part (this module). The architecture specific part deals
00048  * with memory allocation, code and data relocation, and writing the
00049  * relocated ELF code into program memory.
00050  *
00051  * To port the Contiki ELF loader to a new processor type, this module
00052  * has to be implemented for the new processor type.
00053  *
00054  * @{
00055  */
00056 
00057 /**
00058  * \file
00059  *         Header file for the architecture specific parts of the Contiki ELF loader.
00060  *
00061  * \author
00062  *         Adam Dunkels <adam@sics.se>
00063  *
00064  */
00065 
00066 #ifndef __ELFLOADER_ARCH_H__
00067 #define __ELFLOADER_ARCH_H__
00068 
00069 #include "loader/elfloader.h"
00070 
00071 /**
00072  * \brief      Allocate RAM for a new module.
00073  * \param size The size of the requested memory.
00074  * \return     A pointer to the allocated RAM
00075  *
00076  *             This function is called from the Contiki ELF loader to
00077  *             allocate RAM for the module to be loaded into.
00078  *
00079  * \bug        The Contiki ELF loader currently does not contain a
00080  *             mechanism for deallocating the memory allocated with
00081  *             this function.
00082  */
00083 void *elfloader_arch_allocate_ram(int size);
00084 
00085 /**
00086  * \brief      Allocate program memory for a new module.
00087  * \param size The size of the requested memory.
00088  * \return     A pointer to the allocated program memory
00089  *
00090  *             This function is called from the Contiki ELF loader to
00091  *             allocate program memory (typically ROM) for the module
00092  *             to be loaded into.
00093  *
00094  * \bug        The Contiki ELF loader currently does not contain a
00095  *             mechanism for deallocating the memory allocated with
00096  *             this function.
00097  */
00098 void *elfloader_arch_allocate_rom(int size);
00099 
00100 /**
00101  * \brief      Perform a relocation.
00102  * \param fd   The file descriptor for the ELF file.
00103  * \param sectionoffset The file offset at which the relocation can be found.
00104  * \param sectionaddr The section start address (absolute runtime).
00105  * \param rela A pointer to an ELF32 rela structure (struct elf32_rela).
00106  * \param addr The relocated address.
00107  *
00108  *             This function is called from the Contiki ELF loader to
00109  *             perform a relocation on a piece of code or data. The
00110  *             relocated address is calculated by the Contiki ELF
00111  *             loader, based on information in the ELF file, and it is
00112  *             the responsibility of this function to patch the
00113  *             executable code. The Contiki ELF loader passes a
00114  *             pointer to an ELF32 rela structure (struct elf32_rela)
00115  *             that contains information about how to patch the
00116  *             code. This information is different from processor to
00117  *             processor.
00118  */
00119 void elfloader_arch_relocate(int fd, unsigned int sectionoffset,
00120                              char *sectionaddr,
00121                              struct elf32_rela *rela, char *addr);
00122 
00123 /**
00124  * \brief      Write to read-only memory (for example the text segment).
00125  * \param fd   The file descriptor for the ELF file.
00126  * \param textoff       Offset of text segment relative start of file.
00127  * \param size The size of the text segment.
00128  * \param mem  A pointer to the where the text segment should be flashed
00129  *
00130  *             This function is called from the Contiki ELF loader to
00131  *             write the program code (text segment) of a loaded
00132  *             module into memory. The function is called when all
00133  *             relocations have been performed.
00134  */
00135 void elfloader_arch_write_rom(int fd, unsigned short textoff, unsigned int size, char *mem);
00136 
00137 #endif /* __ELFLOADER_ARCH_H__ */
00138 
00139 /** @} */
00140 /** @} */

Generated on Mon Apr 11 14:23:28 2011 for Contiki 2.5 by  doxygen 1.6.1