2 * OpenCores Ethernet MAC 10/100 + subset of
3 * National Semiconductors DP83848C 10/100 PHY
5 * http://opencores.org/svnget,ethmac?file=%2Ftrunk%2F%2Fdoc%2Feth_speci.pdf
6 * http://cache.national.com/ds/DP/DP83848C.pdf
8 * Copyright (c) 2011, Max Filippov, Open Source and Linux Lab.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions are met:
13 * * Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * * Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * * Neither the name of the Open Source and Linux Lab nor the
19 * names of its contributors may be used to endorse or promote products
20 * derived from this software without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
26 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
27 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
29 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 #include "qemu/osdep.h"
36 #include "hw/net/mii.h"
37 #include "hw/qdev-properties.h"
38 #include "hw/sysbus.h"
40 #include "qemu/module.h"
43 #include "qom/object.h"
45 /* RECSMALL is not used because it breaks tap networking in linux:
46 * incoming ARP responses are too short
50 #define GET_FIELD(v, field) (((v) & (field)) >> (field ## _LBN))
51 #define GET_REGBIT(s, reg, field) ((s)->regs[reg] & (reg ## _ ## field))
52 #define GET_REGFIELD(s, reg, field) \
53 GET_FIELD((s)->regs[reg], reg ## _ ## field)
55 #define SET_FIELD(v, field, data) \
56 ((v) = (((v) & ~(field)) | (((data) << (field ## _LBN)) & (field))))
57 #define SET_REGFIELD(s, reg, field, data) \
58 SET_FIELD((s)->regs[reg], reg ## _ ## field, data)
60 /* PHY MII registers */
66 uint16_t regs
[MII_REG_MAX
];
70 static void mii_set_link(Mii
*s
, bool link_ok
)
73 s
->regs
[MII_BMSR
] |= MII_BMSR_LINK_ST
;
74 s
->regs
[MII_ANLPAR
] |= MII_ANLPAR_TXFD
| MII_ANLPAR_TX
|
75 MII_ANLPAR_10FD
| MII_ANLPAR_10
| MII_ANLPAR_CSMACD
;
77 s
->regs
[MII_BMSR
] &= ~MII_BMSR_LINK_ST
;
78 s
->regs
[MII_ANLPAR
] &= 0x01ff;
83 static void mii_reset(Mii
*s
)
85 memset(s
->regs
, 0, sizeof(s
->regs
));
86 s
->regs
[MII_BMCR
] = MII_BMCR_AUTOEN
;
87 s
->regs
[MII_BMSR
] = MII_BMSR_100TX_FD
| MII_BMSR_100TX_HD
|
88 MII_BMSR_10T_FD
| MII_BMSR_10T_HD
| MII_BMSR_MFPS
|
89 MII_BMSR_AN_COMP
| MII_BMSR_AUTONEG
;
90 s
->regs
[MII_PHYID1
] = 0x2000;
91 s
->regs
[MII_PHYID2
] = 0x5c90;
92 s
->regs
[MII_ANAR
] = MII_ANAR_TXFD
| MII_ANAR_TX
|
93 MII_ANAR_10FD
| MII_ANAR_10
| MII_ANAR_CSMACD
;
94 mii_set_link(s
, s
->link_ok
);
97 static void mii_ro(Mii
*s
, uint16_t v
)
101 static void mii_write_bmcr(Mii
*s
, uint16_t v
)
103 if (v
& MII_BMCR_RESET
) {
106 s
->regs
[MII_BMCR
] = v
;
110 static void mii_write_host(Mii
*s
, unsigned idx
, uint16_t v
)
112 static void (*reg_write
[MII_REG_MAX
])(Mii
*s
, uint16_t v
) = {
113 [MII_BMCR
] = mii_write_bmcr
,
115 [MII_PHYID1
] = mii_ro
,
116 [MII_PHYID2
] = mii_ro
,
119 if (idx
< MII_REG_MAX
) {
120 trace_open_eth_mii_write(idx
, v
);
121 if (reg_write
[idx
]) {
122 reg_write
[idx
](s
, v
);
129 static uint16_t mii_read_host(Mii
*s
, unsigned idx
)
131 trace_open_eth_mii_read(idx
, s
->regs
[idx
]);
135 /* OpenCores Ethernet registers */
162 MODER_RECSMALL
= 0x10000,
164 MODER_HUGEN
= 0x4000,
166 MODER_LOOPBCK
= 0x80,
175 INT_SOURCE_BUSY
= 0x10,
176 INT_SOURCE_RXB
= 0x4,
177 INT_SOURCE_TXB
= 0x1,
181 PACKETLEN_MINFL
= 0xffff0000,
182 PACKETLEN_MINFL_LBN
= 16,
183 PACKETLEN_MAXFL
= 0xffff,
184 PACKETLEN_MAXFL_LBN
= 0,
188 MIICOMMAND_WCTRLDATA
= 0x4,
189 MIICOMMAND_RSTAT
= 0x2,
190 MIICOMMAND_SCANSTAT
= 0x1,
194 MIIADDRESS_RGAD
= 0x1f00,
195 MIIADDRESS_RGAD_LBN
= 8,
196 MIIADDRESS_FIAD
= 0x1f,
197 MIIADDRESS_FIAD_LBN
= 0,
201 MIITX_DATA_CTRLDATA
= 0xffff,
202 MIITX_DATA_CTRLDATA_LBN
= 0,
206 MIIRX_DATA_PRSD
= 0xffff,
207 MIIRX_DATA_PRSD_LBN
= 0,
211 MIISTATUS_LINKFAIL
= 0x1,
212 MIISTATUS_LINKFAIL_LBN
= 0,
216 MAC_ADDR0_BYTE2
= 0xff000000,
217 MAC_ADDR0_BYTE2_LBN
= 24,
218 MAC_ADDR0_BYTE3
= 0xff0000,
219 MAC_ADDR0_BYTE3_LBN
= 16,
220 MAC_ADDR0_BYTE4
= 0xff00,
221 MAC_ADDR0_BYTE4_LBN
= 8,
222 MAC_ADDR0_BYTE5
= 0xff,
223 MAC_ADDR0_BYTE5_LBN
= 0,
227 MAC_ADDR1_BYTE0
= 0xff00,
228 MAC_ADDR1_BYTE0_LBN
= 8,
229 MAC_ADDR1_BYTE1
= 0xff,
230 MAC_ADDR1_BYTE1_LBN
= 0,
234 TXD_LEN
= 0xffff0000,
251 RXD_LEN
= 0xffff0000,
267 typedef struct desc
{
272 #define DEFAULT_PHY 1
274 #define TYPE_OPEN_ETH "open_eth"
275 OBJECT_DECLARE_SIMPLE_TYPE(OpenEthState
, OPEN_ETH
)
277 struct OpenEthState
{
278 SysBusDevice parent_obj
;
283 MemoryRegion desc_io
;
287 uint32_t regs
[REG_MAX
];
293 static desc
*rx_desc(OpenEthState
*s
)
295 return s
->desc
+ s
->rx_desc
;
298 static desc
*tx_desc(OpenEthState
*s
)
300 return s
->desc
+ s
->tx_desc
;
303 static void open_eth_update_irq(OpenEthState
*s
,
304 uint32_t old
, uint32_t new)
307 trace_open_eth_update_irq(new);
308 qemu_set_irq(s
->irq
, new);
312 static void open_eth_int_source_write(OpenEthState
*s
,
315 uint32_t old_val
= s
->regs
[INT_SOURCE
];
317 s
->regs
[INT_SOURCE
] = val
;
318 open_eth_update_irq(s
, old_val
& s
->regs
[INT_MASK
],
319 s
->regs
[INT_SOURCE
] & s
->regs
[INT_MASK
]);
322 static void open_eth_set_link_status(NetClientState
*nc
)
324 OpenEthState
*s
= qemu_get_nic_opaque(nc
);
326 if (GET_REGBIT(s
, MIICOMMAND
, SCANSTAT
)) {
327 SET_REGFIELD(s
, MIISTATUS
, LINKFAIL
, nc
->link_down
);
329 mii_set_link(&s
->mii
, !nc
->link_down
);
332 static void open_eth_reset(void *opaque
)
334 OpenEthState
*s
= opaque
;
336 memset(s
->regs
, 0, sizeof(s
->regs
));
337 s
->regs
[MODER
] = 0xa000;
338 s
->regs
[IPGT
] = 0x12;
339 s
->regs
[IPGR1
] = 0xc;
340 s
->regs
[IPGR2
] = 0x12;
341 s
->regs
[PACKETLEN
] = 0x400600;
342 s
->regs
[COLLCONF
] = 0xf003f;
343 s
->regs
[TX_BD_NUM
] = 0x40;
344 s
->regs
[MIIMODER
] = 0x64;
350 open_eth_set_link_status(qemu_get_queue(s
->nic
));
353 static bool open_eth_can_receive(NetClientState
*nc
)
355 OpenEthState
*s
= qemu_get_nic_opaque(nc
);
357 return GET_REGBIT(s
, MODER
, RXEN
) && (s
->regs
[TX_BD_NUM
] < 0x80);
360 static ssize_t
open_eth_receive(NetClientState
*nc
,
361 const uint8_t *buf
, size_t size
)
363 OpenEthState
*s
= qemu_get_nic_opaque(nc
);
364 size_t maxfl
= GET_REGFIELD(s
, PACKETLEN
, MAXFL
);
365 size_t minfl
= GET_REGFIELD(s
, PACKETLEN
, MINFL
);
369 trace_open_eth_receive((unsigned)size
);
372 static const uint8_t bcast_addr
[] = {
373 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
375 if (memcmp(buf
, bcast_addr
, sizeof(bcast_addr
)) == 0) {
376 miss
= GET_REGBIT(s
, MODER
, BRO
);
377 } else if ((buf
[0] & 0x1) || GET_REGBIT(s
, MODER
, IAM
)) {
378 unsigned mcast_idx
= net_crc32(buf
, ETH_ALEN
) >> 26;
379 miss
= !(s
->regs
[HASH0
+ mcast_idx
/ 32] &
380 (1 << (mcast_idx
% 32)));
381 trace_open_eth_receive_mcast(
382 mcast_idx
, s
->regs
[HASH0
], s
->regs
[HASH1
]);
384 miss
= GET_REGFIELD(s
, MAC_ADDR1
, BYTE0
) != buf
[0] ||
385 GET_REGFIELD(s
, MAC_ADDR1
, BYTE1
) != buf
[1] ||
386 GET_REGFIELD(s
, MAC_ADDR0
, BYTE2
) != buf
[2] ||
387 GET_REGFIELD(s
, MAC_ADDR0
, BYTE3
) != buf
[3] ||
388 GET_REGFIELD(s
, MAC_ADDR0
, BYTE4
) != buf
[4] ||
389 GET_REGFIELD(s
, MAC_ADDR0
, BYTE5
) != buf
[5];
393 if (miss
&& !GET_REGBIT(s
, MODER
, PRO
)) {
394 trace_open_eth_receive_reject();
399 if (GET_REGBIT(s
, MODER
, RECSMALL
) || size
>= minfl
) {
403 static const uint8_t zero
[64] = {0};
404 desc
*desc
= rx_desc(s
);
405 size_t copy_size
= GET_REGBIT(s
, MODER
, HUGEN
) ? 65536 : maxfl
;
407 if (!(desc
->len_flags
& RXD_E
)) {
408 open_eth_int_source_write(s
,
409 s
->regs
[INT_SOURCE
] | INT_SOURCE_BUSY
);
413 desc
->len_flags
&= ~(RXD_CF
| RXD_M
| RXD_OR
|
414 RXD_IS
| RXD_DN
| RXD_TL
| RXD_SF
| RXD_CRC
| RXD_LC
);
416 if (copy_size
> size
) {
422 desc
->len_flags
|= RXD_M
;
424 if (GET_REGBIT(s
, MODER
, HUGEN
) && size
> maxfl
) {
425 desc
->len_flags
|= RXD_TL
;
429 desc
->len_flags
|= RXD_SF
;
433 cpu_physical_memory_write(desc
->buf_ptr
, buf
, copy_size
);
435 if (GET_REGBIT(s
, MODER
, PAD
) && copy_size
< minfl
) {
436 if (minfl
- copy_size
> fcsl
) {
439 fcsl
-= minfl
- copy_size
;
441 while (copy_size
< minfl
) {
442 size_t zero_sz
= minfl
- copy_size
< sizeof(zero
) ?
443 minfl
- copy_size
: sizeof(zero
);
445 cpu_physical_memory_write(desc
->buf_ptr
+ copy_size
,
447 copy_size
+= zero_sz
;
451 /* There's no FCS in the frames handed to us by the QEMU, zero fill it.
452 * Don't do it if the frame is cut at the MAXFL or padded with 4 or
453 * more bytes to the MINFL.
455 cpu_physical_memory_write(desc
->buf_ptr
+ copy_size
, zero
, fcsl
);
458 SET_FIELD(desc
->len_flags
, RXD_LEN
, copy_size
);
460 if ((desc
->len_flags
& RXD_WRAP
) || s
->rx_desc
== 0x7f) {
461 s
->rx_desc
= s
->regs
[TX_BD_NUM
];
465 desc
->len_flags
&= ~RXD_E
;
467 trace_open_eth_receive_desc(desc
->buf_ptr
, desc
->len_flags
);
469 if (desc
->len_flags
& RXD_IRQ
) {
470 open_eth_int_source_write(s
,
471 s
->regs
[INT_SOURCE
] | INT_SOURCE_RXB
);
477 static NetClientInfo net_open_eth_info
= {
478 .type
= NET_CLIENT_DRIVER_NIC
,
479 .size
= sizeof(NICState
),
480 .can_receive
= open_eth_can_receive
,
481 .receive
= open_eth_receive
,
482 .link_status_changed
= open_eth_set_link_status
,
485 static void open_eth_start_xmit(OpenEthState
*s
, desc
*tx
)
488 uint8_t buffer
[0x600];
489 unsigned len
= GET_FIELD(tx
->len_flags
, TXD_LEN
);
490 unsigned tx_len
= len
;
492 if ((tx
->len_flags
& TXD_PAD
) &&
493 tx_len
< GET_REGFIELD(s
, PACKETLEN
, MINFL
)) {
494 tx_len
= GET_REGFIELD(s
, PACKETLEN
, MINFL
);
496 if (!GET_REGBIT(s
, MODER
, HUGEN
) &&
497 tx_len
> GET_REGFIELD(s
, PACKETLEN
, MAXFL
)) {
498 tx_len
= GET_REGFIELD(s
, PACKETLEN
, MAXFL
);
501 trace_open_eth_start_xmit(tx
->buf_ptr
, len
, tx_len
);
503 if (tx_len
> sizeof(buffer
)) {
504 buf
= g_new(uint8_t, tx_len
);
511 cpu_physical_memory_read(tx
->buf_ptr
, buf
, len
);
513 memset(buf
+ len
, 0, tx_len
- len
);
515 qemu_send_packet(qemu_get_queue(s
->nic
), buf
, tx_len
);
516 if (tx_len
> sizeof(buffer
)) {
520 if (tx
->len_flags
& TXD_WR
) {
524 if (s
->tx_desc
>= s
->regs
[TX_BD_NUM
]) {
528 tx
->len_flags
&= ~(TXD_RD
| TXD_UR
|
529 TXD_RTRY
| TXD_RL
| TXD_LC
| TXD_DF
| TXD_CS
);
530 if (tx
->len_flags
& TXD_IRQ
) {
531 open_eth_int_source_write(s
, s
->regs
[INT_SOURCE
] | INT_SOURCE_TXB
);
536 static void open_eth_check_start_xmit(OpenEthState
*s
)
538 desc
*tx
= tx_desc(s
);
539 if (GET_REGBIT(s
, MODER
, TXEN
) && s
->regs
[TX_BD_NUM
] > 0 &&
540 (tx
->len_flags
& TXD_RD
) &&
541 GET_FIELD(tx
->len_flags
, TXD_LEN
) > 4) {
542 open_eth_start_xmit(s
, tx
);
546 static uint64_t open_eth_reg_read(void *opaque
,
547 hwaddr addr
, unsigned int size
)
549 static uint32_t (*reg_read
[REG_MAX
])(OpenEthState
*s
) = {
551 OpenEthState
*s
= opaque
;
552 unsigned idx
= addr
/ 4;
557 v
= reg_read
[idx
](s
);
562 trace_open_eth_reg_read((uint32_t)addr
, (uint32_t)v
);
566 static void open_eth_notify_can_receive(OpenEthState
*s
)
568 NetClientState
*nc
= qemu_get_queue(s
->nic
);
570 if (open_eth_can_receive(nc
)) {
571 qemu_flush_queued_packets(nc
);
575 static void open_eth_ro(OpenEthState
*s
, uint32_t val
)
579 static void open_eth_moder_host_write(OpenEthState
*s
, uint32_t val
)
581 uint32_t set
= val
& ~s
->regs
[MODER
];
583 if (set
& MODER_RST
) {
587 s
->regs
[MODER
] = val
;
589 if (set
& MODER_RXEN
) {
590 s
->rx_desc
= s
->regs
[TX_BD_NUM
];
591 open_eth_notify_can_receive(s
);
593 if (set
& MODER_TXEN
) {
595 open_eth_check_start_xmit(s
);
599 static void open_eth_int_source_host_write(OpenEthState
*s
, uint32_t val
)
601 uint32_t old
= s
->regs
[INT_SOURCE
];
603 s
->regs
[INT_SOURCE
] &= ~val
;
604 open_eth_update_irq(s
, old
& s
->regs
[INT_MASK
],
605 s
->regs
[INT_SOURCE
] & s
->regs
[INT_MASK
]);
608 static void open_eth_int_mask_host_write(OpenEthState
*s
, uint32_t val
)
610 uint32_t old
= s
->regs
[INT_MASK
];
612 s
->regs
[INT_MASK
] = val
;
613 open_eth_update_irq(s
, s
->regs
[INT_SOURCE
] & old
,
614 s
->regs
[INT_SOURCE
] & s
->regs
[INT_MASK
]);
617 static void open_eth_tx_bd_num_host_write(OpenEthState
*s
, uint32_t val
)
620 bool enable
= s
->regs
[TX_BD_NUM
] == 0x80;
622 s
->regs
[TX_BD_NUM
] = val
;
624 open_eth_notify_can_receive(s
);
629 static void open_eth_mii_command_host_write(OpenEthState
*s
, uint32_t val
)
631 unsigned fiad
= GET_REGFIELD(s
, MIIADDRESS
, FIAD
);
632 unsigned rgad
= GET_REGFIELD(s
, MIIADDRESS
, RGAD
);
634 if (val
& MIICOMMAND_WCTRLDATA
) {
635 if (fiad
== DEFAULT_PHY
) {
636 mii_write_host(&s
->mii
, rgad
,
637 GET_REGFIELD(s
, MIITX_DATA
, CTRLDATA
));
640 if (val
& MIICOMMAND_RSTAT
) {
641 if (fiad
== DEFAULT_PHY
) {
642 SET_REGFIELD(s
, MIIRX_DATA
, PRSD
,
643 mii_read_host(&s
->mii
, rgad
));
645 s
->regs
[MIIRX_DATA
] = 0xffff;
647 SET_REGFIELD(s
, MIISTATUS
, LINKFAIL
, qemu_get_queue(s
->nic
)->link_down
);
651 static void open_eth_mii_tx_host_write(OpenEthState
*s
, uint32_t val
)
653 SET_REGFIELD(s
, MIITX_DATA
, CTRLDATA
, val
);
654 if (GET_REGFIELD(s
, MIIADDRESS
, FIAD
) == DEFAULT_PHY
) {
655 mii_write_host(&s
->mii
, GET_REGFIELD(s
, MIIADDRESS
, RGAD
),
656 GET_REGFIELD(s
, MIITX_DATA
, CTRLDATA
));
660 static void open_eth_reg_write(void *opaque
,
661 hwaddr addr
, uint64_t val
, unsigned int size
)
663 static void (*reg_write
[REG_MAX
])(OpenEthState
*s
, uint32_t val
) = {
664 [MODER
] = open_eth_moder_host_write
,
665 [INT_SOURCE
] = open_eth_int_source_host_write
,
666 [INT_MASK
] = open_eth_int_mask_host_write
,
667 [TX_BD_NUM
] = open_eth_tx_bd_num_host_write
,
668 [MIICOMMAND
] = open_eth_mii_command_host_write
,
669 [MIITX_DATA
] = open_eth_mii_tx_host_write
,
670 [MIISTATUS
] = open_eth_ro
,
672 OpenEthState
*s
= opaque
;
673 unsigned idx
= addr
/ 4;
676 trace_open_eth_reg_write((uint32_t)addr
, (uint32_t)val
);
677 if (reg_write
[idx
]) {
678 reg_write
[idx
](s
, val
);
685 static uint64_t open_eth_desc_read(void *opaque
,
686 hwaddr addr
, unsigned int size
)
688 OpenEthState
*s
= opaque
;
692 memcpy(&v
, (uint8_t *)s
->desc
+ addr
, size
);
693 trace_open_eth_desc_read((uint32_t)addr
, (uint32_t)v
);
697 static void open_eth_desc_write(void *opaque
,
698 hwaddr addr
, uint64_t val
, unsigned int size
)
700 OpenEthState
*s
= opaque
;
703 trace_open_eth_desc_write((uint32_t)addr
, (uint32_t)val
);
704 memcpy((uint8_t *)s
->desc
+ addr
, &val
, size
);
705 open_eth_check_start_xmit(s
);
709 static const MemoryRegionOps open_eth_reg_ops
= {
710 .read
= open_eth_reg_read
,
711 .write
= open_eth_reg_write
,
714 static const MemoryRegionOps open_eth_desc_ops
= {
715 .read
= open_eth_desc_read
,
716 .write
= open_eth_desc_write
,
719 static void sysbus_open_eth_realize(DeviceState
*dev
, Error
**errp
)
721 SysBusDevice
*sbd
= SYS_BUS_DEVICE(dev
);
722 OpenEthState
*s
= OPEN_ETH(dev
);
724 memory_region_init_io(&s
->reg_io
, OBJECT(dev
), &open_eth_reg_ops
, s
,
725 "open_eth.regs", 0x54);
726 sysbus_init_mmio(sbd
, &s
->reg_io
);
728 memory_region_init_io(&s
->desc_io
, OBJECT(dev
), &open_eth_desc_ops
, s
,
729 "open_eth.desc", 0x400);
730 sysbus_init_mmio(sbd
, &s
->desc_io
);
732 sysbus_init_irq(sbd
, &s
->irq
);
734 s
->nic
= qemu_new_nic(&net_open_eth_info
, &s
->conf
,
735 object_get_typename(OBJECT(s
)), dev
->id
, s
);
738 static void qdev_open_eth_reset(DeviceState
*dev
)
740 OpenEthState
*d
= OPEN_ETH(dev
);
745 static Property open_eth_properties
[] = {
746 DEFINE_NIC_PROPERTIES(OpenEthState
, conf
),
747 DEFINE_PROP_END_OF_LIST(),
750 static void open_eth_class_init(ObjectClass
*klass
, void *data
)
752 DeviceClass
*dc
= DEVICE_CLASS(klass
);
754 dc
->realize
= sysbus_open_eth_realize
;
755 set_bit(DEVICE_CATEGORY_NETWORK
, dc
->categories
);
756 dc
->desc
= "Opencores 10/100 Mbit Ethernet";
757 dc
->reset
= qdev_open_eth_reset
;
758 device_class_set_props(dc
, open_eth_properties
);
761 static const TypeInfo open_eth_info
= {
762 .name
= TYPE_OPEN_ETH
,
763 .parent
= TYPE_SYS_BUS_DEVICE
,
764 .instance_size
= sizeof(OpenEthState
),
765 .class_init
= open_eth_class_init
,
768 static void open_eth_register_types(void)
770 type_register_static(&open_eth_info
);
773 type_init(open_eth_register_types
)