added parameter to relocate method
+ renamed write_text() to write_rom() + added parameter to write_rom()
This commit is contained in:
parent
ea0e2c0f7d
commit
060225a97a
|
@ -28,7 +28,7 @@
|
|||
*
|
||||
* This file is part of the Contiki operating system.
|
||||
*
|
||||
* @(#)$Id: elfloader-arch.h,v 1.2 2006/12/18 12:11:15 adamdunkels Exp $
|
||||
* @(#)$Id: elfloader-arch.h,v 1.3 2006/12/18 14:54:04 fros4943 Exp $
|
||||
*/
|
||||
/**
|
||||
* \addtogroup elfloader
|
||||
|
@ -101,6 +101,7 @@ void *elfloader_arch_allocate_rom(int size);
|
|||
* \brief Perform a relocation.
|
||||
* \param fd The file descriptor for the ELF file.
|
||||
* \param sectionoffset The file offset at which the relocation can be found.
|
||||
* \param sectionaddr The section start address (absolute runtime).
|
||||
* \param rela A pointer to an ELF32 rela structure (struct elf32_rela).
|
||||
* \param addr The relocated address.
|
||||
*
|
||||
|
@ -116,11 +117,13 @@ void *elfloader_arch_allocate_rom(int size);
|
|||
* processor.
|
||||
*/
|
||||
void elfloader_arch_relocate(int fd, unsigned int sectionoffset,
|
||||
struct elf32_rela *rela, char *addr);
|
||||
char *sectionaddr,
|
||||
struct elf32_rela *rela, char *addr);
|
||||
|
||||
/**
|
||||
* \brief Write the program code (text segment) into program memory.
|
||||
* \brief Write to read-only memory (for example the text segment).
|
||||
* \param fd The file descriptor for the ELF file.
|
||||
* \param textoff Offset of text segment relative start of file.
|
||||
* \param size The size of the text segment.
|
||||
* \param mem A pointer to the where the text segment should be flashed
|
||||
*
|
||||
|
@ -129,7 +132,7 @@ void elfloader_arch_relocate(int fd, unsigned int sectionoffset,
|
|||
* module into memory. The function is called when all
|
||||
* relocations have been performed.
|
||||
*/
|
||||
void elfloader_arch_write_text(int fd, unsigned int size, char *mem);
|
||||
void elfloader_arch_write_rom(int fd, unsigned short textoff, unsigned int size, char *mem);
|
||||
|
||||
#endif /* __ELFLOADER_ARCH_H__ */
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
*
|
||||
* This file is part of the Contiki operating system.
|
||||
*
|
||||
* @(#)$Id: elfloader-avr.c,v 1.2 2006/09/01 07:10:01 adamdunkels Exp $
|
||||
* @(#)$Id: elfloader-avr.c,v 1.3 2006/12/18 14:54:04 fros4943 Exp $
|
||||
*/
|
||||
#include "elfloader-arch.h"
|
||||
|
||||
|
@ -76,7 +76,7 @@ elfloader_arch_allocate_rom(int size)
|
|||
/*---------------------------------------------------------------------------*/
|
||||
#define READSIZE 32
|
||||
void
|
||||
elfloader_arch_write_text(int fd, unsigned int size, char *mem)
|
||||
elfloader_arch_write_rom(int fd, unsigned short textoff, unsigned int size, char *mem)
|
||||
{
|
||||
#if 0
|
||||
int i;
|
||||
|
@ -87,6 +87,7 @@ elfloader_arch_write_text(int fd, unsigned int size, char *mem)
|
|||
|
||||
flashptr = (unsigned short *)elfloader_arch_textmemory;
|
||||
|
||||
cfs_seek(fd, textoff);
|
||||
for(ptr = 0; ptr < size; ptr += READSIZE) {
|
||||
|
||||
/* Read data from file into RAM. */
|
||||
|
@ -122,6 +123,7 @@ write_ldi(int fd, unsigned char *instr, unsigned char byte)
|
|||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
elfloader_arch_relocate(int fd, unsigned int sectionoffset,
|
||||
char *sectionaddr,
|
||||
struct elf32_rela *rela, char *addr)
|
||||
{
|
||||
unsigned int type;
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
*
|
||||
* This file is part of the Contiki operating system.
|
||||
*
|
||||
* @(#)$Id: elfloader-msp430.c,v 1.1 2006/06/17 22:41:18 adamdunkels Exp $
|
||||
* @(#)$Id: elfloader-msp430.c,v 1.2 2006/12/18 14:54:04 fros4943 Exp $
|
||||
*/
|
||||
#include "elfloader-arch.h"
|
||||
|
||||
|
@ -54,7 +54,7 @@ elfloader_arch_allocate_rom(int size)
|
|||
/*---------------------------------------------------------------------------*/
|
||||
#define READSIZE 32
|
||||
void
|
||||
elfloader_arch_write_text(int fd, unsigned int size, char *mem)
|
||||
elfloader_arch_write_rom(int fd, unsigned short textoff, unsigned int size, char *mem)
|
||||
{
|
||||
int i;
|
||||
unsigned int ptr;
|
||||
|
@ -64,6 +64,7 @@ elfloader_arch_write_text(int fd, unsigned int size, char *mem)
|
|||
|
||||
flashptr = (unsigned short *)mem;
|
||||
|
||||
cfs_seek(fd, textoff);
|
||||
for(ptr = 0; ptr < size; ptr += READSIZE) {
|
||||
|
||||
/* Read data from file into RAM. */
|
||||
|
@ -90,6 +91,7 @@ elfloader_arch_write_text(int fd, unsigned int size, char *mem)
|
|||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
elfloader_arch_relocate(int fd, unsigned int sectionoffset,
|
||||
char *sectionaddr,
|
||||
struct elf32_rela *rela, char *addr)
|
||||
{
|
||||
addr += rela->r_addend;
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
*
|
||||
* This file is part of the Contiki operating system.
|
||||
*
|
||||
* @(#)$Id: elfloader-stub.c,v 1.1 2006/06/17 22:41:18 adamdunkels Exp $
|
||||
* @(#)$Id: elfloader-stub.c,v 1.2 2006/12/18 14:54:04 fros4943 Exp $
|
||||
*/
|
||||
#include "elfloader-arch.h"
|
||||
|
||||
|
@ -48,15 +48,16 @@ elfloader_arch_allocate_rom(int size)
|
|||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
elfloader_arch_write_text(int fd, unsigned int size, char *mem)
|
||||
elfloader_arch_write_rom(int fd, unsigned short textoff, unsigned int size, char *mem)
|
||||
{
|
||||
printf("elfloader_arch_write_text: size %d, mem %p\n", size, mem);
|
||||
printf("elfloader_arch_write_rom: size %d, offset %i, mem %p\n", size, textoff, mem);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
elfloader_arch_relocate(int fd, unsigned int sectionoffset,
|
||||
char *sectionaddr,
|
||||
struct elf32_rela *rela, char *addr)
|
||||
{
|
||||
printf("elfloader_arch_relocate: sectionoffset 0x%04x, r_offset 0x%04x, r_info 0x%04x, r_addend 0x%04x, addr %p\n", sectionoffset, rela->r_offset, rela->r_info, rela->r_addend, addr);
|
||||
printf("elfloader_arch_relocate: sectionoffset 0x%04x, sectionaddr %p, r_offset 0x%04x, r_info 0x%04x, r_addend 0x%04x, addr %p\n", sectionoffset, sectionaddr, rela->r_offset, rela->r_info, rela->r_addend, addr);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
*
|
||||
* This file is part of the Contiki operating system.
|
||||
*
|
||||
* @(#)$Id: elfloader-x86.c,v 1.1 2006/10/25 10:53:31 fros4943 Exp $
|
||||
* @(#)$Id: elfloader-x86.c,v 1.2 2006/12/18 14:54:04 fros4943 Exp $
|
||||
*/
|
||||
#include "elfloader-arch.h"
|
||||
#include <sys/mman.h>
|
||||
|
@ -67,8 +67,9 @@ elfloader_arch_allocate_rom(int size)
|
|||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
elfloader_arch_write_text(int fd, unsigned int size, char *mem)
|
||||
elfloader_arch_write_rom(int fd, unsigned short textoff, unsigned int size, char *mem)
|
||||
{
|
||||
cfs_seek(fd, textoff);
|
||||
cfs_read(fd, (unsigned char *)mem, size);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
|
Loading…
Reference in a new issue