proto_core.c (285069) | proto_core.c (285707) |
---|---|
1/*- | 1/*- |
2 * Copyright (c) 2014 Marcel Moolenaar | 2 * Copyright (c) 2014, 2015 Marcel Moolenaar |
3 * 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 * 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. --- 9 unchanged lines hidden (view full) --- 20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> | 3 * 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 * 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. --- 9 unchanged lines hidden (view full) --- 20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> |
28__FBSDID("$FreeBSD: head/sys/dev/proto/proto_core.c 285069 2015-07-03 01:52:22Z marcel $"); | 28__FBSDID("$FreeBSD: head/sys/dev/proto/proto_core.c 285707 2015-07-19 23:37:45Z marcel $"); |
29 30#include <sys/param.h> 31#include <sys/systm.h> 32#include <sys/bus.h> 33#include <sys/conf.h> 34#include <sys/cons.h> 35#include <sys/fcntl.h> 36#include <sys/interrupt.h> --- 78 unchanged lines hidden (view full) --- 115 struct proto_softc *sc = arg; 116 117 /* XXX TODO */ 118 return (FILTER_HANDLED); 119} 120#endif 121 122int | 29 30#include <sys/param.h> 31#include <sys/systm.h> 32#include <sys/bus.h> 33#include <sys/conf.h> 34#include <sys/cons.h> 35#include <sys/fcntl.h> 36#include <sys/interrupt.h> --- 78 unchanged lines hidden (view full) --- 115 struct proto_softc *sc = arg; 116 117 /* XXX TODO */ 118 return (FILTER_HANDLED); 119} 120#endif 121 122int |
123proto_probe(device_t dev, const char *prefix, char ***devnamesp) 124{ 125 char **devnames = *devnamesp; 126 const char *dn, *ep, *ev; 127 size_t pfxlen; 128 int idx, names; 129 130 if (devnames == NULL) { 131 pfxlen = strlen(prefix); 132 names = 1; /* NULL pointer */ 133 ev = kern_getenv("hw.proto.attach"); 134 if (ev != NULL) { 135 dn = ev; 136 while (*dn != '\0') { 137 ep = dn; 138 while (*ep != ',' && *ep != '\0') 139 ep++; 140 if ((ep - dn) > pfxlen && 141 strncmp(dn, prefix, pfxlen) == 0) 142 names++; 143 dn = (*ep == ',') ? ep + 1 : ep; 144 } 145 } 146 devnames = malloc(names * sizeof(caddr_t), M_DEVBUF, 147 M_WAITOK | M_ZERO); 148 *devnamesp = devnames; 149 if (ev != NULL) { 150 dn = ev; 151 idx = 0; 152 while (*dn != '\0') { 153 ep = dn; 154 while (*ep != ',' && *ep != '\0') 155 ep++; 156 if ((ep - dn) > pfxlen && 157 strncmp(dn, prefix, pfxlen) == 0) { 158 devnames[idx] = malloc(ep - dn + 1, 159 M_DEVBUF, M_WAITOK | M_ZERO); 160 memcpy(devnames[idx], dn, ep - dn); 161 idx++; 162 } 163 dn = (*ep == ',') ? ep + 1 : ep; 164 } 165 freeenv(__DECONST(char *, ev)); 166 } 167 } 168 169 dn = device_get_desc(dev); 170 while (*devnames != NULL) { 171 if (strcmp(dn, *devnames) == 0) 172 return (BUS_PROBE_SPECIFIC); 173 devnames++; 174 } 175 return (BUS_PROBE_HOOVER); 176} 177 178int |
|
123proto_attach(device_t dev) 124{ 125 struct proto_softc *sc; 126 struct proto_res *r; 127 u_int res; 128 129 sc = device_get_softc(dev); 130 sc->sc_dev = dev; --- 309 unchanged lines hidden --- | 179proto_attach(device_t dev) 180{ 181 struct proto_softc *sc; 182 struct proto_res *r; 183 u_int res; 184 185 sc = device_get_softc(dev); 186 sc->sc_dev = dev; --- 309 unchanged lines hidden --- |