Low level hardware access in FreeBSD

John-Mark Gurney gurney_j at resnet.uoregon.edu
Sat Mar 12 10:47:06 PST 2005


Alex Burke wrote this message on Sat, Mar 12, 2005 at 18:12 +0000:
> I am just wondering how I can access either BIOS calls, or preferably
> registers under FreeBSD?
> 
> I am trying to write a simple system capable of displaying graphics on
> the screen, and I am pretty sure I can mmap the VGA memory to my
> programs address space.

correct, you can do this by opening /dev/mem...

> However, to be able to output graphics onto the screen I think I need
> to change the state of the VGA registers from text mode (I am guessing
> thats what the console driver uses) to graphical mode (of which i know
> there exist a couple) - but I think that involves programming
> registers and I dont know how to do that under FreeBSD.

You don't want to access the registers directly because then you could
get syscons confused on what the state is...

Take a look at vidcontrol..  You can use ioctl's documented in sys/fbio.h
to change modes...

> Also, for the FreeBSD console driver to pick the console back up once
> it finished working, would I be required to reset the VGA registers
> back to text mode?

If you use the sys/fbio.h ioctl's you'll need to do that...  I also
found, that you have to becareful to restore the video mode.  Sometimes
your app will segfault, and won't restore the video display, but the
machine is still running.. 

You can also check out svgalib or sdl in ports...  They also provide
the ability to do console graphics...  sdl I believe can also run under
X11 which can be useful.

-- 
  John-Mark Gurney				Voice: +1 415 225 5579

     "All that I will do, has been done, All that I have, has not."


More information about the freebsd-hackers mailing list