Changeset 41488 in vbox for trunk/src/VBox/Devices/PC
- Timestamp:
- May 29, 2012 8:18:30 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/PC/BIOS-new/MakeDebianBiosAssembly.cpp
r41483 r41488 43 43 char szGroup[32]; 44 44 RTFAR16 Address; 45 uint32_t uFlatAddr; 45 46 uint32_t cb; 46 47 } BIOSSEG; … … 58 59 /** The file name. */ 59 60 const char *pszMapFile; 61 /** Set when EOF has been reached. */ 62 bool fEof; 60 63 /** The current line number (0 based).*/ 61 64 uint32_t iLine; … … 120 123 121 124 122 123 124 static bool SkipEmptyLines(PRTSTREAM hStrm, uint32_t *piLine, char *pszLine, size_t cbLine) 125 /** 126 * Reads a line from the file. 127 * 128 * @returns @c true on success, @c false + msg on failure, @c false on eof. 129 * @param pMap The map file handle. 130 */ 131 static bool mapReadLine(PBIOSMAP pMap) 132 { 133 int rc = RTStrmGetLine(pMap->hStrm, pMap->szLine, sizeof(pMap->szLine)); 134 if (RT_FAILURE(rc)) 135 { 136 if (rc == VERR_EOF) 137 { 138 pMap->fEof = true; 139 pMap->cch = 0; 140 pMap->offNW = 0; 141 pMap->szLine[0] = '\0'; 142 } 143 else 144 RTMsgError("%s:%d: Read error %Rrc", pMap->pszMapFile, pMap->iLine + 1, rc); 145 return false; 146 } 147 pMap->iLine++; 148 pMap->cch = strlen(pMap->szLine); 149 150 /* Check out leading white space. */ 151 if (!RT_C_IS_SPACE(pMap->szLine[0])) 152 pMap->offNW = 0; 153 else 154 { 155 uint32_t off = 1; 156 while (RT_C_IS_SPACE(pMap->szLine[off])) 157 off++; 158 pMap->offNW = off; 159 } 160 161 return true; 162 } 163 164 165 /** 166 * Checks if it is an empty line. 167 * @returns @c true if empty, @c false if not. 168 * @param pMap The map file handle. 169 */ 170 static bool mapIsEmptyLine(PBIOSMAP pMap) 171 { 172 Assert(pMap->offNW <= pMap->cch); 173 return pMap->offNW == pMap->cch; 174 } 175 176 177 /** 178 * Reads ahead in the map file until a non-empty line or EOF is encountered. 179 * 180 * @returns @c true on success, @c false + msg on failure, @c false on eof. 181 * @param pMap The map file handle. 182 */ 183 static bool mapSkipEmptyLines(PBIOSMAP pMap) 125 184 { 126 185 for (;;) 127 186 { 128 int rc = RTStrmGetLine(hStrm, pszLine, cbLine); 129 if (RT_FAILURE(rc)) 130 { 131 RTMsgError("Error reading map-file: %Rrc", rc); 187 if (!mapReadLine(pMap)) 132 188 return false; 133 } 134 135 *piLine += 1; 136 const char *psz = RTStrStripL(pszLine); 137 if (*psz) 189 if (pMap->offNW < pMap->cch) 138 190 return true; 139 191 } … … 141 193 142 194 143 static bool SkipNonEmptyLines(PRTSTREAM hStrm, uint32_t *piLine, char *pszLine, size_t cbLine) 195 /** 196 * Reads ahead in the map file until an empty line or EOF is encountered. 197 * 198 * @returns @c true on success, @c false + msg on failure, @c false on eof. 199 * @param pMap The map file handle. 200 */ 201 static bool mapSkipNonEmptyLines(PBIOSMAP pMap) 144 202 { 145 203 for (;;) 146 204 { 147 int rc = RTStrmGetLine(hStrm, pszLine, cbLine); 148 if (RT_FAILURE(rc)) 149 { 150 RTMsgError("Error reading map-file: %Rrc", rc); 205 if (!mapReadLine(pMap)) 151 206 return false; 152 } 153 154 *piLine += 1; 155 const char *psz = RTStrStripL(pszLine); 156 if (!*psz) 207 if (pMap->offNW == pMap->cch) 157 208 return true; 158 209 } 159 210 } 211 212 213 /** 214 * Strips the current line. 215 * 216 * The string length may change. 217 * 218 * @returns Pointer to the first non-space character. 219 * @param pMap The map file handle. 220 * @param pcch Where to return the length of the unstripped 221 * part. Optional. 222 */ 223 static char *mapStripCurrentLine(PBIOSMAP pMap, size_t *pcch) 224 { 225 char *psz = &pMap->szLine[pMap->offNW]; 226 char *pszEnd = &pMap->szLine[pMap->cch]; 227 while ( (uintptr_t)pszEnd > (uintptr_t)psz 228 && RT_C_IS_SPACE(pszEnd[-1])) 229 { 230 *--pszEnd = '\0'; 231 pMap->cch--; 232 } 233 if (pcch) 234 *pcch = pszEnd - psz; 235 return psz; 236 } 237 238 239 /** 240 * Reads a line from the file and right strips it. 241 * 242 * @returns Pointer to szLine on success, @c NULL + msg on failure, @c NULL on 243 * EOF. 244 * @param pMap The map file handle. 245 * @param pcch Where to return the length of the unstripped 246 * part. Optional. 247 */ 248 static char *mapReadLineStripRight(PBIOSMAP pMap, size_t *pcch) 249 { 250 if (!mapReadLine(pMap)) 251 return NULL; 252 mapStripCurrentLine(pMap, NULL); 253 if (pcch) 254 *pcch = pMap->cch; 255 return pMap->szLine; 256 } 257 160 258 161 259 … … 177 275 178 276 179 static char *ReadMapLineLR(const char *pszBiosMap, PRTSTREAM hStrm, uint32_t *piLine, 180 char *pszLine, size_t cbLine, size_t *pcchLine) 181 { 182 int rc = RTStrmGetLine(hStrm, pszLine, cbLine); 183 if (RT_FAILURE(rc)) 184 { 185 RTMsgError("%s:%d: Read error: %Rrc", pszBiosMap, *piLine, rc); 277 /** 278 * mapReadLine() + mapStripCurrentLine(). 279 * 280 * @returns Pointer to the first non-space character in the new line. NULL on 281 * read error (bitched already) or end of file. 282 * @param pMap The map file handle. 283 * @param pcch Where to return the length of the unstripped 284 * part. Optional. 285 */ 286 static char *mapReadLineStrip(PBIOSMAP pMap, size_t *pcch) 287 { 288 if (!mapReadLine(pMap)) 186 289 return NULL; 187 } 188 *piLine += 1; 189 190 char *psz = RTStrStrip(pszLine); 191 *pcchLine = strlen(psz); 192 return psz; 193 } 194 195 196 static char *ReadMapLine(const char *pszBiosMap, PRTSTREAM hStrm, uint32_t *piLine, 197 char *pszLine, size_t cbLine, size_t *pcchLine) 198 { 199 int rc = RTStrmGetLine(hStrm, pszLine, cbLine); 200 if (RT_FAILURE(rc)) 201 { 202 RTMsgError("%s:%d: Read error: %Rrc", pszBiosMap, *piLine, rc); 203 return NULL; 204 } 205 *piLine += 1; 206 207 *pcchLine = strlen(pszLine); 208 return pszLine; 209 } 210 211 212 static bool ParseWord(char **ppszCursor, char *pszBuf, size_t cbBuf) 290 return mapStripCurrentLine(pMap, pcch); 291 } 292 293 294 /** 295 * Parses a word, copying it into the supplied buffer, and skipping any spaces 296 * following it. 297 * 298 * @returns @c true on success, @c false on failure. 299 * @param ppszCursor Pointer to the cursor variable. 300 * @param pszBuf The output buffer. 301 * @param cbBuf The size of the output buffer. 302 */ 303 static bool mapParseWord(char **ppszCursor, char *pszBuf, size_t cbBuf) 213 304 { 214 305 /* Check that we start on a non-blank. */ … … 237 328 238 329 239 static bool ParseAddress(char **ppszCursor, PRTFAR16 pAddr) 330 /** 331 * Parses an 16:16 address. 332 * 333 * @returns @c true on success, @c false on failure. 334 * @param ppszCursor Pointer to the cursor variable. 335 * @param pAddr Where to return the address. 336 */ 337 static bool mapParseAddress(char **ppszCursor, PRTFAR16 pAddr) 240 338 { 241 339 char szWord[32]; 242 if (! ParseWord(ppszCursor, szWord, sizeof(szWord)))340 if (!mapParseWord(ppszCursor, szWord, sizeof(szWord))) 243 341 return false; 244 342 size_t cchWord = strlen(szWord); … … 270 368 /* Convert it. */ 271 369 szWord[4] = '\0'; 272 int rc1 = RTStrToUInt16 Ex(szWord, NULL, 16, &pAddr->sel); AssertRC(rc1);273 int rc2 = RTStrToUInt16 Ex(szWord + 5, NULL, 16, &pAddr->off); AssertRC(rc2);370 int rc1 = RTStrToUInt16Full(szWord, 16, &pAddr->sel); AssertRCSuccess(rc1); 371 int rc2 = RTStrToUInt16Full(szWord + 5, 16, &pAddr->off); AssertRCSuccess(rc2); 274 372 return true; 275 373 } 276 374 277 375 278 static bool ParseSize(char **ppszCursor, uint32_t *pcb) 376 /** 377 * Parses a size. 378 * 379 * @returns @c true on success, @c false on failure. 380 * @param ppszCursor Pointer to the cursor variable. 381 * @param pcb Where to return the size. 382 */ 383 static bool mapParseSize(char **ppszCursor, uint32_t *pcb) 279 384 { 280 385 char szWord[32]; 281 if (! ParseWord(ppszCursor, szWord, sizeof(szWord)))386 if (!mapParseWord(ppszCursor, szWord, sizeof(szWord))) 282 387 return false; 283 388 size_t cchWord = strlen(szWord); … … 295 400 * Parses a section box and the following column header. 296 401 * 297 * @returns RTEXITCODE_SUCCESS or RTEXITCODE_FAILURE+msg. 298 * @param pszBiosMap The input file name. 299 * @param hStrm The input stream. 300 * @param piLine Pointer to the current line number variable. 402 * @returns @c true on success, @c false + msg on failure, @c false on eof. 403 * @param pMap Map file handle. 301 404 * @param pszSectionNm The expected section name. 302 405 * @param cColumns The number of columns. 303 406 * @param ... The column names. 304 407 */ 305 static RTEXITCODE SkipThruColumnHeadings(const char *pszBiosMap, PRTSTREAM hStrm, uint32_t *piLine, 306 const char *pszSectionNm, uint32_t cColumns, ...) 307 { 308 char szLine[16384]; 309 if (!SkipEmptyLines(hStrm, piLine, szLine, sizeof(szLine))) 310 return RTEXITCODE_FAILURE; 408 static bool mapSkipThruColumnHeadings(PBIOSMAP pMap, const char *pszSectionNm, uint32_t cColumns, ...) 409 { 410 if ( mapIsEmptyLine(pMap) 411 && !mapSkipEmptyLines(pMap)) 412 return false; 311 413 312 414 /* +------------+ */ 313 char *psz = RTStrStrip(szLine);314 size_t cch = strlen(psz);415 size_t cch; 416 char *psz = mapStripCurrentLine(pMap, &cch); 315 417 if (!psz) 316 return RTEXITCODE_FAILURE;418 return false; 317 419 318 420 if ( psz[0] != '+' … … 325 427 || psz[cch - 1] != '+' 326 428 ) 327 return RTMsgErrorExit(RTEXITCODE_FAILURE, "%s:%d: Expected section box: +-----...", pszBiosMap, *piLine); 429 { 430 RTMsgError("%s:%d: Expected section box: +-----...", pMap->pszMapFile, pMap->iLine); 431 return false; 432 } 328 433 329 434 /* | pszSectionNm | */ 330 psz = ReadMapLineLR(pszBiosMap, hStrm, piLine, szLine, sizeof(szLine), &cch);435 psz = mapReadLineStrip(pMap, &cch); 331 436 if (!psz) 332 return RTEXITCODE_FAILURE;437 return false; 333 438 334 439 size_t cchSectionNm = strlen(pszSectionNm); … … 344 449 || strncmp(&psz[4], pszSectionNm, cchSectionNm) 345 450 ) 346 return RTMsgErrorExit(RTEXITCODE_FAILURE, "%s:%d: Expected section box: | %s |", pszBiosMap, *piLine, pszSectionNm); 451 { 452 RTMsgError("%s:%d: Expected section box: | %s |", pMap->pszMapFile, pMap->iLine, pszSectionNm); 453 return false; 454 } 347 455 348 456 /* +------------+ */ 349 psz = ReadMapLineLR(pszBiosMap, hStrm, piLine, szLine, sizeof(szLine), &cch);457 psz = mapReadLineStrip(pMap, &cch); 350 458 if (!psz) 351 return RTEXITCODE_FAILURE;459 return false; 352 460 if ( psz[0] != '+' 353 461 || psz[1] != '-' … … 359 467 || psz[cch - 1] != '+' 360 468 ) 361 return RTMsgErrorExit(RTEXITCODE_FAILURE, "%s:%d: Expected section box: +-----...", p szBiosMap, *piLine);469 return RTMsgErrorExit(RTEXITCODE_FAILURE, "%s:%d: Expected section box: +-----...", pMap->pszMapFile, pMap->iLine); 362 470 363 471 /* There may be a few lines describing the table notation now, surrounded by blank lines. */ 364 472 do 365 473 { 366 psz = ReadMapLineR(pszBiosMap, hStrm, piLine, szLine, sizeof(szLine), &cch);474 psz = mapReadLineStripRight(pMap, &cch); 367 475 if (!psz) 368 return RTEXITCODE_FAILURE;476 return false; 369 477 } while ( *psz == '\0' 370 478 || ( !RT_C_IS_SPACE(psz[0]) … … 386 494 { 387 495 va_end(va); 388 return RTMsgErrorExit(RTEXITCODE_FAILURE, "%s:%d: Expected column '%s' found '%s'",389 pszBiosMap, *piLine, pszColumn, psz);496 RTMsgError("%s:%d: Expected column '%s' found '%s'", pMap->pszMapFile, pMap->iLine, pszColumn, psz); 497 return false; 390 498 } 391 499 psz += cchColumn; … … 396 504 397 505 /* The next line is the underlining. */ 398 psz = ReadMapLineR(pszBiosMap, hStrm, piLine, szLine, sizeof(szLine), &cch);506 psz = mapReadLineStripRight(pMap, &cch); 399 507 if (!psz) 400 return RTEXITCODE_FAILURE;508 return false; 401 509 if (*psz != '=' || psz[cch - 1] != '=') 402 return RTMsgErrorExit(RTEXITCODE_FAILURE, "%s:%d: Expected column header underlining", pszBiosMap, *piLine); 510 { 511 RTMsgError("%s:%d: Expected column header underlining", pMap->pszMapFile, pMap->iLine); 512 return false; 513 } 403 514 404 515 /* Skip one blank line. */ 405 psz = ReadMapLineR(pszBiosMap, hStrm, piLine, szLine, sizeof(szLine), &cch);516 psz = mapReadLineStripRight(pMap, &cch); 406 517 if (!psz) 407 return RTEXITCODE_FAILURE;518 return false; 408 519 if (*psz) 409 return RTMsgErrorExit(RTEXITCODE_FAILURE, "%s:%d: Expected blank line beneath the column headers", pszBiosMap, *piLine); 410 411 return RTEXITCODE_SUCCESS; 412 } 413 414 415 416 static RTEXITCODE ParseMapFileSegments(const char *pszBiosMap, PRTSTREAM hStrm, uint32_t *piLine) 520 { 521 RTMsgError("%s:%d: Expected blank line beneath the column headers", pMap->pszMapFile, pMap->iLine); 522 return false; 523 } 524 525 return true; 526 } 527 528 529 /** 530 * Parses a segment list. 531 * 532 * @returns @c true on success, @c false + msg on failure, @c false on eof. 533 * @param pMap The map file handle. 534 */ 535 static bool mapParseSegments(PBIOSMAP pMap) 417 536 { 418 537 for (;;) 419 538 { 420 /* Read the next line and right strip it. */ 421 char szLine[16384]; 422 int rc = RTStrmGetLine(hStrm, szLine, sizeof(szLine)); 423 if (RT_FAILURE(rc)) 424 return RTMsgErrorExit(RTEXITCODE_FAILURE, "%s:%u: Read error: %Rrc", pszBiosMap, *piLine, rc); 425 426 *piLine += 1; 427 RTStrStripR(szLine); 539 if (!mapReadLineStripRight(pMap, NULL)) 540 return false; 428 541 429 542 /* The end? The line should be empty. Expectes segment name to not 430 543 start with a space. */ 431 if (! szLine[0] || RT_C_IS_SPACE(szLine[0]))544 if (!pMap->szLine[0] || RT_C_IS_SPACE(pMap->szLine[0])) 432 545 { 433 if (szLine[0]) 434 return RTMsgErrorExit(RTEXITCODE_FAILURE, "%s:%u: Malformed segment line", pszBiosMap, *piLine); 435 return RTEXITCODE_SUCCESS; 546 if (!pMap->szLine[0]) 547 return true; 548 RTMsgError("%s:%u: Malformed segment line", pMap->pszMapFile, pMap->iLine); 549 return false; 436 550 } 437 551 … … 439 553 uint32_t iSeg = g_cSegs; 440 554 if (iSeg >= RT_ELEMENTS(g_aSegs)) 441 return RTMsgErrorExit(RTEXITCODE_FAILURE, "%s:%u: Too many segments", pszBiosMap, *piLine); 442 443 char *psz = szLine; 444 if (ParseWord(&psz, g_aSegs[iSeg].szName, sizeof(g_aSegs[iSeg].szName))) 445 return RTMsgErrorExit(RTEXITCODE_FAILURE, "%s:%u: Segment name parser error", pszBiosMap, *piLine); 446 if (ParseWord(&psz, g_aSegs[iSeg].szClass, sizeof(g_aSegs[iSeg].szClass))) 447 return RTMsgErrorExit(RTEXITCODE_FAILURE, "%s:%u: Segment class parser error", pszBiosMap, *piLine); 448 if (ParseWord(&psz, g_aSegs[iSeg].szGroup, sizeof(g_aSegs[iSeg].szGroup))) 449 return RTMsgErrorExit(RTEXITCODE_FAILURE, "%s:%u: Segment group parser error", pszBiosMap, *piLine); 450 if (ParseAddress(&psz, &g_aSegs[iSeg].Address)) 451 return RTMsgErrorExit(RTEXITCODE_FAILURE, "%s:%u: Segment address parser error", pszBiosMap, *piLine); 452 if (ParseSize(&psz, &g_aSegs[iSeg].cb)) 453 return RTMsgErrorExit(RTEXITCODE_FAILURE, "%s:%u: Segment size parser error", pszBiosMap, *piLine); 454 455 g_cSegs++; 456 457 while (RT_C_IS_SPACE(*psz)) 458 psz++; 459 if (*psz) 460 return RTMsgErrorExit(RTEXITCODE_FAILURE, "%s:%u: Junk at end of line", pszBiosMap, *piLine); 461 462 } 463 } 464 465 466 static RTEXITCODE ParseMapFileInner(PBIOSMAP pMap) 467 { 468 uint32_t iLine = 1; 469 char szLine[16384]; 555 return RTMsgErrorExit(RTEXITCODE_FAILURE, "%s:%u: Too many segments", pMap->pszMapFile, pMap->iLine); 556 557 char *psz = pMap->szLine; 558 if (!mapParseWord(&psz, g_aSegs[iSeg].szName, sizeof(g_aSegs[iSeg].szName))) 559 RTMsgError("%s:%u: Segment name parser error", pMap->pszMapFile, pMap->iLine); 560 else if (!mapParseWord(&psz, g_aSegs[iSeg].szClass, sizeof(g_aSegs[iSeg].szClass))) 561 RTMsgError("%s:%u: Segment class parser error", pMap->pszMapFile, pMap->iLine); 562 else if (!mapParseWord(&psz, g_aSegs[iSeg].szGroup, sizeof(g_aSegs[iSeg].szGroup))) 563 RTMsgError("%s:%u: Segment group parser error", pMap->pszMapFile, pMap->iLine); 564 else if (!mapParseAddress(&psz, &g_aSegs[iSeg].Address)) 565 RTMsgError("%s:%u: Segment address parser error", pMap->pszMapFile, pMap->iLine); 566 else if (!mapParseSize(&psz, &g_aSegs[iSeg].cb)) 567 RTMsgError("%s:%u: Segment size parser error", pMap->pszMapFile, pMap->iLine); 568 else 569 { 570 g_aSegs[iSeg].uFlatAddr = ((uint32_t)g_aSegs[iSeg].Address.sel << 4) + g_aSegs[iSeg].Address.off; 571 g_cSegs++; 572 if (g_cVerbose > 2) 573 RTStrmPrintf(g_pStdErr, "read segment at %08x / %04x:%04x LB %04x %s / %s / %s\n", 574 g_aSegs[iSeg].uFlatAddr, 575 g_aSegs[iSeg].Address.sel, 576 g_aSegs[iSeg].Address.off, 577 g_aSegs[iSeg].cb, 578 g_aSegs[iSeg].szName, 579 g_aSegs[iSeg].szClass, 580 g_aSegs[iSeg].szGroup); 581 582 while (RT_C_IS_SPACE(*psz)) 583 psz++; 584 if (!*psz) 585 continue; 586 RTMsgError("%s:%u: Junk at end of line", pMap->pszMapFile, pMap->iLine); 587 } 588 return false; 589 } 590 } 591 592 593 /** 594 * Sorts the segment array by flat address. 595 */ 596 static void mapSortSegments(void) 597 { 598 for (uint32_t i = 0; i < g_cSegs - 1; i++) 599 { 600 for (uint32_t j = i + 1; j < g_cSegs; j++) 601 if (g_aSegs[j].uFlatAddr < g_aSegs[i].uFlatAddr) 602 { 603 BIOSSEG Tmp = g_aSegs[i]; 604 g_aSegs[i] = g_aSegs[j]; 605 g_aSegs[j] = Tmp; 606 } 607 if (g_cVerbose > 0) 608 RTStrmPrintf(g_pStdErr, "segment at %08x / %04x:%04x LB %04x %s / %s / %s\n", 609 g_aSegs[i].uFlatAddr, 610 g_aSegs[i].Address.sel, 611 g_aSegs[i].Address.off, 612 g_aSegs[i].cb, 613 g_aSegs[i].szName, 614 g_aSegs[i].szClass, 615 g_aSegs[i].szGroup); 616 } 617 } 618 619 620 621 /** 622 * Parses the given map file. 623 * 624 * @returns RTEXITCODE_SUCCESS and lots of globals, or RTEXITCODE_FAILURE and a 625 * error message. 626 * @param pMap The map file handle. 627 */ 628 static RTEXITCODE mapParseFile(PBIOSMAP pMap) 629 { 470 630 const char *psz; 471 PRTSTREAM hStrm = pMap->hStrm; /** @todo rewrite the rest. */472 const char *pszBiosMap = pMap->pszMapFile; /** @todo rewrite the rest. */473 631 474 632 /* 475 633 * Read the header. 476 634 */ 477 int rc = RTStrmGetLine(hStrm, szLine, sizeof(szLine)); 478 if (RT_FAILURE(rc)) 479 return RTMsgErrorExit(RTEXITCODE_FAILURE, "Error reading map-file header: %Rrc", rc); 480 if (strncmp(szLine, RT_STR_TUPLE("Open Watcom Linker Version"))) 481 return RTMsgErrorExit(RTEXITCODE_FAILURE, "Unexpected map-file header: '%s'", szLine); 482 if ( !SkipNonEmptyLines(hStrm, &iLine, szLine, sizeof(szLine)) 483 || !SkipEmptyLines(hStrm, &iLine, szLine, sizeof(szLine)) ) 635 if (!mapReadLine(pMap)) 636 return RTEXITCODE_FAILURE; 637 if (strncmp(pMap->szLine, RT_STR_TUPLE("Open Watcom Linker Version"))) 638 return RTMsgErrorExit(RTEXITCODE_FAILURE, "Unexpected map-file header: '%s'", pMap->szLine); 639 if ( !mapSkipNonEmptyLines(pMap) 640 || !mapSkipEmptyLines(pMap)) 484 641 return RTEXITCODE_FAILURE; 485 642 … … 487 644 * Skip groups. 488 645 */ 489 if ( SkipThruColumnHeadings(pszBiosMap, hStrm, &iLine, "Groups", 3, "Group", "Address", "Size", NULL) != RTEXITCODE_SUCCESS)646 if (!mapSkipThruColumnHeadings(pMap, "Groups", 3, "Group", "Address", "Size", NULL)) 490 647 return RTEXITCODE_FAILURE; 491 if (! SkipNonEmptyLines(hStrm, &iLine, szLine, sizeof(szLine)))648 if (!mapSkipNonEmptyLines(pMap)) 492 649 return RTEXITCODE_FAILURE; 493 650 … … 495 652 * Parse segments. 496 653 */ 497 if ( SkipThruColumnHeadings(pszBiosMap, hStrm, &iLine, "Segments", 5, "Segment", "Class", "Group", "Address", "Size") 498 != RTEXITCODE_SUCCESS) 654 if (!mapSkipThruColumnHeadings(pMap, "Segments", 5, "Segment", "Class", "Group", "Address", "Size")) 499 655 return RTEXITCODE_FAILURE; 500 501 if (RT_FAILURE(rc)) 502 return RTMsgErrorExit(RTEXITCODE_FAILURE, "Error reading map-file group: %Rrc", rc); 503 504 505 506 507 508 return RTMsgErrorExit(RTEXITCODE_FAILURE, "ParseMapFileInner is not fully implemented"); 656 if (!mapParseSegments(pMap)) 657 return RTEXITCODE_FAILURE; 658 mapSortSegments(); 659 660 661 return RTMsgErrorExit(RTEXITCODE_FAILURE, "mapParseFile is not fully implemented"); 509 662 } 510 663 … … 524 677 Map.hStrm = NULL; 525 678 Map.iLine = 0; 679 Map.fEof = false; 526 680 Map.cch = 0; 527 681 Map.offNW = 0; 528 int rc = RTStrmOpen(pszBiosMap, "r t", &Map.hStrm);682 int rc = RTStrmOpen(pszBiosMap, "r", &Map.hStrm); 529 683 if (RT_FAILURE(rc)) 530 684 return RTMsgErrorExit(RTEXITCODE_FAILURE, "Error opening '%s': %Rrc", pszBiosMap, rc); 531 RTEXITCODE rcExit = ParseMapFileInner(&Map);685 RTEXITCODE rcExit = mapParseFile(&Map); 532 686 RTStrmClose(Map.hStrm); 533 687 return rcExit; … … 609 763 610 764 case 's': 611 if (pszBios Map)765 if (pszBiosSym) 612 766 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "--bios-sym is given more than once"); 613 pszBios Map= ValueUnion.psz;767 pszBiosSym = ValueUnion.psz; 614 768 break; 615 769
Note:
See TracChangeset
for help on using the changeset viewer.