VirtualBox

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

Last change on this file since 95433 was 93115, checked in by vboxsync, 3 years ago

scm --update-copyright-year

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.8 KB
Line 
1/** $Id: DevE1000Phy.h 93115 2022-01-01 11:31:46Z vboxsync $ */
2/** @file
3 * DevE1000Phy - Intel 82540EM Ethernet Controller Internal PHY Emulation, Header.
4 */
5
6/*
7 * Copyright (C) 2007-2022 Oracle Corporation
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
18#ifndef VBOX_INCLUDED_SRC_Network_DevE1000Phy_h
19#define VBOX_INCLUDED_SRC_Network_DevE1000Phy_h
20#ifndef RT_WITHOUT_PRAGMA_ONCE
21# pragma once
22#endif
23
24#include <VBox/types.h>
25
26#define PHY_EPID_M881000 0xC50
27#define PHY_EPID_M881011 0xC24
28
29#define PCTRL_SPDSELM 0x0040
30#define PCTRL_DUPMOD 0x0100
31#define PCTRL_ANEG 0x1000
32#define PCTRL_SPDSELL 0x2000
33#define PCTRL_RESET 0x8000
34
35#define PSTATUS_LNKSTAT 0x0004
36#define PSTATUS_NEGCOMP 0x0020
37
38/*
39 * Speed: 1000 Mb/s
40 * Duplex: full
41 * Page received
42 * Resolved
43 * Link up
44 * Receive Pause Enable
45 */
46#define PSSTAT_LINK_ALL 0xBC08
47#define PSSTAT_LINK 0x0400
48
49namespace Phy
50{
51 /**
52 * Indices of memory-mapped registers in register table
53 */
54 enum enmRegIdx
55 {
56 PCTRL_IDX,
57 PSTATUS_IDX,
58 PID_IDX,
59 EPID_IDX,
60 ANA_IDX,
61 LPA_IDX,
62 ANE_IDX,
63 NPT_IDX,
64 LPN_IDX,
65 GCON_IDX,
66 GSTATUS_IDX,
67 EPSTATUS_IDX,
68 PSCON_IDX,
69 PSSTAT_IDX,
70 PINTE_IDX,
71 PINTS_IDX,
72 EPSCON1_IDX,
73 PREC_IDX,
74 EPSCON2_IDX,
75 R30PS_IDX,
76 R30AW_IDX,
77 NUM_OF_PHY_REGS
78 };
79 /**
80 * Emulation state of PHY.
81 */
82 struct Phy_st
83 {
84 /** Network controller instance this PHY is attached to. */
85 int iInstance;
86 /** Register storage. */
87 uint16_t au16Regs[NUM_OF_PHY_REGS];
88 /** Current state of serial MDIO interface. */
89 uint16_t u16State;
90 /** Current state of serial MDIO interface. */
91 uint16_t u16Acc;
92 /** Number of bits remaining to be shifted into/out of accumulator. */
93 uint16_t u16Cnt;
94 /** PHY register offset selected for MDIO operation. */
95 uint16_t u16RegAdr;
96 };
97}
98
99#define MDIO_IDLE 0
100#define MDIO_ST 1
101#define MDIO_OP_ADR 2
102#define MDIO_TA_RD 3
103#define MDIO_TA_WR 4
104#define MDIO_READ 5
105#define MDIO_WRITE 6
106
107#define MDIO_READ_OP 2
108#define MDIO_WRITE_OP 1
109
110/* External callback declaration */
111void e1kPhyLinkResetCallback(PPDMDEVINS pDevIns);
112
113
114typedef struct Phy::Phy_st PHY;
115typedef PHY *PPHY;
116
117/* Interface *****************************************************************/
118namespace Phy
119{
120 /** Initialize PHY. */
121 void init(PPHY pPhy, int iNICInstance, uint16_t u16EPid);
122 /** Read PHY register at specified address. */
123 uint16_t readRegister(PPHY pPhy, uint32_t u32Address, PPDMDEVINS pDevIns);
124 /** Write to PHY register at specified address. */
125 void writeRegister(PPHY pPhy, uint32_t u32Address, uint16_t u16Value, PPDMDEVINS pDevIns);
126 /** Read the value on MDIO pin. */
127 bool readMDIO(PPHY pPhy);
128 /** Set the value of MDIO pin. */
129 void writeMDIO(PPHY pPhy, bool fPin, PPDMDEVINS pDevIns);
130 /** Hardware reset. */
131 void hardReset(PPHY pPhy);
132 /** Query link status. */
133 bool isLinkUp(PPHY pPhy);
134 /** Set link status. */
135 void setLinkStatus(PPHY pPhy, bool fLinkIsUp);
136 /** Save PHY state. */
137 int saveState(struct PDMDEVHLPR3 const *pHlp, PSSMHANDLE pSSM, PPHY pPhy);
138 /** Restore previously saved PHY state. */
139 int loadState(struct PDMDEVHLPR3 const *pHlp, PSSMHANDLE pSSM, PPHY pPhy);
140}
141
142#endif /* !VBOX_INCLUDED_SRC_Network_DevE1000Phy_h */
143
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