elfloader executing loaded programs from ram (not rom) by default on msp430 platforms.

This commit is contained in:
fros4943 2009-01-15 09:04:04 +00:00
parent c3b6ff6bd3
commit 5f3c1a0e12
2 changed files with 22 additions and 8 deletions

View file

@ -28,14 +28,18 @@
* *
* This file is part of the Contiki operating system. * 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 "elfloader-arch.h"
#include "dev/flash.h" #include "dev/flash.h"
static char datamemory[ELFLOADER_DATAMEMORY_SIZE]; static char datamemory[ELFLOADER_DATAMEMORY_SIZE];
#if ELFLOADER_CONF_TEXT_IN_ROM
static const char textmemory[ELFLOADER_TEXTMEMORY_SIZE] = {0}; 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 * void *
elfloader_arch_allocate_ram(int size) elfloader_arch_allocate_ram(int size)
@ -46,16 +50,21 @@ elfloader_arch_allocate_ram(int size)
void * void *
elfloader_arch_allocate_rom(int size) elfloader_arch_allocate_rom(int size)
{ {
#if ELFLOADER_CONF_TEXT_IN_ROM
/* Return an 512-byte aligned pointer. */ /* Return an 512-byte aligned pointer. */
return (char *) return (char *)
((unsigned long)&textmemory[0] & 0xfffffe00) + ((unsigned long)&textmemory[0] & 0xfffffe00) +
(((unsigned long)&textmemory[0] & 0x1ff) == 0? 0: 0x200); (((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 #define READSIZE 32
void void
elfloader_arch_write_rom(int fd, unsigned short textoff, unsigned int size, char *mem) elfloader_arch_write_rom(int fd, unsigned short textoff, unsigned int size, char *mem)
{ {
#if ELFLOADER_CONF_TEXT_IN_ROM
int i; int i;
unsigned int ptr; unsigned int ptr;
unsigned short *flashptr; unsigned short *flashptr;
@ -87,6 +96,10 @@ elfloader_arch_write_rom(int fd, unsigned short textoff, unsigned int size, char
} }
flash_done(); 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 void

View file

@ -1,5 +1,5 @@
/* -*- C -*- */ /* -*- 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 #ifndef CONTIKI_CONF_H
#define CONTIKI_CONF_H #define CONTIKI_CONF_H
@ -22,6 +22,7 @@
#define RF_CHANNEL 26 #define RF_CHANNEL 26
#endif /* RF_CHANNEL */ #endif /* RF_CHANNEL */
#define ELFLOADER_CONF_TEXT_IN_ROM 0
#define ELFLOADER_CONF_DATAMEMORY_SIZE 0x800 #define ELFLOADER_CONF_DATAMEMORY_SIZE 0x800
#define ELFLOADER_CONF_TEXTMEMORY_SIZE 0x1000 #define ELFLOADER_CONF_TEXTMEMORY_SIZE 0x1000