Changeset 4197 in vbox for trunk/src/VBox/VMM
- Timestamp:
- Aug 16, 2007 10:56:10 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/testcase/tstAnimate.cpp
r4071 r4197 26 26 #include <VBox/pgm.h> 27 27 #include <VBox/rem.h> 28 #include <VBox/ssm.h> 28 29 #include <VBox/dbgf.h> 29 30 #include <VBox/err.h> 31 #include <VBox/pdmifs.h> 30 32 #include <VBox/param.h> 31 33 #include <VBox/log.h> … … 322 324 int rc; 323 325 int rcAll = VINF_SUCCESS; 326 bool fIOAPIC = false; 324 327 #define UPDATERC() do { if (VBOX_FAILURE(rc) && VBOX_SUCCESS(rcAll)) rcAll = rc; } while (0) 325 328 … … 412 415 rc = CFGMR3InsertString(pCfg, "HardDiskDevice", "piix3ide"); 413 416 UPDATERC(); 414 rc = CFGMR3InsertString(pCfg, "FloppyDevice", ""); 417 rc = CFGMR3InsertString(pCfg, "FloppyDevice", "i82078"); 418 rc = CFGMR3InsertInteger(pCfg, "IOAPIC", fIOAPIC); UPDATERC(); 415 419 UPDATERC(); 416 420 /* Bios logo. */ … … 425 429 426 430 /* 431 * ACPI 432 */ 433 rc = CFGMR3InsertNode(pDevices, "acpi", &pDev); UPDATERC(); 434 rc = CFGMR3InsertNode(pDev, "0", &pInst); UPDATERC(); 435 rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ UPDATERC(); 436 rc = CFGMR3InsertNode(pInst, "Config", &pCfg); UPDATERC(); 437 rc = CFGMR3InsertInteger(pCfg, "RamSize", cbMem); UPDATERC(); 438 rc = CFGMR3InsertInteger(pCfg, "IOAPIC", fIOAPIC); UPDATERC(); 439 rc = CFGMR3InsertInteger(pInst, "PCIDeviceNo", 7); UPDATERC(); 440 rc = CFGMR3InsertInteger(pInst, "PCIFunctionNo", 0); UPDATERC(); 441 442 /* 443 * DMA 444 */ 445 rc = CFGMR3InsertNode(pDevices, "8237A", &pDev); UPDATERC(); 446 rc = CFGMR3InsertNode(pDev, "0", &pInst); UPDATERC(); 447 rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ UPDATERC(); 448 449 /* 427 450 * PCI bus. 428 451 */ … … 435 458 rc = CFGMR3InsertNode(pInst, "Config", &pCfg); 436 459 UPDATERC(); 460 rc = CFGMR3InsertInteger(pCfg, "IOAPIC", fIOAPIC); UPDATERC(); 437 461 438 462 /* … … 443 467 rc = CFGMR3InsertNode(pDev, "0", &pInst); 444 468 UPDATERC(); 469 rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ UPDATERC(); 445 470 rc = CFGMR3InsertNode(pInst, "Config", &pCfg); 446 471 UPDATERC(); 447 472 448 473 /* 474 * Floppy 475 */ 476 rc = CFGMR3InsertNode(pDevices, "i82078", &pDev); UPDATERC(); 477 rc = CFGMR3InsertNode(pDev, "0", &pInst); UPDATERC(); 478 rc = CFGMR3InsertInteger(pInst, "Trusted", 1); UPDATERC(); 479 rc = CFGMR3InsertNode(pInst, "Config", &pCfg); UPDATERC(); 480 rc = CFGMR3InsertInteger(pCfg, "IRQ", 6); UPDATERC(); 481 rc = CFGMR3InsertInteger(pCfg, "DMA", 2); UPDATERC(); 482 rc = CFGMR3InsertInteger(pCfg, "MemMapped", 0 ); UPDATERC(); 483 rc = CFGMR3InsertInteger(pCfg, "IOBase", 0x3f0); UPDATERC(); 484 485 /* 449 486 * i8254 Programmable Interval Timer And Dummy Speaker 450 487 */ … … 469 506 470 507 /* 508 * APIC. 509 */ 510 rc = CFGMR3InsertNode(pDevices, "apic", &pDev); UPDATERC(); 511 rc = CFGMR3InsertNode(pDev, "0", &pInst); UPDATERC(); 512 rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ UPDATERC(); 513 rc = CFGMR3InsertNode(pInst, "Config", &pCfg); UPDATERC(); 514 rc = CFGMR3InsertInteger(pCfg, "IOAPIC", fIOAPIC); UPDATERC(); 515 516 if (fIOAPIC) 517 { 518 /* 519 * I/O Advanced Programmable Interrupt Controller. 520 */ 521 rc = CFGMR3InsertNode(pDevices, "ioapic", &pDev); UPDATERC(); 522 rc = CFGMR3InsertNode(pDev, "0", &pInst); UPDATERC(); 523 rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ UPDATERC(); 524 rc = CFGMR3InsertNode(pInst, "Config", &pCfg); UPDATERC(); 525 } 526 527 528 /* 471 529 * RTC MC146818. 472 530 */ 473 rc = CFGMR3InsertNode(pDevices, "mc146818", &pDev); 531 rc = CFGMR3InsertNode(pDevices, "mc146818", &pDev); UPDATERC(); 532 rc = CFGMR3InsertNode(pDev, "0", &pInst); UPDATERC(); 533 rc = CFGMR3InsertNode(pInst, "Config", &pCfg); UPDATERC(); 534 535 /* 536 * VGA. 537 */ 538 rc = CFGMR3InsertNode(pDevices, "vga", &pDev); UPDATERC(); 539 rc = CFGMR3InsertNode(pDev, "0", &pInst); UPDATERC(); 540 rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ UPDATERC(); 541 rc = CFGMR3InsertInteger(pInst, "PCIDeviceNo", 2); UPDATERC(); 542 rc = CFGMR3InsertInteger(pInst, "PCIFunctionNo", 0); UPDATERC(); 543 rc = CFGMR3InsertNode(pInst, "Config", &pCfg); UPDATERC(); 544 rc = CFGMR3InsertInteger(pCfg, "VRamSize", 8 * _1M); UPDATERC(); 545 rc = CFGMR3InsertInteger(pCfg, "CustomVideoModes", 0); 546 rc = CFGMR3InsertInteger(pCfg, "HeightReduction", 0); UPDATERC(); 547 //rc = CFGMR3InsertInteger(pCfg, "MonitorCount", 1); UPDATERC(); 548 549 /* 550 * IDE controller. 551 */ 552 rc = CFGMR3InsertNode(pDevices, "piix3ide", &pDev); /* piix3 */ 474 553 UPDATERC(); 475 554 rc = CFGMR3InsertNode(pDev, "0", &pInst); 476 555 UPDATERC(); 477 rc = CFGMR3InsertNode(pInst, "Config", &pCfg);478 UPDATERC();479 480 /*481 * VGA.482 */483 rc = CFGMR3InsertNode(pDevices, "vga", &pDev);484 UPDATERC();485 rc = CFGMR3InsertNode(pDev, "0", &pInst);486 UPDATERC();487 556 rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ 488 557 UPDATERC(); 489 rc = CFGMR3InsertNode(pInst, "Config", &pCfg); 490 UPDATERC(); 491 rc = CFGMR3InsertInteger(pCfg, "VRamSize", 4 * _1M); 492 UPDATERC(); 493 494 /* 495 * IDE controller. 496 */ 497 rc = CFGMR3InsertNode(pDevices, "piix3ide", &pDev); /* piix3 */ 498 UPDATERC(); 499 rc = CFGMR3InsertNode(pDev, "0", &pInst); 500 UPDATERC(); 501 rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ 502 UPDATERC(); 503 rc = CFGMR3InsertNode(pInst, "Config", &pCfg); 504 UPDATERC(); 505 506 558 rc = CFGMR3InsertNode(pInst, "Config", &pCfg); UPDATERC(); 559 rc = CFGMR3InsertInteger(pInst, "PCIDeviceNo", 1); UPDATERC(); 560 rc = CFGMR3InsertInteger(pInst, "PCIFunctionNo", 1); UPDATERC(); 561 562 /* 563 * Network card. 564 */ 565 rc = CFGMR3InsertNode(pDevices, "pcnet", &pDev); UPDATERC(); 566 rc = CFGMR3InsertNode(pDev, "0", &pInst); UPDATERC(); 567 rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ UPDATERC(); 568 rc = CFGMR3InsertInteger(pInst, "PCIDeviceNo", 3); UPDATERC(); 569 rc = CFGMR3InsertInteger(pInst, "PCIFunctionNo", 0); UPDATERC(); 570 rc = CFGMR3InsertNode(pInst, "Config", &pCfg); UPDATERC(); 571 rc = CFGMR3InsertInteger(pCfg, "Am79C973", 1); UPDATERC(); 572 PDMMAC Mac; 573 Mac.au16[0] = 0x0080; 574 Mac.au16[2] = Mac.au16[1] = 0x8086; 575 rc = CFGMR3InsertBytes(pCfg, "MAC", &Mac, sizeof(Mac)); UPDATERC(); 576 577 /* 578 * VMM Device 579 */ 580 rc = CFGMR3InsertNode(pDevices, "VMMDev", &pDev); UPDATERC(); 581 rc = CFGMR3InsertNode(pDev, "0", &pInst); UPDATERC(); 582 rc = CFGMR3InsertNode(pInst, "Config", &pCfg); UPDATERC(); 583 rc = CFGMR3InsertInteger(pInst, "Trusted", 1); /* boolean */ UPDATERC(); 584 rc = CFGMR3InsertInteger(pInst, "PCIDeviceNo", 4); UPDATERC(); 585 rc = CFGMR3InsertInteger(pInst, "PCIFunctionNo", 0); UPDATERC(); 507 586 508 587 /* … … 516 595 static void syntax(void) 517 596 { 518 RTPrintf("Syntax: tstAnimate <-r <raw-mem-file>> [-o <rawmem offset>] [-s <script file>] [-m <bytes>]\n" 597 RTPrintf("Syntax: tstAnimate < -r <raw-mem-file> | -z <saved-state> > \n" 598 " [-o <rawmem offset>]\n" 599 " [-s <script file>]\n" 600 " [-m <memory size>]\n" 601 " [-p]\n" 519 602 "\n" 520 603 "The script is on the form:\n" … … 526 609 { 527 610 int rcRet = 1; 611 int rc; 528 612 RTR3Init(); 529 613 … … 537 621 } 538 622 623 bool fPowerOn = false; 539 624 uint64_t cbMem = ~0ULL; 625 const char *pszSavedState = NULL; 540 626 const char *pszRawMem = NULL; 541 627 uint64_t offRawMem = 0; … … 563 649 case 'c': 564 650 case 'm': 651 case 'z': 565 652 if (i + 1 < argc) 566 653 break; … … 574 661 case 'r': 575 662 pszRawMem = argv[++i]; 663 break; 664 665 case 'z': 666 pszSavedState = argv[++i]; 576 667 break; 577 668 … … 589 680 case 'm': 590 681 { 591 int rc = RTStrToUInt64Ex(argv[++i], NULL, 0, &cbMem); 682 char *pszNext; 683 int rc = RTStrToUInt64Ex(argv[++i], &pszNext, 0, &cbMem); 592 684 if (VBOX_FAILURE(rc)) 593 685 { 594 RTPrintf("tstAnimate: Syntax error: Invalid offset given to -m.\n"); 686 RTPrintf("tstAnimate: Syntax error: Invalid memory size given to -m.\n"); 687 return 1; 688 } 689 switch (*pszNext) 690 { 691 case 'G': cbMem *= _1G; pszNext++; break; 692 case 'M': cbMem *= _1M; pszNext++; break; 693 case 'K': cbMem *= _1K; pszNext++; break; 694 case '\0': break; 695 default: 696 RTPrintf("tstAnimate: Syntax error: Invalid memory size given to -m.\n"); 697 return 1; 698 } 699 if (*pszNext) 700 { 701 RTPrintf("tstAnimate: Syntax error: Invalid memory size given to -m.\n"); 595 702 return 1; 596 703 } … … 600 707 case 's': 601 708 pszScript = argv[++i]; 709 break; 710 711 case 'p': 712 fPowerOn = true; 602 713 break; 603 714 … … 624 735 * Check that the basic requirements are met. 625 736 */ 626 if (!pszRawMem) 737 if (pszRawMem && pszSavedState) 738 { 739 RTPrintf("tstAnimate: Syntax error: Either -z or -r, not both.\n"); 740 return 1; 741 } 742 if (!pszRawMem && !pszSavedState) 627 743 { 628 744 RTPrintf("tstAnimate: Syntax error: The -r argument is compulsory.\n"); … … 633 749 * Open the files. 634 750 */ 635 RTFILE FileRawMem; 636 int rc = RTFileOpen(&FileRawMem, pszRawMem, RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_WRITE); 637 if (VBOX_FAILURE(rc)) 638 { 639 RTPrintf("tstAnimate: error: Failed to open '%s': %Vrc\n", pszRawMem, rc); 640 return 1; 751 RTFILE FileRawMem = NIL_RTFILE; 752 if (pszRawMem) 753 { 754 rc = RTFileOpen(&FileRawMem, pszRawMem, RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_WRITE); 755 if (VBOX_FAILURE(rc)) 756 { 757 RTPrintf("tstAnimate: error: Failed to open '%s': %Vrc\n", pszRawMem, rc); 758 return 1; 759 } 641 760 } 642 761 RTFILE FileScript = NIL_RTFILE; … … 656 775 if (cbMem == ~0ULL) 657 776 { 658 rc = RTFileGetSize(FileRawMem, &cbMem); 659 AssertReleaseRC(rc); 660 cbMem -= offRawMem; 661 cbMem &= ~(PAGE_SIZE - 1); 777 if (FileRawMem != NIL_RTFILE) 778 { 779 int rc = RTFileGetSize(FileRawMem, &cbMem); 780 AssertReleaseRC(rc); 781 cbMem -= offRawMem; 782 cbMem &= ~(PAGE_SIZE - 1); 783 } 784 else 785 { 786 RTPrintf("tstAnimate: error: too lazy to figure out the memsize in a saved state.\n"); 787 return 1; 788 } 662 789 } 663 790 RTPrintf("tstAnimate: info: cbMem=0x%llx bytes\n", cbMem); 791 792 /* 793 * Open a release log. 794 */ 795 static const char * const s_apszGroups[] = VBOX_LOGGROUP_NAMES; 796 PRTLOGGER pRelLogger; 797 rc = RTLogCreate(&pRelLogger, RTLOGFLAGS_PREFIX_TIME_PROG, "all", "VBOX_RELEASE_LOG", 798 RT_ELEMENTS(s_apszGroups), s_apszGroups, RTLOGDEST_FILE, "./tstAnimate.log"); 799 if (VBOX_SUCCESS(rc)) 800 RTLogRelSetDefaultInstance(pRelLogger); 801 else 802 RTPrintf("tstAnimate: rtLogCreateEx failed - %Vrc\n", rc); 664 803 665 804 /* … … 674 813 */ 675 814 PVMREQ pReq1 = NULL; 676 rc = VMR3ReqCall(pVM, &pReq1, RT_INDEFINITE_WAIT, (PFNRT)loadMem, 3, pVM, FileRawMem, &offRawMem); 815 if (FileRawMem != NIL_RTFILE) 816 rc = VMR3ReqCall(pVM, &pReq1, RT_INDEFINITE_WAIT, (PFNRT)loadMem, 3, pVM, FileRawMem, &offRawMem); 817 else 818 rc = VMR3ReqCall(pVM, &pReq1, RT_INDEFINITE_WAIT, (PFNRT)SSMR3Load, 4, pVM, pszSavedState, SSMAFTER_DEBUG_IT, NULL, NULL); 677 819 AssertReleaseRC(rc); 678 820 rc = pReq1->iStatus; … … 692 834 if (VBOX_SUCCESS(rc)) 693 835 { 694 /* 695 * Start the thing. 696 */ 697 RTPrintf("info: powering on the VM...\n"); 698 RTLogGroupSettings(NULL, "+REM_DISAS.e.l.f"); 699 rc = REMR3DisasEnableStepping(pVM, true); 700 if (VBOX_SUCCESS(rc)) 836 if (fPowerOn) 701 837 { 702 DBGFR3InfoLog(pVM, "cpumguest", "verbose"); 703 rc = VMR3PowerOn(pVM); 838 /* 839 * Start the thing with single stepping and stuff enabled. 840 */ 841 RTPrintf("info: powering on the VM...\n"); 842 RTLogGroupSettings(NULL, "+REM_DISAS.e.l.f"); 843 rc = REMR3DisasEnableStepping(pVM, true); 704 844 if (VBOX_SUCCESS(rc)) 705 845 { 706 RTPrintf("info: VM is running\n"); 707 signal(SIGINT, SigInterrupt); 708 while (!g_fSignaled) 709 RTThreadSleep(1000); 846 DBGFR3InfoLog(pVM, "cpumguest", "verbose"); 847 if (fPowerOn) 848 rc = VMR3PowerOn(pVM); 849 if (VBOX_SUCCESS(rc)) 850 { 851 RTPrintf("info: VM is running\n"); 852 signal(SIGINT, SigInterrupt); 853 while (!g_fSignaled) 854 RTThreadSleep(1000); 855 } 856 else 857 RTPrintf("error: Failed to power on the VM: %Vrc\n", rc); 710 858 } 711 859 else 712 RTPrintf("error: Failed to power on the VM: %Vrc\n", rc);860 RTPrintf("error: Failed to enabled singlestepping: %Vrc\n", rc); 713 861 } 714 862 else 715 RTPrintf("error: Failed to enabled singlestepping: %Vrc\n", rc); 863 { 864 /* 865 * Don't start it, just enter the debugger. 866 */ 867 RTPrintf("info: entering debugger...\n"); 868 DBGFR3InfoLog(pVM, "cpumguest", "verbose"); 869 signal(SIGINT, SigInterrupt); 870 while (!g_fSignaled) 871 RTThreadSleep(1000); 872 } 716 873 RTPrintf("info: shutting down the VM...\n"); 717 874 } 718 875 /* execScript complains */ 719 876 } 720 /* loadMem complains */ 877 else if (FileRawMem == NIL_RTFILE) /* loadMem complains, SSMR3Load doesn't */ 878 RTPrintf("tstAnimate: error: SSMR3Load failed: rc=%Vrc\n", rc); 721 879 rcRet = VBOX_SUCCESS(rc) ? 0 : 1; 722 880 … … 727 885 if (!VBOX_SUCCESS(rc)) 728 886 { 729 RTPrintf("tstAnimate: error: failed to destroy vm! rc=% d\n", rc);887 RTPrintf("tstAnimate: error: failed to destroy vm! rc=%Vrc\n", rc); 730 888 rcRet++; 731 889 } … … 733 891 else 734 892 { 735 RTPrintf("tstAnimate: fatal error: failed to create vm! rc=% d\n", rc);893 RTPrintf("tstAnimate: fatal error: failed to create vm! rc=%Vrc\n", rc); 736 894 rcRet++; 737 895 }
Note:
See TracChangeset
for help on using the changeset viewer.