A device-driver for Video Memory Introduction to basic principles of the PC’s graphics display.

Slides:



Advertisements
Similar presentations
Introduction to Computers Part II
Advertisements

Monitors and Sound Systems
Lecture 2 Concepts, Terms and Definitions. Display Devices They are divided into a lot of small squares called pixels (“PICture ELements”). Each pixel.
Fabián E. Bustamante, Spring 2007
Using VMX within Linux We explore the feasibility of executing ROM-BIOS code within the Linux x86_64 kernel.
The ATA/IDE Interface Can we write a character-mode device driver for the hard disk?
Monitors and Sound Systems lesson 5 This lesson includes the following sections:  Monitors  PC Projectors  Sound Systems.
Linux ‘Demand-Paging’
Dr A Sahu Dept of Comp Sc & Engg. IIT Guwahati 1.
Lecture 12 Page 1 CS 111 Online Devices and Device Drivers CS 111 On-Line MS Program Operating Systems Peter Reiher.
CS 686: Programming SuperVGA Graphics Devices Introduction: An exercise in working with graphics file formats.
The ‘thread’ abstraction A look at the distinction between the idea of a ‘process’ and the concept of a ‘thread’
Programming Super-VGA Graphics Devices Introduction to VESA graphics modes and to organization of the linear frame-buffer memory.
The Linux PCI Interface An introduction to the PCI configuration space registers.
Linux Memory Issues An introduction to some low-level and some high-level memory management concepts.
IA32 Paging Scheme Introduction to the Pentium’s support for “virtual” memory.
The RealTek interface Introduction to the RTL-8139 network controller registers.
A look at memory issues Data-transfers must occur between system memory and the network interface controller.
SiS 315 Graphics Engine Introduction to some capabilities of graphics accelerator hardware.
“Virtual” Memory How does the OS kernel provide “private” and “shared” memory areas to multiple concurrent processes?
The ‘ioctl’ driver-function On implementing ‘show’ and ‘hide’ for the SiS 315 hardware cursor.
Access to video memory We create a Linux device-driver that gives applications access to our graphics frame-buffer.
Using a hex editor to edit an image We can actually use hex editors to change image files Usually, we will use programs like PhotoPlus or PhotoShop But.
Direct I/O Programming An introduction to the Pentium’s mechanism for programming peripheral hardware components.
XWN740 X-Windows Configuring and Using X-Windows & Hardware (Chapter 1: Pages 11-19)‏
Linux Memory Issues Introduction. Some Architecture History 8080 (late-1970s) 16-bit address (64-KB) 8086 (early-1980s) 20-bit address (1-MB) (mid-’80s)
Managing physical memory
Detecting PCI devices On identifying the peripheral equipment installed in our PC.
CS 686: Programming SuperVGA Graphics Devices Introduction: An exercise in working with graphics file formats.
Looking at kernel objects How a character-mode Linux device driver can be useful in viewing a ‘net_device’ structure.
Access to High Memory Introduction to the kernel functions ‘kmap()’ and ‘kunmap()
The ‘mmap()’ method Adding the ‘mmap()’ capability to our ‘vram.c’ device-driver.
Introduction to the Intel x86’s support for “virtual” memory
What’s needed to transmit? A look at the minimum steps required for programming our anchor nic’s to send packets.
1 King ABDUL AZIZ University Faculty Of Computing and Information Technology CS 454 Computer graphicsIntroduction Dr. Eng. Farag Elnagahy
Ch 1 Intro to Graphics page 1CS 367 First Day Agenda Best course you have ever had (survey) Info Cards Name, , Nickname C / C++ experience, EOS experience.
Linux Memory Management How does the Linux kernel keep track of the Virtual Memory Areas that each process uses?
Notes for Lab 10 On implementing ‘show’ and ‘hide’ for the SiS 315 hardware cursor.
Operating Systems Concepts 1. A Computer Model An operating system has to deal with the fact that a computer is made up of a CPU, random access memory.
Monitors and Sound Systems section 3A This lesson includes the following sections: · Monitors · PC Projectors · Sound Systems.
Memory Mapped Files Using the Linux mechanism for direct access to device data.
Chapter 3.1:Operating Systems Concepts 1. A Computer Model An operating system has to deal with the fact that a computer is made up of a CPU, random access.
Memory Main memory consists of a number of storage locations, each of which is identified by a unique address The ability of the CPU to identify each location.
Basics of a Computer Graphics System Introduction to Computer Graphics CSE 470/598 Arizona State University Dianne Hansford.
Peripherals The term peripherals refers to all hardware devices that are attached to your computer and are controlled by your computer system Peripherals.
CHAPTER 1 Installing and Supporting I/O Devices Suraya Alias.
Random access memory.
Inside the Computer Ms. Rocío Acevedo September 2006.
Raster-scan system In addition to the central processing unit a special purpose processor called the video controller or display controller is used to.
ECE291 Computer Engineering II Lecture 9 Josh Potts University of Illinois at Urbana- Champaign.
Video Monitor Uses raster scanning to display images –Beam of electrons illuminates phosphorus dots on the screen called pixels. Starting at the top of.
Computer Graphics Raster Devices Transformations Areg Sarkissian.
8.4 paging Paging is a memory-management scheme that permits the physical address space of a process to be non-contiguous. The basic method for implementation.
Laface Operating System Design Booting a PC to run a kernel from Low memory VGA display.
Memory  Main memory consists of a number of storage locations, each of which is identified by a unique address  The ability of the CPU to identify each.
Memory Map, Programming Language, and Windows Dr. Harold D. Camp IT February 2007.
Using HiColor graphics
Paging Example What is the data corresponding to the logical address below:
Lecture # 4 Output Devices. Output Devices Devices that convert machine language into human understandable form. Output can be in display form, on paper.
Graphics An image is made up of tiny dots called pixels (“picture elements”) The resolution determines the.
Digression on r/w ‘/proc’ files An application of kernel module programming to Super VGA graphics device control.
Introduction to Virtual Memory and Memory Management
Week 9 Monitors and output to the screen. Monitors, also known as Visual display units (V.D.Us) Desktop computers contain a Cathode Ray Tube (C.R.T.)
CS 1410 Intro to Computer Tecnology Computer Hardware1.
Computer Graphics Lecture 03 Graphics Systems Cont… Taqdees A. Siddiqi
DISPLAY DEVICES CIS 10, Group #1 April 01, 2006 C. X. A. L. K. H. A. V. ((( L. C.
Color Color is one of the most interesting aspects of both human perception and computer graphics. In principle, a display needs only three primary colors.
Memory Main memory consists of a number of storage locations, each of which is identified by a unique address The ability of the CPU to identify each location.
Memory Main memory consists of a number of storage locations, each of which is identified by a unique address The ability of the CPU to identify each location.
Microprocessor and Assembly Language
Presentation transcript:

