delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/10/02/20:46:21

Date: Thu, 2 Oct 1997 17:45:25 -0700 (PDT)
Message-Id: <199710030045.RAA18934@adit.ap.net>
Mime-Version: 1.0
To: pscargill AT cix DOT compulink DOT co DOT uk ("Peter Scargill"), djgpp AT delorie DOT com
From: Nate Eldredge <eldredge AT ap DOT net>
Subject: Re: BEGINNER -address of arrays etc - Help

At 02:59  10/2/1997 GMT, Peter Scargill wrote:
>This is my second attempt at putting this message in. What hope do I have 
>of solving a C problem if I can't even send mail properly :-))
>
>Ok, DOS program ising DJGPP. This came with the BT848 graphic chip 
>development test software.
>
>They send the address A0000 to the PCI chip via a routine so the chip can 
>talk to mode 13 video memory.
>
>I created an array large enough to hold the video data, and gave the 
>routine the address of the array as &my_array.
>
>Being a Borland programmer this looked ok but the program goes for a walk.
>
>Actually I used (unsigned int)&my_array[0]. The compiler took it but the 
>thing goes for a walk so it is obviously writing somewhere it should not.
>
>Remember I've never used a 32 bit compiler before. Seems like a valid 32 
>bit address would be sent but obviously not. Comments anyone?
Yeah, I think I see your problem. DJGPP uses protected mode memory, with a
32-bit *offset* into a single very large segment (flat model). These are
almost always outside of conventional memory, which is the first 1MB of
memory. It looks like your hardware expects a linear address in the first
1MB of memory, which is what 0xA0000 is. AFAIK DMA, which it seems your
hardware is doing, only works in the low 1MB of memory. Your best bet might
be to allocate a conventional memory buffer (__dpmi_allocate_dos_memory())
and have it write to that. I don't know how you can get the physical address
of your program's buffer.

Nate Eldredge
eldredge AT ap DOT net



- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019