1450N/A * Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved. 1450N/A * All functions called in polled I/O mode should not have lock 1450N/A * ASSERT, for lock is not available in polled I/O mode. Each 1450N/A * time polled routines (e.g. efb_polled_consdisplay) are called, 1450N/A * efb_in_polledio is set and then PASSERT will just simply succeed. 1450N/A * Read the terminal emulator's change mode callback 1450N/A * address out of the incoming structure 1450N/A * Allocate memory needed by the the kernel console 1450N/A * Determine which video stream the console will render on. 1450N/A case 0:
/* PROM version 1.10 or earlier uses 0 to mean stream 1 */ 1450N/A * Extract the terminal emulator's video mode change notification 1450N/A * callback information from the incoming struct 1450N/A * Describe this driver's configuration for the caller. 1450N/A * Setup the standalone access (polled mode) entry points 1450N/A * which are also passed back to the terminal emulator. 1450N/A * Get our view of the console as scribbling pad of memory. 1450N/A * Calculate the FULL length of a horizontal line of pixel 1450N/A * memory including both the visible portion and the portion 1450N/A * that extends past the visible boundary on the right. 1450N/A * (The invisible section is where any rounding excess 1450N/A * goes to accomodate to the 64 or 256 byte rounding 1450N/A * requirements of certain device functional block 1450N/A * Clear colormap update flags so we can do lazy loading 1450N/A * TrueColor 24 _requires_ prepping the DAC properly, although it 1450N/A * isn't documented in the Radeon PDF files (there is a reference 1450N/A * in the Mach64 documents, however). 1450N/A * Send framebuffer kernel console rendering parameters back to the 1450N/A * This calls back into the terminal emulator to inform it of 1450N/A /* make sure we have the right stream */ 1450N/A * colormap manipulation entry points ------------------------------------- 1450N/A * For 8-bit a'lazy loading' scheme is used so that only restore cmap entries 1450N/A * that have been flagged as in use by the terminal emulator. The highest 1450N/A * ordered cmap entry that has been accessed since console's VIS_DEVINIT 1450N/A * ioctl was invoked is tracked to optimize colormap restoration for speed. 1450N/A * For 32-bit depth the DAC must be initialized for linear TrueColor 24 before 1450N/A * the colors will work properly. 1450N/A * Initialize the cmap for the current fb depth 1450N/A * This function is called to save a copy of the kernel terminal emulator's c 1450N/A * color map when a VIS_PUTCMAP ioctl is issued to the driver. 1450N/A * Re-establish the kernel's 8-bit color map. 1450N/A * This is a quick chance to see if we've set up the colormap 1450N/A * properly. It is executed for each character so we want to 1450N/A * keep it optimized. It seems to work. Worst case, some 1450N/A * sort of sparse but more thorough checking could be done. 1450N/A * This seems to work for the simple tradeoff between the 1450N/A * X server's colormaps and the kernel terminal emulator's. 1450N/A * ioctl entry points ------------------------------------------------- 1450N/A * The ioctl interface tactics differ from the polled interface's. 1450N/A * The console ioctls need to do context management (ie. unload user mappings, 1450N/A * save user context, load kernel's context). However since the kernel's 1450N/A * context isn't associated with memory mappings, the DDI won't prod us to 1450N/A * re-establish the kernel's context if userland interrupts us. Therefore, 1450N/A * we prevent interruption for the duration of any given rendering operation 1450N/A * (ie. displaying character, scrolling one line, or displaying cursor), 1450N/A * by holding the context lock. 1450N/A * Each rendering operation depends on a particular static setup of the mach64 1450N/A * draw engine state. Besides that, anything the kernel console rendering 1450N/A * functions change in the draw engine state can be discarded, because they 1450N/A * are re-initialized at each rendering operation. Therefore the static 1450N/A * state is saved once when the kernel context is created, and then loaded, 1450N/A * but not saved thereafter. 1450N/A /* Just return if videomode change is on-going */ 1450N/A /* Just return if videomode change is on-going */ 1450N/A /* Just return if videomode change is on-going */ 1450N/A * Polled I/O Entry Points. ----------------------------------------- 1450N/A * The tactics in these routines are based on the fact that we are 1450N/A * -only- called in standalone mode. Therefore time is frozen 1450N/A * for us. We sneak in restore the kernel's colormap, establish 1450N/A * the kernel's draw engine context, render, and then replace the 1450N/A * previous context -- no one the wiser for it. 1450N/A * In polled I/O mode (also called standalone mode), the kernel isn't 1450N/A * running, Only one CPU is enabled, system services are not running, 1450N/A * and all access is single-threaded. The limitations of standalone 1450N/A * mode are: (1) The driver cannot wait for interrupts, (2) The driver 1450N/A * cannot use mutexes, (3) The driver cannot allocate memory. 1450N/A * The advantage of polled I/O mode is, that because we don't have to 1450N/A * worry about concurrent access to device state, we don't need to 1450N/A * unload mappings and can perform a lighter form of graphics context 1450N/A * switching, which doesn't require the use of mutexes. 1450N/A * Setup for DFB rectangle BLIT on a "quiesced" system 1450N/A * Setup for DFB rectangle copy (vertical scroll) on 1450N/A * Setup for DFB inverting rectangle BLIT (cursor) 1450N/A/* ----------------------------------------------------------- */ 1450N/A * Copy to DFB a rectangular image whose size, coordinates and pixels 1450N/A * are defined in the draw struct. The proper pixel conversions 1450N/A * are made based on the video mode depth. This operation is implemented 1450N/A * in terms of memory copies. 1450N/A /* Transform into DFB byte order */ 1450N/A case 8:
/* 8-bit color map index */ 1450N/A * This function implements show/hide cursor functions as appropriate 1450N/A * for the current screen depth. Due to the difficulty of managing 1450N/A * and framebuffer depths with simple ALU operations, particularly 1450N/A * in 8-bit psuedocolor mode, the cursor is always displayed along 1450N/A * retains good legibility for all ANSI fg and bg combinations. 1450N/A * This approach requires saving the contents under the cursor so 1450N/A * they can be restored when the cursor moves by re-blitting them 1450N/A * onto the DFB, rather than using a heuristic. 1450N/A * For the SHOW_CURSOR operation, the contents beneath the cursor 1450N/A * are saved before displaying the monochrome overlay in anticipation 1450N/A * of a HIDE_CURSOR operation over the same location, prior to moving 1450N/A * the cursor to a new location. 1450N/A * The HIDE_CURSOR function simply replaces the text saved under 1450N/A * the cursor rectangle during the previous SHOW_CURSOR operation. 1450N/A * This protocol necessitates tight cursor protocol agreement 1450N/A * with the terminal emulator. 1450N/A * Convert fg/bg into DFB order for direct comparability 1450N/A * This function implements scrolling by copying a rectangular block of 1450N/A * pixels upward on the Y-axis. The caller provides block copy parameters 1450N/A * as a rectangle, defined by (s_col, s_row), (e_col, e_row) and target 1450N/A * This implementation uses the Radeon GUI engine to accomplish this faster 1450N/A * than memory moves done from software. It is left to the caller to 1450N/A * establish the kernel's graphic context prior to calling this function. 1450N/A * Switch access mode to PIO 1450N/A * This function invalidates the user's GUI context. 1450N/A * It MUST NOT be called in standalone (polled I/O mode). Polled I/O 1450N/A * operates within an incompatible set of constraints and liberties. 1450N/A * If there is a user context currently active, this function tears 1450N/A * down the user mappings and saves the user's context. The strategy 1450N/A * is to make kernel operations uninterruptable from a user mapping, 1450N/A * This routine exits HOLDING softc->softc_lock, WHICH THE *CALLER* 1450N/A * MUST RELEASE. This makes each of the following console functions atomic, 1450N/A * ie. Draw one character, scroll one line, render one cursor. 1450N/A * Make sure it's safe to do the context switch 1450N/A * Validate the parameters for the data to be displayed on the 1450N/A * 1. Verify beginning (X,Y) coords are in the displayed area of fb. 1450N/A * 2. Verify that the character doesn't extend beyond displayed area. 1450N/A * If characters exceed perimiter, clip if possible by adjusting 1450N/A * size of characters. This allows the terminal emulator to clear 1450N/A * the full screen or reverse video by writing characters all the way 1450N/A * to the screen edge, merely clipping rather than rejecting all 1450N/A * but the most egregious overlap. 1450N/A * Validate the parameters for the data to be displayed on the 1450N/A * 1. Verify beginning (X,Y) coords are in the displayed area of fb. 1450N/A * 2. Verify that the character doesn't extend beyond displayed area. 1450N/A * Validate the parameters for the source and destination rectangles. 1450N/A * Since being in polled I/O mode, the kernel already has 1450N/A * exclusive access to hardware, so we do not need to