A device-driver for Video Memory Introduction to basic principles of the PC’s graphics display

Raster Display Technology The graphics screen is a two-dimensional array of picture elements (‘pixels’) Each pixel’s color is an individually programmable mix of red, green, and blue These pixels are redrawn sequentially, left-to-right, by rows from top to bottom

Special “dual-ported” memory VRAM RAM CPU CRT 32-MB of VRAM 1024-MB of RAM

Graphics programs What a graphics program must do is put appropriate bit-patterns into the correct locations in the VRAM, so that the CRT will show an array of colored dots which in some way is meaningful to the human eye Thus, programmer must understand what the CRT will do with the contents of VRAM

How much VRAM is needed? This depends on (1) the total number of pixels, and on (2) the number of bits-per-pixel The total number of pixels is determined by the screen’s width and height (measured in pixels) Example: when our “screen-resolution” is set to 1280-by-1024, we are seeing 1,310,720 pixels The number of bits-per-pixel (“color depth”) is a programmable parameter (varies from 1 to 32) Some types of applications also need to use extra VRAM (for multiple displays, or for “special effects” like computer game animations)

How ‘truecolor’ works R B G alpharedgreenblue pixel longword The intensity of each color-component within a pixel is an 8-bit value

Intel uses “little-endian” order BGRBGRBGR VRAM Video Screen

Recall our ‘dram.c’ driver Earlier we wrote a simple character-mode device-driver (named ‘dram.c’) that let an application program read the contents of the processor’s physical memory (1 GB) That device driver’s ‘read()’ function used the Linux kernel’s ‘kmap()’ function to map pages of physical memory to kernel space

We want a ‘vram.c’ driver We can create a similar device-driver that will let an application read, and also write, to our system’s video display memory But a few new issues will arise: –Where is physical video memory located? –How do we ‘map’ vram to virtual addresses? –How can we trasfer data to and from vram?

Physical Memory Space (4GB) VRAM DRAM 1-GigaByte 0x xFFFFFFFF 0x

Mapping a device’s memory We use a pair of special kernel functions to ‘map’ and ‘unmap’ segments of vram: void *virtaddr = ioremap( physaddr, len ); void iounmap( virtaddr ); Remember: device-memory is not tracked by the ‘struct page’ entries of ‘mem_map[]’

Virtual to Physical user space High memory Zone normal kernel space virtual address-space physical address-space video memory

Doing data-transfers Instead of using the ‘copy_to_user()’ and ‘copy_from_user()’ kernel-functions, data is transferred to and from device-memory using this pair of Linux kernel functions: void memcpy_fromio( buf, dev, length); void memcpy_toio( dev, buf, length );

Finding a device’s memory Modern peripheral devices for PCs do not employ standard fixed memory-addresses Device-memory gets physically mapped to unused areas in the CPU’s address-space during the ‘system configuration’ process The locations and sizes of device-memory are ‘remembered’ in non-volatile battery- powered RAM (‘configuration memory’)

Kernel’s PCI functions Linux provides a set of kernel functions for device-drivers to use when locating where a device’s memory was physically mapped The PCI functions (Peripheral Component Interconnect) are based on industry-wide standards based on committee consensus Devices use an identification-number pair: #define VENDOR_ID0x1039 #define DEVICE_ID0x6325

Functions we need struct pci_dev { // contains many fields }; struct pci_dev *devp = NULL; devp = pci_find_device( VID, DID, devp );

Base-address and Length For the SiS-315 Graphics Processor used in our classroom and lab workstations, the display memory is ‘resource number 0’ unsigned long base, size; base = pci_resource_start( devp, 0 ); size = pci_resource_len( devp, 0 ); NOTE: Our machines have 32MB of VRAM (although are capable of addressing 128MB)

In-class exercise We created a ‘vramdraw.cpp’ application that exercises our ‘vram.c’ device-driver’s ‘read()’, ‘write()’, and ‘llseek()’ methods – but it has a noticable programming ‘bug’. Your job is to analyze carefully the driver’s code and the program’s code, in order to find the bug – and then fix it!