VirtualBox

Changeset 3494 in vbox


Ignore:
Timestamp:
Jul 6, 2007 9:09:32 PM (18 years ago)
Author:
vboxsync
Message:

added support for serial ports to Main and VBoxManage

Location:
trunk/src/VBox
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManage.cpp

    r3387 r3494  
    336336                 "                            [-hostifdev<1-N> none|<devicename>]\n"
    337337                 "                            [-intnet<1-N> network]\n"
    338                  "                            [-macaddress<1-N> auto|<mac>\n");
     338                 "                            [-macaddress<1-N> auto|<mac>]\n"
     339                 "                            [-uart<1-N> off | <I/O base> <IRQ> server|client\n"
     340                 "                                              <host pipename>\n"
     341                 );
    339342        if (fLinux)
    340343        {
     
    10371040    }
    10381041
     1042    /* get the maximum amount of UARTs */
     1043    ULONG maxUARTs = 0;
     1044    sysProps->COMGETTER(NetworkAdapterCount)(&maxUARTs);
     1045    for (ULONG currentUART = 0; currentUART < maxUARTs; currentUART++)
     1046    {
     1047        ComPtr<ISerialPort> uart;
     1048        rc = machine->GetSerialPort(currentUART, uart.asOutParam());
     1049        if (SUCCEEDED(rc) && uart)
     1050        {
     1051            BOOL fEnabled;
     1052            uart->COMGETTER(Enabled)(&fEnabled);
     1053            if (!fEnabled)
     1054            {
     1055                RTPrintf("UART %d:          disabled\n", currentUART + 1);
     1056            }
     1057            else
     1058            {
     1059                ULONG uIRQ, uIOBase;
     1060                Bstr pipe;
     1061                BOOL fServer;
     1062                uart->COMGETTER(Irq)(&uIRQ);
     1063                uart->COMGETTER(Iobase)(&uIOBase);
     1064                uart->COMGETTER(Pipe)(pipe.asOutParam());
     1065                uart->COMGETTER(Server)(&fServer);
     1066
     1067                RTPrintf("UART %d:          I/O base: 0x%04x, IRQ: %d, %s, pipe '%lS'\n",
     1068                         currentUART + 1, uIOBase, uIRQ, fServer ? "isServer" : "isClient",
     1069                         pipe.raw());
     1070            }
     1071        }
     1072    }
     1073
    10391074    ComPtr<IAudioAdapter> AudioAdapter;
    10401075    rc = machine->COMGETTER(AudioAdapter)(AudioAdapter.asOutParam());
     
    10711106            switch (enmMode)
    10721107            {
    1073                 case  ClipboardMode_ClipDisabled:      psz = "Disabled"; break;
     1108                case  ClipboardMode_ClipDisabled:      psz = "disabled"; break;
    10741109                case  ClipboardMode_ClipHostToGuest:   psz = "HostToGuest"; break;
    10751110                case  ClipboardMode_ClipGuestToHost:   psz = "GuestToHost"; break;
     
    13341369     * Shared folders
    13351370     */
    1336     RTPrintf("Shared folders:\n\n");
     1371    RTPrintf("Shared folders:  ");
    13371372    uint32_t numSharedFolders = 0;
    13381373#if 0 // not yet implemented
     
    13731408            sf->COMGETTER(Name)(name.asOutParam());
    13741409            sf->COMGETTER(HostPath)(hostPath.asOutParam());
     1410            if (!numSharedFolders)
     1411                RTPrintf("\n\n");
    13751412            RTPrintf("Name: '%lS', Host path: '%lS' (machine mapping)\n", name.raw(), hostPath.raw());
    13761413            ++numSharedFolders;
     
    13941431            sf->COMGETTER(Name)(name.asOutParam());
    13951432            sf->COMGETTER(HostPath)(hostPath.asOutParam());
     1433            if (!numSharedFolders)
     1434                RTPrintf("\n\n");
    13961435            RTPrintf("Name: '%lS', Host path: '%lS' (transient mapping)\n", name.raw(), hostPath.raw());
    13971436            ++numSharedFolders;
     
    27012740
    27022741/**
    2703  * Parses a NIC number.
     2742 * Parses a number.
    27042743 *
    2705  * @returns Valid nic number on success.
    2706  * @returns 0 if invalid nic. All necesary bitching has been done.
     2744 * @returns Valid number on success.
     2745 * @returns 0 if invalid number. All necesary bitching has been done.
    27072746 * @param   psz     Pointer to the nic number.
    27082747 */
    2709 static unsigned parseNicNum(const char *psz, unsigned cMaxNics)
     2748static unsigned parseNum(const char *psz, unsigned cMaxNum, const char *name)
    27102749{
    27112750    uint32_t u32;
     
    27152754        &&  *pszNext == '\0'
    27162755        &&  u32 >= 1
    2717         &&  u32 <= cMaxNics)
     2756        &&  u32 <= cMaxNum)
    27182757        return (unsigned)u32;
    2719     errorArgument("Invalid NIC number '%s'", psz);
     2758    errorArgument("Invalid %s number '%s'", name, psz);
    27202759    return 0;
    27212760}
     
    27702809        CHECK_ERROR_RET (info, COMGETTER(NetworkAdapterCount) (&NetworkAdapterCount), 1);
    27712810    }
     2811    ULONG SerialPortCount = 0;
     2812    {
     2813        ComPtr <ISystemProperties> info;
     2814        CHECK_ERROR_RET (virtualBox, COMGETTER(SystemProperties) (info.asOutParam()), 1);
     2815        CHECK_ERROR_RET (info, COMGETTER(SerialPortCount) (&SerialPortCount), 1);
     2816    }
    27722817
    27732818    std::vector <char *> nics (NetworkAdapterCount, 0);
     
    27832828#endif
    27842829    std::vector <char *> macs (NetworkAdapterCount, 0);
     2830    std::vector <ULONG>  uarts_base (SerialPortCount, 0);
     2831    std::vector <ULONG>  uarts_irq (SerialPortCount, 0);
     2832    std::vector <char *> uarts_pipe (SerialPortCount, 0);
     2833    std::vector <char *> uarts_server (SerialPortCount, 0);
    27852834
    27862835    for (int i = 1; i < argc; i++)
     
    30283077        else if (strncmp(argv[i], "-cableconnected", 15) == 0)
    30293078        {
    3030             unsigned n = parseNicNum(&argv[i][15], NetworkAdapterCount);
     3079            unsigned n = parseNum(&argv[i][15], NetworkAdapterCount, "NIC");
    30313080            if (!n)
    30323081                return 1;
     
    30413090        else if (strncmp(argv[i], "-nictracefile", 13) == 0)
    30423091        {
    3043             unsigned n = parseNicNum(&argv[i][13], NetworkAdapterCount);
     3092            unsigned n = parseNum(&argv[i][13], NetworkAdapterCount, "NIC");
    30443093            if (!n)
    30453094                return 1;
     
    30533102        else if (strncmp(argv[i], "-nictrace", 9) == 0)
    30543103        {
    3055             unsigned n = parseNicNum(&argv[i][9], NetworkAdapterCount);
     3104            unsigned n = parseNum(&argv[i][9], NetworkAdapterCount, "NIC");
    30563105            if (!n)
    30573106                return 1;
     
    30653114        else if (strncmp(argv[i], "-nictype", 8) == 0)
    30663115        {
    3067             unsigned n = parseNicNum(&argv[i][8], NetworkAdapterCount);
     3116            unsigned n = parseNum(&argv[i][8], NetworkAdapterCount, "NIC");
    30683117            if (!n)
    30693118                return 1;
     
    30773126        else if (strncmp(argv[i], "-nic", 4) == 0)
    30783127        {
    3079             unsigned n = parseNicNum(&argv[i][4], NetworkAdapterCount);
     3128            unsigned n = parseNum(&argv[i][4], NetworkAdapterCount, "NIC");
    30803129            if (!n)
    30813130                return 1;
     
    30893138        else if (strncmp(argv[i], "-hostifdev", 10) == 0)
    30903139        {
    3091             unsigned n = parseNicNum(&argv[i][10], NetworkAdapterCount);
     3140            unsigned n = parseNum(&argv[i][10], NetworkAdapterCount, "NIC");
    30923141            if (!n)
    30933142                return 1;
     
    31013150        else if (strncmp(argv[i], "-intnet", 7) == 0)
    31023151        {
    3103             unsigned n = parseNicNum(&argv[i][7], NetworkAdapterCount);
     3152            unsigned n = parseNum(&argv[i][7], NetworkAdapterCount, "NIC");
    31043153            if (!n)
    31053154                return 1;
     
    31143163        else if (strncmp(argv[i], "-tapsetup", 9) == 0)
    31153164        {
    3116             unsigned n = parseNicNum(&argv[i][9], NetworkAdapterCount);
     3165            unsigned n = parseNum(&argv[i][9], NetworkAdapterCount, "NIC");
    31173166            if (!n)
    31183167                return 1;
     
    31263175        else if (strncmp(argv[i], "-tapterminate", 13) == 0)
    31273176        {
    3128             unsigned n = parseNicNum(&argv[i][13], NetworkAdapterCount);
     3177            unsigned n = parseNum(&argv[i][13], NetworkAdapterCount, "NIC");
    31293178            if (!n)
    31303179                return 1;
     
    31393188        else if (strncmp(argv[i], "-macaddress", 11) == 0)
    31403189        {
    3141             unsigned n = parseNicNum(&argv[i][11], NetworkAdapterCount);
     3190            unsigned n = parseNum(&argv[i][11], NetworkAdapterCount, "NIC");
    31423191            if (!n)
    31433192                return 1;
     
    32213270            i++;
    32223271            snapshotFolder = argv[i];
     3272        }
     3273        else if (strncmp(argv[i], "-uart", 5) == 0)
     3274        {
     3275            unsigned n = parseNum(&argv[i][5], SerialPortCount, "UART");
     3276            if (!n)
     3277                return 1;
     3278            if (argc <= i + 1)
     3279            {
     3280                return errorArgument("Missing argument to '%s'", argv[i]);
     3281            }
     3282            i++;
     3283            if (strcmp(argv[i], "off") == 0 || strcmp(argv[i], "disable") == 0)
     3284            {
     3285                uarts_base[n - 1] = (ULONG)-1;
     3286            }
     3287            else
     3288            {
     3289                if (argc <= i + 2)
     3290                {
     3291                    return errorArgument("Missing argument to '%s'", argv[i-1]);
     3292                }
     3293                uint32_t uVal;
     3294                int vrc;
     3295                vrc = RTStrToUInt32Ex(argv[i], NULL, 0, &uVal);
     3296                if (vrc != VINF_SUCCESS || uVal == 0)
     3297                    return errorArgument("Error parsing UART I/O base '%s'", argv[i]);
     3298                uarts_base[n - 1] = uVal;
     3299                i++;
     3300                vrc = RTStrToUInt32Ex(argv[i], NULL, 0, &uVal);
     3301                if (vrc != VINF_SUCCESS)
     3302                    return errorArgument("Error parsing UART IRQ '%s'", argv[i]);
     3303                uarts_irq[n - 1]  = uVal;
     3304                i++;
     3305                if (strcmp(argv[i], "server") && strcmp(argv[i], "client"))
     3306                    return errorArgument("Third UART argument must be 'client' or 'server'");
     3307                uarts_server[n - 1] = argv[i];
     3308                i++;
     3309#ifdef __WIN__
     3310                if (strncmp(argv[i], "\\\\.\\pipe\\", 9))
     3311                    return errorArgument("Uart pipe must start with \\\\.\\pipe\\");
     3312#endif
     3313                uarts_pipe[n - 1] = argv[i];
     3314            }
    32233315        }
    32243316        else
     
    39454037        if (FAILED(rc))
    39464038            break;
     4039
     4040        /* iterate through all possible serial ports */
     4041        for (ULONG n = 0; n < SerialPortCount; n ++)
     4042        {
     4043            ComPtr<ISerialPort> uart;
     4044            CHECK_ERROR_RET (machine, GetSerialPort (n, uart.asOutParam()), 1);
     4045
     4046            ASSERT(uart);
     4047
     4048            /* something about the NIC? */
     4049            if (uarts_base[n])
     4050            {
     4051                if (uarts_base[n] == (ULONG)-1)
     4052                {
     4053                    CHECK_ERROR_RET(uart, COMSETTER(Enabled) (FALSE), 1);
     4054                }
     4055                else
     4056                {
     4057                    CHECK_ERROR_RET(uart, COMSETTER(Iobase) (uarts_base[n]), 1);
     4058                    CHECK_ERROR_RET(uart, COMSETTER(Irq) (uarts_irq[n]), 1);
     4059                    CHECK_ERROR_RET(uart, COMSETTER(Pipe) (Bstr(uarts_pipe[n])), 1);
     4060                    CHECK_ERROR_RET(uart, COMSETTER(Server)
     4061                                          (0 == strcmp(uarts_server[n], "server")), 1);
     4062                    CHECK_ERROR_RET(uart, COMSETTER(Enabled) (TRUE), 1);
     4063                }
     4064            }
     4065        }
     4066        if (FAILED(rc))
     4067            break;
     4068
    39474069#ifdef VBOX_VRDP
    39484070        if (vrdp || (vrdpport != UINT16_MAX) || vrdpaddress || vrdpauthtype || vrdpmulticon)
     
    42194341            CHECK_ERROR_BREAK (info, COMGETTER(NetworkAdapterCount) (&NetworkAdapterCount));
    42204342
    4221             unsigned n = parseNicNum(&argv[1][12], NetworkAdapterCount);
     4343            unsigned n = parseNum(&argv[1][12], NetworkAdapterCount, "NIC");
    42224344            if (!n)
    42234345            {
  • trunk/src/VBox/Main/ConsoleImpl.cpp

    r3481 r3494  
    30213021    LogFlowThisFunc (("Leaving rc=%#x\n", rc));
    30223022    return rc;
     3023}
     3024
     3025/**
     3026 *  Called by IInternalSessionControl::OnSerialPortChange().
     3027 *
     3028 *  @note Locks this object for writing.
     3029 */
     3030HRESULT Console::onSerialPortChange(ISerialPort *serialPort)
     3031{
     3032    LogFlowThisFunc (("\n"));
     3033
     3034    AutoCaller autoCaller (this);
     3035    AssertComRCReturnRC (autoCaller.rc());
     3036
     3037    AutoLock alock (this);
     3038
     3039    /* Don't do anything if the VM isn't running */
     3040    if (!mpVM)
     3041        return S_OK;
     3042
     3043    /* protect mpVM */
     3044    AutoVMCaller autoVMCaller (this);
     3045    CheckComRCReturnRC (autoVMCaller.rc());
     3046
     3047    LogFlowThisFunc (("Leaving rc=%#x\n", S_OK));
     3048    return S_OK;
    30233049}
    30243050
     
    45164542    PCFGMNODE pLunL0 = NULL;        /* /Devices/Dev/0/LUN#0/ */
    45174543    PCFGMNODE pLunL1 = NULL;        /* /Devices/Dev/0/LUN#0/AttachedDriver/ */
     4544    PCFGMNODE pLunL2 = NULL;        /* /Devices/Dev/0/LUN#0/AttachedDriver/Config/ */
     4545
    45184546    rc = CFGMR3InsertNode(pRoot, "Devices", &pDevices);                             RC_CHECK();
    45194547
     
    48054833    rc = CFGMR3InsertNode(pInst,    "Config", &pCfg);                               RC_CHECK();
    48064834
    4807 #if 0
    4808     /*
    4809      * Serial ports
    4810      */
    4811     rc = CFGMR3InsertNode(pDevices, "serial", &pDev);                               RC_CHECK();
    4812     rc = CFGMR3InsertNode(pDev,     "0", &pInst);                                   RC_CHECK();
    4813     rc = CFGMR3InsertNode(pInst,    "Config", &pCfg);                               RC_CHECK();
    4814     rc = CFGMR3InsertInteger(pCfg,  "IRQ",       4);                                RC_CHECK();
    4815     rc = CFGMR3InsertInteger(pCfg,  "IOBase",    0x3f8);                            RC_CHECK();
    4816 
    4817     rc = CFGMR3InsertNode(pDev,     "1", &pInst);                                   RC_CHECK();
    4818     rc = CFGMR3InsertNode(pInst,    "Config", &pCfg);                               RC_CHECK();
    4819     rc = CFGMR3InsertInteger(pCfg,  "IRQ",       3);                                RC_CHECK();
    4820     rc = CFGMR3InsertInteger(pCfg,  "IOBase",    0x2f8);                            RC_CHECK();
    4821 #endif
    4822 
    48234835    /*
    48244836     * VGA.
     
    50405052
    50415053            /* The iSCSI initiator needs an attached iSCSI transport driver. */
    5042             PCFGMNODE pLunL2 = NULL;        /* /Devices/Dev/0/LUN#0/AttachedDriver/AttachedDriver */
    50435054            rc = CFGMR3InsertNode(pLunL1,   "AttachedDriver", &pLunL2);                 RC_CHECK();
    50445055            rc = CFGMR3InsertString(pLunL2, "Driver",           "iSCSITCP");            RC_CHECK();
     
    53495360
    53505361    /*
     5362     * Serial (UART) Ports
     5363     */
     5364    rc = CFGMR3InsertNode(pDevices, "serial", &pDev);                               RC_CHECK();
     5365    for (ULONG ulInstance = 0; ulInstance < SchemaDefs::SerialPortCount; ulInstance++)
     5366    {
     5367        ComPtr<ISerialPort> serialPort;
     5368        hrc = pMachine->GetSerialPort (ulInstance, serialPort.asOutParam());        H();
     5369        BOOL fEnabled = FALSE;
     5370        if (serialPort)
     5371            hrc = serialPort->COMGETTER(Enabled)(&fEnabled);                        H();
     5372        if (!fEnabled)
     5373            continue;
     5374
     5375        char szInstance[4]; Assert(ulInstance <= 999);
     5376        RTStrPrintf(szInstance, sizeof(szInstance), "%lu", ulInstance);
     5377
     5378        rc = CFGMR3InsertNode(pDev, szInstance, &pInst);                            RC_CHECK();
     5379        rc = CFGMR3InsertNode(pInst, "Config", &pCfg);                              RC_CHECK();
     5380
     5381        ULONG uIRQ, uIOBase;
     5382        Bstr  pipe;
     5383        BOOL  fServer;
     5384        hrc = serialPort->COMGETTER(Irq)(&uIRQ);                                    H();
     5385        hrc = serialPort->COMGETTER(Iobase)(&uIOBase);                              H();
     5386        hrc = serialPort->COMGETTER(Pipe)(pipe.asOutParam());                       H();
     5387        hrc = serialPort->COMGETTER(Server)(&fServer);                              H();
     5388        rc = CFGMR3InsertInteger(pCfg,   "IRQ", uIRQ);                              RC_CHECK();
     5389        rc = CFGMR3InsertInteger(pCfg,   "IOBase", uIOBase);                        RC_CHECK();
     5390        rc = CFGMR3InsertNode(pInst,     "LUN#0", &pLunL0);                         RC_CHECK();
     5391        rc = CFGMR3InsertString(pLunL0,  "Driver", "Char");                         RC_CHECK();
     5392        rc = CFGMR3InsertNode(pLunL0,    "AttachedDriver", &pLunL1);                RC_CHECK();
     5393        rc = CFGMR3InsertString(pLunL1,  "Driver", "NamedPipe");                    RC_CHECK();
     5394        rc = CFGMR3InsertNode(pLunL1,    "Config", &pLunL2);                        RC_CHECK();
     5395        rc = CFGMR3InsertString(pLunL2,  "Location", Utf8Str(pipe));                RC_CHECK();
     5396        rc = CFGMR3InsertInteger(pLunL2, "IsServer", fServer);                      RC_CHECK();
     5397    }
     5398
     5399    /*
    53515400     * VMM Device
    53525401     */
  • trunk/src/VBox/Main/MachineImpl.cpp

    r3480 r3494  
    452452    unconst (mFloppyDrive).createObject();
    453453    mFloppyDrive->init (this);
     454
     455    /* create associated serial port objects */
     456    for (ULONG slot = 0; slot < ELEMENTS (mSerialPorts); slot ++)
     457    {
     458        unconst (mSerialPorts [slot]).createObject();
     459        mSerialPorts [slot]->init (this, slot);
     460    }
    454461
    455462    /* create the audio adapter object (always present, default is disabled) */
     
    18141821}
    18151822
     1823STDMETHODIMP Machine::GetSerialPort (ULONG slot, ISerialPort **port)
     1824{
     1825    if (!port)
     1826        return E_POINTER;
     1827    if (slot >= ELEMENTS (mSerialPorts))
     1828        return setError (E_INVALIDARG, tr ("Invalid slot number: %d"), slot);
     1829
     1830    AutoCaller autoCaller (this);
     1831    CheckComRCReturnRC (autoCaller.rc());
     1832
     1833    AutoReaderLock alock (this);
     1834
     1835    mSerialPorts [slot].queryInterfaceTo (port);
     1836
     1837    return S_OK;
     1838}
     1839
    18161840STDMETHODIMP Machine::GetNetworkAdapter (ULONG slot, INetworkAdapter **adapter)
    18171841{
     
    32263250    }
    32273251
     3252    for (ULONG slot = 0; slot < ELEMENTS (mSerialPorts); slot ++)
     3253    {
     3254        if (mSerialPorts [slot])
     3255        {
     3256            mSerialPorts [slot]->uninit();
     3257            unconst (mSerialPorts [slot]).setNull();
     3258        }
     3259    }
     3260
    32283261    if (mFloppyDrive)
    32293262    {
     
    42364269        if (FAILED (rc))
    42374270            return rc;
     4271    }
     4272
     4273    /* Serial node (optional) */
     4274    CFGNODE serialNode = 0;
     4275    CFGLDRGetChildNode (aNode, "Uart", 0, &serialNode);
     4276    if (serialNode)
     4277    {
     4278        HRESULT rc = S_OK;
     4279        unsigned cPorts = 0;
     4280        CFGLDRCountChildren (serialNode, "Port", &cPorts);
     4281        for (unsigned slot = 0; slot < cPorts; slot++)
     4282        {
     4283            rc = mSerialPorts [slot]->loadSettings (serialNode, slot);
     4284            CheckComRCReturnRC (rc);
     4285        }
     4286        CFGLDRReleaseNode (serialNode);
    42384287    }
    42394288
     
    60366085        return rc;
    60376086
     6087    /* Serial ports */
     6088    CFGNODE serialNode = 0;
     6089    CFGLDRCreateChildNode (aNode, "Uart", &serialNode);
     6090
     6091    for (ULONG slot = 0; slot < ELEMENTS (mSerialPorts); slot++)
     6092    {
     6093        rc = mSerialPorts [slot]->saveSettings (serialNode);
     6094        CheckComRCReturnRC (rc);
     6095    }
     6096    CFGLDRReleaseNode (serialNode);
     6097
    60386098    /* Audio adapter */
    60396099    do
     
    70807140            return true;
    70817141
     7142    for (ULONG slot = 0; slot < ELEMENTS (mSerialPorts); slot ++)
     7143        if (mSerialPorts [slot] && mSerialPorts [slot]->isModified())
     7144            return true;
     7145
    70827146    return
    70837147        mUserData.isBackedUp() ||
     
    71117175    for (ULONG slot = 0; slot < ELEMENTS (mNetworkAdapters); slot ++)
    71127176        if (mNetworkAdapters [slot] && mNetworkAdapters [slot]->isReallyModified())
     7177            return true;
     7178
     7179    for (ULONG slot = 0; slot < ELEMENTS (mSerialPorts); slot ++)
     7180        if (mSerialPorts [slot] && mSerialPorts [slot]->isReallyModified())
    71137181            return true;
    71147182
     
    71527220         usbChanged = false;
    71537221    ComPtr <INetworkAdapter> networkAdapters [ELEMENTS (mNetworkAdapters)];
     7222    ComPtr <ISerialPort> serialPorts [ELEMENTS (mSerialPorts)];
    71547223
    71557224    if (mBIOSSettings)
     
    71777246            if (mNetworkAdapters [slot]->rollback())
    71787247                networkAdapters [slot] = mNetworkAdapters [slot];
     7248
     7249    for (ULONG slot = 0; slot < ELEMENTS (mSerialPorts); slot ++)
     7250        if (mSerialPorts [slot])
     7251            if (mSerialPorts [slot]->rollback())
     7252                serialPorts [slot] = mSerialPorts [slot];
    71797253
    71807254    if (aNotify)
     
    71967270            if (networkAdapters [slot])
    71977271                that->onNetworkAdapterChange (networkAdapters [slot]);
     7272        for (ULONG slot = 0; slot < ELEMENTS (serialPorts); slot ++)
     7273            if (serialPorts [slot])
     7274                that->onSerialPortChange (serialPorts [slot]);
    71987275    }
    71997276}
     
    72427319    for (ULONG slot = 0; slot < ELEMENTS (mNetworkAdapters); slot ++)
    72437320        mNetworkAdapters [slot]->commit();
     7321    for (ULONG slot = 0; slot < ELEMENTS (mSerialPorts); slot ++)
     7322        mSerialPorts [slot]->commit();
    72447323
    72457324    if (mType == IsSessionMachine)
     
    73037382    for (ULONG slot = 0; slot < ELEMENTS (mNetworkAdapters); slot ++)
    73047383        mNetworkAdapters [slot]->copyFrom (aThat->mNetworkAdapters [slot]);
     7384    for (ULONG slot = 0; slot < ELEMENTS (mSerialPorts); slot ++)
     7385        mSerialPorts [slot]->copyFrom (aThat->mSerialPorts [slot]);
    73057386}
    73067387
     
    74837564    unconst (mAudioAdapter).createObject();
    74847565    mAudioAdapter->init (this, aMachine->mAudioAdapter);
     7566    /* create a list of serial ports that will be mutable */
     7567    for (ULONG slot = 0; slot < ELEMENTS (mSerialPorts); slot ++)
     7568    {
     7569        unconst (mSerialPorts [slot]).createObject();
     7570        mSerialPorts [slot]->init (this, aMachine->mSerialPorts [slot]);
     7571    }
    74857572    /* create another USB controller object that will be mutable */
    74867573    unconst (mUSBController).createObject();
     
    86268713 *  @note Locks this object for reading.
    86278714 */
     8715HRESULT SessionMachine::onSerialPortChange(ISerialPort *serialPort)
     8716{
     8717    LogFlowThisFunc (("\n"));
     8718
     8719    AutoCaller autoCaller (this);
     8720    AssertComRCReturn (autoCaller.rc(), autoCaller.rc());
     8721
     8722    ComPtr <IInternalSessionControl> directControl;
     8723    {
     8724        AutoReaderLock alock (this);
     8725        directControl = mData->mSession.mDirectControl;
     8726    }
     8727
     8728    /* ignore notifications sent after #OnSessionEnd() is called */
     8729    if (!directControl)
     8730        return S_OK;
     8731
     8732    return directControl->OnSerialPortChange(serialPort);
     8733}
     8734
     8735/**
     8736 *  @note Locks this object for reading.
     8737 */
    86288738HRESULT SessionMachine::onVRDPServerChange()
    86298739{
     
    993910049    }
    994010050
     10051    for (ULONG slot = 0; slot < ELEMENTS (mSerialPorts); slot ++)
     10052    {
     10053        unconst (mSerialPorts [slot]).createObject();
     10054        mSerialPorts [slot]->initCopy (this, mPeer->mSerialPorts [slot]);
     10055    }
     10056
    994110057    /* Confirm a successful initialization when it's the case */
    994210058    autoInitSpan.setSucceeded();
     
    1002310139    }
    1002410140
     10141    for (ULONG slot = 0; slot < ELEMENTS (mSerialPorts); slot ++)
     10142    {
     10143        unconst (mSerialPorts [slot]).createObject();
     10144        mSerialPorts [slot]->init (this, slot);
     10145    }
     10146
    1002510147    /* load hardware and harddisk settings */
    1002610148
  • trunk/src/VBox/Main/Makefile.kmk

    r3480 r3494  
    181181        GuestOSTypeImpl.cpp \
    182182        NetworkAdapterImpl.cpp \
     183        SerialPortImpl.cpp \
    183184        USBControllerImpl.cpp \
    184185        AudioAdapterImpl.cpp \
  • trunk/src/VBox/Main/SessionImpl.cpp

    r3480 r3494  
    537537
    538538    return mConsole->onNetworkAdapterChange(networkAdapter);
     539}
     540
     541STDMETHODIMP Session::OnSerialPortChange(ISerialPort *serialPort)
     542{
     543    LogFlowThisFunc (("\n"));
     544
     545    AutoCaller autoCaller (this);
     546    AssertComRCReturn (autoCaller.rc(), autoCaller.rc());
     547
     548    AutoReaderLock alock (this);
     549    AssertReturn (mState == SessionState_SessionOpen &&
     550                  mType == SessionType_DirectSession, E_FAIL);
     551
     552    return mConsole->onSerialPortChange(serialPort);
    539553}
    540554
  • trunk/src/VBox/Main/SystemPropertiesImpl.cpp

    r2981 r3494  
    190190}
    191191
     192STDMETHODIMP SystemProperties::COMGETTER(SerialPortCount)(ULONG *count)
     193{
     194    if (!count)
     195        return E_POINTER;
     196    AutoLock lock (this);
     197    CHECK_READY();
     198
     199    *count = SchemaDefs::SerialPortCount;
     200
     201    return S_OK;
     202}
    192203
    193204STDMETHODIMP SystemProperties::COMGETTER(MaxBootPosition)(ULONG *aMaxBootPosition)
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r3297 r3494  
    24382438    </method>
    24392439
     2440    <method name="getSerialPort" const="yes">
     2441      <desc>
     2442        Returns the serial port associated with the given slot.
     2443        Slots are numbered sequentially, starting with zero. The total
     2444        number of serial ports per every machine is defined by the
     2445        <link to="ISystemProperties::serialPortCount"/> property,
     2446        so the maximum slot number is one less than that property's value.
     2447      </desc>
     2448      <param name="slot" type="unsigned long" dir="in"/>
     2449      <param name="port" type="ISerialPort" dir="return"/>
     2450    </method>
     2451
    24402452    <method name="getNextExtraDataKey">
    24412453      <desc>
     
    39513963    </attribute>
    39523964
     3965    <attribute name="serialPortCount" type="unsigned long" readonly="yes">
     3966      <desc>
     3967        Number of serial ports associated with every
     3968        <link to="IMachine"/> instance.
     3969      </desc>
     3970    </attribute>
     3971
    39533972    <attribute name="maxBootPosition" type="unsigned long" readonly="yes">
    39543973      <desc>
     
    66396658
    66406659  <!--
     6660  // ISerialPort
     6661  /////////////////////////////////////////////////////////////////////////
     6662  -->
     6663
     6664  <interface
     6665     name="ISerialPort" extends="$unknown"
     6666     uuid="924107d2-1cac-4fc8-93be-e2d54f78dc67"
     6667     wsmap="managed"
     6668     >
     6669 
     6670     <attribute name="slot" type="unsigned long" readonly="yes">
     6671      <desc>
     6672        Slot number this serial port is plugged into. Corresponds to
     6673        the value you pass to <link to="IMachine::getSerialPort"/>
     6674        to obtain this instance.
     6675      </desc>
     6676    </attribute>
     6677
     6678    <attribute name="enabled" type="boolean">
     6679      <desc>
     6680        Flag whether the serial port is enabled. If it is disabled,
     6681        the serial port will not be reported to the guest.
     6682      </desc>
     6683    </attribute>
     6684
     6685    <attribute name="iobase" type="unsigned long">
     6686      <desc>Gets the I/O base of the serial port.</desc>
     6687    </attribute>
     6688
     6689    <attribute name="irq" type="unsigned long">
     6690      <desc>Gets the IRQ of the serial port.</desc>
     6691    </attribute>
     6692
     6693    <attribute name="pipe" type="wstring">
     6694      <desc>Gets the name of the host pipe connected to the serial port.</desc>
     6695    </attribute>
     6696
     6697    <attribute name="server" type="boolean">
     6698      <desc>Flag whether this serial port acts as a server or a client.</desc>
     6699    </attribute>
     6700
     6701  </interface>
     6702
     6703
     6704  <!--
    66416705  // IMachineDebugger
    66426706  /////////////////////////////////////////////////////////////////////////
     
    75957659    </method>
    75967660
     7661    <method name="onSerialPortChange">
     7662      <desc>
     7663        Triggered when settions of a serial port of the
     7664        associated virtual machine have changed.
     7665      </desc>
     7666      <param name="serialPort" type="ISerialPort" dir="in"/>
     7667    </method>
     7668
    75977669    <method name="onVRDPServerChange">
    75987670      <desc>
  • trunk/src/VBox/Main/include/ConsoleImpl.h

    r3288 r3494  
    172172    HRESULT onFloppyDriveChange();
    173173    HRESULT onNetworkAdapterChange(INetworkAdapter *networkAdapter);
     174    HRESULT onSerialPortChange(ISerialPort *serialPort);
    174175    HRESULT onVRDPServerChange();
    175176    HRESULT onUSBControllerChange();
  • trunk/src/VBox/Main/include/MachineImpl.h

    r3480 r3494  
    3434#include "NetworkAdapterImpl.h"
    3535#include "AudioAdapterImpl.h"
     36#include "SerialPortImpl.h"
    3637#include "BIOSSettingsImpl.h"
    3738
     
    480481    STDMETHOD(GetHardDisk)(DiskControllerType_T aCtl, LONG aDev, IHardDisk **aHardDisk);
    481482    STDMETHOD(DetachHardDisk) (DiskControllerType_T aCtl, LONG aDev);
     483    STDMETHOD(GetSerialPort) (ULONG slot, ISerialPort **port);
    482484    STDMETHOD(GetNetworkAdapter) (ULONG slot, INetworkAdapter **adapter);
    483485    STDMETHOD(GetNextExtraDataKey)(INPTR BSTR aKey, BSTR *aNextKey, BSTR *aNextValue);
     
    526528    virtual HRESULT onFloppyDriveChange() { return S_OK; }
    527529    virtual HRESULT onNetworkAdapterChange(INetworkAdapter *networkAdapter) { return S_OK; }
     530    virtual HRESULT onSerialPortChange(ISerialPort *serialPort) { return S_OK; }
    528531    virtual HRESULT onVRDPServerChange() { return S_OK; }
    529532    virtual HRESULT onUSBControllerChange() { return S_OK; }
     
    675678    const ComObjPtr <DVDDrive> mDVDDrive;
    676679    const ComObjPtr <FloppyDrive> mFloppyDrive;
     680    const ComObjPtr <SerialPort>
     681        mSerialPorts [SchemaDefs::SerialPortCount];
    677682    const ComObjPtr <AudioAdapter> mAudioAdapter;
    678683    const ComObjPtr <USBController> mUSBController;
    679684    const ComObjPtr <BIOSSettings> mBIOSSettings;
    680 
    681685    const ComObjPtr <NetworkAdapter>
    682686        mNetworkAdapters [SchemaDefs::NetworkAdapterCount];
     
    766770    HRESULT onFloppyDriveChange();
    767771    HRESULT onNetworkAdapterChange(INetworkAdapter *networkAdapter);
     772    HRESULT onSerialPortChange(ISerialPort *serialPort);
    768773    HRESULT onVRDPServerChange();
    769774    HRESULT onUSBControllerChange();
  • trunk/src/VBox/Main/include/SessionImpl.h

    r3480 r3494  
    9898    STDMETHOD(OnFloppyDriveChange)();
    9999    STDMETHOD(OnNetworkAdapterChange)(INetworkAdapter *networkAdapter);
     100    STDMETHOD(OnSerialPortChange)(ISerialPort *serialPort);
    100101    STDMETHOD(OnVRDPServerChange)();
    101102    STDMETHOD(OnUSBControllerChange)();
  • trunk/src/VBox/Main/include/SystemPropertiesImpl.h

    r2981 r3494  
    6363    STDMETHOD(COMGETTER(MaxVDISize)(ULONG64 *maxVDISize));
    6464    STDMETHOD(COMGETTER(NetworkAdapterCount)(ULONG *count));
     65    STDMETHOD(COMGETTER(SerialPortCount)(ULONG *count));
    6566    STDMETHOD(COMGETTER(MaxBootPosition)(ULONG *aMaxBootPosition));
    6667    STDMETHOD(COMGETTER(DefaultVDIFolder)) (BSTR *aDefaultVDIFolder);
  • trunk/src/VBox/Main/linux/server.cpp

    r3388 r3494  
    9797#include <GuestOSTypeImpl.h>
    9898#include <NetworkAdapterImpl.h>
     99#include <SerialPortImpl.h>
    99100#include <USBControllerImpl.h>
    100101#include <USBDeviceImpl.h>
     
    152153NS_DECL_CLASSINFO(NetworkAdapter)
    153154NS_IMPL_THREADSAFE_ISUPPORTS1_CI(NetworkAdapter, INetworkAdapter)
     155NS_DECL_CLASSINFO(SerialPort)
     156NS_IMPL_THREADSAFE_ISUPPORTS1_CI(SerialPort, ISerialPort)
    154157NS_DECL_CLASSINFO(USBController)
    155158NS_IMPL_THREADSAFE_ISUPPORTS1_CI(USBController, IUSBController)
  • trunk/src/VBox/Main/xml/SchemaDefs.xsl

    r2988 r3494  
    137137  </xsl:call-template>
    138138  <xsl:call-template name="defineEnumMember">
     139      <xsl:with-param name="member" select="'        SerialPortCount'"/>
     140      <xsl:with-param name="select" select="
     141        xsd:complexType[@name='TUartPort']/xsd:attribute[@name='slot']//xsd:maxExclusive/@value
     142      "/>
     143  </xsl:call-template>
     144  <xsl:call-template name="defineEnumMember">
    139145      <xsl:with-param name="member" select="'        MaxBootPosition'"/>
    140146      <xsl:with-param name="select" select="
  • trunk/src/VBox/Main/xml/VirtualBox-settings-common.xsd

    r2988 r3494  
    515515</xsd:complexType>
    516516
     517<xsd:complexType name="TUartPort">
     518  <xsd:attribute name="slot" use="required">
     519    <xsd:simpleType>
     520      <xsd:restriction base="xsd:unsignedInt">
     521        <xsd:minInclusive value="0"/>
     522        <xsd:maxExclusive value="2"/>
     523      </xsd:restriction>
     524    </xsd:simpleType>
     525  </xsd:attribute>
     526  <xsd:attribute name="enabled" type="xsd:boolean" use="required"/>
     527  <xsd:attribute name="IRQ" type="xsd:unsignedInt" default="4"/>
     528  <xsd:attribute name="IOBase" type="xsd:unsignedInt" default="1016"/>
     529  <xsd:attribute name="pipe" type="xsd:string"/>
     530  <xsd:attribute name="server" type="xsd:boolean"/>
     531</xsd:complexType>
     532
     533<xsd:complexType name="TUart">
     534  <xsd:sequence>
     535    <xsd:element name="Port" minOccurs="0" maxOccurs="unbounded">
     536      <xsd:complexType>
     537        <xsd:complexContent>
     538          <xsd:extension base="TUartPort">
     539          </xsd:extension>
     540        </xsd:complexContent>
     541      </xsd:complexType>
     542    </xsd:element>
     543  </xsd:sequence>
     544</xsd:complexType>
     545
    517546<xsd:complexType name="TSharedFolder">
    518547  <xsd:attribute name="name" type="TNonEmptyString" use="required"/>
     
    549578      <xsd:unique name="THardware-Network-Adapter">
    550579        <xsd:selector xpath="vb:Adapter"/>
     580        <xsd:field xpath="@slot"/>
     581      </xsd:unique>
     582    </xsd:element>
     583    <xsd:element name="Uart" type="TUart" minOccurs="0">
     584      <xsd:unique name="THardware-Uart-Port">
     585        <xsd:selector xpath="vb:Port"/>
    551586        <xsd:field xpath="@slot"/>
    552587      </xsd:unique>
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette