Re: midi problem, an isa device on a pci card

2003-04-06 Thread Mathew Kanner
Hello,
I've recived no responses.  Anyway, the following includes my
own solution to the question, lots of trial and error.  I've found that
isahints was the closest exsting code to what I wanted. 
As always, I would love to hear any comments.

>   How do I create isa devices from a pci device.  Do I search up the
> soundcard tree for the pci bus then search down for the isa bus, then
> create_child(..."mpushim")?

In pci device_attach:
isa=devclass_find("isa");
if( !isa ) {
device_printf(sc->dev,"cmi midi error no devclass for isa\n");
goto err;
}
if (devclass_get_devices(isa, &isalistp, &isacountp) != 0 ) {
device_printf(sc->dev,"cmi midi error fetching isa devices\n");
goto err;
}
if ( isacountp < 1 ) {
device_printf(sc->dev,"cmi midi no isa busses found\n");
goto err;
}
/*
 *  Be stupid and just pick the first isa bus
 */
sc->isadev = isalistp[0];
mpuisa=devclass_find("mpuisa");
if( !mpuisa ) {
device_printf(sc->dev,"cmi: midi driver not found\n");
goto err;
}
i = devclass_find_free_unit(mpuisa,0);
sc->mpudev = BUS_ADD_CHILD(sc->isadev, 1, "mpuisa", i);

[Needs to be done with BUS_ADD_CHILD, I tried with others, m' yo
they just don't work]

>   How do I tell the shim before the probe/attach what io region to look
> at, do I fiddle with ivars (or some internal structure),  do I mess with hints
> via kenv(9) [Is there a kenv(9)? ]

[ Say, p->port=0x300, then following would set it to 0x300-0x302 
  and the same IRQ as the pci device ]

bus_set_resource(sc->mpudev, SYS_RES_IOPORT, 0, p->port, 2);
bus_set_resource(sc->mpudev, SYS_RES_IRQ, 0, rman_get_start(sc->irq), 1);
if( device_probe_and_attach(sc->mpudev) == 0 ) {
device_printf(sc->dev,"added %s/%s\n", 
device_get_nameunit(sc->isadev), 
device_get_nameunit(sc->mpudev) );
   return ;
}


Cheers,
--Mat
-- 
Brain: Are you pondering what I'm pondering?
Pinky: I think so Brain, but the Rockettes, it's mostly girls, isn't it?
___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


midi problem, an isa device on a pci card

2003-04-04 Thread Mathew Kanner
Hello,
I've been fiddling with pci drivers in freebsd for a couple of
months and up to now everything has ok, I did a midi driver for es137x
which was relatively easy because the io was done on the pci bus.  I
was very pleased that there were enough resources for a newbie like me
to dive into kernel hacking.
Now I want to do one for the cmi card, but it seems to offer
the midi device on the isa bus, as does a bunch of cards.  I'm sure
they did this to confuse me.  
Linux seems to be happy just inb,outb in their pci driver,
which seems uncool to me.  Also since I can program the mpu to appear
to different locations I think the ISA bus driver can help determine
the best one to use...

Theory of Reality (mostly hand waving, as I've done no code yet)

Drivers:
cmi(pci),   my pci sound, it's on board btw.
mpushim(isa), the mpu401 from the tree but hacked to receive
from the pci soundcard driver

How I think should work:

probe cmi,
attach cmi,
do {
enable mpu401 at port region,
probe attach mpushim
while ( ! mpushim attached )
done

Big question mark:
How do I create isa devices from a pci device.  Do I search up the
soundcard tree for the pci bus then search down for the isa bus, then
create_child(..."mpushim")?
How do I tell the shim before the probe/attach what io region to look
at, do I fiddle with ivars (or some internal structure),  do I mess with hints
via kenv(9) [Is there a kenv(9)? ]

I think that these questions equally apply to joysticks.

Thanks,
--Mat
-- 
Brain: Are you pondering what I'm pondering?
Pinky: I think so, Brain, but if the plural of mouse is mice, wouldn't
the plural of spouse be spice?
___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "[EMAIL PROTECTED]"