Generic int 13h driver

Die Gestalt die.gestalt at gmail.com
Mon Jun 4 11:55:05 UTC 2007


Problem understood.  What happens is that for reading the BIOS writes at the
physical address and not the virtual address, and the virtual translation
doesn't occur in this case since the write doesn't come from the CPU. I
don't get why it works with writing though, maybe the BIOS uses DMA only for
reading?

My buffer is therefore never written but physical memory get happilly
overwritten (omg!!).

Unfortunately I cannot manage to allocate physical memory below 1 MB by the
time I load my driver. bus_dmamem_alloc fails as well as contigalloc (on
which bus_dmamem_alloc is based anyways).

Any clue? Should I add some code in the booting process to reserve few
chunks below 1 MB for me? Is the dark side stronger?

Another question, is there anyway I can know if the BIOS is using DMA or
not? Obviously in one case I need to give a physical address and the other
case virtual address.

When this is fixed I will have a fully working int13h driver. w00t.

On 6/1/07, Die Gestalt <die.gestalt at gmail.com> wrote:
>
> Hi me again... ;)
>
> Well now I correctly hook the interrupts, they are correctly reflected
> back to the BIOS and I can write to the disk without a problem. When DMA is
> on, however, reading fails (it works when DMA is off in the BIOS). This is
> obviously a DMA problem and for some reason the machine does not read the
> correct page value.
>
> The problem is that the Virtual 8086 monitor makes an "invalidate page"
> call when the operation is finished and my buffers are loaded into a DMA
> mapping and I do the proper pre/post synchronization, I've even tried with
> reversed sync in case I got it wrong.
>
> I think the problem is a lack of understanding on my side about how DMA
> works in FreeBSD. What I do is I have a parent tag and two child tags (one
> for reading the other for writing), I do :
>
> bus_dma_tag_create -> bus_dmamap_create
>
> Later I do contigmalloc of my buffer and I load this buffer with bus_dmamap_load.
> I do bus_dmamap_sync before and after the call the BIOS.
>
> The writes are succesfull but the read buffer is left untouched. What do I
> do wrong? What is the exact use of the callback?
>
> Thanks for any hint.
>
>


More information about the freebsd-drivers mailing list