VirtualBox

Changeset 5059 in vbox


Ignore:
Timestamp:
Sep 26, 2007 5:12:27 PM (17 years ago)
Author:
vboxsync
Message:

Added a mechanism to report custom line speed to guest driver (VBoxNET.sys).
Changes saved state version.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Network/DevPCNet.cpp

    r5015 r5059  
    11/** $Id$ */
    22/** @file
    3  * AMD PC-Net II (Am79C970A + Am79C973) Ethernet Controller Emulation.
     3 * AMD PCnet-PCI II / PCnet-FAST III (Am79C970A / Am79C973) Ethernet Controller Emulation.
    44 */
    55
     
    9797#define PCNET_PNPMMIO_SIZE              0x20
    9898
    99 #define PCNET_SAVEDSTATE_VERSION        6
     99#define PCNET_SAVEDSTATE_VERSION        7
    100100
    101101#define BCR_MAX_RAP                     50
     
    238238    bool                                fAm79C973;
    239239    bool                                afAlignment[5];
     240    uint32_t                            u32LinkSpeed;
    240241
    241242#ifdef VBOX_WITH_STATISTICS
     
    25652566}
    25662567
     2568/**
     2569 * Encode a 32-bit link speed into a custom 16-bit floating-point value
     2570 */
     2571static uint32_t pcnetLinkSpd(uint32_t speed)
     2572{
     2573    unsigned    exp = 0;
     2574
     2575    while (speed & 0xFFFFE000)
     2576    {
     2577        speed /= 10;
     2578        ++exp;
     2579    }
     2580    return (exp << 13) | speed;
     2581}
     2582
    25672583static uint32_t pcnetCSRReadU16(PCNetState *pData, uint32_t u32RAP)
    25682584{
     
    25822598        case 58:
    25832599            return pcnetBCRReadU16(pData, BCR_SWS);
     2600        case 68:    /* Custom register to pass link speed to driver */
     2601            return pcnetLinkSpd(pData->u32LinkSpeed);
    25842602        case 88:
    25852603            val = pData->aCSR[89];
     
    38333851    SSMR3PutMem(pSSMHandle, &pData->MacConfigured, sizeof(pData->MacConfigured));
    38343852    SSMR3PutBool(pSSMHandle, pData->fAm79C973);
     3853    SSMR3PutU32(pSSMHandle, pData->u32LinkSpeed);
    38353854#ifdef PCNET_NO_POLLING
    38363855    return VINF_SUCCESS;
     
    38733892           ||   SSMR3HandleGetAfter(pSSMHandle) == SSMAFTER_DEBUG_IT);
    38743893    SSMR3GetBool(pSSMHandle, &pData->fAm79C973);
     3894    SSMR3GetU32(pSSMHandle, &pData->u32LinkSpeed);
    38753895#ifndef PCNET_NO_POLLING
    38763896    TMR3TimerLoad(pData->CTXSUFF(pTimerPoll), pSSMHandle);
     
    41924212     * Validate configuration.
    41934213     */
    4194     if (!CFGMR3AreValuesValid(pCfgHandle, "MAC\0CableConnected\0Am79C973\0GCEnabled\0R0Enabled\0"))
     4214    if (!CFGMR3AreValuesValid(pCfgHandle, "MAC\0CableConnected\0Am79C973\0LineSpeed\0GCEnabled\0R0Enabled\0"))
    41954215        return PDMDEV_SET_ERROR(pDevIns, VERR_PDM_DEVINS_UNKNOWN_CFG_VALUES,
    41964216                                N_("Invalid configuraton for pcnet device"));
     
    42164236        return PDMDEV_SET_ERROR(pDevIns, rc,
    42174237                                N_("Configuration error: Failed to get the \"Am79C973\" value"));
     4238
     4239    rc = CFGMR3QueryU32(pCfgHandle, "LineSpeed", &pData->u32LinkSpeed);
     4240    if (rc == VERR_CFGM_VALUE_NOT_FOUND)
     4241        pData->u32LinkSpeed = 100000;    /* 100 Mbps (in kbps units)*/
     4242    else if (VBOX_FAILURE(rc))
     4243        return PDMDEV_SET_ERROR(pDevIns, rc,
     4244                                N_("Configuration error: Failed to get the \"LineSpeed\" value"));
    42184245
    42194246#ifdef PCNET_GC_ENABLED
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