~fboudra/qemu-linaro/new-upstream-release-1.2.0-2012.09-0ubuntu1

« back to all changes in this revision

Viewing changes to hw/ne2000.c

  • Committer: Fathi Boudra
  • Author(s): Fathi Boudra
  • Date: 2012-08-21 06:47:11 UTC
  • mfrom: (0.1.16)
  • Revision ID: fathi.boudra@linaro.org-20120821064711-7yxmubp2v8a44xce
Tags: 1.1.50-2012.08-0ubuntu1
* New upstream release.
  - support emulated systems with more than 2G of memory. (LP: #1030588)
* Drop powerpc-missing-include.patch - merged upstream.
* Update debian/control: 
  - drop perl build dependency.
  - add libfdt-dev build dependency.
* Update debian/qemu-keymaps.install file.
* Update debian/rules:
  - update QEMU_CPU for ARM architecture: armv4l -> armv7l.
  - update conf_audio_drv: default to PulseAudio since PA is the default on
    Ubuntu.
  - enable KVM on ARM architecture.
  - enable flat device tree support (--enable-fdt). (LP: #1030594)

Show diffs side-by-side

added added

removed removed

Lines of Context:
150
150
    qemu_set_irq(s->irq, (isr != 0));
151
151
}
152
152
 
153
 
#define POLYNOMIAL 0x04c11db6
154
 
 
155
 
/* From FreeBSD */
156
 
/* XXX: optimize */
157
 
static int compute_mcast_idx(const uint8_t *ep)
158
 
{
159
 
    uint32_t crc;
160
 
    int carry, i, j;
161
 
    uint8_t b;
162
 
 
163
 
    crc = 0xffffffff;
164
 
    for (i = 0; i < 6; i++) {
165
 
        b = *ep++;
166
 
        for (j = 0; j < 8; j++) {
167
 
            carry = ((crc & 0x80000000L) ? 1 : 0) ^ (b & 0x01);
168
 
            crc <<= 1;
169
 
            b >>= 1;
170
 
            if (carry)
171
 
                crc = ((crc ^ POLYNOMIAL) | carry);
172
 
        }
173
 
    }
174
 
    return (crc >> 26);
175
 
}
176
 
 
177
153
static int ne2000_buffer_full(NE2000State *s)
178
154
{
179
155
    int avail, index, boundary;
189
165
    return 0;
190
166
}
191
167
 
192
 
int ne2000_can_receive(VLANClientState *nc)
 
168
int ne2000_can_receive(NetClientState *nc)
193
169
{
194
170
    NE2000State *s = DO_UPCAST(NICState, nc, nc)->opaque;
195
171
 
200
176
 
201
177
#define MIN_BUF_SIZE 60
202
178
 
203
 
ssize_t ne2000_receive(VLANClientState *nc, const uint8_t *buf, size_t size_)
 
179
ssize_t ne2000_receive(NetClientState *nc, const uint8_t *buf, size_t size_)
204
180
{
205
181
    NE2000State *s = DO_UPCAST(NICState, nc, nc)->opaque;
206
182
    int size = size_;
701
677
    NE2000State *s = opaque;
702
678
 
703
679
    if (addr < 0x10 && size == 1) {
704
 
        return ne2000_ioport_write(s, addr, data);
 
680
        ne2000_ioport_write(s, addr, data);
705
681
    } else if (addr == 0x10) {
706
682
        if (size <= 2) {
707
 
            return ne2000_asic_ioport_write(s, addr, data);
 
683
            ne2000_asic_ioport_write(s, addr, data);
708
684
        } else {
709
 
            return ne2000_asic_ioport_writel(s, addr, data);
 
685
            ne2000_asic_ioport_writel(s, addr, data);
710
686
        }
711
687
    } else if (addr == 0x1f && size == 1) {
712
 
        return ne2000_reset_ioport_write(s, addr, data);
 
688
        ne2000_reset_ioport_write(s, addr, data);
713
689
    }
714
690
}
715
691
 
727
703
    memory_region_init_io(&s->io, &ne2000_ops, s, "ne2000", size);
728
704
}
729
705
 
730
 
static void ne2000_cleanup(VLANClientState *nc)
 
706
static void ne2000_cleanup(NetClientState *nc)
731
707
{
732
708
    NE2000State *s = DO_UPCAST(NICState, nc, nc)->opaque;
733
709
 
735
711
}
736
712
 
737
713
static NetClientInfo net_ne2000_info = {
738
 
    .type = NET_CLIENT_TYPE_NIC,
 
714
    .type = NET_CLIENT_OPTIONS_KIND_NIC,
739
715
    .size = sizeof(NICState),
740
716
    .can_receive = ne2000_can_receive,
741
717
    .receive = ne2000_receive,
768
744
    return 0;
769
745
}
770
746
 
771
 
static int pci_ne2000_exit(PCIDevice *pci_dev)
 
747
static void pci_ne2000_exit(PCIDevice *pci_dev)
772
748
{
773
749
    PCINE2000State *d = DO_UPCAST(PCINE2000State, dev, pci_dev);
774
750
    NE2000State *s = &d->ne2000;
775
751
 
776
752
    memory_region_destroy(&s->io);
777
 
    qemu_del_vlan_client(&s->nic->nc);
778
 
    return 0;
 
753
    qemu_del_net_client(&s->nic->nc);
779
754
}
780
755
 
781
756
static Property ne2000_properties[] = {