>
> 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, \\ [EMAIL PROTECTED]
\\ and he'll hate you for a lifetime. \\ [EMAIL PROTECTED]
To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message