/* * Tool to convert ELF image to be the AP downloadable binary * * Authors: David Hsu * * $Id: cvimg.c,v 1.4 2009/06/12 07:10:44 michael Exp $ * */ #include #include #include #include #include #include #include #include #define HOME_GATEWAY #define CONFIG_RTL_8196C #include "apmib.h" #define COMPACT_FILENAME_BUFFER static int friendly_strcmp(const char *s1, const char *s2) { if (!s1 || !s2) return (s1>s2) ? -1 : !(s1==s2); return strcmp(s1,s2); } /* 32-bit ELF base types. */ typedef unsigned int Elf32_Addr; typedef unsigned short Elf32_Half; typedef unsigned int Elf32_Off; typedef unsigned int Elf32_Word; #define EI_NIDENT 16 typedef struct elf32_hdr{ unsigned char e_ident[EI_NIDENT]; Elf32_Half e_type; Elf32_Half e_machine; Elf32_Word e_version; Elf32_Addr e_entry; /* Entry point */ Elf32_Off e_phoff; Elf32_Off e_shoff; Elf32_Word e_flags; Elf32_Half e_ehsize; Elf32_Half e_phentsize; Elf32_Half e_phnum; Elf32_Half e_shentsize; Elf32_Half e_shnum; Elf32_Half e_shstrndx; } Elf32_Ehdr; #define DEFAULT_START_ADDR 0x80500000 #define DEFAULT_BASE_ADDR 0x80000000 static unsigned short calculateChecksum(char *buf, int len); ///////////////////////////////////////////////////////// static unsigned int calculate_long_checksum(unsigned int *buf, int len) { int i, j; unsigned int sum=0, tmp; j = len/4; for (i=0; i input-filename output-filename start-addr burn-addr [signature]\n"); printf("