- Timestamp:
- Mar 4, 2016 2:01:54 PM (9 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/include/ParallelPortImpl.h
r57979 r59926 6 6 7 7 /* 8 * Copyright (C) 2006-201 3Oracle Corporation8 * Copyright (C) 2006-2016 Oracle Corporation 9 9 * 10 10 * This file is part of VirtualBox Open Source Edition (OSE), as … … 38 38 39 39 // public initializer/uninitializer for internal purposes only 40 HRESULT init 41 HRESULT init 42 HRESULT initCopy 40 HRESULT init(Machine *aParent, ULONG aSlot); 41 HRESULT init(Machine *aParent, ParallelPort *aThat); 42 HRESULT initCopy(Machine *parent, ParallelPort *aThat); 43 43 void uninit(); 44 44 … … 52 52 void i_copyFrom(ParallelPort *aThat); 53 53 void i_applyDefaults(); 54 bool i_hasDefaults(); 54 55 55 56 private: -
trunk/src/VBox/Main/include/SerialPortImpl.h
r49644 r59926 7 7 8 8 /* 9 * Copyright (C) 2006-201 3Oracle Corporation9 * Copyright (C) 2006-2016 Oracle Corporation 10 10 * 11 11 * This file is part of VirtualBox Open Source Edition (OSE), as … … 41 41 42 42 // public initializer/uninitializer for internal purposes only 43 HRESULT init 44 HRESULT init 45 HRESULT initCopy 43 HRESULT init(Machine *aParent, ULONG aSlot); 44 HRESULT init(Machine *aParent, SerialPort *aThat); 45 HRESULT initCopy(Machine *parent, SerialPort *aThat); 46 46 void uninit(); 47 47 … … 55 55 void i_copyFrom(SerialPort *aThat); 56 56 57 void i_applyDefaults (GuestOSType *aOsType); 57 void i_applyDefaults(GuestOSType *aOsType); 58 bool i_hasDefaults(); 58 59 59 60 // public methods for internal purposes only … … 79 80 HRESULT setPath(const com::Utf8Str &aPath); 80 81 81 //////////////////////////////////////////////////////////////////////////////// 82 //// 83 //// SerialPort private data definition 84 //// 85 ////////////////////////////////////////////////////////////////////////////////// 86 // 87 struct Data 88 { 89 Data() 90 : fModified(false), 91 pMachine(NULL) 92 { } 93 94 bool fModified; 95 Machine * const pMachine; 96 const ComObjPtr<SerialPort> pPeer; 97 Backupable<settings::SerialPort> bd; 98 }; 99 82 struct Data; 100 83 Data *m; 101 84 }; -
trunk/src/VBox/Main/src-server/MachineImpl.cpp
r59464 r59926 10305 10305 for (ULONG slot = 0; slot < RT_ELEMENTS(mSerialPorts); ++slot) 10306 10306 { 10307 if (mSerialPorts[slot]->i_hasDefaults()) 10308 continue; 10309 10307 10310 settings::SerialPort s; 10308 10311 s.ulSlot = slot; … … 10317 10320 for (ULONG slot = 0; slot < RT_ELEMENTS(mParallelPorts); ++slot) 10318 10321 { 10322 if (mParallelPorts[slot]->i_hasDefaults()) 10323 continue; 10324 10319 10325 settings::ParallelPort p; 10320 10326 p.ulSlot = slot; -
trunk/src/VBox/Main/src-server/ParallelPortImpl.cpp
r57979 r59926 5 5 6 6 /* 7 * Copyright (C) 2006-201 5Oracle Corporation7 * Copyright (C) 2006-2016 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 124 124 unconst(m->pPeer) = aThat; 125 125 126 AutoCaller thatCaller 126 AutoCaller thatCaller(aThat); 127 127 AssertComRCReturnRC(thatCaller.rc()); 128 128 … … 442 442 /* sanity */ 443 443 AutoCaller autoCaller(this); 444 AssertComRCReturnVoid 444 AssertComRCReturnVoid(autoCaller.rc()); 445 445 446 446 /* sanity too */ 447 AutoCaller peerCaller 448 AssertComRCReturnVoid 447 AutoCaller peerCaller(m->pPeer); 448 AssertComRCReturnVoid(peerCaller.rc()); 449 449 450 450 /* lock both for writing since we modify both (m->pPeer is "master" so locked … … 469 469 void ParallelPort::i_copyFrom(ParallelPort *aThat) 470 470 { 471 AssertReturnVoid 471 AssertReturnVoid(aThat != NULL); 472 472 473 473 /* sanity */ 474 474 AutoCaller autoCaller(this); 475 AssertComRCReturnVoid 475 AssertComRCReturnVoid(autoCaller.rc()); 476 476 477 477 /* sanity too */ 478 AutoCaller thatCaller 479 AssertComRCReturnVoid 478 AutoCaller thatCaller(aThat); 479 AssertComRCReturnVoid(thatCaller.rc()); 480 480 481 481 /* peer is not modified, lock it for reading (aThat is "master" so locked … … 495 495 /* sanity */ 496 496 AutoCaller autoCaller(this); 497 AssertComRCReturnVoid 497 AssertComRCReturnVoid(autoCaller.rc()); 498 498 499 499 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); … … 514 514 break; 515 515 } 516 default: break; 517 } 516 default: 517 AssertMsgFailed(("Parallel port slot %u exceeds limit\n", m->bd->ulSlot)); 518 break; 519 } 520 } 521 522 bool ParallelPort::i_hasDefaults() 523 { 524 /* sanity */ 525 AutoCaller autoCaller(this); 526 AssertComRCReturn(autoCaller.rc(), true); 527 528 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 529 530 if (!m->bd->fEnabled) 531 { 532 /* Could be default, check the IO base and IRQ. */ 533 switch (m->bd->ulSlot) 534 { 535 case 0: 536 if (m->bd->ulIOBase == 0x378 && m->bd->ulIRQ == 7) 537 return true; 538 break; 539 case 1: 540 if (m->bd->ulIOBase == 0x278 && m->bd->ulIRQ == 5) 541 return true; 542 break; 543 default: 544 AssertMsgFailed(("Parallel port slot %u exceeds limit\n", m->bd->ulSlot)); 545 break; 546 } 547 548 /* Detect old-style defaults (0x378, irq 4) in any slot, they are still 549 * in place for many VMs created by old VirtualBox versions. */ 550 if (m->bd->ulIOBase == 0x378 && m->bd->ulIRQ == 4) 551 return true; 552 } 553 554 return false; 518 555 } 519 556 -
trunk/src/VBox/Main/src-server/SerialPortImpl.cpp
r55401 r59926 6 6 7 7 /* 8 * Copyright (C) 2006-201 5Oracle Corporation8 * Copyright (C) 2006-2016 Oracle Corporation 9 9 * 10 10 * This file is part of VirtualBox Open Source Edition (OSE), as … … 22 22 #include "GuestOSTypeImpl.h" 23 23 24 #include <iprt/assert.h> 24 25 #include <iprt/string.h> 25 26 #include <iprt/cpp/utils.h> … … 31 32 #include "Logging.h" 32 33 34 ////////////////////////////////////////////////////////////////////////////////// 35 // 36 // SerialPort private data definition 37 // 38 ////////////////////////////////////////////////////////////////////////////////// 39 40 struct SerialPort::Data 41 { 42 Data() 43 : fModified(false), 44 pMachine(NULL) 45 { } 46 47 bool fModified; 48 Machine * const pMachine; 49 const ComObjPtr<SerialPort> pPeer; 50 Backupable<settings::SerialPort> bd; 51 }; 52 33 53 // constructor / destructor 34 54 ///////////////////////////////////////////////////////////////////////////// 35 55 36 DEFINE_EMPTY_CTOR_DTOR 56 DEFINE_EMPTY_CTOR_DTOR(SerialPort) 37 57 38 58 HRESULT SerialPort::FinalConstruct() … … 106 126 unconst(m->pPeer) = aThat; 107 127 108 AutoCaller thatCaller 128 AutoCaller thatCaller(aThat); 109 129 AssertComRCReturnRC(thatCaller.rc()); 110 130 111 131 AutoReadLock thatLock(aThat COMMA_LOCKVAL_SRC_POS); 112 m->bd.share 132 m->bd.share(aThat->m->bd); 113 133 114 134 /* Confirm a successful initialization */ … … 140 160 /* pPeer is left null */ 141 161 142 AutoCaller thatCaller 162 AutoCaller thatCaller(aThat); 143 163 AssertComRCReturnRC(thatCaller.rc()); 144 164 145 165 AutoReadLock thatLock(aThat COMMA_LOCKVAL_SRC_POS); 146 m->bd.attachCopy 166 m->bd.attachCopy(aThat->m->bd); 147 167 148 168 /* Confirm a successful initialization */ … … 545 565 /* sanity */ 546 566 AutoCaller autoCaller(this); 547 AssertComRCReturnVoid 567 AssertComRCReturnVoid(autoCaller.rc()); 548 568 549 569 /* sanity too */ … … 570 590 * represented by @a aThat (locked for reading). 571 591 */ 572 void SerialPort::i_copyFrom 573 { 574 AssertReturnVoid 592 void SerialPort::i_copyFrom(SerialPort *aThat) 593 { 594 AssertReturnVoid(aThat != NULL); 575 595 576 596 /* sanity */ 577 597 AutoCaller autoCaller(this); 578 AssertComRCReturnVoid 598 AssertComRCReturnVoid(autoCaller.rc()); 579 599 580 600 /* sanity too */ 581 AutoCaller thatCaller 582 AssertComRCReturnVoid 601 AutoCaller thatCaller(aThat); 602 AssertComRCReturnVoid(thatCaller.rc()); 583 603 584 604 /* peer is not modified, lock it for reading (aThat is "master" so locked … … 588 608 589 609 /* this will back up current data */ 590 m->bd.assignCopy 591 } 592 593 void SerialPort::i_applyDefaults 594 { 595 AssertReturnVoid 610 m->bd.assignCopy(aThat->m->bd); 611 } 612 613 void SerialPort::i_applyDefaults(GuestOSType *aOsType) 614 { 615 AssertReturnVoid(aOsType != NULL); 596 616 597 617 /* sanity */ 598 618 AutoCaller autoCaller(this); 599 AssertComRCReturnVoid 619 AssertComRCReturnVoid(autoCaller.rc()); 600 620 601 621 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); … … 608 628 case 1: 609 629 { 610 m->bd->ulIOBase = 0x2 F8;630 m->bd->ulIOBase = 0x2f8; 611 631 m->bd->ulIRQ = 3; 612 632 break; … … 624 644 break; 625 645 } 626 default: break; 646 default: 647 AssertMsgFailed(("Serial port slot %u exceeds limit\n", m->bd->ulSlot)); 648 break; 627 649 } 628 650 … … 634 656 m->bd->fEnabled = true; 635 657 } 658 } 659 660 bool SerialPort::i_hasDefaults() 661 { 662 /* sanity */ 663 AutoCaller autoCaller(this); 664 AssertComRCReturn(autoCaller.rc(), true); 665 666 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 667 668 if ( !m->bd->fEnabled 669 && m->bd->portMode == PortMode_Disconnected 670 && !m->bd->fServer) 671 { 672 /* Could be default, check the IO base and IRQ. */ 673 switch (m->bd->ulSlot) 674 { 675 case 0: 676 if (m->bd->ulIOBase == 0x3f8 && m->bd->ulIRQ == 4) 677 return true; 678 break; 679 case 1: 680 if (m->bd->ulIOBase == 0x2f8 && m->bd->ulIRQ == 3) 681 return true; 682 break; 683 case 2: 684 if (m->bd->ulIOBase == 0x3e8 && m->bd->ulIRQ == 4) 685 return true; 686 break; 687 case 3: 688 if (m->bd->ulIOBase == 0x2e8 && m->bd->ulIRQ == 3) 689 return true; 690 break; 691 default: 692 AssertMsgFailed(("Serial port slot %u exceeds limit\n", m->bd->ulSlot)); 693 break; 694 } 695 696 /* Detect old-style defaults (0x3f8, irq 4) in any slot, they are still 697 * in place for many VMs created by old VirtualBox versions. */ 698 if (m->bd->ulIOBase == 0x3f8 && m->bd->ulIRQ == 4) 699 return true; 700 } 701 702 return false; 636 703 } 637 704
Note:
See TracChangeset
for help on using the changeset viewer.