| 1 |
/* |
| 2 |
* Mach Operating System |
| 3 |
* Copyright (c) 1993,1992,1991,1990,1989 Carnegie Mellon University |
| 4 |
* All Rights Reserved. |
| 5 |
* |
| 6 |
* Permission to use, copy, modify and distribute this software and its |
| 7 |
* documentation is hereby granted, provided that both the copyright |
| 8 |
* notice and this permission notice appear in all copies of the |
| 9 |
* software, derivative works or modified versions, and any portions |
| 10 |
* thereof, and that both notices appear in supporting documentation. |
| 11 |
* |
| 12 |
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" |
| 13 |
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR |
| 14 |
* ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. |
| 15 |
* |
| 16 |
* Carnegie Mellon requests users of this software to return to |
| 17 |
* |
| 18 |
* Software Distribution Coordinator or [email protected] |
| 19 |
* School of Computer Science |
| 20 |
* Carnegie Mellon University |
| 21 |
* Pittsburgh PA 15213-3890 |
| 22 |
* |
| 23 |
* any improvements or extensions that they make and grant Carnegie Mellon |
| 24 |
* the rights to redistribute these changes. |
| 25 |
*/ |
| 26 |
|
| 27 |
#include <kern/printf.h> |
| 28 |
#include <mach/std_types.h> |
| 29 |
#include <i386at/autoconf.h> |
| 30 |
#include <i386/irq.h> |
| 31 |
#include <i386/ipl.h> |
| 32 |
#ifdef APIC |
| 33 |
# include <i386/apic.h> |
| 34 |
#else |
| 35 |
# include <i386/pic.h> |
| 36 |
#endif |
| 37 |
#include <chips/busses.h> |
| 38 |
|
| 39 |
/* initialization typecasts */ |
| 40 |
#define SPL_FIVE (vm_offset_t)SPL5 |
| 41 |
#define SPL_SIX (vm_offset_t)SPL6 |
| 42 |
#define SPL_TTY (vm_offset_t)SPLTTY |
| 43 |
|
| 44 |
|
| 45 |
#if NCOM > 0 |
| 46 |
extern struct bus_driver comdriver; |
| 47 |
#include <i386at/com.h> |
| 48 |
#endif /* NCOM */ |
| 49 |
|
| 50 |
#if NLPR > 0 |
| 51 |
extern struct bus_driver lprdriver; |
| 52 |
#include <i386at/lpr.h> |
| 53 |
#endif /* NLPR */ |
| 54 |
|
| 55 |
struct bus_ctlr bus_master_init[] = { |
| 56 |
|
| 57 |
/* driver name unit intr address len phys_address |
| 58 |
adaptor alive flags spl pic */ |
| 59 |
|
| 60 |
{0} |
| 61 |
}; |
| 62 |
|
| 63 |
|
| 64 |
struct bus_device bus_device_init[] = { |
| 65 |
|
| 66 |
/* driver name unit intr address am phys_address |
| 67 |
adaptor alive ctlr slave flags *mi *next sysdep sysdep */ |
| 68 |
|
| 69 |
#if NCOM > 0 |
| 70 |
{&comdriver, "com", 0, comintr, 0x3f8, 8, 0x3f8, |
| 71 |
'?', 0, -1, -1, 0, 0, 0, SPL_TTY, 4}, |
| 72 |
{&comdriver, "com", 1, comintr, 0x2f8, 8, 0x2f8, |
| 73 |
'?', 0, -1, -1, 0, 0, 0, SPL_TTY, 3}, |
| 74 |
{&comdriver, "com", 2, comintr, 0x3e8, 8, 0x3e8, |
| 75 |
'?', 0, -1, -1, 0, 0, 0, SPL_TTY, 5}, |
| 76 |
#endif /* NCOM > 0 */ |
| 77 |
|
| 78 |
#ifdef MACH_LPR |
| 79 |
#if NLPR > 0 |
| 80 |
{&lprdriver, "lpr", 0, lprintr, 0x378, 3, 0x378, |
| 81 |
'?', 0, -1, -1, 0, 0, 0, SPL_TTY, 7}, |
| 82 |
{&lprdriver, "lpr", 0, lprintr, 0x278, 3, 0x278, |
| 83 |
'?', 0, -1, -1, 0, 0, 0, SPL_TTY, 7}, |
| 84 |
{&lprdriver, "lpr", 0, lprintr, 0x3bc, 3, 0x3bc, |
| 85 |
'?', 0, -1, -1, 0, 0, 0, SPL_TTY, 7}, |
| 86 |
#endif /* NLPR > 0 */ |
| 87 |
#endif /* MACH_LPR */ |
| 88 |
|
| 89 |
{0} |
| 90 |
}; |
| 91 |
|
| 92 |
/* |
| 93 |
* probeio: |
| 94 |
* |
| 95 |
* Probe and subsequently attach devices out on the AT bus. |
| 96 |
* |
| 97 |
* |
| 98 |
*/ |
| 99 |
void probeio(void) |
| 100 |
{ |
| 101 |
struct bus_device *device; |
| 102 |
struct bus_ctlr *master; |
| 103 |
int i = 0; |
| 104 |
|
| 105 |
for (master = bus_master_init; master->driver; master++) |
| 106 |
{ |
| 107 |
if (configure_bus_master(master->name, master->address, |
| 108 |
master->phys_address, i, "atbus")) |
| 109 |
i++; |
| 110 |
} |
| 111 |
|
| 112 |
for (device = bus_device_init; device->driver; device++) |
| 113 |
{ |
| 114 |
/* ignore what we (should) have found already */ |
| 115 |
if (device->alive || device->ctlr >= 0) |
| 116 |
continue; |
| 117 |
if (configure_bus_device(device->name, device->address, |
| 118 |
device->phys_address, i, "atbus")) |
| 119 |
i++; |
| 120 |
} |
| 121 |
|
| 122 |
} |
| 123 |
|
| 124 |
void take_dev_irq( |
| 125 |
const struct bus_device *dev) |
| 126 |
{ |
| 127 |
int pic = (int)dev->sysdep1; |
| 128 |
|
| 129 |
if (ivect[pic] == intnull) { |
| 130 |
iunit[pic] = dev->unit; |
| 131 |
ivect[pic] = dev->intr; |
| 132 |
} else { |
| 133 |
printf("The device below will clobber IRQ %d (%p).\n", pic, ivect[pic]); |
| 134 |
printf("You have two devices at the same IRQ.\n"); |
| 135 |
printf("This won't work. Reconfigure your hardware and try again.\n"); |
| 136 |
printf("%s%d: port = %zx, spl = %zd, pic = %d.\n", |
| 137 |
dev->name, dev->unit, dev->address, |
| 138 |
dev->sysdep, dev->sysdep1); |
| 139 |
while (1); |
| 140 |
} |
| 141 |
|
| 142 |
unmask_irq(pic); |
| 143 |
} |