34 #include "dev/flash.h"
36 static uint16_t datamemory_aligned[ELFLOADER_DATAMEMORY_SIZE/2+1];
37 static uint8_t* datamemory = (uint8_t *)datamemory_aligned;
38 #if ELFLOADER_CONF_TEXT_IN_ROM
39 static const char textmemory[ELFLOADER_TEXTMEMORY_SIZE] = {0};
41 static char textmemory[ELFLOADER_TEXTMEMORY_SIZE];
53 #if ELFLOADER_CONF_TEXT_IN_ROM
56 ((
unsigned long)&textmemory[0] & 0xfffffe00) +
57 (((
unsigned long)&textmemory[0] & 0x1ff) == 0? 0: 0x200);
67 #if ELFLOADER_CONF_TEXT_IN_ROM
70 unsigned short *flashptr;
74 flashptr = (
unsigned short *)mem;
77 for(ptr = 0; ptr < size; ptr += READSIZE) {
80 cfs_read(fd, (
unsigned char *)datamemory, READSIZE);
83 if((((
unsigned short)flashptr) & 0x01ff) == 0) {
92 for(i = 0; i < READSIZE / 2; ++i) {
93 flash_write(flashptr, ((
unsigned short *)datamemory)[i]);
101 cfs_read(fd, (
unsigned char *)mem, size);
108 struct elf32_rela *rela,
char *addr)
110 addr += rela->r_addend;
113 cfs_write(fd, (
char *)&addr, 2);
void elfloader_arch_relocate(int fd, unsigned int sectionoffset, char *sectionaddr, struct elf32_rela *rela, char *addr)
Perform a relocation.
cfs_offset_t cfs_seek(int fd, cfs_offset_t offset, int whence)
Seek to a specified position in an open file.
void flash_clear(unsigned short *ptr)
Clear a 16-bit word in flash ROM.
Header file for the architecture specific parts of the Contiki ELF loader.
void * elfloader_arch_allocate_ram(int size)
Allocate RAM for a new module.
void flash_done(void)
Function that is to be called after flashing is done.
void flash_write(unsigned short *ptr, unsigned short word)
Write a 16-bit word to flash ROM.
void * elfloader_arch_allocate_rom(int size)
Allocate program memory for a new module.
#define CFS_SEEK_SET
Specify that cfs_seek() should compute the offset from the beginning of the file. ...
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).
void flash_setup(void)
Setup function to be called before any of the flash programming functions.