1 | /* $NetBSD: hmevar.h,v 1.24 2015/04/13 16:33:24 riastradh Exp $ */ |
2 | |
3 | /*- |
4 | * Copyright (c) 1999 The NetBSD Foundation, Inc. |
5 | * All rights reserved. |
6 | * |
7 | * This code is derived from software contributed to The NetBSD Foundation |
8 | * by Paul Kranenburg. |
9 | * |
10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions |
12 | * are met: |
13 | * 1. Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. |
15 | * 2. 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 | * |
19 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS |
20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS |
23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
29 | * POSSIBILITY OF SUCH DAMAGE. |
30 | */ |
31 | |
32 | #include <sys/callout.h> |
33 | #include <sys/rndsource.h> |
34 | |
35 | struct hme_ring { |
36 | /* Ring Descriptors */ |
37 | void * rb_membase; /* Packet buffer: CPU address */ |
38 | bus_addr_t rb_dmabase; /* Packet buffer: DMA address */ |
39 | void * rb_txd; /* Transmit descriptors */ |
40 | bus_addr_t rb_txddma; /* DMA address of same */ |
41 | void * rb_rxd; /* Receive descriptors */ |
42 | bus_addr_t rb_rxddma; /* DMA address of same */ |
43 | void * rb_txbuf; /* Transmit buffers */ |
44 | void * rb_rxbuf; /* Receive buffers */ |
45 | int rb_ntbuf; /* # of transmit buffers */ |
46 | int rb_nrbuf; /* # of receive buffers */ |
47 | |
48 | /* Ring Descriptor state */ |
49 | int rb_tdhead, rb_tdtail; |
50 | int rb_rdtail; |
51 | int rb_td_nbusy; |
52 | }; |
53 | |
54 | struct hme_softc { |
55 | device_t sc_dev; /* boilerplate device view */ |
56 | struct ethercom sc_ethercom; /* Ethernet common part */ |
57 | struct mii_data sc_mii; /* MII media control */ |
58 | struct callout sc_tick_ch; /* tick callout */ |
59 | |
60 | /* The following bus handles are to be provided by the bus front-end */ |
61 | bus_space_tag_t sc_bustag; /* bus tag */ |
62 | bus_dma_tag_t sc_dmatag; /* bus dma tag */ |
63 | bus_dmamap_t sc_dmamap; /* bus dma handle */ |
64 | bus_space_handle_t sc_seb; /* HME Global registers */ |
65 | bus_space_handle_t sc_erx; /* HME ERX registers */ |
66 | bus_space_handle_t sc_etx; /* HME ETX registers */ |
67 | bus_space_handle_t sc_mac; /* HME MAC registers */ |
68 | bus_space_handle_t sc_mif; /* HME MIF registers */ |
69 | int sc_burst; /* DVMA burst size in effect */ |
70 | int sc_phys[2]; /* MII instance -> PHY map */ |
71 | |
72 | int sc_pci; /* XXXXX -- PCI buses are LE. */ |
73 | |
74 | /* Ring descriptor */ |
75 | struct hme_ring sc_rb; |
76 | #if notused |
77 | void (*sc_copytobuf)(struct hme_softc *, |
78 | void *, void *, size_t); |
79 | void (*sc_copyfrombuf)(struct hme_softc *, |
80 | void *, void *, size_t); |
81 | #endif |
82 | |
83 | int sc_debug; |
84 | int sc_ec_capenable; |
85 | short sc_if_flags; |
86 | uint8_t sc_enaddr[ETHER_ADDR_LEN]; /* MAC address */ |
87 | |
88 | /* Special hardware hooks */ |
89 | void (*sc_hwreset)(struct hme_softc *); |
90 | void (*sc_hwinit)(struct hme_softc *); |
91 | |
92 | krndsource_t rnd_source; |
93 | }; |
94 | |
95 | |
96 | void hme_config(struct hme_softc *); |
97 | int hme_intr(void *); |
98 | |