Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Direct memory access on Linux...

30 views
Skip to first unread message

Chong Kai Xiong

unread,
Jul 6, 1999, 3:00:00 AM7/6/99
to
I've just installed Linux Redhat 6.0 on my Cyrix 6x86 machine. I've
tried out gcc and gpp and they feel very much like DJGPP which I use
when I run Win95. But one thing I've been trying to figure out...how do
you gain access to the video memory? In DJGPP there's the DPMI library
to set the video mode (__dpmi_int()) and the nearptr library to
directly access conventional memory (with __djgpp_nearptr_enable() and
__djgpp_nearptr_enable()).

How do I do anything equivalent on Linux using gcc/gpp? I prefer to use
my own graphics library. Thanks for any help =)

Kai


Marcus Sundberg

unread,
Jul 6, 1999, 3:00:00 AM7/6/99
to

You don't want to access video hardware directly under Linux.

Have a look at LibGGI at http://www.ggi-project.org/
It hides away all the nasties of video and input under Linux/UNIX,
runs on all existing Linux graphics systems, uses acceleration
where available, and also allows you to access framebuffer memory
directly if possible.

//Marcus
--
-------------------------------+------------------------------------
Marcus Sundberg | http://www.stacken.kth.se/~mackan/
Royal Institute of Technology | Phone: +46 707 295404
Stockholm, Sweden | E-Mail: mac...@stacken.kth.se

Non root dan mills

unread,
Jul 6, 1999, 3:00:00 AM7/6/99
to
Chong Kai Xiong <w_vel...@yahoo.com> wrote:
> I've just installed Linux Redhat 6.0 on my Cyrix 6x86 machine. I've
> tried out gcc and gpp and they feel very much like DJGPP which I use

Should do, it is the same compiler!

> when I run Win95. But one thing I've been trying to figure out...how do
> you gain access to the video memory? In DJGPP there's the DPMI library
> to set the video mode (__dpmi_int()) and the nearptr library to
> directly access conventional memory (with __djgpp_nearptr_enable() and
> __djgpp_nearptr_enable()).

> How do I do anything equivalent on Linux using gcc/gpp? I prefer to use
> my own graphics library. Thanks for any help =)

Are you writing a console or a graphics application??
For console the /dev/vcs* devices are what you need (just mmap them).
For graphics I am not sure that it can be done in any simple way,
I would be inclined to use svgalib.
If it is for a console app, PLEASE consider slang or curses, these are
portable in a way that opening /dev/vcsa is not! And on a modern
system the overhead in writing a screenful of text is tiny.

--
The email address **IS** valid (You do **NOT** need to remove spamblock).
And on the evening of the first day the lord said.....
.... LX 1, GO!! and there was light!

Jon Bloom

unread,
Jul 7, 1999, 3:00:00 AM7/7/99
to
Chong Kai Xiong wrote:
>
> I've just installed Linux Redhat 6.0 on my Cyrix 6x86 machine. I've
> tried out gcc and gpp and they feel very much like DJGPP which I use
> when I run Win95. But one thing I've been trying to figure out...how do
> you gain access to the video memory?

See /usr/doc/kernel-doc-2.2.5/fb/framebuffer.txt
(If it isn't present, install the kernel-doc-2.2.5 pacckage.)

Jon
--
Jon Bloom, KE3Z
jbl...@arrl.org
Electronic Publications Manager (Software, CD-ROMs and Web site)

David Konerding

unread,
Jul 7, 1999, 3:00:00 AM7/7/99
to
On Tue, 6 Jul 1999 16:15:14 +0100, Non root dan mills <dmi...@spamblock.demon.co.uk> wrote:
>Chong Kai Xiong <w_vel...@yahoo.com> wrote:
>Should do, it is the same compiler!
>
>> when I run Win95. But one thing I've been trying to figure out...how do
>> you gain access to the video memory? In DJGPP there's the DPMI library
>> to set the video mode (__dpmi_int()) and the nearptr library to
>> directly access conventional memory (with __djgpp_nearptr_enable() and
>> __djgpp_nearptr_enable()).

In a UNIX (or Linux) operating system, unprivileged processes (not running in kernel
space) are not normally permitted to directly access memory in the way that DOS/Windows95
allow. This is for your own protection- it makes it harder to crash the kernel.

>
>Are you writing a console or a graphics application??
>For console the /dev/vcs* devices are what you need (just mmap them).
>For graphics I am not sure that it can be done in any simple way,
>I would be inclined to use svgalib.
>If it is for a console app, PLEASE consider slang or curses, these are
>portable in a way that opening /dev/vcsa is not! And on a modern
>system the overhead in writing a screenful of text is tiny.


The simplest way to access the graphics directly for the purposes of writing
your own graphics library is to use the framebuffer option that's available in
2.2 (and newer) kernels. You just "mmap" /dev/fb and you can "poke" the video
memory all you want.

SVGAlib is a dead-end project which is not going to support new cards.
It has a number of caveats and security issues. It really isn't a portable way
to go.

However, I suggest you reconsider your decision to access the video memory directly.
You are giving up on the benefits of libraries like libggi and X11; these libraries
make your program more portable and "safe" (from the OS point of view).

Dave
--
--------------------------------------------------------------------------------
Email: d...@cgl.ucsf.edu David Konerding WWW: http://picasso.ucsf.edu/~dek
--------------------------------------------------------------------------------
Snail: Graduate Group in Biophysics
Medical Sciences 926, Box 0446
University of California
San Francisco, CA 94143

Marcus Sundberg

unread,
Jul 8, 1999, 3:00:00 AM7/8/99
to
David Konerding wrote:
> However, I suggest you reconsider your decision to access the video memory directly.
> You are giving up on the benefits of libraries like libggi and X11; these libraries
> make your program more portable and "safe" (from the OS point of view).

Note that, as said earlier, you can access video memory directly from
LibGGI just fine when running on a target which supports this (svgalib,
fbdev, XFree DGA, glide).

0 new messages