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. | |
void * | elfloader_arch_allocate_rom (int size) |
Allocate program memory for a new module. | |
void | elfloader_arch_relocate (int fd, unsigned int sectionoffset, char *sectionaddr, struct elf32_rela *rela, char *addr) |
Perform a relocation. | |
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). | |
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. |
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.
void* elfloader_arch_allocate_ram | ( | int | size | ) |
Allocate RAM for a new module.
size | The size of the requested memory. |
This function is called from the Contiki ELF loader to allocate RAM for the module to be loaded into.
Definition at line 75 of file elfloader-avr.c.
References mmem_alloc(), mmem_free(), and MMEM_PTR.
Referenced by elfloader_load().
void* elfloader_arch_allocate_rom | ( | int | size | ) |
Allocate program memory for a new module.
size | The size of the requested 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 96 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.
output | The output object for the segment. | |
sectionoffset | The file offset at which the relocation can be found. | |
sectionaddr | The section start address (absolute runtime). | |
rela | A pointer to an ELF32 rela structure (struct elf32_rela). | |
addr | The 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.
fd | The file descriptor for the ELF file. | |
sectionoffset | The file offset at which the relocation can be found. | |
sectionaddr | The section start address (absolute runtime). | |
rela | A pointer to an ELF32 rela structure (struct elf32_rela). | |
addr | The 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 177 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).
fd | The file descriptor for the ELF file. | |
textoff | Offset of text segment relative start of file. | |
size | The size of the text segment. | |
mem | A 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 116 of file elfloader-avr.c.
References cfs_seek(), CFS_SEEK_SET, flash_clear(), flash_done(), flash_setup(), and flash_write().
Referenced by elfloader_load().