CS 686 PROJECT 1 Due Date: Noon Thursday 10/16/2003 The purpose of this project is to acquaint students with fundamental programming issues involved in adapting legacy PC graphics software so it can be executed as an SVGA application by a contemporary Linux system. PROJECT STATEMENT Modify the source-text for the 'polyfill.cpp' program (available for copying from our class website) so it will execute correctly under Linux. That program was written as a demonstration of the Bresenham Line-Drawing algorithm as used for implementing polygon fill operations. The compiler for which its code was designed was Borland's popular TURBO-C++ compiler, used to build applications for the MS-DOS operating system. All hardware and firmware capabilities upon which that software depends have continued to be supported by modern PC systems, but the system software environment provided by Linux differs from that of MS-DOS in several significant ways that affect this application, including the following: Linux is a virtual memory, protected-mode, multitasking operating system which adheres to certain user-interface standards for UNIX systems. Any physical memory which needs to be accessed by an application program must be "mapped" by the Linux kernel to virtual addresses located within the region allocated for unprivileged access (i.e., in the address-range from 0x00000000 to 0xC0000000). These mappings are performed by calling the 'mmap()' function on an already opened device-file. Any direct i/o programming of peripheral hardware, such as SVGA graphics controllers, requires that the application must be allowed to adjust the IOPL field in the processor's EFLAGS register, an operation normally not permitted unless arranged by the system administrator. If allowed, this adjustment will be accomplished by calling the 'iopl()' function with an argument equal to 3. Any deviations that are desired from the computer terminal's 'canonical' mode of handling user-input from the keyboard will need to be explicitly programmed, using standard API functions and data-structures. The "raw" keyboard input (unbuffered) that was always available to MS-DOS programs is not a feature of the default keyboard behavior under Linux. Any use of routines in the SVGA manufacturer's ROM-BIOS firmware, to set graphics display modes or perform other "low-level" graphics operations, will require programs written in C/C++ to employ a special interface for transmitting the function parameters which those routines expect to find in specific CPU registers. This issue also was present with MS-DOS, and can be handled in a similar (though not identical) way under Linux, with the LRMI library (provided as part of the SVGALIB package). The library also allows the real-mode ROM-BIOS instructions to execute transparently in the Pentium's so-called Virtual-8086 mode. The GNU C++ compiler for Linux uses some differently-sized data objects, such as 32-bits for 'int', and enforces stricter rules for the declaring of constants and functions, than did the TURBO-C++ compiler for MS-DOS. ________________________________________________________________________ Allan B. Cruse University of San Francisco Fall 2003