Contiki 2.5
Files | Functions
Architecture specific functionality for the ELF loader.

The architecture specific functionality for the Contiki ELF loader has to be implemented for each processor type Contiki runs on. More...

Files

file  elfloader-arch.h
 
    Header file for the architecture specific parts of the Contiki ELF loader.

 
file  elfloader-arch-otf.h
 
    Header file for the architecture specific parts of the Contiki ELF loader.

 

Functions

void * elfloader_arch_allocate_ram (int size)
 Allocate RAM for a new module. More...
 
void * elfloader_arch_allocate_rom (int size)
 Allocate program memory for a new module. More...
 
void elfloader_arch_relocate (int fd, unsigned int sectionoffset, char *sectionaddr, struct elf32_rela *rela, char *addr)
 Perform a relocation. More...
 
void elfloader_arch_write_rom (int fd, unsigned short textoff, unsigned int size, char *mem)
 Write to read-only memory (for example the text segment). More...
 
int elfloader_arch_relocate (int input_fd, struct elfloader_output *output, unsigned int sectionoffset, char *sectionaddr, struct elf32_rela *rela, char *addr)
 Perform a relocation. More...
 

Detailed Description

The architecture specific functionality for the Contiki ELF loader has to be implemented for each processor type Contiki runs on.

Since the ELF format is slightly different for different processor types, the Contiki ELF loader is divided into two parts: the generic ELF loader module (The Contiki ELF loader) and the architecture specific part (this module). The architecture specific part deals with memory allocation, code and data relocation, and writing the relocated ELF code into program memory.

To port the Contiki ELF loader to a new processor type, this module has to be implemented for the new processor type.

Function Documentation

void* elfloader_arch_allocate_ram ( int  size)

Allocate RAM for a new module.

Parameters
sizeThe size of the requested memory.
Returns
A pointer to the allocated RAM
        This function is called from the Contiki ELF loader to
        allocate RAM for the module to be loaded into.

Definition at line 76 of file elfloader-avr.c.

References mmem_alloc(), mmem_free(), MMEM_PTR, and NULL.

Referenced by elfloader_load().

void* elfloader_arch_allocate_rom ( int  size)

Allocate program memory for a new module.

Parameters
sizeThe size of the requested memory.
Returns
A pointer to the allocated program memory
        This function is called from the Contiki ELF loader to
        allocate program memory (typically ROM) for the module
        to be loaded into.

Definition at line 97 of file elfloader-avr.c.

Referenced by elfloader_load().

int elfloader_arch_relocate ( int  input_fd,
struct elfloader_output output,
unsigned int  sectionoffset,
char *  sectionaddr,
struct elf32_rela *  rela,
char *  addr 
)

Perform a relocation.

Parameters
outputThe output object for the segment.
sectionoffsetThe file offset at which the relocation can be found.
sectionaddrThe section start address (absolute runtime).
relaA pointer to an ELF32 rela structure (struct elf32_rela).
addrThe relocated address.
        This function is called from the Contiki ELF loader to
        perform a relocation on a piece of code or data. The
        relocated address is calculated by the Contiki ELF
        loader, based on information in the ELF file, and it is
        the responsibility of this function to patch the
        executable code. The Contiki ELF loader passes a
        pointer to an ELF32 rela structure (struct elf32_rela)
        that contains information about how to patch the
        code. This information is different from processor to
        processor.

Definition at line 22 of file elfloader-arm.c.

References cfs_seek(), CFS_SEEK_SET, ELFLOADER_OK, and ELFLOADER_UNHANDLED_RELOC.

void elfloader_arch_relocate ( int  fd,
unsigned int  sectionoffset,
char *  sectionaddr,
struct elf32_rela *  rela,
char *  addr 
)

Perform a relocation.

Parameters
fdThe file descriptor for the ELF file.
sectionoffsetThe file offset at which the relocation can be found.
sectionaddrThe section start address (absolute runtime).
relaA pointer to an ELF32 rela structure (struct elf32_rela).
addrThe relocated address.
        This function is called from the Contiki ELF loader to
        perform a relocation on a piece of code or data. The
        relocated address is calculated by the Contiki ELF
        loader, based on information in the ELF file, and it is
        the responsibility of this function to patch the
        executable code. The Contiki ELF loader passes a
        pointer to an ELF32 rela structure (struct elf32_rela)
        that contains information about how to patch the
        code. This information is different from processor to
        processor.

Definition at line 178 of file elfloader-avr.c.

References cfs_seek(), CFS_SEEK_CUR, CFS_SEEK_SET, and ELFLOADER_UNHANDLED_RELOC.

void elfloader_arch_write_rom ( int  fd,
unsigned short  textoff,
unsigned int  size,
char *  mem 
)

Write to read-only memory (for example the text segment).

Parameters
fdThe file descriptor for the ELF file.
textoffOffset of text segment relative start of file.
sizeThe size of the text segment.
memA pointer to the where the text segment should be flashed
        This function is called from the Contiki ELF loader to
        write the program code (text segment) of a loaded
        module into memory. The function is called when all
        relocations have been performed.

Definition at line 117 of file elfloader-avr.c.

References cfs_seek(), CFS_SEEK_SET, flash_clear(), flash_done(), flash_setup(), and flash_write().

Referenced by elfloader_load().