third_party/virtualbox/src/VBox/Devices/Network/DevE1000.cpp
/**
 * Write handler for Device Control register.
 *
 * Handles reset.
 *
 * @param   pThis       The device state structure.
 * @param   offset      Register offset in memory-mapped frame.
 * @param   index       Register index in register array.
 * @param   value       The value to store.
 * @param   mask        Used to implement partial writes (8 and 16-bit).
 * @thread  EMT
 */
Write handler for Device Control register.
Handles reset.

@param   pThis       The device state structure.
@param   offset      Register offset in memory-mapped frame.
@param   index       Register index in register array.
@param   value       The value to store.
@param   mask        Used to implement partial writes (8 and 16-bit).
@thread  EMT
Write handler for Device Control register . Handles reset . @param pThis The device state structure . @param offset Register offset in memory - mapped frame . @param index Register index in register array . @param value The value to store . @param mask Used to implement partial writes ( 8 and 16 - bit ) . @thread EMT
static int e1kRegWriteCTRL(PE1KSTATE pThis, uint32_t offset, uint32_t index, uint32_t value)
{
    int rc = VINF_SUCCESS;
    if (value & CTRL_RESET)
    { 
#ifndef IN_RING3
        return VINF_IOM_R3_MMIO_WRITE;
#else
        e1kHardReset(pThis);
#endif
    }
    else
    {
#ifdef E1K_LSC_ON_SLU
        if (   (value & CTRL_SLU)
            && !(CTRL & CTRL_SLU)
            && pThis->fCableConnected
            && !(STATUS & STATUS_LU))
        {
            e1kArmTimer(pThis, pThis->CTX_SUFF(pLUTimer), E1K_INIT_LINKUP_DELAY_US);
        }
#else 
        if (   (value & CTRL_SLU)
            && !(CTRL & CTRL_SLU)
            && pThis->fCableConnected
            && !TMTimerIsActive(pThis->CTX_SUFF(pLUTimer)))
        {
            STATUS |= STATUS_LU;
        }
#endif 
        if ((value & CTRL_VME) != (CTRL & CTRL_VME))
        {
            E1kLog(("%s VLAN Mode %s\n", pThis->szPrf, (value & CTRL_VME) ? "Enabled" : "Disabled"));
        }
        Log7(("%s e1kRegWriteCTRL: mdio dir=%s mdc dir=%s mdc=%s mdio=%d\n",
              pThis->szPrf, (value & CTRL_MDIO_DIR)?"OUT":"IN ",
              (value & CTRL_MDC_DIR)?"OUT":"IN ", (value & CTRL_MDC)?"HIGH":"LOW ", !!(value & CTRL_MDIO)));
        if (value & CTRL_MDC)
        {
            if (value & CTRL_MDIO_DIR)
            {
                Log7(("%s e1kRegWriteCTRL: Phy::writeMDIO(%d)\n", pThis->szPrf, !!(value & CTRL_MDIO)));
                Phy::writeMDIO(&pThis->phy, !!(value & CTRL_MDIO));
            }
            else
            {
                if (Phy::readMDIO(&pThis->phy))
                    value |= CTRL_MDIO;
                else
                    value &= ~CTRL_MDIO;
                Log7(("%s e1kRegWriteCTRL: Phy::readMDIO(%d)\n", pThis->szPrf, !!(value & CTRL_MDIO)));
            }
        }
        rc = e1kRegWriteDefault(pThis, offset, index, value);
    }
    return rc;
}
static int e1kRegWriteCTRL ( PE1KSTATE pThis , uint32_t offset , uint32_t index , uint32_t value ) { int rc = VINF_SUCCESS ; if ( value & CTRL_RESET ) { #ifndef IN_RING3 return VINF_IOM_R3_MMIO_WRITE ; #else e1kHardReset ( pThis ) ; #endif } else { #ifdef E1K_LSC_ON_SLU if ( ( value & CTRL_SLU ) && ! ( CTRL & CTRL_SLU ) && pThis -> fCableConnected && ! ( STATUS & STATUS_LU ) ) { e1kArmTimer ( pThis , pThis -> CTX_SUFF ( pLUTimer ) , E1K_INIT_LINKUP_DELAY_US ) ; } #else if ( ( value & CTRL_SLU ) && ! ( CTRL & CTRL_SLU ) && pThis -> fCableConnected && ! TMTimerIsActive ( pThis -> CTX_SUFF ( pLUTimer ) ) ) { STATUS |= STATUS_LU ; } #endif if ( ( value & CTRL_VME ) != ( CTRL & CTRL_VME ) ) { E1kLog ( ( " \n " , pThis -> szPrf , ( value & CTRL_VME ) ? " " : " " ) ) ; } Log7 ( ( " \n " , pThis -> szPrf , ( value & CTRL_MDIO_DIR ) ? " " : " " , ( value & CTRL_MDC_DIR ) ? " " : " " , ( value & CTRL_MDC ) ? " " : " " , ! ! ( value & CTRL_MDIO ) ) ) ; if ( value & CTRL_MDC ) { if ( value & CTRL_MDIO_DIR ) { Log7 ( ( " \n " , pThis -> szPrf , ! ! ( value & CTRL_MDIO ) ) ) ; Phy :: writeMDIO ( & pThis -> phy , ! ! ( value & CTRL_MDIO ) ) ; } else { if ( Phy :: readMDIO ( & pThis -> phy ) ) value |= CTRL_MDIO ; else value &= ~ CTRL_MDIO ; Log7 ( ( " \n " , pThis -> szPrf , ! ! ( value & CTRL_MDIO ) ) ) ; } } rc = e1kRegWriteDefault ( pThis , offset , index , value ) ; } return rc ; }
Write handler for Device Control register.
Write handler for Device Control register .
/* RST */ /*
         * When the guest changes 'Set Link Up' bit from 0 to 1 we check if
         * the link is down and the cable is connected, and if they are we
         * bring the link up, see @bugref{8624}.
         */ /* It should take about 2 seconds for the link to come up */ /* !E1K_LSC_ON_SLU */ /* PXE does not use LSC interrupts, see @bugref{9113}. */ /* !E1K_LSC_ON_SLU */ /* MDIO direction pin is set to output and MDC is high, write MDIO pin value to PHY */