Deleted Added
sdiff udiff text old ( 119288 ) new ( 120980 )
full compact
1/*
2 * Copyright (c) 1997, 1998, 1999
3 * Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 63 unchanged lines hidden (view full) ---

72 * - Raymond Lee of Netgear, for providing a pair of Netgear
73 * GA620 Tigon 2 boards for testing
74 * - Ulf Zimmermann, for bringing the GA260 to my attention and
75 * convincing me to write this driver.
76 * - Andrew Gallatin for providing FreeBSD/Alpha support.
77 */
78
79#include <sys/cdefs.h>
80__FBSDID("$FreeBSD: head/sys/dev/ti/if_ti.c 120980 2003-10-10 20:35:28Z phk $");
81
82#include "opt_ti.h"
83
84#include <sys/param.h>
85#include <sys/systm.h>
86#include <sys/sockio.h>
87#include <sys/mbuf.h>
88#include <sys/malloc.h>

--- 38 unchanged lines hidden (view full) ---

127#include <vm/vm_pageout.h>
128#include <sys/vmmeter.h>
129#include <vm/vm_page.h>
130#include <vm/vm_object.h>
131#include <vm/vm_kern.h>
132#include <sys/proc.h>
133#include <sys/jumbo.h>
134#endif /* !TI_PRIVATE_JUMBOS */
135
136#include <dev/pci/pcireg.h>
137#include <dev/pci/pcivar.h>
138
139#include <sys/tiio.h>
140#include <pci/if_tireg.h>
141#include <pci/ti_fw.h>
142#include <pci/ti_fw2.h>

--- 134 unchanged lines hidden (view full) ---

277};
278
279static devclass_t ti_devclass;
280
281DRIVER_MODULE(ti, pci, ti_driver, ti_devclass, 0, 0);
282MODULE_DEPEND(ti, pci, 1, 1, 1);
283MODULE_DEPEND(ti, ether, 1, 1, 1);
284
285/*
286 * Send an instruction or address to the EEPROM, check for ACK.
287 */
288static u_int32_t ti_eeprom_putbyte(sc, byte)
289 struct ti_softc *sc;
290 int byte;
291{
292 register int i, ack = 0;

--- 1934 unchanged lines hidden (view full) ---

2227 ifmedia_add(&sc->ifmedia, IFM_ETHER|IFM_AUTO, 0, NULL);
2228 ifmedia_set(&sc->ifmedia, IFM_ETHER|IFM_AUTO);
2229
2230 /*
2231 * We're assuming here that card initialization is a sequential
2232 * thing. If it isn't, multiple cards probing at the same time
2233 * could stomp on the list of softcs here.
2234 */
2235
2236 /* Register the device */
2237 sc->dev = make_dev(&ti_cdevsw, sc->ti_unit, UID_ROOT, GID_OPERATOR,
2238 0600, "ti%d", sc->ti_unit);
2239 sc->dev->si_drv1 = sc;
2240
2241 /*
2242 * Call MI attach routine.
2243 */
2244 ether_ifattach(ifp, sc->arpcom.ac_enaddr);
2245
2246 /* Hook interrupt last to avoid having to lock softc */
2247 error = bus_setup_intr(dev, sc->ti_irq, INTR_TYPE_NET,

--- 8 unchanged lines hidden (view full) ---

2256fail:
2257 if (sc && error)
2258 ti_detach(dev);
2259
2260 return(error);
2261}
2262
2263/*
2264 * Shutdown hardware and free up resources. This can be called any
2265 * time after the mutex has been initialized. It is called in both
2266 * the error case in attach and the normal detach case so it needs
2267 * to be careful about only freeing resources that have actually been
2268 * allocated.
2269 */
2270static int
2271ti_detach(dev)
2272 device_t dev;
2273{
2274 struct ti_softc *sc;
2275 struct ifnet *ifp;
2276
2277 sc = device_get_softc(dev);
2278 destroy_dev(sc->dev);
2279 KASSERT(mtx_initialized(&sc->ti_mtx), ("ti mutex not initialized"));
2280 TI_LOCK(sc);
2281 ifp = &sc->arpcom.ac_if;
2282
2283 /* These should only be active if attach succeeded */
2284 if (device_is_attached(dev)) {
2285 ti_stop(sc);
2286 ether_ifdetach(ifp);

--- 834 unchanged lines hidden (view full) ---

3121 TI_UNLOCK(sc);
3122
3123 return(error);
3124}
3125
3126static int
3127ti_open(dev_t dev, int flags, int fmt, struct thread *td)
3128{
3129 struct ti_softc *sc;
3130
3131 sc = dev->si_drv1;
3132 if (sc == NULL)
3133 return(ENODEV);
3134
3135 TI_LOCK(sc);
3136 sc->ti_flags |= TI_FLAG_DEBUGING;
3137 TI_UNLOCK(sc);
3138
3139 return(0);
3140}
3141
3142static int
3143ti_close(dev_t dev, int flag, int fmt, struct thread *td)
3144{
3145 struct ti_softc *sc;
3146
3147 sc = dev->si_drv1;
3148 if (sc == NULL)
3149 return(ENODEV);
3150
3151 TI_LOCK(sc);
3152 sc->ti_flags &= ~TI_FLAG_DEBUGING;
3153 TI_UNLOCK(sc);
3154
3155 return(0);
3156}
3157
3158/*
3159 * This ioctl routine goes along with the Tigon character device.
3160 */
3161static int
3162ti_ioctl2(dev_t dev, u_long cmd, caddr_t addr, int flag, struct thread *td)
3163{
3164 int error;
3165 struct ti_softc *sc;
3166
3167 sc = dev->si_drv1;
3168 if (sc == NULL)
3169 return(ENODEV);
3170
3171 error = 0;
3172
3173 switch(cmd) {
3174 case TIIOCGETSTATS:
3175 {

--- 342 unchanged lines hidden ---