comp.lang.ada
 help / color / mirror / Atom feed
* Device driver in Ada95
@ 2002-02-25 21:20 Dave Poirier
  2002-02-25 21:47 ` sk
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Dave Poirier @ 2002-02-25 21:20 UTC (permalink / raw)


I'm currently trying to write a basic device driver in Ada95.  The 
device is a simple text mode videocard under a x86 PC. I got the boot 
record going as well as a small rtk of my own which allow me to run 
simple programs that return values.

My next step is to start to write device drivers in Ada95 using this 
same setup, so as to have as useable os sooner or later.  As my first 
try, I decided to create a small vga driver for text mode.  This 
requires that I write in memory from 0xB8000 to 0xB8A9F.

Here's what I tried:
--------------------
with System.Address_to_Access_Conversions;

procedure Hello is
   type Screen is array(0 .. 999) of Character;
   type Char_Ptr is access Screen;
   package CharPtrs is new System.Address_To_Access_Conversions(Char_Ptr);
   Vga : CharPtrs.Object_Pointer;
   VgaAddress : System.Address;

begin
   VgaAddress := System.Address(16#B8000#);
   Vga := CharPtrs.To_Pointer(VgaAddress);
   Vga.all(0) := '!';
end Hello;

---------

Ofcourse that doesn't compile, it doesn't like the assignment I'm trying 
to do for VgaAddress :=...

Now, could any of you indicate how I'm supposed to do that as properly 
as possible using only Ada95?

I'm compiling with GNAT to generate a .s which I then compile with my 
own wrappers, so as long as it's valid Ada95 and that it can get to 
generating my .o it should be fine.

Thanks for any help.




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

* Re: Device driver in Ada95
  2002-02-25 21:20 Dave Poirier
@ 2002-02-25 21:47 ` sk
  2002-02-26  0:02   ` Dave Poirier
  2002-02-25 21:53 ` chris.danx
  2002-02-25 22:06 ` Jerry van Dijk
  2 siblings, 1 reply; 9+ messages in thread
From: sk @ 2002-02-25 21:47 UTC (permalink / raw)


Hi, 

You might explore the "Address" clause.

declare

    type Screen_Type ...

    Screen : Screen_Type;

    for Screen'Address use 16#b8000#;

begin
    Screen (Screen'First) := ...

    ...

end;

--
-- This is a QUAD so you will need to explore the 
-- details for yourself and also be aware of the
-- potential pitfalls.
-- 

-------------------------------------
-- Merge vertically for real address
-------------------------------------
s n p @ t . o
 k i e k c c m
------------------------------------



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

* Re: Device driver in Ada95
  2002-02-25 21:20 Dave Poirier
  2002-02-25 21:47 ` sk
@ 2002-02-25 21:53 ` chris.danx
  2002-02-25 22:06 ` Jerry van Dijk
  2 siblings, 0 replies; 9+ messages in thread
From: chris.danx @ 2002-02-25 21:53 UTC (permalink / raw)




> My next step is to start to write device drivers in Ada95 using this
> same setup, so as to have as useable os sooner or later.  As my first
> try, I decided to create a small vga driver for text mode.  This
> requires that I write in memory from 0xB8000 to 0xB8A9F.

> Now, could any of you indicate how I'm supposed to do that as properly
> as possible using only Ada95?

Try Serge Robyns code at http://web.wanadoo.be/rc.s/AdaOS/.  It contains
code for writing to 16#b8000# as well as a host of other things.


Chris





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

* Re: Device driver in Ada95
  2002-02-25 21:20 Dave Poirier
  2002-02-25 21:47 ` sk
  2002-02-25 21:53 ` chris.danx
@ 2002-02-25 22:06 ` Jerry van Dijk
  2002-02-25 22:54   ` Dave Poirier
  2 siblings, 1 reply; 9+ messages in thread
From: Jerry van Dijk @ 2002-02-25 22:06 UTC (permalink / raw)



Dave Poirier <instinc@users.sf.net> writes:

> My next step is to start to write device drivers in Ada95 using this same
> setup, so as to have as useable os sooner or later.  As my first try, I
> decided to create a small vga driver for text mode.  This requires that I
> write in memory from 0xB8000 to 0xB8A9F.

This is not very difficult to do. However, GNAT generated x86 code depends
on the memory management used. So the question here is: are you using
real-mode, or DPMI, or some other PMODE driver for your own kernel ? Or
if you use your own scheme, how is the memory organised ?

-- 
--  Jerry van Dijk   | email: jvandyk@attglobal.net
--  Leiden, Holland  | web:   users.ncrvnet.nl/gmvdijk



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

* Re: Device driver in Ada95
  2002-02-25 22:06 ` Jerry van Dijk
@ 2002-02-25 22:54   ` Dave Poirier
  2002-02-25 23:21     ` sk
  2002-02-26 10:05     ` chris.danx
  0 siblings, 2 replies; 9+ messages in thread
From: Dave Poirier @ 2002-02-25 22:54 UTC (permalink / raw)


Jerry van Dijk wrote:
> Dave Poirier <instinc@users.sf.net> writes:
> 
> 
>>My next step is to start to write device drivers in Ada95 using this same
>>setup, so as to have as useable os sooner or later.  As my first try, I
>>decided to create a small vga driver for text mode.  This requires that I
>>write in memory from 0xB8000 to 0xB8A9F.
>>
> 
> This is not very difficult to do. However, GNAT generated x86 code depends
> on the memory management used. So the question here is: are you using
> real-mode, or DPMI, or some other PMODE driver for your own kernel ? Or
> if you use your own scheme, how is the memory organised ?

