Deleted Added
full compact
pccard_cis_quirks.c (119418) pccard_cis_quirks.c (120849)
1/* $NetBSD: pcmcia_cis_quirks.c,v 1.6 2000/04/12 21:07:55 scw Exp $ */
2
3#include <sys/cdefs.h>
1/* $NetBSD: pcmcia_cis_quirks.c,v 1.6 2000/04/12 21:07:55 scw Exp $ */
2
3#include <sys/cdefs.h>
4__FBSDID("$FreeBSD: head/sys/dev/pccard/pccard_cis_quirks.c 119418 2003-08-24 17:55:58Z obrien $");
4__FBSDID("$FreeBSD: head/sys/dev/pccard/pccard_cis_quirks.c 120849 2003-10-06 07:17:20Z imp $");
5
6#define PCCARDDEBUG
7
8/*
9 * Copyright (c) 1998 Marc Horowitz. All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions

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

203 &pccard_sveclancard_func0, &pccard_sveclancard_func0_cfe0 },
204 { PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID, PCMCIA_CIS_NDC_ND5100_E,
205 &pccard_ndc_nd5100_func0, &pccard_ndc_nd5100_func0_cfe0 },
206};
207
208static int n_pccard_cis_quirks =
209 sizeof(pccard_cis_quirks)/sizeof(pccard_cis_quirks[0]);
210
5
6#define PCCARDDEBUG
7
8/*
9 * Copyright (c) 1998 Marc Horowitz. All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions

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

203 &pccard_sveclancard_func0, &pccard_sveclancard_func0_cfe0 },
204 { PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID, PCMCIA_CIS_NDC_ND5100_E,
205 &pccard_ndc_nd5100_func0, &pccard_ndc_nd5100_func0_cfe0 },
206};
207
208static int n_pccard_cis_quirks =
209 sizeof(pccard_cis_quirks)/sizeof(pccard_cis_quirks[0]);
210
211static int
212pccard_cis_quirk_match(struct pccard_softc *sc, struct pccard_cis_quirk *q)
213{
214 if ((sc->card.manufacturer == q->manufacturer) &&
215 (sc->card.product == q->product) &&
216 (((sc->card.manufacturer != PCMCIA_VENDOR_INVALID) &&
217 (sc->card.product != PCMCIA_PRODUCT_INVALID)) ||
218 ((sc->card.manufacturer == PCMCIA_VENDOR_INVALID) &&
219 (sc->card.product == PCMCIA_PRODUCT_INVALID) &&
220 sc->card.cis1_info[0] &&
221 (strcmp(sc->card.cis1_info[0], q->cis1_info[0]) == 0) &&
222 sc->card.cis1_info[1] &&
223 (strcmp(sc->card.cis1_info[1], q->cis1_info[1]) == 0))))
224 return (1);
225 return (0);
226}
227
211void pccard_check_cis_quirks(device_t dev)
212{
213 struct pccard_softc *sc = PCCARD_SOFTC(dev);
214 int wiped = 0;
215 int i, j;
216 struct pccard_function *pf, *pf_next, *pf_last;
217 struct pccard_config_entry *cfe, *cfe_next;
228void pccard_check_cis_quirks(device_t dev)
229{
230 struct pccard_softc *sc = PCCARD_SOFTC(dev);
231 int wiped = 0;
232 int i, j;
233 struct pccard_function *pf, *pf_next, *pf_last;
234 struct pccard_config_entry *cfe, *cfe_next;
235 struct pccard_cis_quirk *q;
218
219 pf = NULL;
220 pf_last = NULL;
221
222 for (i=0; i<n_pccard_cis_quirks; i++) {
236
237 pf = NULL;
238 pf_last = NULL;
239
240 for (i=0; i<n_pccard_cis_quirks; i++) {
223 if ((sc->card.manufacturer == pccard_cis_quirks[i].manufacturer) &&
224 (sc->card.product == pccard_cis_quirks[i].product) &&
225 (((sc->card.manufacturer != PCMCIA_VENDOR_INVALID) &&
226 (sc->card.product != PCMCIA_PRODUCT_INVALID)) ||
227 ((sc->card.manufacturer == PCMCIA_VENDOR_INVALID) &&
228 (sc->card.product == PCMCIA_PRODUCT_INVALID) &&
229 sc->card.cis1_info[0] &&
230 (strcmp(sc->card.cis1_info[0],
231 pccard_cis_quirks[i].cis1_info[0]) == 0) &&
232 sc->card.cis1_info[1] &&
233 (strcmp(sc->card.cis1_info[1],
234 pccard_cis_quirks[i].cis1_info[1]) == 0)))) {
235 if (!wiped) {
236 if (bootverbose) {
237 device_printf(dev, "using CIS quirks for ");
238 for (j = 0; j < 4; j++) {
239 if (sc->card.cis1_info[j] == NULL)
240 break;
241 if (j)
242 printf(", ");
243 printf("%s", sc->card.cis1_info[j]);
244 }
245 printf("\n");
241 q = &pccard_cis_quirks[i];
242 if (!pccard_cis_quirk_match(sc, q))
243 continue;
244 if (!wiped) {
245 if (bootverbose) {
246 device_printf(dev, "using CIS quirks for ");
247 for (j = 0; j < 4; j++) {
248 if (sc->card.cis1_info[j] == NULL)
249 break;
250 if (j)
251 printf(", ");
252 printf("%s", sc->card.cis1_info[j]);
246 }
253 }
254 printf("\n");
255 }
247
256
248 for (pf = STAILQ_FIRST(&sc->card.pf_head); pf != NULL;
249 pf = pf_next) {
250 for (cfe = STAILQ_FIRST(&pf->cfe_head); cfe != NULL;
251 cfe = cfe_next) {
252 cfe_next = STAILQ_NEXT(cfe, cfe_list);
253 free(cfe, M_DEVBUF);
254 }
255 pf_next = STAILQ_NEXT(pf, pf_list);
256 free(pf, M_DEVBUF);
257 for (pf = STAILQ_FIRST(&sc->card.pf_head); pf != NULL;
258 pf = pf_next) {
259 for (cfe = STAILQ_FIRST(&pf->cfe_head); cfe != NULL;
260 cfe = cfe_next) {
261 cfe_next = STAILQ_NEXT(cfe, cfe_list);
262 free(cfe, M_DEVBUF);
257 }
263 }
258
259 STAILQ_INIT(&sc->card.pf_head);
260 wiped = 1;
264 pf_next = STAILQ_NEXT(pf, pf_list);
265 free(pf, M_DEVBUF);
261 }
262
266 }
267
263 if (pf_last == pccard_cis_quirks[i].pf) {
264 cfe = malloc(sizeof(*cfe), M_DEVBUF, M_NOWAIT);
265 *cfe = *pccard_cis_quirks[i].cfe;
268 STAILQ_INIT(&sc->card.pf_head);
269 wiped = 1;
270 }
266
271
267 STAILQ_INSERT_TAIL(&pf->cfe_head, cfe, cfe_list);
268 } else {
269 pf = malloc(sizeof(*pf), M_DEVBUF, M_NOWAIT);
270 *pf = *pccard_cis_quirks[i].pf;
271 STAILQ_INIT(&pf->cfe_head);
272
273 cfe = malloc(sizeof(*cfe), M_DEVBUF, M_NOWAIT);
274 *cfe = *pccard_cis_quirks[i].cfe;
275
276 STAILQ_INSERT_TAIL(&pf->cfe_head, cfe, cfe_list);
277 STAILQ_INSERT_TAIL(&sc->card.pf_head, pf, pf_list);
278
279 pf_last = pccard_cis_quirks[i].pf;
280 }
272 if (pf_last == q->pf) {
273 cfe = malloc(sizeof(*cfe), M_DEVBUF, M_NOWAIT);
274 *cfe = *q->cfe;
275 STAILQ_INSERT_TAIL(&pf->cfe_head, cfe, cfe_list);
276 } else {
277 pf = malloc(sizeof(*pf), M_DEVBUF, M_NOWAIT);
278 *pf = *q->pf;
279 STAILQ_INIT(&pf->cfe_head);
280 cfe = malloc(sizeof(*cfe), M_DEVBUF, M_NOWAIT);
281 *cfe = *q->cfe;
282 STAILQ_INSERT_TAIL(&pf->cfe_head, cfe, cfe_list);
283 STAILQ_INSERT_TAIL(&sc->card.pf_head, pf, pf_list);
284 pf_last = q->pf;
281 }
282 }
283}
285 }
286 }
287}