VirtualBox

source: vbox/trunk/src/VBox/Devices/Network/DevE1000Phy.h@ 26837

Last change on this file since 26837 was 26310, checked in by vboxsync, 15 years ago

e1000: Mega-patch to bring up the link in OSX.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.6 KB
Line 
1/** $Id: DevE1000Phy.h 26310 2010-02-05 21:30:38Z vboxsync $ */
2/** @file
3 * DevE1000Phy - Intel 82540EM Ethernet Controller Internal PHY Emulation, Header.
4 */
5
6/*
7 * Copyright (C) 2007 Sun Microsystems, Inc.
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
18 * Clara, CA 95054 USA or visit http://www.sun.com if you need
19 * additional information or have any questions.
20 */
21
22#include <VBox/types.h>
23
24#define PHY_EPID_M881000 0xC50
25#define PHY_EPID_M881011 0xC24
26
27#define PCTRL_SPDSELM 0x0040
28#define PCTRL_DUPMOD 0x0100
29#define PCTRL_ANEG 0x1000
30#define PCTRL_SPDSELL 0x2000
31#define PCTRL_RESET 0x8000
32
33#define PSTATUS_LNKSTAT 0x0004
34
35/*
36 * Speed: 1000 Mb/s
37 * Duplex: full
38 * Page received
39 * Resolved
40 * Link up
41 * Receive Pause Enable
42 */
43#define PSSTAT_LINK 0xBC08
44
45namespace Phy
46{
47 /**
48 * Indices of memory-mapped registers in register table
49 */
50 enum enmRegIdx
51 {
52 PCTRL_IDX,
53 PSTATUS_IDX,
54 PID_IDX,
55 EPID_IDX,
56 ANA_IDX,
57 LPA_IDX,
58 ANE_IDX,
59 NPT_IDX,
60 LPN_IDX,
61 GCON_IDX,
62 GSTATUS_IDX,
63 EPSTATUS_IDX,
64 PSCON_IDX,
65 PSSTAT_IDX,
66 PINTE_IDX,
67 PINTS_IDX,
68 EPSCON1_IDX,
69 PREC_IDX,
70 EPSCON2_IDX,
71 R30PS_IDX,
72 R30AW_IDX,
73 NUM_OF_PHY_REGS
74 };
75 /**
76 * Emulation state of PHY.
77 */
78 struct Phy_st
79 {
80 /** Network controller instance this PHY is attached to. */
81 int iInstance;
82 /** Register storage. */
83 uint16_t au16Regs[NUM_OF_PHY_REGS];
84 /** Current state of serial MDIO interface. */
85 uint16_t u16State;
86 /** Current state of serial MDIO interface. */
87 uint16_t u16Acc;
88 /** Number of bits remaining to be shifted into/out of accumulator. */
89 uint16_t u16Cnt;
90 /** PHY register offset selected for MDIO operation. */
91 uint16_t u16RegAdr;
92 };
93}
94
95#define MDIO_IDLE 0
96#define MDIO_ST 1
97#define MDIO_OP_ADR 2
98#define MDIO_TA_RD 3
99#define MDIO_TA_WR 4
100#define MDIO_READ 5
101#define MDIO_WRITE 6
102
103#define MDIO_READ_OP 2
104#define MDIO_WRITE_OP 1
105
106typedef struct Phy::Phy_st PHY;
107typedef PHY *PPHY;
108
109/* Interface *****************************************************************/
110namespace Phy {
111 /** Initialize PHY. */
112 void init(PPHY pPhy, int iNICInstance, uint16_t u16EPid);
113 /** Read PHY register at specified address. */
114 uint16_t readRegister(PPHY pPhy, uint32_t u32Address);
115 /** Write to PHY register at specified address. */
116 void writeRegister(PPHY pPhy, uint32_t u32Address, uint16_t u16Value);
117 /** Read the value on MDIO pin. */
118 bool readMDIO(PPHY pPhy);
119 /** Set the value of MDIO pin. */
120 void writeMDIO(PPHY pPhy, bool fPin);
121 /** Hardware reset. */
122 void hardReset(PPHY pPhy);
123 /** Query link status. */
124 bool isLinkUp(PPHY pPhy);
125 /** Set link status. */
126 void setLinkStatus(PPHY pPhy, bool fLinkIsUp);
127 /** Save PHY state. */
128 int saveState(PSSMHANDLE pSSMHandle, PPHY pPhy);
129 /** Restore previously saved PHY state. */
130 int loadState(PSSMHANDLE pSSMHandle, PPHY pPhy);
131}
132
Note: See TracBrowser for help on using the repository browser.

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