*BSD News Article 11704


Return to BSD News archive

Received: by minnie.vk1xwt.ampr.org with NNTP
	id AA2009 ; Wed, 24 Feb 93 13:01:03 EST
Newsgroups: comp.unix.bsd
Path: sserve!manuel.anu.edu.au!munnari.oz.au!news.Hawaii.Edu!ames!sun-barr!cs.utexas.edu!qt.cs.utexas.edu!yale.edu!ira.uka.de!gmd.de!fanoe!veit
From: veit@fanoe.NoSubdomain.NoDomain (Holger Veit)
Subject: Re: Accessing the VGA in 386BSD
Message-ID: <1993Feb23.115323.489@gmd.de>
Sender: veit@fanoe (Holger Veit)
Nntp-Posting-Host: fanoe
Organization: GMD, Sankt Augustin, Germany
References:  <1993Feb19.190256.1247@mcshub.dcss.mcmaster.ca>
Date: Tue, 23 Feb 1993 11:53:23 GMT
Lines: 48

In article <1993Feb19.190256.1247@mcshub.dcss.mcmaster.ca>, dsantry@maccs.mcmaster.ca (Doug Santry) writes:
|> 
|> Hi, I was wondering if anyone out there knows how to access the VGA in
|> bsd.  I want to change the videomode to a super-vga mode, draw my stuff,

This is the method, as used by DOS and other junk, but it is not feasible in UNIX.
You process is not alone in the system, so you have to take care of a couple of
things beside this stuff. One is that there are many different versions of
SVGA's, any of them needing special handling. You must have real good knowledge
about VGA cards and their low level programming (you know, INT 10h is *absolutely*
unavailable).

|> then return to standard text mode.  I assume the kernel won't let you simply
|> access the VGA yourself and protects it.  Turning on a pixel involves writing

This is right, but switching pixels is not a problem at all. Perhaps you should
have a look at some good BSD UNIX book on that to understand the mmap(2) syscall,
and what the pcmmap / comap functions in some versions of the console device
drivers are supposed to do.
The real problem is access to the i/o ports. inb and outb are machine instructions,
which require certain privilege (no, not root privilege), so they normally cannot be
executed from outside the kernel (which has this privilege).
There is a method to achieve this with kernels that can run XFree86, but it is
(by intent) not for general purpose. You'll learn much more about the insides of
device drivers and their working, if you find it out by your own. There is 
enough code inside the "codrv" device driver to learn how to do things.

|> a byte to the VGA, in other words accessing memory that your session doesn't
|> own.  Any advice or suggestions would be greatly appreciated.  I have never
|> done any low-level UNIX programming before so this is perplexing.
|> 
|> thankx

If you have never done such work before, you shouldn't try this without sufficient
experience in related areas. This is a well-meant advice by someone who is hacking
long enough in this area. You are going to encounter many more problems than just
the ones to enter another video mode, write some pixels, and switch back to text
(even if you expect only an "island" solution).

Holger

-- 
         Dr. Holger Veit                   | INTERNET: Holger.Veit@gmd.de
|  |   / GMD-SET German National Research  | Phone: (+49) 2241 14 2448
|__|  /  Center for Computer Science       | Fax:   (+49) 2241 14 2342
|  | /   P.O. Box 13 16                    |    Three lines Signature space
|  |/    Schloss Birlinghoven              |    available for rent. Nearly
         DW-5205 St. Augustin, Germany     |    unused, good conditions