diff options
author | bxing <bxing@6f19259b-4bc3-4df7-8a09-765794883524> | 2006-12-31 09:55:05 +0000 |
---|---|---|
committer | bxing <bxing@6f19259b-4bc3-4df7-8a09-765794883524> | 2006-12-31 09:55:05 +0000 |
commit | a3ab2a47d9ecb2295802726fd17f048c14519aab (patch) | |
tree | 43346ac9424cadf70f85dd4fb2a858eb40f6ce92 /Tools/CCode | |
parent | 8733430b83565480540d1d890986cbf22c54db0d (diff) | |
download | edk2-platforms-a3ab2a47d9ecb2295802726fd17f048c14519aab.tar.xz |
Integrated FV memory map into R9
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@2158 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'Tools/CCode')
-rw-r--r-- | Tools/CCode/Source/GenFvMap/GenFvMap.cpp | 172 | ||||
-rw-r--r-- | Tools/CCode/Source/GenFvMap/build.xml | 1 | ||||
-rw-r--r-- | Tools/CCode/Source/PeiRebase/PeiRebaseExe.c | 18 |
3 files changed, 70 insertions, 121 deletions
diff --git a/Tools/CCode/Source/GenFvMap/GenFvMap.cpp b/Tools/CCode/Source/GenFvMap/GenFvMap.cpp index 4a8c726785..0ff5bd07ee 100644 --- a/Tools/CCode/Source/GenFvMap/GenFvMap.cpp +++ b/Tools/CCode/Source/GenFvMap/GenFvMap.cpp @@ -1,10 +1,10 @@ //****************************************************************************
//**
-//** Copyright (C) 2006 Intel Corporation. All rights reserved.
+//** Copyright (C) 2006 Intel Corporation. All rights reserved.
//**
-//** The information and source code contained herein is the exclusive
+//** The information and source code contained herein is the exclusive
//** property of Intel Corporation and may not be disclosed, examined
-//** or reproduced in whole or in part without explicit written authorization
+//** or reproduced in whole or in part without explicit written authorization
//** from the company.
//**
//****************************************************************************
@@ -78,6 +78,7 @@ public: bool operator < (const CIdentity&) const;
friend istream& operator >> (istream&, CIdentity&);
+ friend ostream& operator << (ostream&, const CIdentity&);
static const string::size_type s_nIdStrLen;
@@ -134,6 +135,16 @@ istream& operator >> (istream& is, CIdentity& idRight) return is;
}
+ostream& operator << (ostream& os, const CIdentity& idRight)
+{
+ return os << hex << setfill('0')
+ << setw(8) << (unsigned long)(idRight.m_ullId[0] >> 32) << '-'
+ << setw(4) << (unsigned short)(idRight.m_ullId[0] >> 16) << '-'
+ << setw(4) << (unsigned short)idRight.m_ullId[0] << '-'
+ << setw(4) << (unsigned short)(idRight.m_ullId[1] >> 48) << '-'
+ << setw(12) << (idRight.m_ullId[1] & 0xffffffffffff);
+}
+
class CInputFile : public CObjRoot
{
protected:
@@ -183,74 +194,22 @@ istream& CInputFile::GetLine(string& strALine) return m_is;
}
-class CIdAddressMap : public CInputFile, public map<CIdentity, ulonglong_t>
+class CIdAddressPathMap : public CInputFile, public map<CIdentity, pair<ulonglong_t, string> >
{
public:
- CIdAddressMap(istream&);
+ CIdAddressPathMap(istream&);
};
-CIdAddressMap::CIdAddressMap(istream& is)
+CIdAddressPathMap::CIdAddressPathMap(istream& is)
: CInputFile(is)
{
- CIdentity id;
- ulonglong_t ullBase;
-
- while (!!(m_is >> hex >> id >> ullBase))
- if (!insert(value_type(id, ullBase)).second)
+ key_type k;
+ mapped_type m;
+ while (!!(m_is >> hex >> k >> m.first) && !!GetLine(m.second))
+ if (!insert(value_type(k, m)).second)
throw runtime_error(__FUNCTION__ ": Duplicated files");
}
-class CIdPathMap : public CInputFile, public map<CIdentity, string>
-{
-public:
- CIdPathMap(istream&);
-};
-
-CIdPathMap::CIdPathMap(istream& is)
-: CInputFile(is)
-{
- static const char cszFileSec[] = "[files]";
- static const char cszFfsFile[] = "EFI_FILE_NAME";
-
- string strALine;
-
- // Find the [files] section
- while (!!GetLine(strALine) && strALine.compare(0, sizeof(cszFileSec) - 1, cszFileSec));
-
- // m_is error means no FFS files listed in this INF file
- if (!m_is)
- return;
-
- // Parse FFS files one by one
- while (!!GetLine(strALine))
- {
- // Test if this begins a new section
- if (strALine[0] == '[')
- break;
-
- // Is it a line of FFS file?
- if (strALine.compare(0, sizeof(cszFfsFile) - 1, cszFfsFile))
- continue;
-
- string::size_type pos = strALine.find_first_not_of(' ', sizeof(cszFfsFile) - 1);
- if (pos == string::npos || strALine[pos] != '=')
- throw runtime_error(__FUNCTION__ ": Invalid FV INF format");
- pos = strALine.find_first_not_of(' ', pos + 1);
- if (pos == string::npos)
- throw runtime_error(__FUNCTION__ ": Incomplete line");
-
- strALine.erase(0, pos);
- pos = strALine.rfind('\\');
- if (pos == string::npos)
- pos = 0;
- else pos++;
-
- CIdentity id(strALine.substr(pos, CIdentity::s_nIdStrLen));
- if (!insert(value_type(id, strALine)).second)
- throw runtime_error(__FUNCTION__ ": Duplicated FFS files");
- }
-}
-
class CSymbol : public CObjRoot
{
public:
@@ -286,7 +245,7 @@ ostream& operator << (ostream& os, const CSymbol& symbol) os << hex << setw(16) << setfill('0') << symbol.m_ullRva << setw(0);
os << ' ' << (symbol.m_bFunction ? 'F' : ' ')
<< (symbol.m_bStatic ? 'S' : ' ') << ' ';
- return os << symbol.m_strName << endl;
+ return os << symbol.m_strName;
}
class CMapFile : public CInputFile, public list<CSymbol>
@@ -295,7 +254,6 @@ public: CMapFile(const string&);
void SetLoadAddress(ulonglong_t);
- friend ostream& operator << (ostream&, const CMapFile&);
string m_strModuleName;
ulonglong_t m_ullLoadAddr;
@@ -344,32 +302,11 @@ CMapFile::CMapFile(const string& strFName) void CMapFile::SetLoadAddress(ulonglong_t ullLoadAddr)
{
for (iterator i = begin(); i != end(); i++)
- if (i->m_ullRva != 0)
+ if (i->m_ullRva >= m_ullLoadAddr)
i->m_ullRva += ullLoadAddr - m_ullLoadAddr;
m_ullLoadAddr = ullLoadAddr;
}
-ostream& operator << (ostream& os, const CMapFile& mapFile)
-{
- CMapFile::const_iterator i = mapFile.begin();
- while (i != mapFile.end() && i->m_strAddress != mapFile.m_strEntryPoint)
- i++;
- if (i == mapFile.end())
- throw runtime_error(
- __FUNCTION__ ": Entry point not found for module " +
- mapFile.m_strModuleName);
-
- os << endl << hex
- << mapFile.m_strModuleName << " (EP=" << i->m_ullRva
- << ", BA=" << mapFile.m_ullLoadAddr << ')' << endl
- << endl;
-
- for (i = mapFile.begin(); i != mapFile.end(); i++)
- os << " " << *i;
-
- return os << endl;
-}
-
class COutputFile : public CObjRoot
{
protected:
@@ -384,7 +321,7 @@ private: class CFvMapFile : public CObjRoot, public map<CIdentity, CMapFile*>
{
public:
- CFvMapFile(const CIdAddressMap&, const CIdPathMap&);
+ CFvMapFile(const CIdAddressPathMap&);
~CFvMapFile(void);
friend ostream& operator << (ostream&, const CFvMapFile&);
@@ -393,27 +330,16 @@ private: void Cleanup(void);
};
-CFvMapFile::CFvMapFile(const CIdAddressMap& idAddr, const CIdPathMap& idPath)
+CFvMapFile::CFvMapFile(const CIdAddressPathMap& idAddrPath)
{
- for (CIdAddressMap::const_iterator i = idAddr.begin(); i != idAddr.end(); i++)
+ for (CIdAddressPathMap::const_iterator i = idAddrPath.begin(); i != idAddrPath.end(); i++)
{
- CIdPathMap::const_iterator j = idPath.find(i->first);
- if (j == idPath.end())
- throw runtime_error(__FUNCTION__ ": Map file not found");
-
- try
- {
- pair<iterator, bool> k = insert(value_type(i->first,
- new CMapFile(j->second.substr(0, j->second.rfind('.')) + ".map")));
- if (!k.second)
- throw logic_error(__FUNCTION__ ": Duplicated file found in rebase log");
+ if (i->second.second == "*")
+ continue;
- k.first->second->SetLoadAddress(i->second);
- }
- catch (const runtime_error& e)
- {
- cerr << e.what() << endl;
- }
+ pair<iterator, bool> r = insert(value_type(i->first,
+ new CMapFile(i->second.second.substr(0, i->second.second.rfind('.')) + ".map")));
+ r.first->second->SetLoadAddress(i->second.first);
}
}
@@ -426,7 +352,27 @@ void CFvMapFile::Cleanup(void) ostream& operator << (ostream& os, const CFvMapFile& fvMap)
{
for (CFvMapFile::const_iterator i = fvMap.begin(); !!os && i != fvMap.end(); i++)
- os << *i->second;
+ {
+ CMapFile::const_iterator j = i->second->begin();
+ while (j != i->second->end() && j->m_strAddress != i->second->m_strEntryPoint) j++;
+ if (j == i->second->end())
+ throw runtime_error(
+ __FUNCTION__ ":Entry point not found for module " +
+ i->second->m_strModuleName);
+
+ os << hex
+ << i->second->m_strModuleName
+ << " (EP=" << j->m_ullRva
+ << ", BA=" << i->second->m_ullLoadAddr
+ << ", GUID=" << i->first
+ << ")" << endl << endl;
+
+ for (j = i->second->begin(); j != i->second->end(); j++)
+ os << " " << *j << endl;
+
+ os << endl << endl;
+ }
+
return os;
}
@@ -446,7 +392,7 @@ private: static const char s_szUsage[];
};
-const char CGenFvMapUsage::s_szUsage[] = "Usage: GenFvMap <LOG> <INF> <MAP>";
+const char CGenFvMapUsage::s_szUsage[] = "Usage: GenFvMap <LOG> <MAP>";
class CGenFvMapApp : public CObjRoot
{
@@ -465,7 +411,7 @@ CGenFvMapApp::CGenFvMapApp(int cArgc, char *ppszArgv[]) : m_cArgc(cArgc)
, m_ppszArgv(ppszArgv)
{
- if (cArgc != 4)
+ if (cArgc != 3)
throw CGenFvMapUsage();
}
@@ -476,14 +422,10 @@ CGenFvMapApp::~CGenFvMapApp(void) int CGenFvMapApp::Run(void)
{
ifstream isLog(m_ppszArgv[1]);
- ifstream isInf(m_ppszArgv[2]);
-
- CIdAddressMap idAddress(isLog);
- CIdPathMap idPath(isInf);
-
- CFvMapFile fvMap(idAddress, idPath);
+ CIdAddressPathMap idAddrPath(isLog);
+ CFvMapFile fvMap(idAddrPath);
- ofstream osMap(m_ppszArgv[3], ios_base::out | ios_base::trunc);
+ ofstream osMap(m_ppszArgv[2], ios_base::out | ios_base::trunc);
osMap << fvMap;
if (!osMap)
diff --git a/Tools/CCode/Source/GenFvMap/build.xml b/Tools/CCode/Source/GenFvMap/build.xml index 6c236bf979..4d7e155591 100644 --- a/Tools/CCode/Source/GenFvMap/build.xml +++ b/Tools/CCode/Source/GenFvMap/build.xml @@ -40,6 +40,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. optimize="speed">
<compilerarg value="${ExtraArgus}" if="ExtraArgus" />
<compilerarg value="/EHsc" unless="GCC"/>
+ <compilerarg value="/Za" unless="GCC"/>
<fileset dir="${basedir}/${ToolName}"
includes="${FileSet}"
diff --git a/Tools/CCode/Source/PeiRebase/PeiRebaseExe.c b/Tools/CCode/Source/PeiRebase/PeiRebaseExe.c index 11192c428b..7519a55e48 100644 --- a/Tools/CCode/Source/PeiRebase/PeiRebaseExe.c +++ b/Tools/CCode/Source/PeiRebase/PeiRebaseExe.c @@ -799,9 +799,10 @@ Returns: //
fprintf (
LogFile,
- "%s %016I64X\n",
+ "%s %016I64X %s\n",
FileGuidString,
- ImageContext.DestinationAddress
+ ImageContext.DestinationAddress,
+ ImageContext.PdbPointer == NULL ? "*" : ImageContext.PdbPointer
);
*BaseToUpdate += EFI_SIZE_TO_PAGES (ImageContext.ImageSize) * EFI_PAGE_SIZE;
@@ -1136,8 +1137,6 @@ Returns: GetLength (CurrentPe32Section.Pe32Section->CommonHeader.Size) - sizeof (EFI_PE32_SECTION) -
sizeof (EFI_TE_IMAGE_HEADER)
);
- free ((VOID *) MemoryImagePointer);
- free (TEBuffer);
if (FfsFile->Attributes & FFS_ATTRIB_TAIL_PRESENT) {
TailSize = sizeof (EFI_FFS_FILE_TAIL);
} else {
@@ -1171,10 +1170,17 @@ Returns: fprintf (
LogFile,
- "%s %016I64X\n",
+ "%s %016I64X %s\n",
FileGuidString,
- ImageContext.DestinationAddress
+ ImageContext.DestinationAddress,
+ ImageContext.PdbPointer == NULL ? "*" : ImageContext.PdbPointer
);
+
+ //
+ // Free buffers
+ //
+ free ((VOID *) MemoryImagePointer);
+ free (TEBuffer);
}
return EFI_SUCCESS;
|