comp.lang.ada
 help / color / mirror / Atom feed
* Re: VIDEO MEMORY ACCESS WITH POINTERS
  1999-11-27  0:00 VIDEO MEMORY ACCESS WITH POINTERS ???
@ 1999-11-27  0:00 ` David C. Hoos, Sr.
  1999-11-27  0:00 ` DuckE
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 8+ messages in thread
From: David C. Hoos, Sr. @ 1999-11-27  0:00 UTC (permalink / raw)



??? <xeneve@yahoo.com> wrote in message news:81p3sh$h2m$1@news.colba.net...
> Simple problem: I want to able to read and write directly into the video
> memory using Ada code. Ex: writting the 16bits value 0x4141 at the address
> 0xb8000000.
>
> I'm a new user of ADA, in Pascal or C, it's very simple. But with the
strong
> protection of Ada, I'm lost. I know the basics of pointers in ADA (called
> access), but I don't know how to directly address the value 0xb800000 to a
> pointer. I've tried to assign the address using Unchecked_Conversion and
it
> works. But when I try to read or write the content in memory, a
> constraint_error exception is raisen.
>
> Does anybody could help me?

This is not just an Ada question -- it's also an operating system and
perhaps
even a compiler question.

Please tell us on what platform -- i.e., hardware and operating system
you're
running, and with which Ada compiler you're attempting to write to Video
memory.

Then, someone will be able to help you.

More importantly, if you tell us what you're trying to accomplish, perhaps
there's a better way to do it than writing directly to video memory -- e.g.,
an operating system service.

Access types are for accessing memory within the virtual address space of a
process, not for accessing absolute hardware addresses.

On some operating systems, a user program is not even allowed to do it
directly,
but must use an operating system service, or a device driver to do it.








^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: VIDEO MEMORY ACCESS WITH POINTERS
  1999-11-27  0:00 VIDEO MEMORY ACCESS WITH POINTERS ???
  1999-11-27  0:00 ` David C. Hoos, Sr.
@ 1999-11-27  0:00 ` DuckE
  1999-11-29  0:00   ` Nick Roberts
  1999-11-28  0:00 ` Vladimir Olensky
  1999-11-30  0:00 ` Gautier
  3 siblings, 1 reply; 8+ messages in thread
From: DuckE @ 1999-11-27  0:00 UTC (permalink / raw)


It has been a long time since I've had to address video memory, or used a
system
in which you could directly access video memory.  But if you can do it with
C or Pascal, then this is probably the method you'd use for Ada:

with system.storage_elements;

procedure video_memory_example is

  max_video_memory : constant := 16#2000#;

  type video_cell is mod 2**16;

  type video_memory_type is
    array( 1 .. max_video_memory ) of video_cell;

  video_memory : video_memory_type;
  for video_memory'address use
ystem.storage_elements.to_address( 16#b8000000# );
  pragma volatile( video_memory );

begin
  video_memory( 1 ) := 16#4141#;
end video_memory_example;

In Ada it is convenient to make the range of memory appear as an array that
is fixed at an absolute address.  When you reference elements in the array,
you are referencing that memory.

I hope this helps,
SteveD

??? <xeneve@yahoo.com> wrote in message news:81p3sh$h2m$1@news.colba.net...
> Simple problem: I want to able to read and write directly into the video
> memory using Ada code. Ex: writting the 16bits value 0x4141 at the address
> 0xb8000000.
>
> I'm a new user of ADA, in Pascal or C, it's very simple. But with the
strong
> protection of Ada, I'm lost. I know the basics of pointers in ADA (called
> access), but I don't know how to directly address the value 0xb800000 to a
> pointer. I've tried to assign the address using Unchecked_Conversion and
it
> works. But when I try to read or write the content in memory, a
> constraint_error exception is raisen.
>
> Does anybody could help me?
>
>






^ permalink raw reply	[flat|nested] 8+ messages in thread

* VIDEO MEMORY ACCESS WITH POINTERS
@ 1999-11-27  0:00 ???
  1999-11-27  0:00 ` David C. Hoos, Sr.
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: ??? @ 1999-11-27  0:00 UTC (permalink / raw)


Simple problem: I want to able to read and write directly into the video
memory using Ada code. Ex: writting the 16bits value 0x4141 at the address
0xb8000000.

I'm a new user of ADA, in Pascal or C, it's very simple. But with the strong
protection of Ada, I'm lost. I know the basics of pointers in ADA (called
access), but I don't know how to directly address the value 0xb800000 to a
pointer. I've tried to assign the address using Unchecked_Conversion and it
works. But when I try to read or write the content in memory, a
constraint_error exception is raisen.

Does anybody could help me?






^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: VIDEO MEMORY ACCESS WITH POINTERS
  1999-11-27  0:00 VIDEO MEMORY ACCESS WITH POINTERS ???
  1999-11-27  0:00 ` David C. Hoos, Sr.
  1999-11-27  0:00 ` DuckE
@ 1999-11-28  0:00 ` Vladimir Olensky
  1999-11-30  0:00 ` Gautier
  3 siblings, 0 replies; 8+ messages in thread
From: Vladimir Olensky @ 1999-11-28  0:00 UTC (permalink / raw)



??? wrote in message <81p3sh$h2m$1@news.colba.net>...
>Simple problem: I want to able to read and write directly into the video
>memory using Ada code

Have look at DOS VGA and SVGA packages on Jerry van Dijk site
http://stad.dsl.nl/~jvandyk/other_os.html







