Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/ctau/if_ct.c
Show First 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | |||||
static short porttab [] = { | static short porttab [] = { | ||||
0x200, 0x220, 0x240, 0x260, 0x280, 0x2a0, 0x2c0, 0x2e0, | 0x200, 0x220, 0x240, 0x260, 0x280, 0x2a0, 0x2c0, 0x2e0, | ||||
0x300, 0x320, 0x340, 0x360, 0x380, 0x3a0, 0x3c0, 0x3e0, 0 | 0x300, 0x320, 0x340, 0x360, 0x380, 0x3a0, 0x3c0, 0x3e0, 0 | ||||
}; | }; | ||||
static char dmatab [] = { 7, 6, 5, 0 }; | static char dmatab [] = { 7, 6, 5, 0 }; | ||||
static char irqtab [] = { 5, 10, 11, 7, 3, 15, 12, 0 }; | static char irqtab [] = { 5, 10, 11, 7, 3, 15, 12, 0 }; | ||||
static int ct_is_free_res (device_t dev, int rid, int type, u_long start, | static int ct_is_free_res (device_t dev, int rid, int type, rman_res_t start, | ||||
u_long end, u_long count) | rman_res_t end, rman_res_t count) | ||||
{ | { | ||||
struct resource *res; | struct resource *res; | ||||
if (!(res = bus_alloc_resource (dev, type, &rid, start, end, count, 0))) | if (!(res = bus_alloc_resource (dev, type, &rid, start, end, count, 0))) | ||||
return 0; | return 0; | ||||
bus_release_resource (dev, type, rid, res); | bus_release_resource (dev, type, rid, res); | ||||
return 1; | return 1; | ||||
} | } | ||||
static void ct_identify (driver_t *driver, device_t dev) | static void ct_identify (driver_t *driver, device_t dev) | ||||
{ | { | ||||
u_long iobase, rescount; | rman_res_t iobase, rescount; | ||||
int devcount; | int devcount; | ||||
device_t *devices; | device_t *devices; | ||||
device_t child; | device_t child; | ||||
devclass_t my_devclass; | devclass_t my_devclass; | ||||
int i, k; | int i, k; | ||||
if ((my_devclass = devclass_find ("ct")) == NULL) | if ((my_devclass = devclass_find ("ct")) == NULL) | ||||
return; | return; | ||||
▲ Show 20 Lines • Show All 84 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
return; | return; | ||||
} | } | ||||
static int ct_probe (device_t dev) | static int ct_probe (device_t dev) | ||||
{ | { | ||||
int unit = device_get_unit (dev); | int unit = device_get_unit (dev); | ||||
u_long iobase, rescount; | rman_res_t iobase, rescount; | ||||
if (!device_get_desc (dev) || | if (!device_get_desc (dev) || | ||||
strcmp (device_get_desc (dev), "Cronyx Tau-ISA")) | strcmp (device_get_desc (dev), "Cronyx Tau-ISA")) | ||||
return ENXIO; | return ENXIO; | ||||
/* KASSERT ((bd != NULL), ("ct%d: NULL device softc\n", unit));*/ | /* KASSERT ((bd != NULL), ("ct%d: NULL device softc\n", unit));*/ | ||||
if (bus_get_resource (dev, SYS_RES_IOPORT, 0, &iobase, &rescount) != 0) { | if (bus_get_resource (dev, SYS_RES_IOPORT, 0, &iobase, &rescount) != 0) { | ||||
printf ("ct%d: Couldn't get IOPORT\n", unit); | printf ("ct%d: Couldn't get IOPORT\n", unit); | ||||
return ENXIO; | return ENXIO; | ||||
} | } | ||||
if (!ct_is_free_res (dev, 0, SYS_RES_IOPORT, | if (!ct_is_free_res (dev, 0, SYS_RES_IOPORT, | ||||
iobase, iobase + NPORT, NPORT)) { | iobase, iobase + NPORT, NPORT)) { | ||||
printf ("ct%d: Resource IOPORT isn't free\n", unit); | printf ("ct%d: Resource IOPORT isn't free\n", unit); | ||||
return ENXIO; | return ENXIO; | ||||
} | } | ||||
if (!ct_probe_board (iobase, -1, -1)) { | if (!ct_probe_board (iobase, -1, -1)) { | ||||
printf ("ct%d: probing for Tau-ISA at %lx faild\n", unit, iobase); | printf ("ct%d: probing for Tau-ISA at %jx faild\n", unit, iobase); | ||||
return ENXIO; | return ENXIO; | ||||
} | } | ||||
return 0; | return 0; | ||||
} | } | ||||
static void | static void | ||||
ct_bus_dmamap_addr (void *arg, bus_dma_segment_t *segs, int nseg, int error) | ct_bus_dmamap_addr (void *arg, bus_dma_segment_t *segs, int nseg, int error) | ||||
▲ Show 20 Lines • Show All 53 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
/* | /* | ||||
* The adapter is present, initialize the driver structures. | * The adapter is present, initialize the driver structures. | ||||
*/ | */ | ||||
static int ct_attach (device_t dev) | static int ct_attach (device_t dev) | ||||
{ | { | ||||
bdrv_t *bd = device_get_softc (dev); | bdrv_t *bd = device_get_softc (dev); | ||||
u_long iobase, drq, irq, rescount; | rman_res_t iobase, drq, irq, rescount; | ||||
int unit = device_get_unit (dev); | int unit = device_get_unit (dev); | ||||
char *ct_ln = CT_LOCK_NAME; | char *ct_ln = CT_LOCK_NAME; | ||||
ct_board_t *b; | ct_board_t *b; | ||||
ct_chan_t *c; | ct_chan_t *c; | ||||
drv_t *d; | drv_t *d; | ||||
int i; | int i; | ||||
int s; | int s; | ||||
▲ Show 20 Lines • Show All 84 Lines • ▼ Show 20 Lines | |||||
return ENXIO; | return ENXIO; | ||||
} | } | ||||
bd->board = b; | bd->board = b; | ||||
ct_ln[2] = '0' + unit; | ct_ln[2] = '0' + unit; | ||||
mtx_init (&bd->ct_mtx, ct_ln, MTX_NETWORK_LOCK, MTX_DEF|MTX_RECURSE); | mtx_init (&bd->ct_mtx, ct_ln, MTX_NETWORK_LOCK, MTX_DEF|MTX_RECURSE); | ||||
if (! probe_irq (b, irq)) { | if (! probe_irq (b, irq)) { | ||||
printf ("ct%d: irq %ld not functional\n", unit, irq); | printf ("ct%d: irq %jd not functional\n", unit, irq); | ||||
bd->board = 0; | bd->board = 0; | ||||
adapter [unit] = 0; | adapter [unit] = 0; | ||||
free (b, M_DEVBUF); | free (b, M_DEVBUF); | ||||
bus_release_resource (dev, SYS_RES_IRQ, bd->irq_rid, | bus_release_resource (dev, SYS_RES_IRQ, bd->irq_rid, | ||||
bd->irq_res); | bd->irq_res); | ||||
bus_release_resource (dev, SYS_RES_DRQ, bd->drq_rid, | bus_release_resource (dev, SYS_RES_DRQ, bd->drq_rid, | ||||
bd->drq_res); | bd->drq_res); | ||||
bus_release_resource (dev, SYS_RES_IOPORT, bd->base_rid, | bus_release_resource (dev, SYS_RES_IOPORT, bd->base_rid, | ||||
bd->base_res); | bd->base_res); | ||||
mtx_destroy (&bd->ct_mtx); | mtx_destroy (&bd->ct_mtx); | ||||
return ENXIO; | return ENXIO; | ||||
} | } | ||||
callout_init (&led_timo[unit], 1); | callout_init (&led_timo[unit], 1); | ||||
s = splimp (); | s = splimp (); | ||||
if (bus_setup_intr (dev, bd->irq_res, | if (bus_setup_intr (dev, bd->irq_res, | ||||
INTR_TYPE_NET|INTR_MPSAFE, | INTR_TYPE_NET|INTR_MPSAFE, | ||||
NULL, ct_intr, bd, &bd->intrhand)) { | NULL, ct_intr, bd, &bd->intrhand)) { | ||||
printf ("ct%d: Can't setup irq %ld\n", unit, irq); | printf ("ct%d: Can't setup irq %jd\n", unit, irq); | ||||
bd->board = 0; | bd->board = 0; | ||||
adapter [unit] = 0; | adapter [unit] = 0; | ||||
free (b, M_DEVBUF); | free (b, M_DEVBUF); | ||||
bus_release_resource (dev, SYS_RES_IRQ, bd->irq_rid, | bus_release_resource (dev, SYS_RES_IRQ, bd->irq_rid, | ||||
bd->irq_res); | bd->irq_res); | ||||
bus_release_resource (dev, SYS_RES_DRQ, bd->drq_rid, | bus_release_resource (dev, SYS_RES_DRQ, bd->drq_rid, | ||||
bd->drq_res); | bd->drq_res); | ||||
bus_release_resource (dev, SYS_RES_IOPORT, bd->base_rid, | bus_release_resource (dev, SYS_RES_IOPORT, bd->base_rid, | ||||
▲ Show 20 Lines • Show All 42 Lines • Show Last 20 Lines |