MakeAlternativeSource.cpp revision 0d5ce79297e3b1c4e2cc0f5f74900fc21a7581dd
/* $Id$ */
/** @file
* MakeAlternative - Generate an Alternative BIOS Source that requires less tools.
*/
/*
* Copyright (C) 2012 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
#include <iprt/buildconfig.h>
#include <iprt/initterm.h>
/*******************************************************************************
* Structures and Typedefs *
*******************************************************************************/
/**
* A BIOS segment.
*/
typedef struct BIOSSEG
{
char szName[32];
char szClass[32];
char szGroup[32];
} BIOSSEG;
/** Pointer to a BIOS segment. */
/**
* A BIOS object file.
*/
typedef struct BIOSOBJFILE
{
char *pszSource;
char *pszObject;
} BIOSOBJFILE;
/** A BIOS object file. */
typedef BIOSOBJFILE *PBIOSOBJFILE;
/**
* Pointer to a BIOS map parser handle.
*/
typedef struct BIOSMAP
{
/** The stream pointer. */
/** The file name. */
const char *pszMapFile;
/** Set when EOF has been reached. */
bool fEof;
/** The current line number (0 based).*/
/** The length of the current line. */
/** The offset of the first non-white character on the line. */
/** The line buffer. */
char szLine[16384];
} BIOSMAP;
/** Pointer to a BIOS map parser handle. */
/*******************************************************************************
* Global Variables *
*******************************************************************************/
/** The verbosity level.*/
/** Pointer to the BIOS image. */
/** The size of the BIOS image. */
/** Debug module for the map file. */
/** The number of BIOS segments found in the map file. */
/** Array of BIOS segments from the map file. */
/** List of BIOSOBJFILE. */
static RTLISTANCHOR g_ObjList;
/** The output stream. */
/** The type of BIOS we're working on. */
static enum BIOSTYPE
{
kBiosType_System = 0,
/** The flat ROM base address. */
{
if (RT_FAILURE(rc))
{
return false;
}
return true;
}
static bool outputPrintf(const char *pszFormat, ...)
{
return fRc;
}
/**
* Opens the output file for writing.
*
* @returns RTEXITCODE_SUCCESS or RTEXITCODE_FAILURE+msg.
* @param pszOutput Path to the output file.
*/
{
if (!pszOutput)
else
{
if (RT_FAILURE(rc))
}
return RTEXITCODE_SUCCESS;
}
/**
* Displays a disassembly error and returns @c false.
*
* @returns @c false.
* @param pszFormat The error format string.
* @param ... Format argument.
*/
{
return false;
}
/**
* Output the disassembly file header.
*
* @returns @c true on success,
*/
static bool disFileHeader(void)
{
bool fRc;
";; @file\n"
"; Auto Generated source file. Do not edit.\n"
";\n"
);
if (!fRc)
return fRc;
/*
* List the header of each source file, up to and including the
* copyright notice.
*/
{
if (RT_SUCCESS(rc))
{
";\n"
"; Source file: %Rbn\n"
";\n"
bool fSeenCopyright = false;
char szLine[4096];
{
iLine++;
/* Check if we're done. */
if ( fSeenCopyright
|| psz[0] == '\0') )
break;
/* Strip comment suffix. */
{
}
/* Skip line prefix. */
psz += 2;
else if (psz[0] == '*')
psz += 1;
else
while (*psz == ';')
psz++;
if (RT_C_IS_SPACE(*psz))
psz++;
/* Skip the doxygen file tag line. */
continue;
/* Detect copyright section. */
if ( !fSeenCopyright
fSeenCopyright = true;
}
if (rc != VINF_SUCCESS)
}
}
/*
* Set the org.
*/
"\n"
"\n"
) && fRc;
return fRc;
}
/**
* Checks if a byte sequence could be a string litteral.
*
* @returns @c true if it is, @c false if it isn't.
* @param uFlatAddr The address of the byte sequence.
* @param cb The length of the sequence.
*/
{
if (cb < 6)
return false;
while (cb > 0)
{
if ( !RT_C_IS_PRINT(*pb)
&& *pb != '\r'
&& *pb != '\n'
&& *pb != '\t')
{
if (*pb == '\0')
{
do
{
pb++;
cb--;
return cb == 0;
}
return false;
}
pb++;
cb--;
}
return true;
}
/**
* Checks if a dword could be a far 16:16 BIOS address.
*
* @returns @c true if it is, @c false if it isn't.
* @param uFlatAddr The address of the dword.
*/
{
return false;
return false;
return false;
return true;
}
{
while (cb-- > 0)
{
bool fRc;
if (cbOnLine >= 16)
{
" db 0%02xh", *pb);
cbOnLine = 1;
}
else if (!cbOnLine)
{
cbOnLine = 1;
}
else
{
cbOnLine++;
}
if (!fRc)
return false;
pb++;
}
return outputPrintf("\n");
}
{
if (cb & 1)
while (cb > 0)
{
bool fRc;
if (cbOnLine >= 16)
{
" dw 0%04xh", *pu16);
cbOnLine = 2;
}
else if (!cbOnLine)
{
cbOnLine = 2;
}
else
{
cbOnLine += 2;
}
if (!fRc)
return false;
pu16++;
cb -= 2;
}
return outputPrintf("\n");
}
{
if (cb & 3)
while (cb > 0)
{
bool fRc;
if (cbOnLine >= 16)
{
" dd 0%08xh", *pu32);
cbOnLine = 4;
}
else if (!cbOnLine)
{
cbOnLine = 4;
}
else
{
cbOnLine += 4;
}
if (!fRc)
return false;
pu32++;
cb -= 4;
}
return outputPrintf("\n");
}
{
while (cb > 0)
{
/* Line endings and beginnings. */
if (cchOnLine >= 72)
{
if (!outputPrintf("\n"))
return false;
cchOnLine = 0;
}
if ( !cchOnLine
&& !outputPrintf(" db "))
return false;
/* See how many printable character we've got. */
uint32_t cchPrintable = 0;
while ( cchPrintable < cb
cchPrintable++;
bool fRc = true;
if (cchPrintable)
{
if (cchOnLine)
{
}
else
{
}
pb += cchPrintable;
cb -= cchPrintable;
}
else
{
if (cchOnLine)
{
cchOnLine += 6;
}
else
{
cchOnLine += 4;
}
pb++;
cb--;
}
if (!fRc)
return false;
}
return outputPrintf("\n");
}
/**
* For dumping a portion of a string table.
*
* @returns @c true on success, @c false on failure.
* @param uFlatAddr The start address.
* @param cb The size of the string table.
*/
{
while (cb > 0)
{
/* Line endings and beginnings. */
if ( cchOnLine >= 72
{
if (!outputPrintf("\n"))
return false;
cchOnLine = 0;
}
if ( !cchOnLine
&& !outputPrintf(" db "))
return false;
/* See how many printable character we've got. */
uint32_t cchPrintable = 0;
while ( cchPrintable < cb
cchPrintable++;
bool fRc = true;
if (cchPrintable)
{
if (cchOnLine)
{
}
else
{
}
pb += cchPrintable;
cb -= cchPrintable;
}
else
{
if (cchOnLine)
{
cchOnLine += 6;
}
else
{
cchOnLine += 4;
}
pb++;
cb--;
}
if (!fRc)
return false;
}
return outputPrintf("\n");
}
/**
* Minds the gap between two segments.
*
* Gaps should generally be zero filled.
*
* @returns @c true on success, @c false on failure.
* @param uFlatAddr The address of the gap.
* @param cbPadding The size of the gap.
*/
{
if (g_cVerbose > 0)
outputPrintf("\n"
}
/**
* Worker for disGetNextSymbol that only does the looking up, no RTDBSYMBOL::cb
* calc.
*
* @param uFlatAddr The address to start searching at.
* @param cbMax The size of the search range.
* @param poff Where to return the offset between the symbol
* and @a uFlatAddr.
* @param pSym Where to return the symbol data.
*/
static void disGetNextSymbolWorker(uint32_t uFlatAddr, uint32_t cbMax, uint32_t *poff, PRTDBGSYMBOL pSym)
{
int rc = RTDbgModSymbolByAddr(g_hMapMod, RTDBGSEGIDX_RVA, uFlatAddr, RTDBGSYMADDR_FLAGS_GREATER_OR_EQUAL, &off, pSym);
if (RT_SUCCESS(rc))
{
/* negative offset, indicates beyond. */
if (off <= 0)
{
return;
}
outputPrintf(" ; !! RTDbgModSymbolByAddr(,,%#x,,) -> off=%RTptr cb=%RTptr uValue=%RTptr '%s'\n",
}
else if (rc != VERR_SYMBOL_NOT_FOUND)
}
/**
* Gets the symbol at or after the given address.
*
* If there are no symbols in the specified range, @a pSym and @a poff will be
* set up to indicate a symbol at the first byte after the range.
*
* @param uFlatAddr The address to start searching at.
* @param cbMax The size of the search range.
* @param poff Where to return the offset between the symbol
* and @a uFlatAddr.
* @param pSym Where to return the symbol data.
*/
{
{
{
}
else
}
if (g_cVerbose > 1)
outputPrintf(" ; disGetNextSymbol %#x LB %#x -> off=%#x cb=%RTptr uValue=%RTptr '%s'\n",
}
/**
* For dealing with the const segment (string constants).
*
* @returns @c true on success, @c false on failure.
* @param iSeg The segment.
*/
{
while (cb > 0)
{
if (off > 0)
{
return false;
off = 0;
if (!cb)
break;
}
bool fRc;
if (off == 0)
{
fRc = outputPrintf("%s: %*s; %#x LB %#x\n", Sym.szName, cchName < 41 - 2 ? cchName - 41 - 2 : 0, "", uFlatAddr, Sym.cb);
if (!fRc)
return false;
}
else
{
cb = 0;
}
if (!fRc)
return false;
}
return true;
}
{
while (cb > 0)
{
if (off > 0)
{
return false;
off = 0;
if (!cb)
break;
}
bool fRc;
if (off == 0)
{
fRc = outputPrintf("%s: %*s; %#x LB %#x\n", Sym.szName, cchName < 41 - 2 ? cchName - 41 - 2 : 0, "", uFlatAddr, Sym.cb);
if (!fRc)
return false;
//else if (Sym.cb == 4 && disIsFarBiosAddr(uFlatAddr))
// fRc = disDWordData(uFlatAddr, 4);
else
}
else
{
cb = 0;
}
if (!fRc)
return false;
}
return true;
}
{
switch (g_enmBiosType)
{
/*
* This is for the PC BIOS.
*/
case kBiosType_System:
{
)
return false;
}
break;
/*
* This is for the VGA BIOS.
*/
case kBiosType_Vga:
break;
}
return true;
}
static bool disIs16BitCode(const char *pszSymbol)
{
return true;
}
/**
*/
static size_t disHandleYasmDifferences(PDISCPUSTATE pCpuState, uint32_t uFlatAddr, uint32_t cbInstr,
{
/*
* Disassembler bugs.
*/
/** @todo Group 1a and 11 seems to be disassembled incorrectly when
* modrm.reg != 0. Those encodings should be invalid AFAICT. */
)
fDifferent = true;
/*
* Check these out and consider adding them to DISFormatYasmIsOddEncoding.
*/
else if ( pb[0] == 0xf3
fDifferent = true; /* rep insd - prefix switched. */
else if ( pb[0] == 0xc6
fDifferent = true; /* mov ch, 0bah - yasm uses a short sequence: 0xb5 0xba. */
/*
* 32-bit retf.
*/
else if ( pb[0] == 0x66
fDifferent = true;
/*
* Handle different stuff.
*/
if (fDifferent)
{
{
cchUsed += 2;
}
pszBuf[0] = ';';
}
return cchUsed;
}
/**
* @callback_method_impl{FNDISREADBYTES}
*
* @remarks @a uSrcAddr is the flat address.
*/
static DECLCALLBACK(int) disReadOpcodeBytes(PDISCPUSTATE pDis, uint8_t offInstr, uint8_t cbMinRead, uint8_t cbMaxRead)
{
{
cbToRead = 0;
else
}
return VINF_SUCCESS;
}
/**
* Disassembles code.
*
* @returns @c true on success, @c false on failure.
* @param uFlatAddr The address where the code starts.
* @param cb The amount of code to disassemble.
* @param fIs16Bit Is is 16-bit (@c true) or 32-bit (@c false).
*/
{
while (cb > 0)
{
/* Trailing zero padding detection. */
if ( *pb == '\0'
{
return false;
if ( cb == 2
&& pb[0] == 'X'
}
/* Work arounds for switch tables and such (disas assertions). */
)
|| 0
)
else
{
unsigned cbInstr;
if ( RT_SUCCESS(rc)
{
char szTmp[4096];
if (g_cVerbose > 1)
{
while (cch < 72)
}
return false;
}
else
{
return false;
cb--;
pb++;
uFlatAddr++;
}
}
}
return true;
}
{
while (cb > 0)
{
if (off > 0)
{
return false;
off = 0;
if (!cb)
break;
}
bool fRc;
if (off == 0)
{
fRc = outputPrintf("%s: %*s; %#x LB %#x\n", Sym.szName, cchName < 41 - 2 ? cchName - 41 - 2 : 0, "", uFlatAddr, Sym.cb);
if (!fRc)
return false;
else
}
else
{
cb = 0;
}
if (!fRc)
return false;
}
return true;
}
static RTEXITCODE DisassembleBiosImage(void)
{
if (!disFileHeader())
return RTEXITCODE_FAILURE;
/*
* Work the image segment by segment.
*/
bool fRc = true;
{
/* Is there a gap between the segments? */
{
if (!fRc)
break;
}
return RTMsgErrorExit(RTEXITCODE_FAILURE, "Overlapping segments: %u and %u; uFlatAddr=%#x\n", iSeg - 1, iSeg, uFlatAddr);
/* Disassemble the segment. */
"section %s progbits vstart=%#x align=1 ; size=%#x class=%s group=%s\n",
if (!fRc)
return RTEXITCODE_FAILURE;
else
/* Advance. */
}
/* Final gap. */
return RTMsgErrorExit(RTEXITCODE_FAILURE, "Last segment spills beyond 1MB; uFlatAddr=%#x\n", uFlatAddr);
if (!fRc)
return RTEXITCODE_FAILURE;
return RTEXITCODE_SUCCESS;
}
/**
* Parses the symbol file for the BIOS.
*
*
* @returns RTEXITCODE_SUCCESS or RTEXITCODE_FAILURE+msg.
* @param pszBiosSym Path to the sym file.
*/
{
#if 1
/** @todo use RTDbg* later. (Just checking for existance currently.) */
if (RT_FAILURE(rc))
#else
#endif
return RTEXITCODE_SUCCESS;
}
/**
* Display an error with the mapfile name and current line, return false.
*
* @returns @c false.
* @param pMap The map file handle.
* @param pszFormat The format string.
* @param ... Format arguments.
*/
{
return false;
}
/**
* Reads a line from the file.
*
* @returns @c true on success, @c false + msg on failure, @c false on eof.
* @param pMap The map file handle.
*/
{
if (RT_FAILURE(rc))
{
{
}
else
return false;
}
/* Check out leading white space. */
else
{
off++;
}
return true;
}
/**
* Checks if it is an empty line.
* @returns @c true if empty, @c false if not.
* @param pMap The map file handle.
*/
{
}
/**
* Reads ahead in the map file until a non-empty line or EOF is encountered.
*
* @returns @c true on success, @c false + msg on failure, @c false on eof.
* @param pMap The map file handle.
*/
{
for (;;)
{
if (!mapReadLine(pMap))
return false;
return true;
}
}
/**
* Reads ahead in the map file until an empty line or EOF is encountered.
*
* @returns @c true on success, @c false + msg on failure, @c false on eof.
* @param pMap The map file handle.
*/
{
for (;;)
{
if (!mapReadLine(pMap))
return false;
return true;
}
}
/**
* Strips the current line.
*
* The string length may change.
*
* @returns Pointer to the first non-space character.
* @param pMap The map file handle.
* @param pcch Where to return the length of the unstripped
* part. Optional.
*/
{
{
*--pszEnd = '\0';
}
if (pcch)
return psz;
}
/**
* Reads a line from the file and right strips it.
*
* @returns Pointer to szLine on success, @c NULL + msg on failure, @c NULL on
* EOF.
* @param pMap The map file handle.
* @param pcch Where to return the length of the unstripped
* part. Optional.
*/
{
if (!mapReadLine(pMap))
return NULL;
if (pcch)
}
/**
* mapReadLine() + mapStripCurrentLine().
*
* @returns Pointer to the first non-space character in the new line. NULL on
* read error (bitched already) or end of file.
* @param pMap The map file handle.
* @param pcch Where to return the length of the unstripped
* part. Optional.
*/
{
if (!mapReadLine(pMap))
return NULL;
}
/**
* Parses a word, copying it into the supplied buffer, and skipping any spaces
* following it.
*
* @returns @c true on success, @c false on failure.
* @param ppszCursor Pointer to the cursor variable.
* @param pszBuf The output buffer.
* @param cbBuf The size of the output buffer.
*/
{
/* Check that we start on a non-blank. */
char *pszStart = *ppszCursor;
return false;
/* Find the end of the word. */
psz++;
/* Copy it. */
return false;
/* Skip blanks following it. */
while (RT_C_IS_SPACE(*psz))
psz++;
*ppszCursor = psz;
return true;
}
/**
* Parses an 16:16 address.
*
* @returns @c true on success, @c false on failure.
* @param ppszCursor Pointer to the cursor variable.
* @param pAddr Where to return the address.
*/
{
char szWord[32];
return false;
/* An address is at least 16:16 format. It may be 16:32. It may also be flagged. */
return false;
if ( !RT_C_IS_XDIGIT(szWord[0])
)
return false;
cchAddr += 4;
/* Drop flag if present. */
{
return false;
}
/* Convert it. */
if (rc1 != VINF_SUCCESS)
return false;
if (rc2 != VINF_SUCCESS)
return false;
return true;
}
/**
* Parses a size.
*
* @returns @c true on success, @c false on failure.
* @param ppszCursor Pointer to the cursor variable.
* @param pcb Where to return the size.
*/
{
char szWord[32];
return false;
if (cchWord != 8)
return false;
if (rc != VINF_SUCCESS)
return false;
return true;
}
/**
* Parses a section box and the following column header.
*
* @returns @c true on success, @c false + msg on failure, @c false on eof.
* @param pMap Map file handle.
* @param pszSectionNm The expected section name.
* @param cColumns The number of columns.
* @param ... The column names.
*/
static bool mapSkipThruColumnHeadings(PBIOSMAP pMap, const char *pszSectionNm, uint32_t cColumns, ...)
{
if ( mapIsEmptyLine(pMap)
&& !mapSkipEmptyLines(pMap))
return false;
/* +------------+ */
if (!psz)
return false;
if ( psz[0] != '+'
)
{
return false;
}
/* | pszSectionNm | */
if (!psz)
return false;
if ( psz[0] != '|'
)
{
return false;
}
/* +------------+ */
if (!psz)
return false;
if ( psz[0] != '+'
)
{
return false;
}
/* There may be a few lines describing the table notation now, surrounded by blank lines. */
do
{
if (!psz)
return false;
} while ( *psz == '\0'
|| ( !RT_C_IS_SPACE(psz[0])
);
/* Should have the column heading now. */
{
{
RTMsgError("%s:%d: Expected column '%s' found '%s'", pMap->pszMapFile, pMap->iLine, pszColumn, psz);
return false;
}
while (RT_C_IS_SPACE(*psz))
psz++;
}
/* The next line is the underlining. */
if (!psz)
return false;
{
return false;
}
/* Skip one blank line. */
if (!psz)
return false;
if (*psz)
{
return false;
}
return true;
}
/**
* Parses a segment list.
*
* @returns @c true on success, @c false + msg on failure, @c false on eof.
* @param pMap The map file handle.
*/
{
for (;;)
{
return false;
/* The end? The line should be empty. Expectes segment name to not
start with a space. */
{
return true;
return false;
}
/* Parse the segment line. */
{
return false;
}
else
{
g_cSegs++;
if (g_cVerbose > 2)
while (RT_C_IS_SPACE(*psz))
psz++;
if (!*psz)
continue;
}
return false;
}
}
/**
* Sorts the segment array by flat address and adds them to the debug module.
*
* @returns @c true on success, @c false + msg on failure, @c false on eof.
*/
static bool mapSortAndAddSegments(void)
{
{
{
}
if (g_cVerbose > 0)
RTDBGSEGIDX idx = i;
int rc = RTDbgModSegmentAdd(g_hMapMod, g_aSegs[i].uFlatAddr, g_aSegs[i].cb, g_aSegs[i].szName, 0 /*fFlags*/, &idx);
if (RT_FAILURE(rc))
{
return false;
}
}
return true;
}
/**
* Parses a segment list.
*
* @returns @c true on success, @c false + msg on failure, @c false on eof.
* @param pMap The map file handle.
*/
{
for (;;)
{
return false;
/* The end? The line should be empty. Expectes segment name to not
start with a space. */
{
return true;
}
{
/* Parse the module line. */
offObj++;
char ch;
offSrc++;
offSrc++;
cchSrc++;
if (ch != ')')
if (!pObjFile)
*psz++ = '\0';
}
else
{
/* Parse the segment line. */
char szName[4096];
if (uFlatAddr != 0)
{
int rc = RTDbgModSymbolAdd(g_hMapMod, szName, RTDBGSEGIDX_RVA, uFlatAddr, 0 /*cb*/, 0 /*fFlags*/, NULL);
{
/* HACK ALERT! For dealing with lables at segment size. */ /** @todo fix end labels. */
rc = RTDbgModSymbolAdd(g_hMapMod, szName, RTDBGSEGIDX_RVA, uFlatAddr - 1, 0 /*cb*/, 0 /*fFlags*/, NULL);
}
if (g_cVerbose > 2)
while (RT_C_IS_SPACE(*psz))
psz++;
if (*psz)
}
}
}
}
/**
* Parses the given map file.
*
* @returns RTEXITCODE_SUCCESS and lots of globals, or RTEXITCODE_FAILURE and a
* error message.
* @param pMap The map file handle.
*/
{
if (RT_FAILURE(rc))
/*
* Read the header.
*/
if (!mapReadLine(pMap))
return RTEXITCODE_FAILURE;
if ( !mapSkipNonEmptyLines(pMap)
|| !mapSkipEmptyLines(pMap))
return RTEXITCODE_FAILURE;
/*
* Skip groups.
*/
return RTEXITCODE_FAILURE;
if (!mapSkipNonEmptyLines(pMap))
return RTEXITCODE_FAILURE;
/*
* Parse segments.
*/
if (!mapSkipThruColumnHeadings(pMap, "Segments", 5, "Segment", "Class", "Group", "Address", "Size"))
return RTEXITCODE_FAILURE;
if (!mapParseSegments(pMap))
return RTEXITCODE_FAILURE;
if (!mapSortAndAddSegments())
return RTEXITCODE_FAILURE;
/*
* Parse symbols.
*/
return RTEXITCODE_FAILURE;
if (!mapParseSymbols(pMap))
return RTEXITCODE_FAILURE;
/* Ignore the rest of the file. */
return RTEXITCODE_SUCCESS;
}
/**
* Parses the linker map file for the BIOS.
*
* This is generated by the Watcom linker.
*
* @returns RTEXITCODE_SUCCESS or RTEXITCODE_FAILURE+msg.
* @param pszBiosMap Path to the map file.
*/
{
if (RT_FAILURE(rc))
return rcExit;
}
/**
* Reads the BIOS image into memory (g_pbImg and g_cbImg).
*
* @returns RTEXITCODE_SUCCESS or RTEXITCODE_FAILURE+msg.
* @param pszBiosImg Path to the image file.
*/
{
void *pvImg;
if (RT_FAILURE(rc))
switch (g_enmBiosType)
{
default: cbImgExpect = 0; break;
}
if (cbImg != cbImgExpect)
{
return RTMsgErrorExit(RTEXITCODE_FAILURE, "The BIOS image %u bytes intead of %u bytes", cbImg, cbImgExpect);
}
return RTEXITCODE_SUCCESS;
}
{
if (RT_FAILURE(rc))
return RTMsgInitFailure(rc);
/*
* Option config.
*/
static RTGETOPTDEF const s_aOpts[] =
{
};
const char *pszBiosMap = NULL;
const char *pszBiosSym = NULL;
const char *pszBiosImg = NULL;
rc = RTGetOptInit(&GetOptState, argc, argv, &s_aOpts[0], RT_ELEMENTS(s_aOpts), 1, RTGETOPTINIT_FLAGS_OPTS_FIRST);
/*
* Process the options.
*/
{
switch (rc)
{
case 'i':
if (pszBiosImg)
break;
case 'm':
if (pszBiosMap)
break;
case 's':
if (pszBiosSym)
break;
case 'o':
if (pszOutput)
break;
case 't':
{
g_uBiosFlatBase = 0xf0000;
}
{
g_uBiosFlatBase = 0xc0000;
}
else
break;
case 'v':
g_cVerbose++;
break;
case 'q':
g_cVerbose = 0;
break;
case 'H':
RTPrintf("usage: %Rbn --bios-image <file.img> --bios-map <file.map> [--output <file.asm>]\n",
argv[0]);
return RTEXITCODE_SUCCESS;
case 'V':
{
/* The following is assuming that svn does it's job here. */
return RTEXITCODE_SUCCESS;
}
default:
}
}
/*
* Got it all?
*/
if (!pszBiosImg)
if (!pszBiosMap)
if (!pszBiosSym)
/*
* Do the job.
*/
if (rcExit == RTEXITCODE_SUCCESS)
if (rcExit == RTEXITCODE_SUCCESS)
if (rcExit == RTEXITCODE_SUCCESS)
if (rcExit == RTEXITCODE_SUCCESS)
return rcExit;
}