digression on r/w ‘/proc’ files an application of kernel module programming to super vga...

10
Digression on r/w ‘/proc’ files An application of kernel module programming to Super VGA graphics device control

Upload: clyde-carr

Post on 17-Jan-2016

212 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Digression on r/w ‘/proc’ files An application of kernel module programming to Super VGA graphics device control

Digression on r/w ‘/proc’ files

An application of kernel module programming to Super VGA

graphics device control

Page 2: Digression on r/w ‘/proc’ 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 ‘pixels’

• Each ‘pixel’ is 32-bits of video memory

• Total vram for one full screen: 1280 x 1024 x 4 bytes = 5 megabytes

• Our class machines have 32 megabytes

Page 3: Digression on r/w ‘/proc’ files An application of kernel module programming to Super VGA graphics device control

SVGA ‘Start Address’ parameter

• Our machines use the SiS 315 svga chip• Its ‘Start Address’ governs what we see• It’s 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

Page 4: Digression on r/w ‘/proc’ files An application of kernel module programming to Super VGA graphics device control

How Start Address works

VRAM

visible

Start_address = 0

VRAM

visibleStart_address = 2048

Page 5: Digression on r/w ‘/proc’ files An application of kernel module programming to Super VGA graphics device control

The CRT Controller

• Display monitor uses Cathode Ray Tube• It’s operated by SVGA’s CRT Controller • Old design: It has lots of 8-bit registers• Two i/o port-addresses are ‘multiplrexed’• ADDRESS_PORT: 0x03D4• DATA_PORT: 0x03D5• CRTC register 13: start_address[ 7..0 ]• CRTC register 12: start_address[ 15..8 ]

Page 6: Digression on r/w ‘/proc’ files An application of kernel module programming to Super VGA graphics device control

SVGA incompatibility

• Many features of SVGA are now standard

• But vendors add their own ‘extras’

• These are NOT programmed identically!

• You usually need manufacturer’s manual

• But not always easy to get (proprietary)

• (We found SiS information in a web email)

• Software for SiS chip ‘extras’ non-portable

Page 7: Digression on r/w ‘/proc’ files An application of kernel module programming to Super VGA graphics device control

SVGA Memory Sequencer

• Sequencer also has lots of 8-bit registers

• They’re 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 ‘lock’

• Write 0x86 to ‘unlock’ sequencer registers

Page 8: Digression on r/w ‘/proc’ files An application of kernel module programming to Super VGA graphics device control

pci_find_device()

• Driver must ‘detect’ the SiS SVGA device

• SiS chip’s VENDOR_ID is 0x1039

• SiS chip’s DEVICE_ID is 0x6325

• #include <linux/pci.h>struct pci_dev *devp = NULL;

devp = pci_find_device( VENDOR, DEVICE, devp );

Page 9: Digression on r/w ‘/proc’ files An application of kernel module programming to Super VGA graphics device control

Class Demo

• Module name is ‘sischip.c’

• Creates a pseudo-file: ‘proc/sischip’

• It’s a binary file (don’t use ‘cat’ command)

• File is both readable and writable

• Lets application get or set ‘start_address’

• Our demo-program is ‘vgascroll.cpp’

• It lets us see 16 megabytes of video ram

Page 10: Digression on r/w ‘/proc’ files An application of kernel module programming to Super VGA graphics device control

Today’s Class Exercise

• Use your knowledge of ‘ioremap()’

• Draw an image in the offscreen vram

• Run ‘vgascroll’ to see what you’ve drawn