Docsity

Access to Video Memory - Advanced System Programming - Lecture Slides, Slides of Computer Applications

Partial preview of the text

Download Access to Video Memory - Advanced System Programming - Lecture Slides and more Slides Computer Applications in PDF only on Docsity!

Access to video memory

We create a Linux device-driver

that gives applications access to

our graphics frame-buffer

The role of a device-driver

user application

standard “runtime” libraries

call ret

user space kernel space

Operating System kernel

syscall

sysret

device-driver module

call

ret

hardware device

out

in

i/o memory

RAM

A device-driver is a software module that controls a hardware device in response to OS kernel requests relayed, often, from an application

Special “dual-ported” memory

VRAM

RAM

CPU

CRT

16-MB of VRAM

2048-MB of RAM

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-960, we are seeing 1,228,800 pixels
  • The number of bits-per-pixel (“color depth”) is a programmable parameter (varies from 1 to 32)
  • Certain types of applications also need to use extra VRAM (for multiple displays, or for “special effects” like computer game animations)

x86 uses “little-endian” order

VRAM B G R B G R B G R

0 1 2 3

Video Screen

4 5 6 7 8 9 10 …

“truecolor” graphics-modes use 4-bytes per picture-element

Some operating system issues

  • Linux is a “protected-mode” operating system
  • I/O devices normally are not directly accessible
  • Linux on x86 platforms uses “virtual memory”
  • Privileged software must “map” the VRAM
  • A device-driver module is needed: ‘ vram.c ’
  • We can compile it using: $ mmake vram
  • Device-node: # mknod /dev/vram c 98 0
  • Make it ‘writable’: # chmod a+w /dev/vram

What is PCI?

  • It’s an acronym for “Peripheral Component

Interconnect” and refers to a collection of

industry standards for devices used in PCs

  • An Intel-sponsored initiative (from 1992-9)

having several ambitious goals:

  • Reduce diversity inherent in legacy PC devices
  • Improve speed and efficiency of data-transfers
  • Eliminate (or reduce) platform dependencies
  • Simplify adding/removing peripheral adapters
  • Lower PC’s total consumption of electrical power

PCI Configuration Space

PCI Configuration Space Body (48 doublewords – variable format)

64 doublewords

PCI Configuration Space Header (16 doublewords – fixed format)

A non-volatile parameter-storage area for each PCI device-function

Examples of VENDOR-IDs

  • 0x8086 – Intel Corporation
  • 0x1022 – Advanced Micro Devices, Inc
  • 0x1002 – Advanced Technologies, Inc
  • 0x10EC – RealTek, Incorporated
  • 0x10DE – Nvidia Corporation
  • 0x10B7 – 3Com Corporation
  • 0x101C – Western Digital, Inc
  • 0x1014 – IBM Corporation
  • 0x0E11 – Compaq Corporation
  • 0x1057 – Motorola Corporation
  • 0x106B – Apple Computers, Inc
  • 0x5333 – Silicon Integrated Systems, Inc

Examples of DEVICE-IDs

  • 0x5347: ATI RAGE128 SG
  • 0x4C58: ATI RADEON LX
  • 0x5950: ATI RS
  • 0x436E: ATI IXP300 SATA
  • 0x438C: ATI IXP600 IDE
  • 0x5B60: ATI Radeon X

See this Linux header-file for lots more examples:

</usr/src/linux/include/linux/pci_ids.h>

Example of Sub-Class Codes

  • Class Code 0x01: Mass Storage controller
    • 0x00: SCSI controller
    • 0x01: IDE controller
    • 0x02: Floppy Disk controller
    • 0x03: IPI controller
    • 0x04: RAID controller
    • 0x80: Other Mass Storage controller

Example of Sub-Class Codes

  • Class Code 0x02: Network controller
    • 0x00: Ethernet controller
    • 0x01: Token Ring controller
    • 0x02: FDDI controller
    • 0x03: ATM controller
    • 0x04: ISDN controller
    • 0x80: Other Network controller

Hardware details may differ

  • Graphics controllers use vendor-specific

mechanisms to perform similar operations

  • There’s a common core of compatibility

with IBM’s VGA (Video Graphics Array)

developed in the mid-1980s, but since

IBM’s loss of market dominance, each

manufacturer has added enhancements

which employ incompatible programming

interfaces – you need a vendor’s manual!

The ‘frame-buffer’

  • Today’s PCI graphics systems all provide

a dedicated amount of display memory to

control the screen-image’s pixel-coloring

  • But how much memory will vary with price
  • And its location within the CPU’s physical

address-space can’t be predicted because

it depends upon what other PCI devices

are installed (and mapped) during startup