Unformatted text preview:

SiS 315 Graphics EngineSVGA incompatibilitiesSiS policyWhere to look for infoLinux kernel modulesModule requirementsDriver-Module StructureOur ‘engine2d.c’ moduleHow it worksPentium’s Page-TablesThe PCI InterfaceLinux device-nodesOur ‘sisaccel.cpp’ demo#include “sisaccel.h”Truecolor GraphicsMakefileSiS 315 Graphics Engine Introduction to some capabilities of graphics accelerator hardwareSVGA incompatibilities•SVGA manufacturers have different ways of implementing their accelerator features•SiS provides 2D and 3D graphics engines•Access is via memory-mapped i/o ports•This requires a new Linux device-driver, to allow mapping the io-ports into user-space•A suitable driver is our ‘engine2d.c’ •It only works with SiS graphics hardwareSiS policy•SiS officials say it is not company policy to provide individuals with programming info•But some programming info is available in ‘unofficial’ sources (e.g., in-line comments by programmers who wrote ‘open source’ device-drivers for Linux XFree86 systems)•Not everything is fully explained, though•So a lot of ‘trial-and-error’ is necessary!Where to look for info•The source-code for drivers distributed with the Linux kernel can be found in:/usr/src/local/linux/drivers/video/sis•Recent versions of the SVGALIB package have some SiS-specific code you can view•There is also a website maintained by the author of the SiS driver for Linux (Thomas Winischhofer): http://www.winischhofer.netLinux kernel modules•Linux permits installing new kernel code at runtime (i.e., without recompiling kernel)•A system administrator can install/remove kernel modules, and may grant users this same privilege (by adjusting permissions on the ‘insmod’ and ‘rmmod’ commands)•Modules are written in the C language (not C++) and include special header-files that are distributed with the kernel source-codeModule requirements•Must define __KERNEL__ and MODULE before any #include statements•Must have: #include <linux/module.h>•Maybe others: e.g., #include <linux/pci.h>•Must have these two public functions:int init_module( void );void cleanup_module( void );•Usually device-specific function(s), tooDriver-Module Structureinit_module()cleanup_module()MODULE_LICENSEstruct file_operationswrite()lseek()mmap()read()static data objects#define -----------#include ---------typedef -------------// filename and module abstractThis is the device-driver coreThese are for module mgmtOur ‘engine2d.c’ module•Our module only needs one extra function:int my_mmap( );•Also needs a ‘struct file_operations’ object: struct file_operations my_fops;•The ‘init_module()’ function will install that structure-object in kernel-space, together with executable code which it references•The ‘cleanup_module()’ function removes that code and data after we’re finishedHow it workskernel-spaceuser-spaceapplicationprogramruntimelibrarysyscallhandlerdevice-drivermoduleint $0x80iretmmapretcallretPentium’s Page-Tables•Our driver’s ‘mmap’ method calls a kernel procedure that knows how to setup some new entries in the CPU’s page-directory and page-table data-structures which give the effect of mapping the GPU’s i/o-ports into an application’s virtual address-space•Then the program can read or write these i/o-ports as if they were memory-locationsThe PCI Interface•The graphics hardware connects with the CPU using the AGP bus, conforming to a standard PCI-bus programming interface•Linux kernel functions can be called from our ‘init_module()’ to query the GPU chip–Identify the chip’s make and model –Get physical address for its i/o-memory–Determine the length of the i/o-memoryLinux device-nodes•Linux treats devices as if they were files•We must create a device-file for our GPU •Device-files normally go in ‘/dev’ directory•We invent a filename for our device-file•We pick an unused device id-number•A system administrator creates the file:root# mknod /dev/sismmio c 101 0root# chmod a+rw /dev/sismmioOur ‘sisaccel.cpp’ demo•We have written a short demo-program •It uses the SiS 315’s 2D graphics engine •It fills some rectangles with a solid color•It also shows how to draw a line-segment•These operations could be done, as we know, with software algorithms – but it’s faster to let the hardware do it instead•You are invited to experiment further!#include “sisaccel.h”•This header defines symbolic names for some of the 2D engine’s i/o addresses •Accelerator commands involve writing the values for various parameters to these i/o port-addresses, concluding with a value that encodes a desired engine ‘command’•Some Extended Sequencer registers must be initialized beforehand, to enable engineTruecolor Graphics•We used VESA graphics mode 0x413B•Screen-resolution is 800x600•Pixels are 32-bits in size (‘Truecolor’)•Recall the Truecolor pixel-format:Alpha channelbyte0byte3byte2 byte1Makefile•In order to compile the ‘engine2d.c’ driver, we recommend using the ‘Makefile’ on our class website (copy it to your directory):$ make engine2d.o•Be sure you compile it BEFORE you try to run the ‘gpuaccel.cpp’ demo-program•Don’t forget that your IOPL needs to be 3e.g., run the ‘iopl3’ program


View Full Document

USF CS 686 - Lecture Notes

Documents in this Course
Load more
Download Lecture Notes
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Lecture Notes and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Lecture Notes 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?