^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: VIDEO MEMORY ACCESS WITH POINTERS
  1999-11-27  0:00 ` DuckE
@ 1999-11-29  0:00   ` Nick Roberts
  1999-11-29  0:00     ` Niklas Holsti
  0 siblings, 1 reply; 8+ messages in thread
From: Nick Roberts @ 1999-11-29  0:00 UTC (permalink / raw)


DuckE wrote:
> 
> with system.storage_elements;
> 
> procedure video_memory_example is
> 
>   max_video_memory : constant := 16#2000#;
> 
>   type video_cell is mod 2**16;
> 
>   type video_memory_type is
>     array( 1 .. max_video_memory ) of video_cell;
> 
>   video_memory : video_memory_type;
>   for video_memory'address use
> system.storage_elements.to_address( 16#b8000000# );
>   pragma volatile( video_memory );
> 
> begin
>   video_memory( 1 ) := 16#4141#;
> end video_memory_example;

Strictly, this solution needs two extra declarations:

   for video_cell'Size use 16;

   for video_memory_type'Component_Size use 16;

These declarations will ensure that the types video_cell and
video_memory_type both have the correct size and format. Each should be
inserted just after the declaration of the type itself.

It would probably (but not necessarily) be more convenient for the array
index range to be 0..max_video_memory-1. It may be more convenient to
declare the array as a two-dimensional array, but (interestingly) the
Ada standard provides no way to specify or interrogate whether an array
is stored in row-major or column-major order, so you can't do this if
you need portability. (Row-major order is recommended in the RM95, but
you should check what your compiler does.)

In addition, I think it's worth pointing out that the type video_cell
could be broken down into its component parts (by making it a record or
array type), and also that, in a big program, it will likely be worth
encapsulating all accesses to bare video memory (by putting it all into
a separate package, with an appropriate interface - e.g. procedures for
drawing lines, or text, or whatever).

-- 
Nick Roberts
http://www.adapower.com/lab/adaos
Always call for the professionals. (If they don't help, call for me ;-)






^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: VIDEO MEMORY ACCESS WITH POINTERS
  1999-11-29  0:00   ` Nick Roberts
@ 1999-11-29  0:00     ` Niklas Holsti
  1999-12-01  0:00       ` Robert Dewar
  0 siblings, 1 reply; 8+ messages in thread
From: Niklas Holsti @ 1999-11-29  0:00 UTC (permalink / raw)


Nick Roberts wrote:
  [ snip ]

> Strictly, this solution needs two extra declarations:
> 
>    for video_cell'Size use 16;
> 
>    for video_memory_type'Component_Size use 16;
> 
> ... It may be more convenient to
> declare the array as a two-dimensional array, but (interestingly) the
> Ada standard provides no way to specify or interrogate whether an array
> is stored in row-major or column-major order, so you can't do this if
> you need portability.

Well, it is perhaps perverse in this context, but you
could ensure column-major order by

   pragma Convention (Fortran, TheArray);

but even I wouldn't use the above for video memory access :-)

Regards,
Niklas

Working at but not speaking for Space Systems Finland Ltd.




^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: VIDEO MEMORY ACCESS WITH POINTERS
  1999-11-27  0:00 VIDEO MEMORY ACCESS WITH POINTERS ???
                   ` (2 preceding siblings ...)
  1999-11-28  0:00 ` Vladimir Olensky
@ 1999-11-30  0:00 ` Gautier
  3 siblings, 0 replies; 8+ messages in thread
From: Gautier @ 1999-11-30  0:00 UTC (permalink / raw)


> Simple problem: I want to able to read and write directly into the video
> memory using Ada code. Ex: writting the 16bits value 0x4141 at the address
> 0xb8000000.

> I'm a new user of ADA, in Pascal or C, it's very simple. But with the strong
> protection of Ada, I'm lost. I know the basics of pointers in ADA (called
> access), but I don't know how to directly address the value 0xb800000 to a
> pointer. I've tried to assign the address using Unchecked_Conversion and it
> works. But when I try to read or write the content in memory, a
> constraint_error exception is raisen.

Take a look at SVGA02X4.ZIP

  http://members.xoom.com/gdemont/logiciel/svga02x4.zip

page

  http://members.xoom.com/gdemont/gsoft.htm

HTH

Gautier




^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: VIDEO MEMORY ACCESS WITH POINTERS
  1999-11-29  0:00     ` Niklas Holsti
@ 1999-12-01  0:00       ` Robert Dewar
  0 siblings, 0 replies; 8+ messages in thread
From: Robert Dewar @ 1999-12-01  0:00 UTC (permalink / raw)


In article <3842F727.48B74003@icon.fi>,
  Niklas Holsti <nholsti@icon.fi> wrote:
> Nick Roberts wrote:
>   [ snip ]
>
> > Strictly, this solution needs two extra declarations:
> >
> >    for video_cell'Size use 16;
> >
> >    for video_memory_type'Component_Size use 16;
> >
> > ... It may be more convenient to
> > declare the array as a two-dimensional array, but
(interestingly) the
> > Ada standard provides no way to specify or interrogate
whether an array
> > is stored in row-major or column-major order, so you can't
do this if
> > you need portability.

I hardly think you need worry too much about portability if
you are talking about direct addressing of target specific
hardware, you are almost certain to write compiler dependent
code in any case in such a situation


Sent via Deja.com http://www.deja.com/
Before you buy.




^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~1999-12-01  0:00 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-11-27  0:00 VIDEO MEMORY ACCESS WITH POINTERS ???
1999-11-27  0:00 ` David C. Hoos, Sr.
1999-11-27  0:00 ` DuckE
1999-11-29  0:00   ` Nick Roberts
1999-11-29  0:00     ` Niklas Holsti
1999-12-01  0:00       ` Robert Dewar
1999-11-28  0:00 ` Vladimir Olensky
1999-11-30  0:00 ` Gautier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox