tools/elf4rom/src/romdetails.h
changeset 34 92d87f2e53c2
equal deleted inserted replaced
33:1af5c1be89f8 34:92d87f2e53c2
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 *
       
     5 * This program is free software: you can redistribute it and/or modify
       
     6 * it under the terms of the GNU Lesser General Public License as published by
       
     7 * the Free Software Foundation, either version 3 of the License, or
       
     8 * (at your option) any later version.
       
     9 *
       
    10 * This program is distributed in the hope that it will be useful,
       
    11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       
    13 * GNU Lesser General Public License for more details.
       
    14 * 
       
    15 * You should have received a copy of the GNU Lesser General Public License
       
    16 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
       
    17 */
       
    18 
       
    19 #ifndef ROMDETAILS_H_
       
    20 #define ROMDETAILS_H_
       
    21 
       
    22 #include <vector>
       
    23 
       
    24 #include "defs.h"
       
    25 
       
    26 class XIPFileDetails {
       
    27 public:
       
    28 	XIPFileDetails():
       
    29 		iE32File(""), 
       
    30 		iElfFile(""), 
       
    31 		iLoadAddr(0x0),
       
    32 		iROAddr(0x0), 
       
    33 		iROSize(0),
       
    34 		iRWAddr(0x0),
       
    35 		iRWSize(0),
       
    36 		iROMDataAddr(0), 
       
    37 		iBSSAddr(0),
       
    38 		iBSSDataSize(0),
       
    39 		iElfTextBase(0),
       
    40 		iElfTextLimit(0),
       
    41 		iElfDataBase(0),
       
    42 		iRVCTProduced(false),
       
    43 		iGCCProduced(false)
       
    44 		{};
       
    45 	XIPFileDetails(PathName & aE32File,PathName & aELFFile, LinearAddr load, LinearAddr text, size_t textSize,
       
    46 			VirtualAddr data, size_t dataSize, LinearAddr aRomData, VirtualAddr bss,
       
    47 			size_t bssDataSize):
       
    48 		iE32File(aE32File), 
       
    49 		iElfFile(aELFFile),
       
    50 		iLoadAddr(load),
       
    51 		iROAddr(text),
       
    52 		iROSize(textSize),
       
    53 		iRWAddr(data),
       
    54 		iRWSize(dataSize),
       
    55 		iROMDataAddr(aRomData), 
       
    56 		iBSSAddr(bss),
       
    57 		iBSSDataSize(bssDataSize),
       
    58 		iElfTextBase(0),
       
    59 		iElfTextLimit(0),
       
    60 		iElfDataBase(0),
       
    61 		iRVCTProduced(false),
       
    62 		iGCCProduced(false)
       
    63 		{};	
       
    64 	XIPFileDetails(char * aE32File,char * aELFFile, LinearAddr load, LinearAddr text, size_t textSize,
       
    65 			VirtualAddr data, size_t dataSize, LinearAddr aRomData, VirtualAddr bss, 
       
    66 			size_t bssDataSize):
       
    67 		iE32File(aE32File), 
       
    68 		iElfFile(aELFFile), 
       
    69 		iLoadAddr(load),
       
    70 		iROAddr(text),
       
    71 		iROSize(textSize),
       
    72 		iRWAddr(data),
       
    73 		iRWSize(dataSize),
       
    74 		iROMDataAddr(aRomData), 
       
    75 		iBSSAddr(bss),
       
    76 		iBSSDataSize(bssDataSize),
       
    77 		iElfTextBase(0),
       
    78 		iElfTextLimit(0),
       
    79 		iElfDataBase(0),
       
    80 		iRVCTProduced(false),
       
    81 		iGCCProduced(false)
       
    82 		{};	
       
    83 		
       
    84 	LinearAddr Relocate(LinearAddr addr){
       
    85 		if ((addr >= iElfTextBase) && (addr < iElfTextLimit)){
       
    86 			size_t offset = addr - iElfTextBase;
       
    87 			return iROAddr + offset;
       
    88 		} else if ((addr >= iElfDataBase) && (addr < (iElfDataBase + iBSSDataSize))) {
       
    89 			size_t offset = addr - iElfDataBase;
       
    90 			return iRWAddr + offset;
       
    91 		} else {
       
    92 			return addr;
       
    93 		}
       
    94 	}
       
    95 	PathName iE32File;
       
    96 	PathName iElfFile;
       
    97 	LinearAddr iLoadAddr;
       
    98 	LinearAddr iROAddr;
       
    99 	size_t iROSize;
       
   100 	VirtualAddr iRWAddr;
       
   101 	size_t iRWSize;
       
   102 	LinearAddr iROMDataAddr;
       
   103 	VirtualAddr iBSSAddr;
       
   104 	size_t iBSSDataSize;
       
   105 	VirtualAddr iElfTextBase;
       
   106 	VirtualAddr iElfTextLimit;
       
   107 	VirtualAddr iElfDataBase;
       
   108 	// This is dodgy. We probably need a better way of coping with 'oddities'
       
   109 	bool iRVCTProduced;
       
   110 	bool iGCCProduced;
       
   111 };
       
   112 
       
   113 class RomDetails {
       
   114 public:
       
   115 	RomDetails():
       
   116 		iBoardName(""),
       
   117 		iRomFile(""),
       
   118 		iElfRomFile(""),
       
   119 		iLogFile(""),
       
   120 		iDrive(""),
       
   121 		iRomPhysAddr(0),
       
   122 		iRomBaseLinearAddr(0),
       
   123 		iKernelDataVirtualAddr(0),
       
   124 		iNoDwarf(false),
       
   125 		iSearch(false),
       
   126 		iStrip(false),
       
   127 		iTrace(false),
       
   128 		iVerbosity(0)
       
   129 		{}
       
   130 		
       
   131 	typedef std::vector<XIPFileDetails> XIPFileList;
       
   132 	String iBoardName;
       
   133 	PathName iRomFile;
       
   134 	PathName iElfRomFile;
       
   135 	PathName iLogFile;
       
   136 	PathName iDrive;
       
   137 	LinearAddr iRomPhysAddr;
       
   138 	LinearAddr iRomBaseLinearAddr;
       
   139 	VirtualAddr iKernelDataVirtualAddr;
       
   140 	XIPFileDetails iPrimary;
       
   141 	XIPFileList	iXIPFiles;
       
   142 	bool iNoDwarf;
       
   143 	bool iSearch;
       
   144 	bool iStrip;
       
   145 	bool iTrace;
       
   146 	unsigned int iVerbosity;
       
   147 	std::vector<std::string> iTargetFiles;
       
   148 	std::vector<std::string> iExcludeFiles;
       
   149 
       
   150 };
       
   151 #endif /*ROMDETAILS_H_*/