Date: Fri, 10 Dec 1999 23:08:02 -0800 From: Mike Smith <msmith@freebsd.org> To: Bob Kot <bobkat@azstarnet.com> Cc: freebsd-hackers@FreeBSD.ORG Subject: Re: Device driver - panics executing kvtop() when compiled as KLD module Message-ID: <199912110708.XAA00875@mass.cdrom.com> In-Reply-To: Your message of "Fri, 10 Dec 1999 17:15:43 MST." <99121017414100.00289@atlas.tic.toc>
next in thread | previous in thread | raw e-mail | index | archive | help
> > I am in the process of writing a device driver for the Turtle Beach Multisound > Monterey soundcard. At the moment I am statically compiling my code into the > kernel and it is somewhat operational. I have added conditional compilation > code to also compile as a kld module. My problem is that when I kldload my > module the machine panics in a subfunction of my attach() function that makes > a call on kvtop() I drop into the debugger DDB and the instruction pointer is > in the middle of the kvtop() function. If I disable my attach function the > module will load and unload, but it is nonfunctional without the attach() > being executed. Statically compiled into the kernel kvtop() executes with no > problem. > > To be succinct can I use kvtop() in code that is a kld module? Yes, althought it's not the right way to do this. > If not, what is the alternative to accomplish the same result? You should be using the bus_space functionality to hide the mapping. > switch (kvtop(msd->dev->id_maddr)) { Er. You do understand that kvtop() attempts to return a physical address when given a kernel virtual address, right? The isa_device id_maddr field is a physical address, for which you want a mapping in kernel virtual space. Assuming you don't want to do this properly and use bus_space, you need to use pmap_mapdev(), or to take advantage of the fact that the ISA hole is already mapped into kernel virtual space. You can convert a physical address in the ISA hole to a virtual address in kernel space with: #include <pmap.h> #include <machine/md_var.h> ... vaddr = (paddr - ISA_HOLE_START) + atdevbase; Note that this approach is somewhat frowned upon, and if you're working with -current it is very definitely the wrong way to do it, but for an expedient solution it'll do the job. -- \\ Give a man a fish, and you feed him for a day. \\ Mike Smith \\ Tell him he should learn how to fish himself, \\ msmith@freebsd.org \\ and he'll hate you for a lifetime. \\ msmith@cdrom.com 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?199912110708.XAA00875>