Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 11 Aug 2000 15:35:30 -0700
From:      Mike Smith <msmith@freebsd.org>
To:        Devin Butterfield <dbutter@wireless.net>
Cc:        freebsd-hackers@FreeBSD.ORG
Subject:   Re: Need help with driver.... 
Message-ID:  <200008112235.PAA00839@mass.osd.bsdi.com>
In-Reply-To: Your message of "Fri, 11 Aug 2000 11:33:04 PDT." <399446E0.D4F51CCA@wireless.net> 

next in thread | previous in thread | raw e-mail | index | archive | help
> I'm a newbie to device driver writing and I have been learning well by
> reading the code of the other drivers in the system. I would ultimately
> like to port a linux driver for a VoIP telephony card (Quicknet
> PhoneJack) to FreeBSD, and so far I have a skeleton driver which does
> successfully probe the card.

It does?  How?  Is this a PnP card?

> The problem I'm having is that I don't know how to tell whether or not
> the card is attaching correctly. How can I determine this? I thought
> that I would be able to make a device file in /dev if it correctly
> attached but MAKEDEV responds with:
> 
> {root@dbm /dev]# ./MAKEDEV phone
> phone - no such device name

MAKEDEV is a script which does not interact with the kernel in any way.  
You need to explicitly update MAKEDEV to know about your device.

> For reference, here is my attach routine:
> 
> static int                         	
> ixj_isa_attach (dev)                    /* attach device		*/
> 	device_t dev;
> {
> 	int unit = device_get_unit(dev);
> 	struct ixj_softc *sc = device_get_softc(dev);
> 	struct resource *res;
> 	int rid;
> 	int size;
> 	
> 	if (sc->port_used > 0) {
> 		size = sc->port_used;
> 		rid = sc->port_rid;

Where are you initialising these fields in the softc?  (I assume, in your 
probe, correct?)

> 		res = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid,
> 					0, ~0, size, RF_ACTIVE);
> 		if (res) {
> 			sc->port_rid = rid;
> 			sc->port_res = res;
> 			sc->port_used = size;
> 		}
> 	
> 	}
>      	make_dev(&ixj_cdevsw, UNIT(dev), UID_ROOT, GID_WHEEL,
> 			0666, "phone%d", unit);
> 	
> 	return (0);
> }
> 
> 
> What am I doing wrong? How can I tell if this is working?

You should check the return values from bus_alloc_resource and make_dev, 
both of which you need to save in the softc so that you can detach 
correctly.



-- 
... every activity meets with opposition, everyone who acts has his
rivals and unfortunately opponents also.  But not because people want
to be opponents, rather because the tasks and relationships force
people to take different points of view.  [Dr. Fritz Todt]




To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200008112235.PAA00839>