VirtualBox

Ticket #6008: e1000_eerd.patch

File e1000_eerd.patch, 5.3 KB (added by Aleksey Ilyushin, 15 years ago)

Revised version of the patch

  • src/VBox/Devices/Network/DevE1000.cpp

     
    181181#define EECD_EE_REQ   0x40
    182182#define EECD_EE_GNT   0x80
    183183
     184#define EERD_START       0x00000001
     185#define EERD_DONE        0x00000010
     186#define EERD_DATA_MASK   0xFFFF0000
     187#define EERD_DATA_SHIFT  16
     188#define EERD_ADDR_MASK   0x0000FF00
     189#define EERD_ADDR_SHIFT  8
     190
    184191#define MDIC_DATA_MASK  0x0000FFFF
    185192#define MDIC_DATA_SHIFT 0
    186193#define MDIC_REG_MASK   0x001F0000
     
    577584            eeprom.write(u32Wires);
    578585        }
    579586
     587        bool readWord(uint32_t u32Addr, uint16_t *pu16Value)
     588        {
     589            return eeprom.readWord(u32Addr, pu16Value);
     590        }
     591
    580592        int load(PSSMHANDLE pSSM)
    581593        {
    582594            return eeprom.load(pSSM);
     
    10331045static int e1kRegWriteCTRL         (E1KSTATE* pState, uint32_t offset, uint32_t index, uint32_t u32Value);
    10341046static int e1kRegReadEECD          (E1KSTATE* pState, uint32_t offset, uint32_t index, uint32_t *pu32Value);
    10351047static int e1kRegWriteEECD         (E1KSTATE* pState, uint32_t offset, uint32_t index, uint32_t u32Value);
     1048static int e1kRegWriteEERD         (E1KSTATE* pState, uint32_t offset, uint32_t index, uint32_t u32Value);
    10361049static int e1kRegWriteMDIC         (E1KSTATE* pState, uint32_t offset, uint32_t index, uint32_t u32Value);
    10371050static int e1kRegReadICR           (E1KSTATE* pState, uint32_t offset, uint32_t index, uint32_t *pu32Value);
    10381051static int e1kRegWriteICR          (E1KSTATE* pState, uint32_t offset, uint32_t index, uint32_t u32Value);
     
    10811094    { 0x00000, 0x00004, 0xDBF31BE9, 0xDBF31BE9, e1kRegReadDefault      , e1kRegWriteCTRL         , "CTRL"    , "Device Control" },
    10821095    { 0x00008, 0x00004, 0x0000FDFF, 0x00000000, e1kRegReadDefault      , e1kRegWriteUnimplemented, "STATUS"  , "Device Status" },
    10831096    { 0x00010, 0x00004, 0x000027F0, 0x00000070, e1kRegReadEECD         , e1kRegWriteEECD         , "EECD"    , "EEPROM/Flash Control/Data" },
    1084     { 0x00014, 0x00004, 0xFFFFFFFF, 0xFFFFFFFF, e1kRegReadUnimplemented, e1kRegWriteUnimplemented, "EERD"    , "EEPROM Read" },
     1097    { 0x00014, 0x00004, 0xFFFFFF10, 0xFFFFFF00, e1kRegReadDefault      , e1kRegWriteEERD         , "EERD"    , "EEPROM Read" },
    10851098    { 0x00018, 0x00004, 0xFFFFFFFF, 0xFFFFFFFF, e1kRegReadUnimplemented, e1kRegWriteUnimplemented, "CTRL_EXT", "Extended Device Control" },
    10861099    { 0x0001c, 0x00004, 0xFFFFFFFF, 0xFFFFFFFF, e1kRegReadUnimplemented, e1kRegWriteUnimplemented, "FLA"     , "Flash Access (N/A)" },
    10871100    { 0x00020, 0x00004, 0xFFFFFFFF, 0xFFFFFFFF, e1kRegReadDefault      , e1kRegWriteMDIC         , "MDIC"    , "MDI Control" },
     
    21842197}
    21852198
    21862199/**
     2200 * Write handler for EEPROM Read register.
     2201 *
     2202 * Handles EEPROM word access requests, reads EEPROM and stores the result
     2203 * into DATA field.
     2204 *
     2205 * @param   pState      The device state structure.
     2206 * @param   offset      Register offset in memory-mapped frame.
     2207 * @param   index       Register index in register array.
     2208 * @param   value       The value to store.
     2209 * @param   mask        Used to implement partial writes (8 and 16-bit).
     2210 * @thread  EMT
     2211 */
     2212static int e1kRegWriteEERD(E1KSTATE* pState, uint32_t offset, uint32_t index, uint32_t value)
     2213{
     2214#ifdef IN_RING3
     2215    /* Make use of 'writable' and 'readable' masks. */
     2216    e1kRegWriteDefault(pState, offset, index, value);
     2217    /* DONE and DATA are set only if read was triggered by START. */
     2218    if (value & EERD_START)
     2219    {
     2220        uint16_t tmp;
     2221        STAM_PROFILE_ADV_START(&pState->StatEEPROMRead, a);
     2222        if (pState->eeprom.readWord(GET_BITS_V(value, EERD, ADDR), &tmp))
     2223            SET_BITS(EERD, DATA, tmp);
     2224        EERD |= EERD_DONE;
     2225        STAM_PROFILE_ADV_STOP(&pState->StatEEPROMRead, a);
     2226    }
     2227
     2228    return VINF_SUCCESS;
     2229#else /* !IN_RING3 */
     2230    return VINF_IOM_HC_MMIO_WRITE;
     2231#endif /* !IN_RING3 */
     2232}
     2233
     2234
     2235/**
    21872236 * Write handler for MDI Control register.
    21882237 *
    21892238 * Handles PHY read/write requests; forwards requests to internal PHY device.
  • src/VBox/Devices/Network/DevEEPROM.cpp

     
    6262}
    6363
    6464/**
     65 * Reads one word at specified location.
     66 *
     67 * @returns True if read was successful.
     68 *
     69 * @param   u32Addr     Address to read from
     70 * @param   pu16Value   Placeholder to store the value
     71 */
     72bool EEPROM93C46::readWord(uint32_t u32Addr, uint16_t *pu16Value)
     73{
     74    if (u32Addr < SIZE)
     75    {
     76        *pu16Value = m_au16Data[u32Addr];
     77        return true;
     78    }
     79
     80    return false;
     81}
     82
     83/**
    6584 * Fetch next word pointer by m_u16Addr.
    6685 *
    6786 * m_u16Addr is advanced and mask is reset to support sequential reads.
  • src/VBox/Devices/Network/DevEEPROM.h

     
    121121#ifdef IN_RING3
    122122    uint32_t read();
    123123    void     write(uint32_t u32Wires);
     124    bool     readWord(uint32_t u32Addr, uint16_t *pu16Value);
    124125
    125126    void init(const uint16_t *pu16Initial = 0);
    126127

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