tem.c revision b6bd4f488cd95b4b547777e8a8ca2045ebb34fad
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* ANSI terminal emulator module; parse ANSI X3.64 escape sequences and
* the like.
*
* How Virtual Terminal Emulator Works:
*
* Every virtual terminal is associated with a tem_vt_state structure
* and maintains a virtual screen buffer in tvs_screen_buf, which contains
* all the characters which should be shown on the physical screen when
* the terminal is activated. There are also two other buffers, tvs_fg_buf
* and tvs_bg_buf, which track the foreground and background colors of the
* on screen characters
*
* Data written to a virtual terminal is composed of characters which
* should be displayed on the screen when this virtual terminal is
* information (escape sequence, etc).
*
* When data is passed to a virtual terminal it first is parsed for
* control information by tem_safe_parse(). Subsequently the character
* and color data are written to tvs_screen_buf, tvs_fg_buf, and
* tvs_bg_buf. They are saved in these buffers in order to refresh
* the screen when this terminal is activated. If the terminal is
* currently active, the data (characters and colors) are also written
* to the physical screen by invoking a callback function,
* tem_safe_text_callbacks() or tem_safe_pix_callbacks().
*
* When rendering data to the framebuffer, if the framebuffer is in
* VIS_PIXEL mode, the character data will first be converted to pixel
* data using tem_safe_pix_bit2pix(), and then the pixels get displayed
* on the physical screen. We only store the character and color data in
* tem_vt_state since the bit2pix conversion only happens when actually
* rendering to the physical framebuffer.
*/
#include <sys/visual_io.h>
#include <sys/tem_impl.h>
#ifdef _HAVE_TEM_FIRMWARE
#endif /* _HAVE_TEM_FIRMWARE */
#include <sys/consplat.h>
#include <sys/sysmacros.h>
/* Terminal emulator internal helper functions */
static void tems_modechange_callback(struct vis_modechg_arg *,
struct vis_devinit *);
static void tem_free_buf(struct tem_vt_state *);
/*
* Globals
*/
extern struct mod_ops mod_miscops;
&mod_miscops, /* modops */
"ANSI Terminal Emulator", /* name */
};
static struct modlinkage modlinkage = {
};
int
_init(void)
{
int ret;
if (ret != 0)
return (ret);
if (ret != 0) {
(void) mod_remove(&modlinkage);
return (ret);
}
return (0);
}
int
_fini()
{
int ret;
if (ret == 0) {
}
return (ret);
}
int
{
}
static void
{
}
static void
{
}
/*
* This is the main entry point to the module. It handles output requests
* during normal system operation, when (e.g.) mutexes are available.
*/
void
{
if (!tem->tvs_initialized) {
return;
}
}
static void
{
int i, j;
int total;
ptem->tvs_pix_data =
}
ptem->tvs_outbuf =
for (i = 0; i < height; i++)
for (j = 0; j < width; j++) {
}
}
int
{
int ret;
return (ret);
}
{
struct tem_vt_state *ptem;
/*
* A tem is regarded as initialized only after tem_internal_init(),
* will be set at the end of tem_internal_init().
*/
ptem->tvs_initialized = 0;
if (!tems.ts_initialized) {
/*
* Only happens during early console configuration.
*/
return ((tem_vt_state_t)ptem);
}
return ((tem_vt_state_t)ptem);
}
/*
* re-init the tem after video mode has changed and tems_info has
* been re-inited. The lock is already held.
*/
static void
{
/* reserve color */
}
static void
{
}
void
{
}
static int
{
int lyr_rval;
if (finish_ioctl)
return (ENXIO);
}
/*
* only called once during boot
*/
int
{
struct vis_devinit temargs;
char *pathbuf;
struct tem_vt_state *p;
if (tems.ts_initialized) {
return (0);
}
/*
* Open the layered device using the devfs physical device name
* after adding the /devices prefix.
*/
return (ENXIO);
}
return (ENXIO);
}
/*
* Initialize the console and get the device parameters
*/
return (ret);
}
/* Make sure the fb driver and terminal emulator versions match */
"terminal emulator: VIS_CONS_REV %d (see sys/visual_io.h) "
return (ret);
}
"I/O");
return (ret);
}
/* other sanity checks */
return (ret);
}
return (ret);
}
/*
* Initialize the common terminal emulator info
*/
mutex_enter(&p->tvs_lock);
mutex_exit(&p->tvs_lock);
}
return (0);
}
#define TEMS_DEPTH_DIFF 0x01
#define TEMS_DIMENSION_DIFF 0x02
static uchar_t
{
} else {
}
return (result);
}
static void
{
int i;
case VIS_TEXT:
break;
case VIS_PIXEL:
/*
* First check to see if the user has specified a screen size.
* If so, use those values. Else use 34x80 as the default.
*/
if (width == 0) {
}
/*
* set_font() will select a appropriate sized font for
* the number of rows and columns selected. If we don't
* have a font that will fit, then it will use the
* default builtin font and adjust the rows and columns
* to fit on the screen.
*/
break;
}
/* Now virtual cls also uses the blank_line buffer */
if (tems.ts_blank_line)
tems.ts_blank_line = (unsigned char *)
}
/*
* This is a callback function that we register with the frame
* buffer driver layered underneath. It gets invoked from
* the underlying frame buffer driver to reconfigure the terminal
* emulator to a new screen size and depth in conjunction with
* framebuffer videomode changes.
* Here we keep the foreground/background color and attributes,
* which may be different with the initial settings, so that
* the color won't change while the framebuffer videomode changes.
* And we also reset the kernel terminal emulator and clear the
* whole screen.
*/
/* ARGSUSED */
void
struct vis_devinit *devinit)
{
struct tem_vt_state *p;
/*
* currently only for pixel mode
*/
if (diff == 0) {
return;
}
if (diff == 0) {
/*
* Only need to reinit the active tem.
*/
return;
}
mutex_enter(&p->tvs_lock);
tem_reinit(p, p->tvs_isactive);
mutex_exit(&p->tvs_lock);
}
return;
}
/*
* Release the lock while doing callback.
*/
}
/*
* This function is used to display a rectangular blit of data
* of a given size and location via the underlying framebuffer driver.
* The blit can be as small as a pixel or as large as the screen.
*/
void
struct vis_consdisplay *pda,
{
int rval;
}
/*
* This function is used to invoke a block copy operation in the
* underlying framebuffer driver. Rectangle copies are how scrolling
* is implemented, as well as horizontal text shifting escape seqs.
* such as from vi when deleting characters and words.
*/
void
struct vis_conscopy *pma,
{
int rval;
}
/*
* This function is used to show or hide a rectangluar monochrom
* pixel inverting, text block cursor via the underlying framebuffer.
*/
void
struct vis_conscursor *pca,
{
int rval;
}
static void
{
int rval;
}
static void
{
int rval;
if (called_from == CALLED_FROM_STANDALONE)
return;
case 8:
break;
}
}
void
{
}
void
{
}
/*
* This function is to scroll up the OBP output, which has
* different screen height and width with our kernel console.
*/
static void
enum called_from called_from)
{
struct vis_conscopy ma;
/* copy */
/* clear */
}
#define PROM_DEFAULT_FONT_HEIGHT 22
#define PROM_DEFAULT_WINDOW_TOP 0x8a
/*
* This function is to compute the starting row of the console, according to
* PROM cursor's position. Here we have to take different fonts into account.
*/
static int
enum called_from called_from)
{
int tem_row;
int tem_y;
int prom_charheight = 0;
int prom_window_top = 0;
int scroll_up_lines;
if (prom_charheight == 0)
if (prom_window_top == 0)
tems.ts_p_offset.y;
if (tem_row < 0) {
tem_row = 0;
/*
* Scroll up the prom outputs if the PROM cursor's position is
* below our tem's lower boundary.
*/
}
return (tem_row);
}
void
enum called_from called_from)
{
if (plat_stdout_is_framebuffer()) {
/*
* We are getting the current cursor position in pixel
* mode so that we don't over-write the console output
* during boot.
*/
/*
* Adjust the row if necessary when the font of our
* kernel console tem is different with that of prom
* tem.
*/
/* first line of our kernel console output */
/* re-set and align cusror position */
} else {
}
}
static void
{
int i_inverse = 0;
int i_inverse_screen = 0;
}
/*
* Get the foreground/background color and attributes from the initial
* PROM, so that our kernel console can keep the same visual behaviour.
*/
static void
{
unsigned short flags = 0;
if (plat_stdout_is_framebuffer()) {
if (inverse)
if (inverse_screen)
if (flags != 0) {
/*
* If either reverse flag is set, the screen is in
* white-on-black mode. We set the bold flag to
* improve readability.
*/
flags |= TEM_ATTR_BOLD;
} else {
/*
* Otherwise, the screen is in black-on-white mode.
* The SPARC PROM console, which starts in this mode,
* uses the bright white background colour so we
* match it here.
*/
}
}
}
{
return (fbmode);
}
void
{
return;
}
if (tem->tvs_isactive) {
}
}
void
{
if (unblank)
}
void
{
}