Mail Archives: djgpp/2000/05/15/02:55:33
On Sun, 14 May 2000, Malcolm Herring wrote:
> I need to map to a physical address range to access a memory-mapped device.
> The following code fragments is how I have tried to do it, but this results
> in a GPF when 'movedatal' is called.
Your code has a number of bugs. First, it sets the segment limit
incorrectly:
> __dpmi_set_segment_limit(sel, mmem.address + 65535);
This should be:
__dpmi_set_segment_limit(sel, 65535);
> _movedatal(_my_ds(), (int)&prng, sel, mmem.address, 1);
This is also wrong: the 4th argument is an *offset* into the segment,
so it starts from zero, not from mmem.address.
Btw, section 18.7 of the DJGPP FAQ list explains how to do this and
includes working code that does it. I suggest to use that code as a
basis for your program.
If something in the FAQ is unclear, please ask specific questions.
> __dpmi_set_descriptor_access_rights(sel,
> __dpmi_get_descriptor_access_rights(_my_ds()));
This call is unnecessary: the segment descriptor already has the same
rights as DS by default.
- Raw text -