]> git.ipfire.org Git - thirdparty/qemu.git/blame - hw/ne2000-isa.c
net: Rename VLANClientState to NetClientState
[thirdparty/qemu.git] / hw / ne2000-isa.c
CommitLineData
9453c5bc
GH
1/*
2 * QEMU NE2000 emulation -- isa bus windup
3 *
4 * Copyright (c) 2003-2004 Fabrice Bellard
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 * THE SOFTWARE.
23 */
24#include "hw.h"
25#include "pc.h"
26#include "isa.h"
27#include "qdev.h"
28#include "net.h"
29#include "ne2000.h"
1ec4e1dd 30#include "exec-memory.h"
9453c5bc
GH
31
32typedef struct ISANE2000State {
33 ISADevice dev;
34 uint32_t iobase;
35 uint32_t isairq;
36 NE2000State ne2000;
37} ISANE2000State;
38
4e68f7a0 39static void isa_ne2000_cleanup(NetClientState *nc)
9453c5bc 40{
1c2045b5 41 NE2000State *s = DO_UPCAST(NICState, nc, nc)->opaque;
9453c5bc 42
1c2045b5 43 s->nic = NULL;
9453c5bc
GH
44}
45
1c2045b5 46static NetClientInfo net_ne2000_isa_info = {
2be64a68 47 .type = NET_CLIENT_OPTIONS_KIND_NIC,
1c2045b5
MM
48 .size = sizeof(NICState),
49 .can_receive = ne2000_can_receive,
50 .receive = ne2000_receive,
51 .cleanup = isa_ne2000_cleanup,
52};
53
d05ac8fa 54static const VMStateDescription vmstate_isa_ne2000 = {
be73cfe2
JQ
55 .name = "ne2000",
56 .version_id = 2,
57 .minimum_version_id = 0,
58 .minimum_version_id_old = 0,
59 .fields = (VMStateField []) {
60 VMSTATE_STRUCT(ne2000, ISANE2000State, 0, vmstate_ne2000, NE2000State),
61 VMSTATE_END_OF_LIST()
62 }
63};
64
9453c5bc
GH
65static int isa_ne2000_initfn(ISADevice *dev)
66{
67 ISANE2000State *isa = DO_UPCAST(ISANE2000State, dev, dev);
68 NE2000State *s = &isa->ne2000;
69
1ec4e1dd 70 ne2000_setup_io(s, 0x20);
a5028520 71 isa_register_ioport(dev, &s->io, isa->iobase);
9453c5bc
GH
72
73 isa_init_irq(dev, &s->irq, isa->isairq);
74
93db6685 75 qemu_macaddr_default_if_unset(&s->c.macaddr);
9453c5bc
GH
76 ne2000_reset(s);
77
1c2045b5 78 s->nic = qemu_new_nic(&net_ne2000_isa_info, &s->c,
f79f2bfc 79 object_get_typename(OBJECT(dev)), dev->qdev.id, s);
1c2045b5 80 qemu_format_nic_info_str(&s->nic->nc, s->c.macaddr.a);
9453c5bc 81
9453c5bc
GH
82 return 0;
83}
84
39bffca2
AL
85static Property ne2000_isa_properties[] = {
86 DEFINE_PROP_HEX32("iobase", ISANE2000State, iobase, 0x300),
87 DEFINE_PROP_UINT32("irq", ISANE2000State, isairq, 9),
88 DEFINE_NIC_PROPERTIES(ISANE2000State, ne2000.c),
89 DEFINE_PROP_END_OF_LIST(),
90};
91
8f04ee08
AL
92static void isa_ne2000_class_initfn(ObjectClass *klass, void *data)
93{
39bffca2 94 DeviceClass *dc = DEVICE_CLASS(klass);
8f04ee08
AL
95 ISADeviceClass *ic = ISA_DEVICE_CLASS(klass);
96 ic->init = isa_ne2000_initfn;
39bffca2 97 dc->props = ne2000_isa_properties;
8f04ee08
AL
98}
99
39bffca2
AL
100static TypeInfo ne2000_isa_info = {
101 .name = "ne2k_isa",
102 .parent = TYPE_ISA_DEVICE,
103 .instance_size = sizeof(ISANE2000State),
104 .class_init = isa_ne2000_class_initfn,
9453c5bc
GH
105};
106
83f7d43a 107static void ne2000_isa_register_types(void)
9453c5bc 108{
39bffca2 109 type_register_static(&ne2000_isa_info);
9453c5bc
GH
110}
111
83f7d43a 112type_init(ne2000_isa_register_types)