>
Digression on r/w 00proc00 files
An application of kernel module programming to Super VGA graphics device control
Super VGA
Modern graphics cards have lots of vram Our class machines show only part of it Screen resolution is 1280 x 1024 00ixels00 Each 00ixel00is 32-bits of video memory Total vram for one full screen:1280 x 1024 x 4 bytes = 5 megabytes
Our class machines have 32 megabytesSVGA 00tart Address00 parameter
Our machines use the SiS 315 svga chip Its 00tart Address00governs what we see It00 a 24-bit value, held in 3 byte-registers Registers accessible through i/o ports Kernel code can reprogram these registers Module-inferface gives application-access
How Start Address works
VRAM
visible
Start_address = 0
VRAM
visible
Start_address = 2048
The CRT Controller
Display monitor uses Cathode Ray Tube It00 operated by SVGA00 CRT Controller Old design: It has lots of 8-bit registers Two i/o port-addresses are 00ultiplrexed00/font> ADDRESS_PORT: 0x03D4 DATA_PORT: 0x03D5 CRTC register 13: start_address[ 7..0 ] CRTC register 12: start_address[ 15..8 ]SVGA incompatibility
Many features of SVGA are now standard But vendors add their own 00xtras00/font> These are NOT programmed identically! You usually need manufacturer00 manual But not always easy to get (proprietary) (We found SiS information in a web email) Software for SiS chip 00xtras00 non-portableSVGA Memory Sequencer
Sequencer also has lots of 8-bit registers They00e also accessed via two i/o ports ADDRESS_PORT: 0x03C4 DATA_PORT: 0x03C5 Seq register 13: start_address[ 23..16 ] SiS chip uses Seq register 5 as a 00ock00/font> Write 0x86 to 00nlock00 sequencer registerspci_find_device()
Driver must 00etect00the SiS SVGA device SiS chip00 VENDOR_ID is 0x1039 SiS chip00 DEVICE_ID is 0x6325 #include <linux/pci.h>struct pci_dev *devp = NULL;
devp = pci_find_device( VENDOR, DEVICE, devp );
Class Demo
Module name is 00ischip.c00/font> Creates a pseudo-file: 00roc/sischip00/font> It00 a binary file (don00 use 00at00command) File is both readable and writable Lets application get or set 00tart_address00/font> Our demo-program is 00gascroll.cpp00/font> It lets us see 16 megabytes of video ramToday00 Class Exercise
Use your knowledge of 00oremap()00/font> Draw an image in the offscreen vram Run 00gascroll00to see what you00e drawn