Changeset 24042 in vbox for trunk/src/VBox/Devices
- Timestamp:
- Oct 23, 2009 3:00:46 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Serial/DevSerial.cpp
r23160 r24042 589 589 590 590 /** 591 * Saves a state of the serial port device. 592 * 593 * @returns VBox status code. 594 * @param pDevIns The device instance. 595 * @param pSSMHandle The handle to save the state to. 591 * @copydoc FNSSMDEVLIVEEXEC 592 */ 593 static DECLCALLBACK(int) serialLiveExec(PPDMDEVINS pDevIns, 594 PSSMHANDLE pSSM, 595 uint32_t uPass) 596 { 597 SerialState *pThis = PDMINS_2_DATA(pDevIns, SerialState *); 598 SSMR3PutS32(pSSM, pThis->irq); 599 SSMR3PutU32(pSSM, pThis->base); 600 return VINF_SSM_DONT_CALL_AGAIN; 601 } 602 603 /** 604 * @copydoc FNSSMDEVSAVEEXEC 596 605 */ 597 606 static DECLCALLBACK(int) serialSaveExec(PPDMDEVINS pDevIns, 598 PSSMHANDLE pSSM Handle)607 PSSMHANDLE pSSM) 599 608 { 600 609 SerialState *pThis = PDMINS_2_DATA(pDevIns, SerialState *); 601 610 602 SSMR3PutU16(pSSM Handle, pThis->divider);603 SSMR3PutU8(pSSM Handle, pThis->rbr);604 SSMR3PutU8(pSSM Handle, pThis->ier);605 SSMR3PutU8(pSSM Handle, pThis->lcr);606 SSMR3PutU8(pSSM Handle, pThis->mcr);607 SSMR3PutU8(pSSM Handle, pThis->lsr);608 SSMR3PutU8(pSSM Handle, pThis->msr);609 SSMR3PutU8(pSSM Handle, pThis->scr);610 SSMR3PutS32(pSSM Handle, pThis->thr_ipending);611 SSMR3PutS32(pSSM Handle, pThis->irq);612 SSMR3PutS32(pSSM Handle, pThis->last_break_enable);613 SSMR3PutU32(pSSM Handle, pThis->base);614 SSMR3PutBool(pSSM Handle, pThis->msr_changed);615 return SSMR3PutU32(pSSM Handle, ~0); /* sanity/terminator */611 SSMR3PutU16(pSSM, pThis->divider); 612 SSMR3PutU8(pSSM, pThis->rbr); 613 SSMR3PutU8(pSSM, pThis->ier); 614 SSMR3PutU8(pSSM, pThis->lcr); 615 SSMR3PutU8(pSSM, pThis->mcr); 616 SSMR3PutU8(pSSM, pThis->lsr); 617 SSMR3PutU8(pSSM, pThis->msr); 618 SSMR3PutU8(pSSM, pThis->scr); 619 SSMR3PutS32(pSSM, pThis->thr_ipending); 620 SSMR3PutS32(pSSM, pThis->irq); 621 SSMR3PutS32(pSSM, pThis->last_break_enable); 622 SSMR3PutU32(pSSM, pThis->base); 623 SSMR3PutBool(pSSM, pThis->msr_changed); 624 return SSMR3PutU32(pSSM, ~0); /* sanity/terminator */ 616 625 } 617 626 618 627 /** 619 * Loads a saved serial port device state. 620 * 621 * @returns VBox status code. 622 * @param pDevIns The device instance. 623 * @param pSSMHandle The handle to the saved state. 624 * @param uVersion The data unit version number. 625 * @param uPass The data pass. 628 * @copydoc FNSSMDEVLOADEXEC 626 629 */ 627 630 static DECLCALLBACK(int) serialLoadExec(PPDMDEVINS pDevIns, 628 PSSMHANDLE pSSM Handle,631 PSSMHANDLE pSSM, 629 632 uint32_t uVersion, 630 633 uint32_t uPass) … … 632 635 SerialState *pThis = PDMINS_2_DATA(pDevIns, SerialState *); 633 636 634 Assert(uPass == SSM_PASS_FINAL); NOREF(uPass);635 637 AssertMsgReturn(uVersion == SERIAL_SAVED_STATE_VERSION, ("%d\n", uVersion), VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION); 636 638 637 SSMR3GetU16(pSSMHandle, &pThis->divider); 638 SSMR3GetU8(pSSMHandle, &pThis->rbr); 639 SSMR3GetU8(pSSMHandle, &pThis->ier); 640 SSMR3GetU8(pSSMHandle, &pThis->lcr); 641 SSMR3GetU8(pSSMHandle, &pThis->mcr); 642 SSMR3GetU8(pSSMHandle, &pThis->lsr); 643 SSMR3GetU8(pSSMHandle, &pThis->msr); 644 SSMR3GetU8(pSSMHandle, &pThis->scr); 645 SSMR3GetS32(pSSMHandle, &pThis->thr_ipending); 646 SSMR3GetS32(pSSMHandle, &pThis->irq); 647 SSMR3GetS32(pSSMHandle, &pThis->last_break_enable); 648 SSMR3GetU32(pSSMHandle, &pThis->base); 649 SSMR3GetBool(pSSMHandle, &pThis->msr_changed); 650 651 uint32_t u32; 652 int rc = SSMR3GetU32(pSSMHandle, &u32); 653 if (RT_FAILURE(rc)) 654 return rc; 655 AssertMsgReturn(u32 == ~0U, ("%#x\n", u32), VERR_SSM_DATA_UNIT_FORMAT_CHANGED); 656 657 if (pThis->lsr & UART_LSR_DR) 658 { 659 int rc = RTSemEventSignal(pThis->ReceiveSem); 660 AssertRC(rc); 661 } 662 663 /* this isn't strictly necessary but cannot hurt... */ 664 pThis->pDevInsR3 = pDevIns; 665 pThis->pDevInsR0 = PDMDEVINS_2_R0PTR(pDevIns); 666 pThis->pDevInsRC = PDMDEVINS_2_RCPTR(pDevIns); 639 if (uPass == SSM_PASS_FINAL) 640 { 641 SSMR3GetU16(pSSM, &pThis->divider); 642 SSMR3GetU8(pSSM, &pThis->rbr); 643 SSMR3GetU8(pSSM, &pThis->ier); 644 SSMR3GetU8(pSSM, &pThis->lcr); 645 SSMR3GetU8(pSSM, &pThis->mcr); 646 SSMR3GetU8(pSSM, &pThis->lsr); 647 SSMR3GetU8(pSSM, &pThis->msr); 648 SSMR3GetU8(pSSM, &pThis->scr); 649 SSMR3GetS32(pSSM, &pThis->thr_ipending); 650 } 651 652 int32_t iIrq; 653 SSMR3GetS32(pSSM, &iIrq); 654 655 if (uPass == SSM_PASS_FINAL) 656 SSMR3GetS32(pSSM, &pThis->last_break_enable); 657 658 uint32_t IOBase; 659 int rc = SSMR3GetU32(pSSM, &IOBase); 660 AssertRCReturn(rc, rc); 661 662 if ( pThis->irq != iIrq 663 || pThis->base != IOBase) 664 { 665 LogRel(("Serial#%u: Config mismatch - saved irq=%#x iobase=%#x; configured irq=%#x iobase=%#x\n", 666 pDevIns->iInstance, iIrq, IOBase, pThis->irq, pThis->base)); 667 return VERR_SSM_LOAD_CONFIG_MISMATCH; 668 } 669 670 if (uPass == SSM_PASS_FINAL) 671 { 672 SSMR3GetBool(pSSM, &pThis->msr_changed); 673 674 uint32_t u32; 675 rc = SSMR3GetU32(pSSM, &u32); 676 if (RT_FAILURE(rc)) 677 return rc; 678 AssertMsgReturn(u32 == ~0U, ("%#x\n", u32), VERR_SSM_DATA_UNIT_FORMAT_CHANGED); 679 680 if (pThis->lsr & UART_LSR_DR) 681 { 682 rc = RTSemEventSignal(pThis->ReceiveSem); 683 AssertRC(rc); 684 } 685 686 /* this isn't strictly necessary but cannot hurt... */ 687 pThis->pDevInsR3 = pDevIns; 688 pThis->pDevInsR0 = PDMDEVINS_2_R0PTR(pDevIns); 689 pThis->pDevInsRC = PDMDEVINS_2_RCPTR(pDevIns); 690 } 691 667 692 return VINF_SUCCESS; 668 693 } … … 898 923 899 924 if (pThis->fGCEnabled) 925 { 900 926 rc = PDMDevHlpIOPortRegisterGC(pDevIns, io_base, 8, 0, "serialIOPortWrite", 901 927 "serialIOPortRead", NULL, NULL, "Serial"); 928 if (RT_FAILURE(rc)) 929 return rc; 930 } 931 902 932 903 933 if (pThis->fR0Enabled) 934 { 904 935 rc = PDMDevHlpIOPortRegisterR0(pDevIns, io_base, 8, 0, "serialIOPortWrite", 905 936 "serialIOPortRead", NULL, NULL, "Serial"); 937 if (RT_FAILURE(rc)) 938 return rc; 939 } 906 940 #endif /* !VBOX_SERIAL_PCI */ 907 941 … … 909 943 * Saved state. 910 944 */ 911 rc = PDMDevHlpSSMRegister(pDevIns, SERIAL_SAVED_STATE_VERSION, sizeof (*pThis), serialSaveExec, serialLoadExec); 945 rc = PDMDevHlpSSMRegister3(pDevIns, SERIAL_SAVED_STATE_VERSION, sizeof (*pThis), 946 serialLiveExec, serialSaveExec, serialLoadExec); 912 947 if (RT_FAILURE(rc)) 913 948 return rc;
Note:
See TracChangeset
for help on using the changeset viewer.