To make things simpler at the moment I use a flat memory model in 
protected mode, so I have 1 code segment of 4GB starting at 0 
read/execute with a 4GB data segment start at 0 read/write.

It's my own scheme.

btw, thanks to chris.danx, I couldn't find any code on the original 
AdaOS site, the link you provided was indeed usefull. (maybe you should 
consider using an array of pointers and a loop instead of repeating 255 
times the same code sequence) ;)

also thanks to sk for the small code snippet, was right to the point. 
Where can I find information about QUAD?  I've done a search for "Ada95 
QUAD" on google but nothing related to 'Access came up.

Thanks again :)





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

* Re: Device driver in Ada95
  2002-02-25 22:54   ` Dave Poirier
@ 2002-02-25 23:21     ` sk
  2002-02-26 10:05     ` chris.danx
  1 sibling, 0 replies; 9+ messages in thread
From: sk @ 2002-02-25 23:21 UTC (permalink / raw)


Hi,

Sorry for QUAD --> "quick-and-dirty"

Shorthand for those of us with aging 
fingers ...

  o o
   |
  \_/


-------------------------------------
-- Merge vertically for real address
-------------------------------------
s n p @ t . o
 k i e k c c m
------------------------------------



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

* Re: Device driver in Ada95
  2002-02-25 21:47 ` sk
@ 2002-02-26  0:02   ` Dave Poirier
  0 siblings, 0 replies; 9+ messages in thread
From: Dave Poirier @ 2002-02-26  0:02 UTC (permalink / raw)


sk wrote:
> Hi, 
> 
> You might explore the "Address" clause.
> 
> declare
> 
>     type Screen_Type ...
> 
>     Screen : Screen_Type;
> 
>     for Screen'Address use 16#b8000#;
> 
> begin
>     Screen (Screen'First) := ...
> 
>     ...
> 
> end;
> 
> --
> -- This is a QUAD so you will need to explore the 
> -- details for yourself and also be aware of the
> -- potential pitfalls.
> 

Just for the sake of anyone browsing the archives, to use 
Something'Address like that one needs to do:

for Screen'Address use To_Address(16#B8000#);

the To_Address function is in the System.Storage_Elements package.

Got my screen driver working! Woohoo! :)




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

* Re: Device driver in Ada95
  2002-02-25 22:54   ` Dave Poirier
  2002-02-25 23:21     ` sk
@ 2002-02-26 10:05     ` chris.danx
  1 sibling, 0 replies; 9+ messages in thread
From: chris.danx @ 2002-02-26 10:05 UTC (permalink / raw)



"Dave Poirier" <instinc@users.sf.net> wrote in message
news:3C7AC0B9.2060108@users.sf.net...
> Jerry van Dijk wrote:
> > Dave Poirier <instinc@users.sf.net> writes:
> >
> >
> >>My next step is to start to write device drivers in Ada95 using this
same
> >>setup, so as to have as useable os sooner or later.  As my first try, I
> >>decided to create a small vga driver for text mode.  This requires that
I
> >>write in memory from 0xB8000 to 0xB8A9F.
> >>
> >
> > This is not very difficult to do. However, GNAT generated x86 code
depends
> > on the memory management used. So the question here is: are you using
> > real-mode, or DPMI, or some other PMODE driver for your own kernel ? Or
> > if you use your own scheme, how is the memory organised ?
>
> To make things simpler at the moment I use a flat memory model in
> protected mode, so I have 1 code segment of 4GB starting at 0
> read/execute with a 4GB data segment start at 0 read/write.
>
> It's my own scheme.

You might consider subscribing to the alt.os.development newsgroup if your
into os development or related areas.  They're quite a helpful bunch.  There
are few familiar with Ada there (two ppl), but the amount of information
there is quite substantial and there's no real particular language bias
(assembly, c++, pascal, c, Ada etc), although most are C developers.  Also
their is a new effort underway to provide a journal for os dev by Jens
Olsson and the more experienced developers over there available at
http://www.osjournal.n3.net/.

> btw, thanks to chris.danx, I couldn't find any code on the original
> AdaOS site, the link you provided was indeed usefull. (maybe you should
> consider using an array of pointers and a loop instead of repeating 255
> times the same code sequence) ;)

It isn't my code, it's Serge Robyns.


Chris Campbell





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

* Re: Device driver in Ada95
@ 2002-02-26 11:09 Gautier Write-only-address
  0 siblings, 0 replies; 9+ messages in thread
From: Gautier Write-only-address @ 2002-02-26 11:09 UTC (permalink / raw)


Hello Dave!

If it can help you there are Ada driver sources for DPMI
in the the Engine_3D pack, for

  Keyboard (multi-key input)
  SVGA (from Jerry)
  Precision timers
  Sound Blaster

See URL below. HTH
______________________________________________________
Gautier  --  http://www.mysunrise.ch/users/gdm/e3d.htm

NB: For a direct answer, address on the Web site!

_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp.




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

end of thread, other threads:[~2002-02-26 11:09 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-02-26 11:09 Device driver in Ada95 Gautier Write-only-address
  -- strict thread matches above, loose matches on Subject: below --
2002-02-25 21:20 Dave Poirier
2002-02-25 21:47 ` sk
2002-02-26  0:02   ` Dave Poirier
2002-02-25 21:53 ` chris.danx
2002-02-25 22:06 ` Jerry van Dijk
2002-02-25 22:54   ` Dave Poirier
2002-02-25 23:21     ` sk
2002-02-26 10:05     ` chris.danx

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