elfloader executing loaded programs from ram (not rom) by default on msp430 platforms.
This commit is contained in:
parent
c3b6ff6bd3
commit
5f3c1a0e12
2 changed files with 22 additions and 8 deletions
|
@ -28,14 +28,18 @@
|
|||
*
|
||||
* This file is part of the Contiki operating system.
|
||||
*
|
||||
* @(#)$Id: elfloader-msp430.c,v 1.2 2006/12/18 14:54:04 fros4943 Exp $
|
||||
* @(#)$Id: elfloader-msp430.c,v 1.3 2009/01/15 09:04:55 fros4943 Exp $
|
||||
*/
|
||||
#include "elfloader-arch.h"
|
||||
|
||||
#include "dev/flash.h"
|
||||
|
||||
static char datamemory[ELFLOADER_DATAMEMORY_SIZE];
|
||||
#if ELFLOADER_CONF_TEXT_IN_ROM
|
||||
static const char textmemory[ELFLOADER_TEXTMEMORY_SIZE] = {0};
|
||||
#else /* ELFLOADER_CONF_TEXT_IN_ROM */
|
||||
static char textmemory[ELFLOADER_TEXTMEMORY_SIZE];
|
||||
#endif /* ELFLOADER_CONF_TEXT_IN_ROM */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void *
|
||||
elfloader_arch_allocate_ram(int size)
|
||||
|
@ -46,27 +50,32 @@ elfloader_arch_allocate_ram(int size)
|
|||
void *
|
||||
elfloader_arch_allocate_rom(int size)
|
||||
{
|
||||
#if ELFLOADER_CONF_TEXT_IN_ROM
|
||||
/* Return an 512-byte aligned pointer. */
|
||||
return (char *)
|
||||
((unsigned long)&textmemory[0] & 0xfffffe00) +
|
||||
(((unsigned long)&textmemory[0] & 0x1ff) == 0? 0: 0x200);
|
||||
#else /* ELFLOADER_CONF_TEXT_IN_ROM */
|
||||
return textmemory;
|
||||
#endif /* ELFLOADER_CONF_TEXT_IN_ROM */
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#define READSIZE 32
|
||||
void
|
||||
elfloader_arch_write_rom(int fd, unsigned short textoff, unsigned int size, char *mem)
|
||||
{
|
||||
#if ELFLOADER_CONF_TEXT_IN_ROM
|
||||
int i;
|
||||
unsigned int ptr;
|
||||
unsigned short *flashptr;
|
||||
|
||||
|
||||
flash_setup();
|
||||
|
||||
flashptr = (unsigned short *)mem;
|
||||
|
||||
|
||||
cfs_seek(fd, textoff);
|
||||
for(ptr = 0; ptr < size; ptr += READSIZE) {
|
||||
|
||||
|
||||
/* Read data from file into RAM. */
|
||||
cfs_read(fd, (unsigned char *)datamemory, READSIZE);
|
||||
|
||||
|
@ -74,7 +83,7 @@ elfloader_arch_write_rom(int fd, unsigned short textoff, unsigned int size, char
|
|||
if((((unsigned short)flashptr) & 0x01ff) == 0) {
|
||||
flash_clear(flashptr);
|
||||
}
|
||||
|
||||
|
||||
/* Burn data from RAM into flash ROM. Flash is burned one 16-bit
|
||||
word at a time, so we need to be careful when incrementing
|
||||
pointers. The flashptr is already a short pointer, so
|
||||
|
@ -87,6 +96,10 @@ elfloader_arch_write_rom(int fd, unsigned short textoff, unsigned int size, char
|
|||
}
|
||||
|
||||
flash_done();
|
||||
#else /* ELFLOADER_CONF_TEXT_IN_ROM */
|
||||
cfs_seek(fd, textoff);
|
||||
cfs_read(fd, (unsigned char *)mem, size);
|
||||
#endif /* ELFLOADER_CONF_TEXT_IN_ROM */
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
|
@ -95,8 +108,8 @@ elfloader_arch_relocate(int fd, unsigned int sectionoffset,
|
|||
struct elf32_rela *rela, char *addr)
|
||||
{
|
||||
addr += rela->r_addend;
|
||||
|
||||
cfs_seek(fd, sectionoffset + rela->r_offset);
|
||||
|
||||
cfs_seek(fd, sectionoffset + rela->r_offset);
|
||||
cfs_write(fd, (char *)&addr, 2);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* -*- C -*- */
|
||||
/* @(#)$Id: contiki-conf.h,v 1.31 2008/11/06 20:45:06 nvt-se Exp $ */
|
||||
/* @(#)$Id: contiki-conf.h,v 1.32 2009/01/15 09:04:04 fros4943 Exp $ */
|
||||
|
||||
#ifndef CONTIKI_CONF_H
|
||||
#define CONTIKI_CONF_H
|
||||
|
@ -22,6 +22,7 @@
|
|||
#define RF_CHANNEL 26
|
||||
#endif /* RF_CHANNEL */
|
||||
|
||||
#define ELFLOADER_CONF_TEXT_IN_ROM 0
|
||||
#define ELFLOADER_CONF_DATAMEMORY_SIZE 0x800
|
||||
#define ELFLOADER_CONF_TEXTMEMORY_SIZE 0x1000
|
||||
|
||||
|
|
Loading…
Reference in a new issue