Deleted Added
full compact
eisaconf.c (49281) eisaconf.c (49360)
1/*
2 * EISA bus probe and attach routines
3 *
4 * Copyright (c) 1995, 1996 Justin T. Gibbs.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

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

23 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.
30 *
1/*
2 * EISA bus probe and attach routines
3 *
4 * Copyright (c) 1995, 1996 Justin T. Gibbs.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

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

23 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.
30 *
31 * $Id: eisaconf.c,v 1.48 1999/07/29 01:02:51 mdodd Exp $
31 * $Id: eisaconf.c,v 1.49 1999/07/30 13:54:00 mdodd Exp $
32 */
33
34#include "opt_eisa.h"
35
36#include <sys/param.h>
37#include <sys/systm.h>
38#include <sys/queue.h>
39#include <sys/malloc.h>

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

57 struct resource *res; /* resource manager handle */
58 LIST_ENTRY(resvaddr) links; /* List links */
59} resvaddr_t;
60
61LIST_HEAD(resvlist, resvaddr);
62
63struct irq_node {
64 int irq_no;
32 */
33
34#include "opt_eisa.h"
35
36#include <sys/param.h>
37#include <sys/systm.h>
38#include <sys/queue.h>
39#include <sys/malloc.h>

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

57 struct resource *res; /* resource manager handle */
58 LIST_ENTRY(resvaddr) links; /* List links */
59} resvaddr_t;
60
61LIST_HEAD(resvlist, resvaddr);
62
63struct irq_node {
64 int irq_no;
65 int irq_trigger;
65 void *idesc;
66 TAILQ_ENTRY(irq_node) links;
67};
68
69TAILQ_HEAD(irqlist, irq_node);
70
71struct eisa_ioconf {
72 int slot;

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

87#ifndef EISA_SLOTS
88#define EISA_SLOTS 10 /* PCI clashes with higher ones.. fix later */
89#endif
90int num_eisa_slots = EISA_SLOTS;
91
92static devclass_t eisa_devclass;
93
94static void eisa_reg_print (device_t, char *, char *, int *);
66 void *idesc;
67 TAILQ_ENTRY(irq_node) links;
68};
69
70TAILQ_HEAD(irqlist, irq_node);
71
72struct eisa_ioconf {
73 int slot;

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

88#ifndef EISA_SLOTS
89#define EISA_SLOTS 10 /* PCI clashes with higher ones.. fix later */
90#endif
91int num_eisa_slots = EISA_SLOTS;
92
93static devclass_t eisa_devclass;
94
95static void eisa_reg_print (device_t, char *, char *, int *);
95static int eisa_find_irq(struct eisa_device *e_dev, int rid);
96static struct irq_node * eisa_find_irq(struct eisa_device *e_dev, int rid);
96static struct resvaddr * eisa_find_maddr(struct eisa_device *e_dev, int rid);
97static struct resvaddr * eisa_find_ioaddr(struct eisa_device *e_dev, int rid);
98
99static int
100mainboard_probe(device_t dev)
101{
102 char *idstring;
103 eisa_id_t id = eisa_get_id(dev);

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

297 resv->addr,
298 (resv->addr + (resv->size - 1)));
299 }
300 eisa_reg_print(child, buf,
301 ((rid == 2) ? &separator : NULL), &column);
302 }
303
304 rid = 0;
97static struct resvaddr * eisa_find_maddr(struct eisa_device *e_dev, int rid);
98static struct resvaddr * eisa_find_ioaddr(struct eisa_device *e_dev, int rid);
99
100static int
101mainboard_probe(device_t dev)
102{
103 char *idstring;
104 eisa_id_t id = eisa_get_id(dev);

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

298 resv->addr,
299 (resv->addr + (resv->size - 1)));
300 }
301 eisa_reg_print(child, buf,
302 ((rid == 2) ? &separator : NULL), &column);
303 }
304
305 rid = 0;
305 while ((irq = eisa_find_irq(e_dev, rid++)) != -1) {
306 snprintf(buf, sizeof(buf), "irq %d", irq);
306 while ((irq = eisa_find_irq(e_dev, rid++)) != NULL) {
307 snprintf(buf, sizeof(buf), "irq %d (%s)", irq->irq_no,
308 (irq->irq_trigger ? "level" : "edge"));
307 eisa_reg_print(child, buf,
308 ((rid == 1) ? &separator : NULL), &column);
309 }
310
311 snprintf(buf, sizeof(buf), "on %s slot %d\n",
312 device_get_nameunit(dev), eisa_get_slot(child));
313 eisa_reg_print(child, buf, NULL, &column);
314
315 return (retval);
316}
317
309 eisa_reg_print(child, buf,
310 ((rid == 1) ? &separator : NULL), &column);
311 }
312
313 snprintf(buf, sizeof(buf), "on %s slot %d\n",
314 device_get_nameunit(dev), eisa_get_slot(child));
315 eisa_reg_print(child, buf, NULL, &column);
316
317 return (retval);
318}
319
318static int
320static struct irq_node *
319eisa_find_irq(struct eisa_device *e_dev, int rid)
320{
321 int i;
322 struct irq_node *irq;
323
324 for (i = 0, irq = TAILQ_FIRST(&e_dev->ioconf.irqs);
325 i < rid && irq;
326 i++, irq = TAILQ_NEXT(irq, links))
327 ;
328
329 if (irq)
321eisa_find_irq(struct eisa_device *e_dev, int rid)
322{
323 int i;
324 struct irq_node *irq;
325
326 for (i = 0, irq = TAILQ_FIRST(&e_dev->ioconf.irqs);
327 i < rid && irq;
328 i++, irq = TAILQ_NEXT(irq, links))
329 ;
330
331 if (irq)
330 return irq->irq_no;
332 return (irq);
331 else
333 else
332 return -1;
334 return (NULL);
333}
334
335static struct resvaddr *
336eisa_find_maddr(struct eisa_device *e_dev, int rid)
337{
338 int i;
339 struct resvaddr *resv;
340

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

359
360 return resv;
361}
362
363static int
364eisa_read_ivar(device_t dev, device_t child, int which, u_long *result)
365{
366 struct eisa_device *e_dev = device_get_ivars(child);
335}
336
337static struct resvaddr *
338eisa_find_maddr(struct eisa_device *e_dev, int rid)
339{
340 int i;
341 struct resvaddr *resv;
342

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

361
362 return resv;
363}
364
365static int
366eisa_read_ivar(device_t dev, device_t child, int which, u_long *result)
367{
368 struct eisa_device *e_dev = device_get_ivars(child);
369 struct irq_node *irq;
367
368 switch (which) {
369 case EISA_IVAR_SLOT:
370 *result = e_dev->ioconf.slot;
371 break;
372
373 case EISA_IVAR_ID:
374 *result = e_dev->id;
375 break;
376
377 case EISA_IVAR_IRQ:
378 /* XXX only first irq */
370
371 switch (which) {
372 case EISA_IVAR_SLOT:
373 *result = e_dev->ioconf.slot;
374 break;
375
376 case EISA_IVAR_ID:
377 *result = e_dev->id;
378 break;
379
380 case EISA_IVAR_IRQ:
381 /* XXX only first irq */
379 *result = eisa_find_irq(e_dev, 0);
382 if ((irq = eisa_find_irq(e_dev, 0)) != NULL) {
383 *result = irq->irq_no;
384 } else {
385 *result = -1;
386 }
380 break;
381
382 default:
383 return (ENOENT);
384 }
385
386 return (0);
387}

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

401 struct resource *rv, **rvp = 0;
402
403 isdefault = (device_get_parent(child) == dev
404 && start == 0UL && end == ~0UL && count == 1);
405
406 switch (type) {
407 case SYS_RES_IRQ:
408 if (isdefault) {
387 break;
388
389 default:
390 return (ENOENT);
391 }
392
393 return (0);
394}

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

408 struct resource *rv, **rvp = 0;
409
410 isdefault = (device_get_parent(child) == dev
411 && start == 0UL && end == ~0UL && count == 1);
412
413 switch (type) {
414 case SYS_RES_IRQ:
415 if (isdefault) {
409 int irq = eisa_find_irq(e_dev, *rid);
410 if (irq == -1)
416 struct irq_node * irq = eisa_find_irq(e_dev, *rid);
417 if (irq == NULL)
411 return 0;
418 return 0;
412 start = end = irq;
419 start = end = irq->irq_no;
413 count = 1;
420 count = 1;
421 if (irq->irq_trigger == EISA_TRIGGER_LEVEL) {
422 flags |= RF_SHAREABLE;
423 } else {
424 flags &= ~RF_SHAREABLE;
425 }
414 }
415 break;
416
417 case SYS_RES_MEMORY:
418 if (isdefault) {
419 struct resvaddr *resv;
420
421 resv = eisa_find_maddr(e_dev, *rid);

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

461 struct resource *r)
462{
463 int rv;
464 struct eisa_device *e_dev = device_get_ivars(child);
465 struct resvaddr *resv = 0;
466
467 switch (type) {
468 case SYS_RES_IRQ:
426 }
427 break;
428
429 case SYS_RES_MEMORY:
430 if (isdefault) {
431 struct resvaddr *resv;
432
433 resv = eisa_find_maddr(e_dev, *rid);

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

473 struct resource *r)
474{
475 int rv;
476 struct eisa_device *e_dev = device_get_ivars(child);
477 struct resvaddr *resv = 0;
478
479 switch (type) {
480 case SYS_RES_IRQ:
469 if (eisa_find_irq(e_dev, rid) == -1)
481 if (eisa_find_irq(e_dev, rid) == NULL)
470 return EINVAL;
471 break;
472
473 case SYS_RES_MEMORY:
474 if (device_get_parent(child) == dev)
475 resv = eisa_find_maddr(e_dev, rid);
476 break;
477

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

491 if (resv)
492 resv->res = 0;
493 }
494
495 return rv;
496}
497
498int
482 return EINVAL;
483 break;
484
485 case SYS_RES_MEMORY:
486 if (device_get_parent(child) == dev)
487 resv = eisa_find_maddr(e_dev, rid);
488 break;
489

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

503 if (resv)
504 resv->res = 0;
505 }
506
507 return rv;
508}
509
510int
499eisa_add_intr(device_t dev, int irq)
511eisa_add_intr(device_t dev, int irq, int trigger)
500{
501 struct eisa_device *e_dev = device_get_ivars(dev);
512{
513 struct eisa_device *e_dev = device_get_ivars(dev);
502 struct irq_node *irq_info;
514 struct irq_node *irq_info;
503
504 irq_info = (struct irq_node *)malloc(sizeof(*irq_info), M_DEVBUF,
505 M_NOWAIT);
506 if (irq_info == NULL)
507 return (1);
508
509 irq_info->irq_no = irq;
515
516 irq_info = (struct irq_node *)malloc(sizeof(*irq_info), M_DEVBUF,
517 M_NOWAIT);
518 if (irq_info == NULL)
519 return (1);
520
521 irq_info->irq_no = irq;
522 irq_info->irq_trigger = trigger;
510 irq_info->idesc = NULL;
511 TAILQ_INSERT_TAIL(&e_dev->ioconf.irqs, irq_info, links);
512 return 0;
513}
514
515static int
516eisa_add_resvaddr(struct eisa_device *e_dev, struct resvlist *head, u_long base,
517 u_long size, int flags)

--- 96 unchanged lines hidden ---
523 irq_info->idesc = NULL;
524 TAILQ_INSERT_TAIL(&e_dev->ioconf.irqs, irq_info, links);
525 return 0;
526}
527
528static int
529eisa_add_resvaddr(struct eisa_device *e_dev, struct resvlist *head, u_long base,
530 u_long size, int flags)

--- 96 unchanged lines hidden ---