3 Volume 3, Issue 8 -- February 24, 1999
5 --------------------------------------------------------------------------------
6 BE ENGINEERING INSIGHTS: Adventures in Graphics Drivers
7 By Leo Schwab -- <ewhac@be.com>
8 --------------------------------------------------------------------------------
10 This adventure is more true than I might otherwise be
11 willing to admit. All persons and events depicted are
12 entirely fictitious, except where they aren't. Unflattering
13 characterizations of certain organizations are entirely
14 deliberate and intentional.
16 You are in a cube. In front of you is a 16"
17 (visible) Sony monitor. In front of that is a
18 Mitsumi keyboard and an unbranded mouse. Just to
19 the right is a 266 MHz PC clone. The system is
20 running a development version of BeOS R4.
22 There is a graphics card here.
23 There is a floppy disk here.
24 There is a note from your boss here.
25 There is a Hoberman sphere here.
29 You have a well-used satchel. Inside it are
33 A 16M laptop RAM module
34 A book on decorative knots
35 A PCMCIA Ethernet card
36 Last year's tax return
37 A 166 MHz Pentium laptop computer
38 A bottle of echinacea capsules
41 Your wallet contains $3200.
45 You put aside the amazingly cruddy Mitsumi keyboard
46 and substitute your favorite AT&T keyboard.
50 The laptop is now on the desk.
54 "Write a driver for this card. We'd like it in time
57 > EXAMINE GRAPHICS CARD
59 You are evidently the proud owner of a Yoyodyne
60 Monstra VelocElite-LX 128-3D-AGP graphics card.
62 > INSERT CARD IN MACHINE
64 The machine emits a curious and worrying noise.
66 > TURN OFF MACHINE AND INSERT CARD
68 The graphics card is now installed in the machine.
72 BeOS R4(devel) boots. You are looking at a
77 The handwritten label reads, "Programming docs."
79 > INSERT DISK AND PRINT DOCS
83 > INSERT DISK, MOUNT DISK, AND PRINT DOCS
85 The drive spins for a moment, and the command prompt
92 > GO TO PRINTER AND GET DOCS
94 The printer is out of paper.
96 > PUT PAPER IN PRINTER
98 There is no paper here.
100 > STEAL PAPER FROM COPIER UPSTAIRS
102 After installing the liberated paper in the printer,
107 The cover page reads, "Yoyodyne Monstra
108 VelocElite-LX 128-3D Programmer's Reference. Alpha
109 Revision 05-31-98. Confidential and Proprietary.
110 Restricted Secret; Level Violet. Do not expose in
111 public. This document must be kept secured when not
112 in use. Disclosure of this document to third
113 parties is punishable by death."
117 After several hours, you finish reading the docs.
118 The VelocElite-LX is a depressingly predictable
119 variation on the VGA register set. There are some
120 registers that have unhelpfully terse descriptions.
121 The card also has the ability to execute rendering
122 command lists out of RAM.
124 You now know enough to write a rough driver for the
129 After several days, you have driver ready to test.
131 > INSTALL DRIVER AND TEST
132 You reboot the machine. The screen is blank.
134 > RUN 'minicom' ON LAPTOP
136 The 'minicom' terminal emulator is now running in an
139 > PRESS ALT-SYSRQ ON MACHINE
143 > PLUG SERIAL CABLE INTO LAPTOP
145 The "kdebug>" prompt from the kernel debugger
146 appears on the XTerm.
150 After thirty minutes, you determine that two of the
151 sync registers are set incorrectly.
153 > FIX BUGS IN DRIVER AND TEST
155 You can't see anything.
157 > REBOOT IN SAFE MODE AND FIX BUGS
159 A new version of the driver is ready to test.
163 You reboot the machine. You see a color BeOS
168 You switch to 800*600. It looks fine.
169 You switch to 1024*768. It looks fine.
170 You switch to 1152*864. There are pixel sparkles on
173 > PRESS ALT-SYSRQ ON MACHINE
179 Oh, sorry, I forgot. You get a "kdebug>" prompt.
181 > EXAMINE SYNC REGISTERS
183 After forty minutes, you find nothing wrong with the
186 > EXAMINE REGISTER 0x6000
188 Register 0x6000 (FIFO watermarks) contains 0x0201
191 > WRITE 0x0200 TO REGISTER 0x6000
193 This is one of the poorly documented registers. Are
194 you sure you want to do this?
198 The screen goes blank.
200 > WRITE 0x0201 TO REGISTER 0x6000
202 You see a color BeOS desktop.
204 > WRITE 0x0202 TO REGISTER 0x6000
206 The screen goes blank.
208 [ ...Many more iterations deleted... ]
210 > WRITE 0x1810 TO REGISTER 0x6000
212 The pixel sparkles cease.
214 > MODIFY DRIVER TO WRITE 0x1810 to 0x6000 AND TEST
216 You reboot the machine. You see a color BeOS
217 desktop, sans pixel sparkles.
219 > ADD HARDWARE BLITTER SUPPORT TO DRIVER AND TEST
221 You reboot the machine. You see a perfectly stable
222 display of utter garbage with icons and text on top
225 > FIX RECTANGLE CODE AND TEST
227 You reboot the machine. You see a color BeOS desktop.
231 The screen turns blank.
233 > FIX BLITTING CODE AND TEST
235 You can't see anything. If you proceed, you will
236 likely be eaten by a Grue.
238 > REBOOT IN SAFE MODE, FIX BLITTING CODE, AND TEST
240 You reboot the machine. A color BeOS desktop greets
245 The window moves, but leaves "dirt" behind it.
247 > READ DOCS ON BLITTER
249 "The blit width register is set to the number of
250 bytes copied per row." Your code reflects this
253 > ADD FENCEPOST TO BLIT WIDTH AND TEST
255 You reboot the machine. Windows now drag normally,
256 except for some weirdness at the left edge of the
261 It looks as if the left four columns of pixels are
262 being blitted 64 pixels too high.
264 > READ DOCS ON BLITTER
266 There is nothing in the docs to explain this behavior.
268 > GO www.yoyodyne.com
270 You are in a Web site.
272 There are many links here.
274 > GO DEVELOPER SUPPORT
276 There is no developer support here.
278 > READ DOCS ON SUPPORT
280 There is nothing in the docs on how to get support.
284 Your boss gives you the e-mail address of the contact
287 > SEND MAIL DESCRIBING PROBLEM
289 The e-mail disappears down the Ethernet port, on its
300 You have 1 new message(s):
302 From: john.smallberries@yoyodyne.com
303 "Oh, yeah. That's a known bug. The official
304 workaround is to copy those four pixel columns in
307 > WRITE SPECIAL CASE FOR BLITTING CODE AND TEST
309 You reboot the machine. Windows now glide across
310 the display like silk.
314 All 15 bit modes work perfectly.
318 All 16 bit modes work perfectly.
322 The screen turns blank, then returns to the previous
325 > READ DOCS ON DISPLAY DEPTHS
327 "The following display depths are supported:
331 0x04: 16 bits (RGB 555)
332 0x05: 16 bits (RGB 565)
333 0x06: 24 bits (RGB 888)
334 0x08: 32 bits (xRGB 8888)"
336 > PRESS ALT-SYSRQ AND EXAMINE REGISTER
338 The display depth register is set to 0x05.
340 > WRITE 0x08 TO REGISTER
342 The display turns blank.
344 > WRITE 0x06 TO REGISTER
346 You see a color BeOS desktop.
348 > WRITE MAIL DESCRIBING PROBLEM
352 > ENTER 'c' AT DEBUGGER PROMPT AND WRITE MAIL
354 The e-mail disappears down the Ethernet port, on its
365 You have 1 new message(s):
367 From: john.smallberries@yoyodyne.com
368 "I just spoke to our hardware engineer, and he says
369 that 32-bit modes don't really work all that well,
370 and they should be avoided. 24-bit works fine,
373 > REMOVE 32 BIT SUPPORT FROM DRIVER AND TEST
375 You reboot the machine. You have now have a
376 functional accelerated BeOS desktop.
378 > CHECK DRIVER INTO SOURCE TREE
380 You check in your new source files into the master
383 You have broken the build.
385 A dunce cap has appeared in your cube.
387 > FIX DEPENDENCY FILE AND CHECK IN
389 The build is restored to its former glory.
391 The dunce cap has vanished.
397 You have 1 new message(s):
400 "We're having trouble with the Yoyodyne driver in
401 the QA lab. Can you look at it?"
405 You are in the QA Lab. Many machines on many
406 shelves are here, running test programs. The Baron
407 directs you to the misbehaving machine. Its screen
410 > TELNET INTO MACHINE
412 A 'bash' shell prompt greets you.
414 > REMOVE FILE '/boot/home/config/settings/app_server_settings'
417 You reboot the machine. You see a perfectly
418 functional 640*480 display.
420 The Baron looks like he has something to say.
424 He directs you to another machine. The monitor
425 looks as if it can't quite sync to the card's
428 > TELNET INTO MACHINE
430 A 'bash' shell prompt greets you.
432 > REMOVE FILE '/boot/home/config/settings/app_server_settings'
435 Ha ha! That doesn't work this time! A sense of
436 crushing defeat envelops you.
444 You are looking at a Flabloden 15ZF monitor.
448 "Congratulations on your purchase of a Flabloden
449 15ZF monitor. Our products are fully compliant with
450 VESA standards, including the VESA signalling and
451 GTF specifications, assuring your monitor will work
452 with whatever the hell graphics card you have
457 You are at the Video Electronics Standards
458 Association's Web site.
460 There are many links here.
462 A Reporter from CNN visiting Jean-Louis wanders by.
463 He glances in your cube.
465 > HIDE YOYODYNE DOCS!
467 It is too late. The Reporter has seen the docs on
468 your desk. A lightning bolt stabs out of the sky
469 and through the ceiling, striking the Reporter,
470 leaving only a smoking pile of ash.
474 You dutifully clean up the Reporter's remains.
476 > SEARCH FOR GTF DOCS
478 You find a link here named "VESA General Timing
481 > GO VESA GENERAL TIMING FORMULA
483 A Troll bars your way. He is demanding tribute.
487 He is big, strong, mean, ugly, pitiless, and
488 unusually well dressed.
492 Despite your best efforts, the Troll thwarts your
493 attempts to evade him.
497 "THOU CANST NOT PASS LEST THOU PAYEST UNTO ME MY
498 RIGHTFUL TRIBUTE!" thunders the Troll.
500 > EXPLAIN SITUATION TO TROLL
502 The Troll ignores you.
510 Now who's editorializing?
514 Reluctantly, you hand over the required tribute.
515 The Troll gives you a token so that you may pass
518 Your wallet now contains $2500.
520 > GO VESA GENERAL TIMING FORMULA
522 There is a file here. The description says it
523 contains the algorithm for calculating sync timings
524 for any display mode.
528 A copy of the file is now on your machine.
532 There is no PDF reader here.
534 > TRANSFER FILE TO LAPTOP AND READ
536 After picking through some opaque language, you now
537 understand the VESA GTF.
539 > ADD VESA GTF CODE TO DRIVER AND TEST
541 You reboot the machine. The Flabloden 15ZF monitor
548 You have 2 new message(s):
550 From: xf541ceuc8@aol.com
551 "MAKE.MONEY.FAST! Hi, my name is Dave Rhodes..."
553 > DELETE MESSAGE, NEXT MESSAGE
556 "We're going to need AGP support on the Yoyodyne
557 card so we can start on OpenGL acceleration. Can
562 Except for a few PCI configuration registers, there
563 is no mention of AGP in the docs.
565 > GO developer.intel.com
567 You are at Intel's developers' Web site.
569 There are many links here.
573 You find a single file named, "Accelerated Graphics
574 Port Interface Specification (v2.0)".
576 > DOWNLOAD FILE TO LAPTOP AND READ
578 AGP is an extension to PCI. Like a modern CPU's
579 MMU, AGP uses a translation table (called a GART) to
580 make disjoint blocks of system memory appear
581 contiguous. Both the graphics card and the
582 motherboard controller must be properly configured
583 for AGP to work. The layout and function of the PCI
584 AGP configuration registers are described only in
585 general terms. Most of the rest of the document
586 describes hardware implementation and signalling
589 > EXAMINE MOTHERBOARD IN MACHINE
591 Your machine uses an Intel 440LX motherboard
594 > GO developer.intel.com
596 You are at Intel's developers' Web site.
598 There are many links here.
602 You find a file named, "Intel 440LX AGPset: 82443LX
603 PCI AGP Controller (PAC) Datasheet"
605 > DOWNLOAD FILE TO LAPTOP AND READ
607 You now understand how to program the host's and
608 graphics card's AGP control registers.
610 > ADD CODE ENABLING AGP 1X MODE TO DRIVER AND TEST
612 You reboot the machine. Everything still works.
614 > ADD CODE ENABLING SIDEBAND ADDRESSING TO DRIVER AND TEST
616 You reboot the machine. Everything still works.
618 > ADD CODE ENABLING GART TO DRIVER AND TEST
620 You do not know how to create a GART.
622 > READ AGP DOCS ON GART
624 "The specific layout of the GART is
625 chipset-specific, and not documented here. GART
626 manipulation is done via a miniport driver or HAL
627 supplied with the chipset BIOS reference
630 > READ 440LX DOCS ON GART
632 There is no description of the GART here.
634 > GO developer.intel.com
636 You are at Intel's developers' Web site.
638 There are many links here.
642 There are no GART docs here.
644 > SEARCH FOR OTHER AGP RESOURCES
646 There is a link to the AGP Implementor's Forum, at
649 > GO www.agpforum.org
651 You are at the AGP Implementor's Forum Web site.
653 There are many links here.
657 A Troll bars your way. He is demanding tribute.
661 Despite your best efforts, the Troll thwarts your
662 attempts to evade him.
666 Reluctantly, you hand over the required tribute.
667 The Troll gives you a token so that you may pass
670 Your wallet is now empty.
674 There are no GART docs here. The Troll laughs
677 > FIND ALL PROGRAMMING DOCS
679 You find a file named, "System Software."
681 > DOWNLOAD FILE TO LAPTOP AND READ
683 'ghostscript' reports: "This PDF file is encrypted
684 and cannot be processed."
686 > CRASH LAPTOP BACK TO WINDOWS
688 You close your XTerms, reboot the laptop, and in
689 mere minutes, Windows is ready.
691 > OPEN "SYSTEM SOFTWARE" DOCS
693 The PDF reader opens. This looks suspiciously like a
696 > SEARCH DOCS FOR "GART"
698 "GART manipulation is performed through the miniport
699 driver and DirectX 5 extensions..."
703 You heartily curse in a manner that comes only with
704 long practice. Co-workers pop up from their cubes
709 Out of a possible 127 points, you have a total score
714 Your adventure has been saved...