Unformatted text preview:

The CRTC InterfaceMotivationBut it’s tedious to program…Info the CRTC engine needsHardware registersHow it worksA useful optimizationCursor-related CRTC registers8x16 character boxCURSOR START/ENDOrganization of the VRAMChanging the visual pageMoving the CRT’s cursorScrolling the screenLinux uses hardware scrollingThe ROM-BIOS variablesStandard data-addressesReal-mode INT-0x10 servicesCursor-movement demoPolling the status-registerDisadvantage of pollingAnother noteworthy featureIn-Class exerciseThe CRTC InterfaceEssential aspects of display page and cursor control for standard 80-column by 25-row textMotivation•When a UNIX application wishes to write a text message to the display, and then wait for a keyboard-response from the user, the application will want a ‘cursor’ to be visible at the position where the next keystroke is going to be echoed•EXAMPLE: Please type a number: We expect a blinking cursor to appear hereBut it’s tedious to program…•To write code that draws a blinking cursor on the screen would be a time-consuming chore for both programmer and processor:–You have to repeatedly ‘draw’ and then ‘hide’–You have to setup careful timing controls–Your program-loop will keep the CPU busy! •Fortunately the video system’s hardware is able to handle this tedious chore for you!Info the CRTC engine needs•The display hardware already knows how to do the timing for normal cursor blinking (i.e., usually about two blinks per second) •Software only needs to tell the hardware a few specific pieces of information:–Where does the cursor appear (row, column)? –How large is the cursor? Where does it start and end within the 8x16 character-cell?–Which region of display-memory is visible?Hardware registers•The CRT Controller is a peripheral chip •It implements 25 standard CRTC registers•Access to these registers is accomplished via a multiplexing scheme which uses just two I/O port-addresses for color text:address-port: 0x03D4data-port: 0x03D5How it works•The multiplexing scheme for access to the CRTC registers was designed to function as a two-step operation:–First, specify which register is to be accessed (by writing the register’s index to port 0x3D4)–Then, read (or write) to the specified register (by inputting, or outputting, at port 0x3D5) •But a multi-step scheme is problematic for preemptive multitasking (also it is slow!)A useful optimization•To improve the multiplexing scheme when writing values to CRTC registers, the CPU is able to perform the two steps in a single ‘atomic’ fetch-execute cycle:•Here the ‘outw’ instruction will write AL to port $0x03D4 and AH to port $0x03D5 mov $0x03D4, %dxmov $0xFF14, %axoutw %ax, %dxCursor-related CRTC registers•For text-mode cursor-control, we are concerned with just 6 (of the 25) standard CRTC registers:•Index 0x0A: CURSOR_START•Index 0x0B: CURSOR_END•Index 0x0C: START_ADDRESS_HI•Index 0x0D: START_ADDRESS_LO•Index 0x0E: CURSOR_LOCATION_HI•Index 0x0F: CURSOR_LOCATION_LO8x16 character boxscanline 0scanline 1 scanline 2scanline 3scanline 4scanline 5scanline 6scanline 7scanline 8scanline 9scanline 10scanline 11scanline 12scanline 13scanline 14scanline 15Cursor_start = 12Cursor_end = 13CURSOR START/ENDdis-ablestarting_scanlineskew ending_scanline7 6 5 4 3 2 1 07 6 5 4 3 2 1 0Index 0x0A:Index 0x0B:CURSOR_START REGISTERCURSOR_END REGISTERNOTE: The ‘skew’ capability works by delaying the cursor’s appearance for0, 1, 2, or 3 character-cells (i.e., shifting the cursor toward the right). WhenIs this useful? We couldn’t find any examples. Recommend skew be zero.Organization of the VRAMPage 0Page 1Page 2Page 3Page 4Page 5Page 6Page 7Base_Address = 0xB80004KB4KB4KB4KB4KB4KB4KB4KBChanging the visual page7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0START_ADDRESS_HI START_ADDRESS_LOregister-index 0x0Cregister-index 0x0DProgramming example: # switches display to vram page 5# the word-offset for page 5 is 0x2800 (= 5 * 2048)mov $0x03D4, %dx # port-address in register DXmov $0x280C, %ax # value=0x28, register=0x0Cout %ax, %dx # write value to CRTC registermov $0x000D, %ax # value=0x00, register=0x0Dout %ax, %dx # write value to CRTC registerMoving the CRT’s cursor7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0CURSOR_LOCATION_HI CURSOR_LOCATION_LOregister-index 0x0E register-index 0x0FProgramming example: // moves cursor to row 5, column 9, on page 0mov $0x03D4, %dx // port-address in register DXmov $5, %bx // row-numberimul $80, %bx // times cells-per-rowadd $9, %bx // plus column-numbermov %bh, %ah // cursor offset’s MSBmov $0x0E, %al // CURSOR_HI indexout %ax, %dx // write value to CRTC registermov %bl, %ah // cursor offset’s LSBmov $0x0F, %al // CURSOR_LO indexout %ax, %dx // write value to CRTC registerScrolling the screen•Here’s a code-fragment that will scroll the contents of vram page 0 up by one line: mov $0xB800, %ax // address vram page 0 mov %ax, %ds // with DS register mov %ax, %es // also ES register mov $0, %di // destination is the top line mov $160, %si // source is one line lower cld // do forward copying mov $3840, %cx // 24 times 160 rep movsb // perform the copying mov $0x0720, %ax // blank character w/color mov $80, %cx // characters on bottom line rep stosw // fill final line with blanksLinux uses hardware scrolling•The value of the CRT START_ADDRESS is reprogrammed, to change the region of visible vram by one line (i.e., add #80)•So instead of subdividing vram into eight 4KB pages, the entire 32KB vram is one continuous page, but only partially visible•To scroll up by one line, Linux adds $80 to the value of the CRT_START_ADDRESSThe ROM-BIOS variables•Several variables in the ROM-BIOS DATA AREA are used by the VIDEO ROM-BIOS routines (i.e., int-0x10) to keep track of the current visisible page and of the positions of the cursors on each of the eight pages•The locations of these variables are part of the IBM-PC BIOS standard, and as such they are widely documentedStandard data-addresses0x449 (byte) current video mode-number0x44A (word) number of columns on screen0x44C (word) current page-size (in bytes)0x44E (word) current page-address0x450 (byte array) cursor-positions (col,row)0x460 byte-pair) cursor type (END, START)0x462 (byte) current display page-number0x463 (word) CRTC base i/o port-addressReal-mode INT-0x10 services•Function 0x00: set_display_mode•Function 0x01: set_cursor_type•Function 0x02:


View Full Document

USF CS 630 - The CRTC Interface

Documents in this Course
Load more
Download The CRTC Interface
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view The CRTC Interface and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view The CRTC Interface 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?