/* * 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 /* This define is needed to generate proper binary for * rtl8196c, rtl8198, rtl819Xe and rtl8196e. * rtl8196b is somehow different (can be fixed in bootloder?). * See apmib.h for details. */ #define CONFIG_RTL_8196C #include "apmib.h" #define COMPACT_FILENAME_BUFFER /* 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("