fea9cb91bd8e12d84069b4dab1268363668b4bfflq * CDDL HEADER START
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * The contents of this file are subject to the terms of the
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * Common Development and Distribution License (the "License").
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * You may not use this file except in compliance with the License.
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * See the License for the specific language governing permissions
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * and limitations under the License.
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * When distributing Covered Code, include this CDDL HEADER in each
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * If applicable, add the following below this CDDL HEADER, with the
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * fields enclosed by brackets "[]" replaced with your own identifying
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * information: Portions Copyright [yyyy] [name of copyright owner]
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * CDDL HEADER END
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * Use is subject to license terms.
a6631734faac5336cd6374b6f15e0469e12d2ac5Joshua M. Clulow * Copyright 2016 Joyent, Inc.
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * Polled I/O safe ANSI terminal emulator module;
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * Supporting TERM types 'sun' and 'sun-color, parsing
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * ANSI x3.64 escape sequences, and the like. (See wscons(7d)
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * for more information).
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * IMPORTANT:
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * The functions in this file *must* be able to function in
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * standalone mode, ie. on a quiesced system. In that state,
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * access is single threaded, only one CPU is running.
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * System services are NOT available.
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * The following restrictions pertain to every function
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * in this file:
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * - CANNOT use the DDI or LDI interfaces
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * - CANNOT call system services
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * - CANNOT use mutexes
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * - CANNOT wait for interrupts
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * - CANNOT allocate memory
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China * All non-static functions in this file which:
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China * - Operates on tems and tem_vt_state
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China * - Not only called from standalone mode, i.e. has
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China * a "calledfrom" argument
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China * should assert this at the beginning:
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China * ASSERT((MUTEX_HELD(&tems.ts_lock) && MUTEX_HELD(&tem->tvs_lock)) ||
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China * called_from == CALLED_FROM_STANDALONE);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China#include <sys/note.h>
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China#include <sys/t_lock.h>
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing Chinatem_safe_callbacks_t tem_safe_text_callbacks = {
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China &tem_safe_text_display,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China &tem_safe_text_copy,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China &tem_safe_text_cursor,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China &tem_safe_text_cls
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing Chinatem_safe_callbacks_t tem_safe_pix_callbacks = {
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China &tem_safe_pix_display,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China &tem_safe_pix_copy,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China &tem_safe_pix_cursor,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China &tem_safe_pix_bit2pix,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China &tem_safe_pix_cls
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing Chinastatic void tem_safe_control(struct tem_vt_state *, uchar_t,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing Chinastatic void tem_safe_setparam(struct tem_vt_state *, int, int);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing Chinastatic void tem_safe_selgraph(struct tem_vt_state *);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing Chinastatic void tem_safe_chkparam(struct tem_vt_state *, uchar_t,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing Chinastatic void tem_safe_getparams(struct tem_vt_state *, uchar_t,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing Chinastatic void tem_safe_outch(struct tem_vt_state *, uchar_t,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing Chinastatic void tem_safe_parse(struct tem_vt_state *, uchar_t,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing Chinastatic void tem_safe_new_line(struct tem_vt_state *,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing Chinastatic void tem_safe_cr(struct tem_vt_state *);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing Chinastatic void tem_safe_lf(struct tem_vt_state *,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing Chinastatic void tem_safe_send_data(struct tem_vt_state *, cred_t *,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing Chinastatic void tem_safe_cls(struct tem_vt_state *,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing Chinastatic void tem_safe_tab(struct tem_vt_state *,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing Chinastatic void tem_safe_back_tab(struct tem_vt_state *,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing Chinastatic void tem_safe_clear_tabs(struct tem_vt_state *, int);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing Chinastatic void tem_safe_set_tab(struct tem_vt_state *);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing Chinastatic void tem_safe_mv_cursor(struct tem_vt_state *, int, int,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing Chinastatic void tem_safe_shift(struct tem_vt_state *, int, int,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing Chinastatic void tem_safe_scroll(struct tem_vt_state *, int, int,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing Chinastatic void tem_safe_clear_chars(struct tem_vt_state *tem,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing Chinastatic void tem_safe_copy_area(struct tem_vt_state *tem,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing Chinastatic void tem_safe_image_display(struct tem_vt_state *, uchar_t *,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing Chinastatic void tem_safe_bell(struct tem_vt_state *tem,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing Chinastatic void tem_safe_pix_clear_prom_output(struct tem_vt_state *tem,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing Chinastatic void tem_safe_virtual_cls(struct tem_vt_state *, int, screen_pos_t,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing Chinastatic void tem_safe_virtual_display(struct tem_vt_state *,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China unsigned char *, int, screen_pos_t, screen_pos_t,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China text_color_t, text_color_t);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing Chinastatic void tem_safe_virtual_copy(struct tem_vt_state *, screen_pos_t,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China screen_pos_t, screen_pos_t, screen_pos_t,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China screen_pos_t, screen_pos_t);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing Chinastatic void tem_safe_align_cursor(struct tem_vt_state *tem);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing Chinastatic void bit_to_pix4(struct tem_vt_state *tem, uchar_t c,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China text_color_t fg_color, text_color_t bg_color);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing Chinastatic void bit_to_pix8(struct tem_vt_state *tem, uchar_t c,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China text_color_t fg_color, text_color_t bg_color);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing Chinastatic void bit_to_pix24(struct tem_vt_state *tem, uchar_t c,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China text_color_t fg_color, text_color_t bg_color);
fea9cb91bd8e12d84069b4dab1268363668b4bfflq/* BEGIN CSTYLED */
b6bd4f488cd95b4b547777e8a8ca2045ebb34fadToomas Soome/* Bk Rd Gr Br Bl Mg Cy Wh */
b6bd4f488cd95b4b547777e8a8ca2045ebb34fadToomas Soomestatic text_color_t dim_xlate[] = { 1, 5, 3, 7, 2, 6, 4, 8 };
b6bd4f488cd95b4b547777e8a8ca2045ebb34fadToomas Soomestatic text_color_t brt_xlate[] = { 9, 13, 11, 15, 10, 14, 12, 0 };
fea9cb91bd8e12d84069b4dab1268363668b4bfflq/* END CSTYLED */
fea9cb91bd8e12d84069b4dab1268363668b4bfflq/* BEGIN CSTYLED */
fea9cb91bd8e12d84069b4dab1268363668b4bfflq/* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
fea9cb91bd8e12d84069b4dab1268363668b4bfflq Wh+ Bk Bl Gr Cy Rd Mg Br Wh Bk+ Bl+ Gr+ Cy+ Rd+ Mg+ Yw */
fea9cb91bd8e12d84069b4dab1268363668b4bfflq 0xff,0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x40,0x00,0x00,0x00,0xff,0xff,0xff,
fea9cb91bd8e12d84069b4dab1268363668b4bfflq 0xff,0x00,0x00,0x80,0x80,0x00,0x00,0x80,0x80,0x40,0x00,0xff,0xff,0x00,0x00,0xff,
fea9cb91bd8e12d84069b4dab1268363668b4bfflq 0xff,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x40,0xff,0x00,0xff,0x00,0xff,0x00
fea9cb91bd8e12d84069b4dab1268363668b4bfflq/* END CSTYLED */
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * Fonts are statically linked with this module. At some point an
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * RFE might be desireable to allow dynamic font loading. The
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * original intention to facilitate dynamic fonts can be seen
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * by examining the data structures and set_font(). As much of
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * the original code is retained but modified to be suited to
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * traversing a list of static fonts.
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * Must be sorted by font size in descending order
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China#define tem_safe_callback_display (*tems.ts_callbacks->tsc_display)
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China#define tem_safe_callback_copy (*tems.ts_callbacks->tsc_copy)
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China#define tem_safe_callback_cursor (*tems.ts_callbacks->tsc_cursor)
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China#define tem_safe_callback_cls (*tems.ts_callbacks->tsc_cls)
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China#define tem_safe_callback_bit2pix(tem, c, fg, bg) { \
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China ASSERT(tems.ts_callbacks->tsc_bit2pix != NULL); \
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China (void) (*tems.ts_callbacks->tsc_bit2pix)((tem), (c), (fg), (bg));\
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing Chinatem_safe_check_first_time(
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China struct tem_vt_state *tem,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China ASSERT((MUTEX_HELD(&tems.ts_lock) && MUTEX_HELD(&tem->tvs_lock)) ||
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China called_from == CALLED_FROM_STANDALONE);
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * Realign the console cursor. We did this in tem_init().
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * However, drivers in the console stream may emit additional
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * messages before we are ready. This causes text overwrite
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * on the screen. This is a workaround.
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China if (!first_time)
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China if (tems.ts_display_mode == VIS_TEXT) {
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_text_cursor(tem, VIS_GET_CURSOR, credp, called_from);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_align_cursor(tem);
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * This entry point handles output requests from restricted contexts like
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * kmdb, where services like mutexes are not available. This function
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * is entered when OBP or when a kernel debugger (such as kmdb)
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * are generating console output. In those cases, power management
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * concerns are handled by the abort sequence initiation (ie. when
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * the user hits L1+A or the equivalent to enter OBP or the debugger.).
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * It is also entered when the kernel is panicing.
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing Chinatem_safe_polled_write(
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_vt_state_t tem_arg,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China struct tem_vt_state *tem = (struct tem_vt_state *)tem_arg;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China#ifdef __lock_lint
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China _NOTE(NO_COMPETING_THREADS_NOW)
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China _NOTE(NO_COMPETING_THREADS_AS_SIDE_EFFECT)
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China if (!tem->tvs_initialized) {
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_check_first_time(tem, kcred, CALLED_FROM_STANDALONE);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_terminal_emulate(tem, buf, len, NULL, CALLED_FROM_STANDALONE);
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * This is the main entry point into the terminal emulator.
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * For each data message coming downstream, ANSI assumes that it is composed
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * of ASCII characters, which are treated as a byte-stream input to the
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * parsing state machine. All data is parsed immediately -- there is
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * no enqueing.
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing Chinatem_safe_terminal_emulate(
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China struct tem_vt_state *tem,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China ASSERT((MUTEX_HELD(&tems.ts_lock) && MUTEX_HELD(&tem->tvs_lock)) ||
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China called_from == CALLED_FROM_STANDALONE);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China if (tem->tvs_isactive)
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_callback_cursor(tem,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China VIS_HIDE_CURSOR, credp, called_from);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China for (; len > 0; len--, buf++)
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_parse(tem, *buf, credp, called_from);
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * Send the data we just got to the framebuffer.
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_send_data(tem, credp, called_from);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China if (tem->tvs_isactive)
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_callback_cursor(tem,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China VIS_DISPLAY_CURSOR, credp, called_from);
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * Display an rectangular image on the frame buffer using the
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * mechanism appropriate for the system state being called
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * from quiesced or normal (ie. use polled I/O vs. layered ioctls)
fea9cb91bd8e12d84069b4dab1268363668b4bfflqstatic void
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing Chinatems_safe_display(
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tems.ts_fb_polledio->display(tems.ts_fb_polledio->arg, pda);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tems_display_layered(pda, credp);
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * Copy a rectangle from one location to another on the frame buffer
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * using the mechanism appropriate for the system state being called
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * from, quiesced or normal (ie. use polled I/O vs. layered ioctls)
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tems.ts_fb_polledio->copy(tems.ts_fb_polledio->arg, pca);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tems_copy_layered(pca, credp);
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * Display or hide a rectangular block text cursor of a specificsize
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * at a specific location on frame buffer* using the mechanism
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * appropriate for the system state being called from, quisced or
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * normal (ie. use polled I/O vs. layered ioctls).
fea9cb91bd8e12d84069b4dab1268363668b4bfflqstatic void
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing Chinatems_safe_cursor(
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tems.ts_fb_polledio->cursor(tems.ts_fb_polledio->arg, pca);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tems_cursor_layered(pca, credp);
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * send the appropriate control message or set state based on the
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * value of the control character ch
fea9cb91bd8e12d84069b4dab1268363668b4bfflqstatic void
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing Chinatem_safe_control(
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China struct tem_vt_state *tem,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_state = A_STATE_START;
fea9cb91bd8e12d84069b4dab1268363668b4bfflq switch (ch) {
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_bell(tem, called_from);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_mv_cursor(tem,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_c_cursor.row,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_c_cursor.col - 1,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_tab(tem, credp, called_from);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China * tem_safe_send_data(tem, credp, called_from);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China * tem_safe_new_line(tem, credp, called_from);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_send_data(tem, credp, called_from);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_lf(tem, credp, called_from);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_send_data(tem, credp, called_from);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_cls(tem, credp, called_from);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_send_data(tem, credp, called_from);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_cr(tem);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_state = A_STATE_ESC;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_curparam = 0;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_paramval = 0;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_gotparam = B_FALSE;
fea9cb91bd8e12d84069b4dab1268363668b4bfflq /* clear the parameters */
fea9cb91bd8e12d84069b4dab1268363668b4bfflq for (i = 0; i < TEM_MAXPARAMS; i++)
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_params[i] = -1;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_state = A_STATE_CSI;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_back_tab(tem, credp, called_from);
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * if parameters [0..count - 1] are not set, set them to the value
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * of newparam.
fea9cb91bd8e12d84069b4dab1268363668b4bfflqstatic void
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing Chinatem_safe_setparam(struct tem_vt_state *tem, int count, int newparam)
fea9cb91bd8e12d84069b4dab1268363668b4bfflq for (i = 0; i < count; i++) {
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China if (tem->tvs_params[i] == -1)
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_params[i] = newparam;
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * select graphics mode based on the param vals stored in a_params
fea9cb91bd8e12d84069b4dab1268363668b4bfflqstatic void
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing Chinatem_safe_selgraph(struct tem_vt_state *tem)
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_state = A_STATE_START;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China curparam = tem->tvs_curparam;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China param = tem->tvs_params[count];
fea9cb91bd8e12d84069b4dab1268363668b4bfflq switch (param) {
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China /* reset to initial normal settings */
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_fg_color = tems.ts_init_color.fg_color;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_bg_color = tems.ts_init_color.bg_color;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_flags = tems.ts_init_color.a_flags;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_flags |= TEM_ATTR_BOLD;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_flags &= ~TEM_ATTR_BOLD;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_flags |= TEM_ATTR_BLINK;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China if (tem->tvs_flags & TEM_ATTR_SCREEN_REVERSE) {
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_flags &= ~TEM_ATTR_REVERSE;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_flags |= TEM_ATTR_REVERSE;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_fg_color = param - 30;
b6bd4f488cd95b4b547777e8a8ca2045ebb34fadToomas Soome * Reset the foreground colour and brightness.
a6631734faac5336cd6374b6f15e0469e12d2ac5Joshua M. Clulow tem->tvs_fg_color = tems.ts_init_color.fg_color;
b6bd4f488cd95b4b547777e8a8ca2045ebb34fadToomas Soome if (tems.ts_init_color.a_flags & TEM_ATTR_BRIGHT_FG)
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_bg_color = param - 40;
b6bd4f488cd95b4b547777e8a8ca2045ebb34fadToomas Soome * Reset the background colour and brightness.
a6631734faac5336cd6374b6f15e0469e12d2ac5Joshua M. Clulow tem->tvs_bg_color = tems.ts_init_color.bg_color;
b6bd4f488cd95b4b547777e8a8ca2045ebb34fadToomas Soome if (tems.ts_init_color.a_flags & TEM_ATTR_BRIGHT_BG)
b6bd4f488cd95b4b547777e8a8ca2045ebb34fadToomas Soome case 95: /* magenta (light magenta) foreground */
b6bd4f488cd95b4b547777e8a8ca2045ebb34fadToomas Soome case 105: /* magenta (light magenta) background */
b6bd4f488cd95b4b547777e8a8ca2045ebb34fadToomas Soome case 107: /* white (bright white) background */
fea9cb91bd8e12d84069b4dab1268363668b4bfflq } while (curparam > 0);
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * perform the appropriate action for the escape sequence
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * General rule: This code does not validate the arguments passed.
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * It assumes that the next lower level will do so.
fea9cb91bd8e12d84069b4dab1268363668b4bfflqstatic void
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing Chinatem_safe_chkparam(
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China struct tem_vt_state *tem,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China MUTEX_HELD(&tem->tvs_lock));
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China row = tem->tvs_c_cursor.row;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China col = tem->tvs_c_cursor.col;
fea9cb91bd8e12d84069b4dab1268363668b4bfflq switch (ch) {
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_send_data(tem, credp, called_from);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_selgraph(tem);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_setparam(tem, 1, 1);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_shift(tem, tem->tvs_params[0], TEM_SHIFT_RIGHT,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_setparam(tem, 1, 1);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_mv_cursor(tem, row - tem->tvs_params[0], col,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_setparam(tem, 1, 1);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_mv_cursor(tem, tem->tvs_params[0] - 1, col,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_setparam(tem, 1, 1);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_mv_cursor(tem, row + tem->tvs_params[0], col,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_setparam(tem, 1, 1);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_mv_cursor(tem, row, col + tem->tvs_params[0],
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_setparam(tem, 1, 1);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_mv_cursor(tem, row, tem->tvs_params[0] - 1,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_setparam(tem, 1, 1);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_mv_cursor(tem, row, col - tem->tvs_params[0],
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_setparam(tem, 1, 1);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_mv_cursor(tem, row + tem->tvs_params[0], 0,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_setparam(tem, 1, 1);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_mv_cursor(tem, row - tem->tvs_params[0], 0,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_setparam(tem, 1, 1);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_mv_cursor(tem, row, tem->tvs_params[0] - 1,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_setparam(tem, 1, 0);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_clear_tabs(tem, tem->tvs_params[0]);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_setparam(tem, 2, 1);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_mv_cursor(tem,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_params[0] - 1,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_params[1] - 1,
fea9cb91bd8e12d84069b4dab1268363668b4bfflq /* Not implemented */
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_send_data(tem, credp, called_from);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_setparam(tem, 1, 0);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China switch (tem->tvs_params[0]) {
fea9cb91bd8e12d84069b4dab1268363668b4bfflq /* erase cursor to end of screen */
fea9cb91bd8e12d84069b4dab1268363668b4bfflq /* FIRST erase cursor to end of line */
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_clear_chars(tem,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tems.ts_c_dimension.width -
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_c_cursor.col,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_c_cursor.row,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_c_cursor.col, credp, called_from);
fea9cb91bd8e12d84069b4dab1268363668b4bfflq /* THEN erase lines below the cursor */
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China for (row = tem->tvs_c_cursor.row + 1;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China row < tems.ts_c_dimension.height;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_clear_chars(tem,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tems.ts_c_dimension.width,
fea9cb91bd8e12d84069b4dab1268363668b4bfflq /* erase beginning of screen to cursor */
fea9cb91bd8e12d84069b4dab1268363668b4bfflq /* FIRST erase lines above the cursor */
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China row < tem->tvs_c_cursor.row;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_clear_chars(tem,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tems.ts_c_dimension.width,
fea9cb91bd8e12d84069b4dab1268363668b4bfflq /* THEN erase beginning of line to cursor */
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_clear_chars(tem,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_c_cursor.col + 1,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_c_cursor.row,
fea9cb91bd8e12d84069b4dab1268363668b4bfflq /* erase whole screen */
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China row < tems.ts_c_dimension.height;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_clear_chars(tem,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tems.ts_c_dimension.width,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_send_data(tem, credp, called_from);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_setparam(tem, 1, 0);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China switch (tem->tvs_params[0]) {
fea9cb91bd8e12d84069b4dab1268363668b4bfflq /* erase cursor to end of line */
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_clear_chars(tem,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China (tems.ts_c_dimension.width -
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_c_cursor.col),
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_c_cursor.row,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_c_cursor.col,
fea9cb91bd8e12d84069b4dab1268363668b4bfflq /* erase beginning of line to cursor */
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_clear_chars(tem,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_c_cursor.col + 1,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_c_cursor.row,
fea9cb91bd8e12d84069b4dab1268363668b4bfflq /* erase whole line */
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_clear_chars(tem,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tems.ts_c_dimension.width,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_c_cursor.row,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_send_data(tem, credp, called_from);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_setparam(tem, 1, 1);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_scroll(tem,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_c_cursor.row,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tems.ts_c_dimension.height - 1,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_params[0], TEM_SCROLL_DOWN,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_send_data(tem, credp, called_from);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_setparam(tem, 1, 1);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_scroll(tem,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_c_cursor.row,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tems.ts_c_dimension.height - 1,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_params[0], TEM_SCROLL_UP,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_setparam(tem, 1, 1);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_shift(tem, tem->tvs_params[0], TEM_SHIFT_LEFT,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_send_data(tem, credp, called_from);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_setparam(tem, 1, 1);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_scroll(tem, 0,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tems.ts_c_dimension.height - 1,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_params[0], TEM_SCROLL_UP,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_send_data(tem, credp, called_from);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_setparam(tem, 1, 1);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_scroll(tem, 0,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tems.ts_c_dimension.height - 1,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_params[0], TEM_SCROLL_DOWN,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_setparam(tem, 1, 1);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_clear_chars(tem,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_params[0],
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_c_cursor.row,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_c_cursor.col,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_setparam(tem, 1, 1);
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * Rule exception - We do sanity checking here.
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * Restrict the count to a sane value to keep from
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * looping for a long time. There can't be more than one
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * tab stop per column, so use that as a limit.
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China if (tem->tvs_params[0] > tems.ts_c_dimension.width)
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_params[0] = tems.ts_c_dimension.width;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China for (i = 0; i < tem->tvs_params[0]; i++)
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_back_tab(tem, credp, called_from);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_state = A_STATE_START;
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * Gather the parameters of an ANSI escape sequence
fea9cb91bd8e12d84069b4dab1268363668b4bfflqstatic void
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing Chinatem_safe_getparams(struct tem_vt_state *tem, uchar_t ch,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China MUTEX_HELD(&tem->tvs_lock));
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_paramval = ((tem->tvs_paramval * 10) + (ch - '0'));
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_gotparam = B_TRUE; /* Remember got parameter */
fea9cb91bd8e12d84069b4dab1268363668b4bfflq return; /* Return immediately */
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China } else if (tem->tvs_state == A_STATE_CSI_EQUAL ||
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_state == A_STATE_CSI_QMARK) {
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_state = A_STATE_START;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China if (tem->tvs_curparam < TEM_MAXPARAMS) {
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China if (tem->tvs_gotparam) {
51fd492135573005d200c766ef62f709b4cb312clt /* get the parameter value */
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_params[tem->tvs_curparam] =
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_paramval;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_curparam++;
fea9cb91bd8e12d84069b4dab1268363668b4bfflq /* Restart parameter search */
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_gotparam = B_FALSE;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_paramval = 0; /* No parame value yet */
fea9cb91bd8e12d84069b4dab1268363668b4bfflq /* Handle escape sequence */
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_chkparam(tem, ch, credp, called_from);
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * Add character to internal buffer.
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * When its full, send it to the next layer.
fea9cb91bd8e12d84069b4dab1268363668b4bfflqstatic void
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing Chinatem_safe_outch(struct tem_vt_state *tem, uchar_t ch,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China ASSERT((MUTEX_HELD(&tems.ts_lock) && MUTEX_HELD(&tem->tvs_lock)) ||
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China called_from == CALLED_FROM_STANDALONE);
fea9cb91bd8e12d84069b4dab1268363668b4bfflq /* buffer up the character until later */
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_outbuf[tem->tvs_outindex++] = ch;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_c_cursor.col++;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China if (tem->tvs_c_cursor.col >= tems.ts_c_dimension.width) {
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_send_data(tem, credp, called_from);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_new_line(tem, credp, called_from);
fea9cb91bd8e12d84069b4dab1268363668b4bfflqstatic void
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing Chinatem_safe_new_line(struct tem_vt_state *tem,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_cr(tem);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_lf(tem, credp, called_from);
fea9cb91bd8e12d84069b4dab1268363668b4bfflqstatic void
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing Chinatem_safe_cr(struct tem_vt_state *tem)
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_c_cursor.col = 0;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_align_cursor(tem);
fea9cb91bd8e12d84069b4dab1268363668b4bfflqstatic void
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing Chinatem_safe_lf(struct tem_vt_state *tem,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China MUTEX_HELD(&tem->tvs_lock));
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * Sanity checking notes:
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * . a_nscroll was validated when it was set.
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China * . Regardless of that, tem_safe_scroll and tem_safe_mv_cursor
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China * will prevent anything bad from happening.
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China row = tem->tvs_c_cursor.row + 1;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China if (row >= tems.ts_c_dimension.height) {
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China if (tem->tvs_nscroll != 0) {
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_scroll(tem, 0,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tems.ts_c_dimension.height - 1,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_nscroll, TEM_SCROLL_UP,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China row = tems.ts_c_dimension.height -
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_nscroll;
fea9cb91bd8e12d84069b4dab1268363668b4bfflq } else { /* no scroll */
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * implement Esc[#r when # is zero. This means no
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * scroll but just return cursor to top of screen,
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * do not clear screen.
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_mv_cursor(tem, row, tem->tvs_c_cursor.col,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China if (tem->tvs_nscroll == 0) {
fea9cb91bd8e12d84069b4dab1268363668b4bfflq /* erase rest of cursor line */
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_clear_chars(tem,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tems.ts_c_dimension.width -
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_c_cursor.col,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_c_cursor.row,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_c_cursor.col,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_align_cursor(tem);
fea9cb91bd8e12d84069b4dab1268363668b4bfflqstatic void
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing Chinatem_safe_send_data(struct tem_vt_state *tem, cred_t *credp,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China MUTEX_HELD(&tem->tvs_lock));
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China if (tem->tvs_outindex == 0) {
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_align_cursor(tem);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_get_color(tem, &fg_color, &bg_color, TEM_ATTR_REVERSE);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_virtual_display(tem,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_outbuf, tem->tvs_outindex,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_s_cursor.row, tem->tvs_s_cursor.col,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China fg_color, bg_color);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China if (tem->tvs_isactive) {
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * Call the primitive to render this data.
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_callback_display(tem,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_outbuf, tem->tvs_outindex,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_s_cursor.row, tem->tvs_s_cursor.col,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_outindex = 0;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_align_cursor(tem);
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * We have just done something to the current output point. Reset the start
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * point for the buffered data in a_outbuf. There shouldn't be any data
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * buffered yet.
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing Chinatem_safe_align_cursor(struct tem_vt_state *tem)
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_s_cursor.row = tem->tvs_c_cursor.row;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_s_cursor.col = tem->tvs_c_cursor.col;
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * State machine parser based on the current state and character input
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * major terminations are to control character or normal character
fea9cb91bd8e12d84069b4dab1268363668b4bfflqstatic void
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing Chinatem_safe_parse(struct tem_vt_state *tem, uchar_t ch,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China MUTEX_HELD(&tem->tvs_lock));
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China if (tem->tvs_state == A_STATE_START) { /* Normal state? */
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China if (ch == A_CSI || ch == A_ESC || ch < ' ') {
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_control(tem, ch, credp, called_from);
fea9cb91bd8e12d84069b4dab1268363668b4bfflq /* Display */
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_outch(tem, ch, credp, called_from);
fea9cb91bd8e12d84069b4dab1268363668b4bfflq /* In <ESC> sequence */
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China if (tem->tvs_state != A_STATE_ESC) { /* Need to get parameters? */
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China if (tem->tvs_state != A_STATE_CSI) {
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_getparams(tem, ch, credp, called_from);
fea9cb91bd8e12d84069b4dab1268363668b4bfflq switch (ch) {
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_state = A_STATE_CSI_QMARK;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_state = A_STATE_CSI_EQUAL;
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * As defined below, this sequence
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * saves the cursor. However, Sun
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * defines ESC[s as reset. We resolved
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * the conflict by selecting reset as it
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * is exported in the termcap file for
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * sun-mon, while the "save cursor"
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * definition does not exist anywhere in
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * However, having no coherent
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * definition of reset, we have not
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * implemented it.
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * Original code
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China * tem->tvs_r_cursor.row = tem->tvs_c_cursor.row;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China * tem->tvs_r_cursor.col = tem->tvs_c_cursor.col;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China * tem->tvs_state = A_STATE_START;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_state = A_STATE_START;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_mv_cursor(tem, tem->tvs_r_cursor.row,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_r_cursor.col, credp, called_from);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_state = A_STATE_START;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_send_data(tem, credp, called_from);
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * Don't set anything if we are
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * already as we want to be.
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China if (tem->tvs_flags & TEM_ATTR_SCREEN_REVERSE) {
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_flags &= ~TEM_ATTR_SCREEN_REVERSE;
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * If we have switched the characters to be the
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * inverse from the screen, then switch them as
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * well to keep them the inverse of the screen.
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China if (tem->tvs_flags & TEM_ATTR_REVERSE)
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_flags &= ~TEM_ATTR_REVERSE;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_flags |= TEM_ATTR_REVERSE;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_cls(tem, credp, called_from);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_state = A_STATE_START;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_send_data(tem, credp, called_from);
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * Don't set anything if we are
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * already where as we want to be.
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China if (!(tem->tvs_flags & TEM_ATTR_SCREEN_REVERSE)) {
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_flags |= TEM_ATTR_SCREEN_REVERSE;
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * If we have switched the characters to be the
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * inverse from the screen, then switch them as
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * well to keep them the inverse of the screen.
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China if (!(tem->tvs_flags & TEM_ATTR_REVERSE))
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_flags |= TEM_ATTR_REVERSE;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_flags &= ~TEM_ATTR_REVERSE;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_cls(tem, credp, called_from);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_state = A_STATE_START;
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * Rule exception: check for validity here.
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_nscroll = tem->tvs_paramval;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China if (tem->tvs_nscroll > tems.ts_c_dimension.height)
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_nscroll = tems.ts_c_dimension.height;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China if (tem->tvs_nscroll < 0)
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_nscroll = 1;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_state = A_STATE_START;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_getparams(tem, ch, credp, called_from);
fea9cb91bd8e12d84069b4dab1268363668b4bfflq /* Previous char was <ESC> */
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_curparam = 0;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_paramval = 0;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_gotparam = B_FALSE;
fea9cb91bd8e12d84069b4dab1268363668b4bfflq /* clear the parameters */
fea9cb91bd8e12d84069b4dab1268363668b4bfflq for (i = 0; i < TEM_MAXPARAMS; i++)
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_params[i] = -1;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_state = A_STATE_CSI;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_state = A_STATE_START;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_state = A_STATE_START;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_state = A_STATE_START;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China if (ch == 'c') {
fea9cb91bd8e12d84069b4dab1268363668b4bfflq /* ESC c resets display */
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_reset_display(tem, credp, called_from,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China B_TRUE, B_TRUE);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China } else if (ch == 'H') {
fea9cb91bd8e12d84069b4dab1268363668b4bfflq /* ESC H sets a tab */
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_set_tab(tem);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China } else if (ch == '7') {
fea9cb91bd8e12d84069b4dab1268363668b4bfflq /* ESC 7 Save Cursor position */
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_r_cursor.row = tem->tvs_c_cursor.row;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_r_cursor.col = tem->tvs_c_cursor.col;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China } else if (ch == '8') {
fea9cb91bd8e12d84069b4dab1268363668b4bfflq /* ESC 8 Restore Cursor position */
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_mv_cursor(tem, tem->tvs_r_cursor.row,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_r_cursor.col, credp, called_from);
fea9cb91bd8e12d84069b4dab1268363668b4bfflq /* check for control chars */
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China } else if (ch < ' ') {
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_control(tem, ch, credp, called_from);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_outch(tem, ch, credp, called_from);
fea9cb91bd8e12d84069b4dab1268363668b4bfflq/* ARGSUSED */
fea9cb91bd8e12d84069b4dab1268363668b4bfflqstatic void
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing Chinatem_safe_bell(struct tem_vt_state *tem, enum called_from called_from)
fea9cb91bd8e12d84069b4dab1268363668b4bfflqstatic void
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing Chinatem_safe_scroll(struct tem_vt_state *tem, int start, int end, int count,
b6bd4f488cd95b4b547777e8a8ca2045ebb34fadToomas Soome int direction, cred_t *credp, enum called_from called_from)
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China ASSERT((MUTEX_HELD(&tems.ts_lock) && MUTEX_HELD(&tem->tvs_lock)) ||
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China called_from == CALLED_FROM_STANDALONE);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_copy_area(tem, 0, start + count,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tems.ts_c_dimension.width - 1, end,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_clear_chars(tem, tems.ts_c_dimension.width,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_copy_area(tem, 0, start,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tems.ts_c_dimension.width - 1,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_clear_chars(tem, tems.ts_c_dimension.width,
fea9cb91bd8e12d84069b4dab1268363668b4bfflqstatic void
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing Chinatem_safe_copy_area(struct tem_vt_state *tem,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China ASSERT((MUTEX_HELD(&tems.ts_lock) && MUTEX_HELD(&tem->tvs_lock)) ||
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China called_from == CALLED_FROM_STANDALONE);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China s_col >= tems.ts_c_dimension.width ||
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China e_col >= tems.ts_c_dimension.width ||
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China t_col >= tems.ts_c_dimension.width ||
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China s_row >= tems.ts_c_dimension.height ||
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China e_row >= tems.ts_c_dimension.height ||
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China t_row >= tems.ts_c_dimension.height)
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China if (t_row + rows > tems.ts_c_dimension.height ||
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China t_col + cols > tems.ts_c_dimension.width)
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_virtual_copy(tem,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China if (!tem->tvs_isactive)
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_callback_copy(tem, s_col, s_row,
fea9cb91bd8e12d84069b4dab1268363668b4bfflqstatic void
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing Chinatem_safe_clear_chars(struct tem_vt_state *tem, int count, screen_pos_t row,
b6bd4f488cd95b4b547777e8a8ca2045ebb34fadToomas Soome screen_pos_t col, cred_t *credp, enum called_from called_from)
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China ASSERT((MUTEX_HELD(&tems.ts_lock) && MUTEX_HELD(&tem->tvs_lock)) ||
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China called_from == CALLED_FROM_STANDALONE);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China if (row < 0 || row >= tems.ts_c_dimension.height ||
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China col < 0 || col >= tems.ts_c_dimension.width ||
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * Note that very large values of "count" could cause col+count
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * to overflow, so we check "count" independently.
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China if (count > tems.ts_c_dimension.width ||
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China col + count > tems.ts_c_dimension.width)
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China count = tems.ts_c_dimension.width - col;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_virtual_cls(tem, count, row, col);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China if (!tem->tvs_isactive)
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_callback_cls(tem, count, row, col, credp, called_from);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing Chinatem_safe_text_display(struct tem_vt_state *tem, uchar_t *string,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China ASSERT((MUTEX_HELD(&tems.ts_lock) && MUTEX_HELD(&tem->tvs_lock)) ||
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China called_from == CALLED_FROM_STANDALONE);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China da.width = (screen_size_t)count;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tems_safe_display(&da, credp, called_from);
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * This function is used to blit a rectangular color image,
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * unperturbed on the underlying framebuffer, to render
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * icons and pictures. The data is a pixel pattern that
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * fills a rectangle bounded to the width and height parameters.
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * The color pixel data must to be pre-adjusted by the caller
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * for the current video depth.
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * This function is unused now.
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing Chinatem_safe_image_display(struct tem_vt_state *tem, uchar_t *image,
b6bd4f488cd95b4b547777e8a8ca2045ebb34fadToomas Soome int height, int width, screen_pos_t row, screen_pos_t col,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China mutex_enter(&tems.ts_lock);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China mutex_enter(&tem->tvs_lock);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China da.width = (screen_size_t)width;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China da.height = (screen_size_t)height;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tems_safe_display(&da, credp, called_from);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China mutex_exit(&tem->tvs_lock);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China mutex_exit(&tems.ts_lock);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing Chinatem_safe_text_copy(struct tem_vt_state *tem,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China ASSERT((MUTEX_HELD(&tems.ts_lock) && MUTEX_HELD(&tem->tvs_lock)) ||
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China called_from == CALLED_FROM_STANDALONE);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tems_safe_copy(&da, credp, called_from);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing Chinatem_safe_text_cls(struct tem_vt_state *tem,
b6bd4f488cd95b4b547777e8a8ca2045ebb34fadToomas Soome int count, screen_pos_t row, screen_pos_t col, cred_t *credp,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China ASSERT((MUTEX_HELD(&tems.ts_lock) && MUTEX_HELD(&tem->tvs_lock)) ||
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China called_from == CALLED_FROM_STANDALONE);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China da.data = tems.ts_blank_line;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China da.width = (screen_size_t)count;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_get_color(tem, &da.fg_color, &da.bg_color,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China TEM_ATTR_SCREEN_REVERSE);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tems_safe_display(&da, credp, called_from);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing Chinatem_safe_pix_display(struct tem_vt_state *tem,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China ASSERT((MUTEX_HELD(&tems.ts_lock) && MUTEX_HELD(&tem->tvs_lock)) ||
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China called_from == CALLED_FROM_STANDALONE);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China da.data = (uchar_t *)tem->tvs_pix_data;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China da.width = tems.ts_font.width;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China da.height = tems.ts_font.height;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China da.row = (row * da.height) + tems.ts_p_offset.y;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China da.col = (col * da.width) + tems.ts_p_offset.x;
fea9cb91bd8e12d84069b4dab1268363668b4bfflq for (i = 0; i < count; i++) {
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_callback_bit2pix(tem, string[i], fg_color, bg_color);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tems_safe_display(&da, credp, called_from);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing Chinatem_safe_pix_copy(struct tem_vt_state *tem,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China ASSERT((MUTEX_HELD(&tems.ts_lock) && MUTEX_HELD(&tem->tvs_lock)) ||
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China called_from == CALLED_FROM_STANDALONE);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China if (need_clear && tem->tvs_first_line > 0) {
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * Clear OBP output above our kernel console term
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * when our kernel console term begins to scroll up,
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * we hope it is user friendly.
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China * (Also see comments on tem_safe_pix_clear_prom_output)
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * This is only one time call.
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_pix_clear_prom_output(tem, credp, called_from);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China ma.s_row = s_row * tems.ts_font.height + tems.ts_p_offset.y;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China ma.e_row = (e_row + 1) * tems.ts_font.height + tems.ts_p_offset.y - 1;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China ma.t_row = t_row * tems.ts_font.height + tems.ts_p_offset.y;
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * Check if we're in process of clearing OBP's columns area,
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * which only happens when term scrolls up a whole line.
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China if (tem->tvs_first_line > 0 && t_row < s_row && t_col == 0 &&
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China e_col == tems.ts_c_dimension.width - 1) {
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * We need to clear OBP's columns area outside our kernel
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * console term. So that we set ma.e_col to entire row here.
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China ma.s_col = s_col * tems.ts_font.width;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China ma.e_col = tems.ts_p_dimension.width - 1;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China ma.t_col = t_col * tems.ts_font.width;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China ma.s_col = s_col * tems.ts_font.width + tems.ts_p_offset.x;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China ma.e_col = (e_col + 1) * tems.ts_font.width +
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tems.ts_p_offset.x - 1;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China ma.t_col = t_col * tems.ts_font.width + tems.ts_p_offset.x;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tems_safe_copy(&ma, credp, called_from);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China if (tem->tvs_first_line > 0 && t_row < s_row) {
fea9cb91bd8e12d84069b4dab1268363668b4bfflq /* We have scrolled up (s_row - t_row) rows. */
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_first_line -= (s_row - t_row);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China if (tem->tvs_first_line <= 0) {
fea9cb91bd8e12d84069b4dab1268363668b4bfflq /* All OBP rows have been cleared. */
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_first_line = 0;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing Chinatem_safe_pix_bit2pix(struct tem_vt_state *tem, unsigned char c,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China unsigned char fg, unsigned char bg)
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China void (*fp)(struct tem_vt_state *, unsigned char,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China unsigned char, unsigned char);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China switch (tems.ts_pdepth) {
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China fp = bit_to_pix4;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China fp = bit_to_pix8;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China fp = bit_to_pix24;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China fp(tem, c, fg, bg);
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * This function only clears count of columns in one row
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing Chinatem_safe_pix_cls(struct tem_vt_state *tem, int count,
b6bd4f488cd95b4b547777e8a8ca2045ebb34fadToomas Soome screen_pos_t row, screen_pos_t col, cred_t *credp,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China ASSERT((MUTEX_HELD(&tems.ts_lock) && MUTEX_HELD(&tem->tvs_lock)) ||
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China called_from == CALLED_FROM_STANDALONE);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_pix_cls_range(tem, row, 1, tems.ts_p_offset.y,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China col, count, tems.ts_p_offset.x, B_FALSE, credp, called_from);
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * This function clears OBP output above our kernel console term area
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * because OBP's term may have a bigger terminal window than that of
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * our kernel console term. So we need to clear OBP output garbage outside
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * of our kernel console term at a proper time, which is when the first
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * row output of our kernel console term scrolls at the first screen line.
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * _________________________________
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * | _____________________ | ---> OBP's bigger term window
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * |___| | |
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * | | | | |
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * | | | | |
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * |_|_|___________________|_______|
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * | | | ---> first line
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * | |___________________|---> our kernel console term window
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * |---> columns area to be cleared
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * This function only takes care of the output above our kernel console term,
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * and tem_prom_scroll_up takes care of columns area outside of our kernel
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * console term.
fea9cb91bd8e12d84069b4dab1268363668b4bfflqstatic void
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing Chinatem_safe_pix_clear_prom_output(struct tem_vt_state *tem, cred_t *credp,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China ASSERT((MUTEX_HELD(&tems.ts_lock) && MUTEX_HELD(&tem->tvs_lock)) ||
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China called_from == CALLED_FROM_STANDALONE);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China width = tems.ts_font.width;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China height = tems.ts_font.height;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China nrows = (tems.ts_p_offset.y + (height - 1))/ height;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China ncols = (tems.ts_p_dimension.width + (width - 1))/ width;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_pix_cls_range(tem, 0, nrows, 0, 0, ncols, 0,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China * clear the whole screen for pixel mode, just clear the
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China * physical screen.
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing Chinatem_safe_pix_clear_entire_screen(struct tem_vt_state *tem, cred_t *credp,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China ASSERT((MUTEX_HELD(&tems.ts_lock) && MUTEX_HELD(&tem->tvs_lock)) ||
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China called_from == CALLED_FROM_STANDALONE);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China width = tems.ts_font.width;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China height = tems.ts_font.height;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China nrows = (tems.ts_p_dimension.height + (height - 1))/ height;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China ncols = (tems.ts_p_dimension.width + (width - 1))/ width;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_pix_cls_range(tem, 0, nrows, 0, 0, ncols, 0,
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * Since the whole screen is cleared, we don't need
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * to clear OBP output later.
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China if (tem->tvs_first_line > 0)
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_first_line = 0;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China * clear the whole screen, including the virtual screen buffer,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China * and reset the cursor to start point.
fea9cb91bd8e12d84069b4dab1268363668b4bfflqstatic void
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing Chinatem_safe_cls(struct tem_vt_state *tem,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China ASSERT((MUTEX_HELD(&tems.ts_lock) && MUTEX_HELD(&tem->tvs_lock)) ||
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China called_from == CALLED_FROM_STANDALONE);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China if (tems.ts_display_mode == VIS_TEXT) {
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China for (row = 0; row < tems.ts_c_dimension.height; row++) {
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_clear_chars(tem, tems.ts_c_dimension.width,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_c_cursor.row = 0;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_c_cursor.col = 0;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_align_cursor(tem);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China ASSERT(tems.ts_display_mode == VIS_PIXEL);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China for (row = 0; row < tems.ts_c_dimension.height; row++) {
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_virtual_cls(tem, tems.ts_c_dimension.width, row, 0);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_c_cursor.row = 0;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_c_cursor.col = 0;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_align_cursor(tem);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China if (!tem->tvs_isactive)
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_pix_clear_entire_screen(tem, credp, called_from);
fea9cb91bd8e12d84069b4dab1268363668b4bfflqstatic void
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing Chinatem_safe_back_tab(struct tem_vt_state *tem,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China ASSERT((MUTEX_HELD(&tems.ts_lock) && MUTEX_HELD(&tem->tvs_lock)) ||
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China called_from == CALLED_FROM_STANDALONE);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China for (i = tem->tvs_ntabs - 1; i >= 0; i--) {
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China if (tem->tvs_tabs[i] < tem->tvs_c_cursor.col) {
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tabstop = tem->tvs_tabs[i];
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_mv_cursor(tem, tem->tvs_c_cursor.row,
fea9cb91bd8e12d84069b4dab1268363668b4bfflqstatic void
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing Chinatem_safe_tab(struct tem_vt_state *tem,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China ASSERT((MUTEX_HELD(&tems.ts_lock) && MUTEX_HELD(&tem->tvs_lock)) ||
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China called_from == CALLED_FROM_STANDALONE);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tabstop = tems.ts_c_dimension.width - 1;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China for (i = 0; i < tem->tvs_ntabs; i++) {
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China if (tem->tvs_tabs[i] > tem->tvs_c_cursor.col) {
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tabstop = tem->tvs_tabs[i];
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_mv_cursor(tem, tem->tvs_c_cursor.row,
fea9cb91bd8e12d84069b4dab1268363668b4bfflqstatic void
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing Chinatem_safe_set_tab(struct tem_vt_state *tem)
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China if (tem->tvs_ntabs == TEM_MAXTAB)
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China if (tem->tvs_ntabs == 0 ||
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_tabs[tem->tvs_ntabs] < tem->tvs_c_cursor.col) {
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_tabs[tem->tvs_ntabs++] = tem->tvs_c_cursor.col;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China for (i = 0; i < tem->tvs_ntabs; i++) {
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China if (tem->tvs_tabs[i] == tem->tvs_c_cursor.col)
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China if (tem->tvs_tabs[i] > tem->tvs_c_cursor.col) {
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China for (j = tem->tvs_ntabs - 1; j >= i; j--)
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_tabs[j+ 1] = tem->tvs_tabs[j];
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_tabs[i] = tem->tvs_c_cursor.col;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_ntabs++;
fea9cb91bd8e12d84069b4dab1268363668b4bfflqstatic void
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing Chinatem_safe_clear_tabs(struct tem_vt_state *tem, int action)
fea9cb91bd8e12d84069b4dab1268363668b4bfflq switch (action) {
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_ntabs = 0;
fea9cb91bd8e12d84069b4dab1268363668b4bfflq case 0: /* clr tab at cursor */
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China for (i = 0; i < tem->tvs_ntabs; i++) {
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China if (tem->tvs_tabs[i] == tem->tvs_c_cursor.col) {
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_ntabs--;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China for (j = i; j < tem->tvs_ntabs; j++)
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_tabs[j] = tem->tvs_tabs[j + 1];
fea9cb91bd8e12d84069b4dab1268363668b4bfflqstatic void
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing Chinatem_safe_mv_cursor(struct tem_vt_state *tem, int row, int col,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China ASSERT((MUTEX_HELD(&tems.ts_lock) && MUTEX_HELD(&tem->tvs_lock)) ||
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China called_from == CALLED_FROM_STANDALONE);
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * Sanity check and bounds enforcement. Out of bounds requests are
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * clipped to the screen boundaries. This seems to be what SPARC
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China if (row >= tems.ts_c_dimension.height)
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China row = tems.ts_c_dimension.height - 1;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China if (col >= tems.ts_c_dimension.width)
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China col = tems.ts_c_dimension.width - 1;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_send_data(tem, credp, called_from);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_c_cursor.row = (screen_pos_t)row;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_c_cursor.col = (screen_pos_t)col;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_align_cursor(tem);
fea9cb91bd8e12d84069b4dab1268363668b4bfflq/* ARGSUSED */
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing Chinatem_safe_reset_emulator(struct tem_vt_state *tem,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China boolean_t init_color)
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China ASSERT((MUTEX_HELD(&tems.ts_lock) && MUTEX_HELD(&tem->tvs_lock)) ||
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China called_from == CALLED_FROM_STANDALONE);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_c_cursor.row = 0;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_c_cursor.col = 0;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_r_cursor.row = 0;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_r_cursor.col = 0;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_s_cursor.row = 0;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_s_cursor.col = 0;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_outindex = 0;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_state = A_STATE_START;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_gotparam = B_FALSE;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_curparam = 0;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_paramval = 0;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_nscroll = 1;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China if (init_color) {
c9503a497f482bf9524b37eea8c69239425bcdf4lq /* use initial settings */
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_fg_color = tems.ts_init_color.fg_color;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_bg_color = tems.ts_init_color.bg_color;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_flags = tems.ts_init_color.a_flags;
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * set up the initial tab stops
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_ntabs = 0;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China for (j = 8; j < tems.ts_c_dimension.width; j += 8)
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_tabs[tem->tvs_ntabs++] = (screen_pos_t)j;
fea9cb91bd8e12d84069b4dab1268363668b4bfflq for (j = 0; j < TEM_MAXPARAMS; j++)
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_params[j] = 0;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing Chinatem_safe_reset_display(struct tem_vt_state *tem,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China cred_t *credp, enum called_from called_from,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China boolean_t clear_txt, boolean_t init_color)
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China ASSERT((MUTEX_HELD(&tems.ts_lock) && MUTEX_HELD(&tem->tvs_lock)) ||
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China called_from == CALLED_FROM_STANDALONE);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_reset_emulator(tem, credp, called_from, init_color);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China if (tem->tvs_isactive)
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_callback_cursor(tem,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China VIS_HIDE_CURSOR, credp, called_from);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_cls(tem, credp, called_from);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China if (tem->tvs_isactive)
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_callback_cursor(tem,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China VIS_DISPLAY_CURSOR, credp, called_from);
fea9cb91bd8e12d84069b4dab1268363668b4bfflqstatic void
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China struct tem_vt_state *tem,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China ASSERT((MUTEX_HELD(&tems.ts_lock) && MUTEX_HELD(&tem->tvs_lock)) ||
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China called_from == CALLED_FROM_STANDALONE);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China rest_of_line = tems.ts_c_dimension.width - tem->tvs_c_cursor.col;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_copy_area(tem,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_c_cursor.col + count,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_c_cursor.row,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tems.ts_c_dimension.width - 1,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_c_cursor.row,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_c_cursor.col,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_c_cursor.row,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_clear_chars(tem, count, tem->tvs_c_cursor.row,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China (tems.ts_c_dimension.width - count), credp,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_copy_area(tem,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_c_cursor.col,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_c_cursor.row,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tems.ts_c_dimension.width - count - 1,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_c_cursor.row,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_c_cursor.col + count,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_c_cursor.row,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_clear_chars(tem, count, tem->tvs_c_cursor.row,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_c_cursor.col, credp, called_from);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing Chinatem_safe_text_cursor(struct tem_vt_state *tem, short action,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China ASSERT((MUTEX_HELD(&tems.ts_lock) && MUTEX_HELD(&tem->tvs_lock)) ||
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China called_from == CALLED_FROM_STANDALONE);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China ca.row = tem->tvs_c_cursor.row;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China ca.col = tem->tvs_c_cursor.col;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tems_safe_cursor(&ca, credp, called_from);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_c_cursor.row = ca.row;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_c_cursor.col = ca.col;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing Chinatem_safe_pix_cursor(struct tem_vt_state *tem, short action,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China ASSERT((MUTEX_HELD(&tems.ts_lock) && MUTEX_HELD(&tem->tvs_lock)) ||
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China called_from == CALLED_FROM_STANDALONE);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China ca.row = tem->tvs_c_cursor.row * tems.ts_font.height +
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tems.ts_p_offset.y;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China ca.col = tem->tvs_c_cursor.col * tems.ts_font.width +
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tems.ts_p_offset.x;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China ca.width = tems.ts_font.width;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China ca.height = tems.ts_font.height;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China if (tems.ts_pdepth == 8 || tems.ts_pdepth == 4) {
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China if (tem->tvs_flags & TEM_ATTR_REVERSE) {
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China } else if (tems.ts_pdepth == 24 || tems.ts_pdepth == 32) {
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China if (tem->tvs_flags & TEM_ATTR_REVERSE) {
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tems_safe_cursor(&ca, credp, called_from);
fea9cb91bd8e12d84069b4dab1268363668b4bfflqset_font(struct font *f, short *rows, short *cols, short height, short width)
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * Find best font for these dimensions, or use default
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * A 1 pixel border is the absolute minimum we could have
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * as a border around the text window (BORDER_PIXELS = 2),
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * however a slightly larger border not only looks better
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * but for the fonts currently statically built into the
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * emulator causes much better font selection for the
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * normal range of screen resolutions.
fea9cb91bd8e12d84069b4dab1268363668b4bfflq if ((((*rows * fl->data->height) + BORDER_PIXELS) <= height) &&
fea9cb91bd8e12d84069b4dab1268363668b4bfflq (((*cols * fl->data->width) + BORDER_PIXELS) <= width)) {
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * The minus 2 is to make sure we have at least a 1 pixel
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * boarder around the entire screen.
fea9cb91bd8e12d84069b4dab1268363668b4bfflq bcopy((caddr_t)font_selected->encoding, (caddr_t)f->char_ptr,
c35aa225b9ae500f1d14f0d39a94f1eb6cda333dmarx sizeof (f->char_ptr));
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * bit_to_pix4 is for 4-bit frame buffers. It will write one output byte
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * for each 2 bits of input bitmap. It inverts the input bits before
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * doing the output translation, for reverse video.
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * Assuming foreground is 0001 and background is 0000...
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * An input data byte of 0x53 will output the bit pattern
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * 00000001 00000001 00000000 00010001.
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China struct tem_vt_state *tem,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China dest = (uint8_t *)tem->tvs_pix_data;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China cp = tems.ts_font.char_ptr[c];
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China bytes_wide = (tems.ts_font.width + 7) / 8;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China for (row = 0; row < tems.ts_font.height; row++) {
fea9cb91bd8e12d84069b4dab1268363668b4bfflq for (i = 0; i < 4; i++) {
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * bit_to_pix8 is for 8-bit frame buffers. It will write one output byte
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * for each bit of input bitmap. It inverts the input bits before
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * doing the output translation, for reverse video.
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * Assuming foreground is 00000001 and background is 00000000...
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * An input data byte of 0x53 will output the bit pattern
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * 0000000 000000001 00000000 00000001 00000000 00000000 00000001 00000001.
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China struct tem_vt_state *tem,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China dest = (uint8_t *)tem->tvs_pix_data;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China cp = tems.ts_font.char_ptr[c];
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China bytes_wide = (tems.ts_font.width + 7) / 8;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China for (row = 0; row < tems.ts_font.height; row++) {
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China bitsleft = tems.ts_font.width;
fea9cb91bd8e12d84069b4dab1268363668b4bfflq for (i = 0; i < nbits; i++) {
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * bit_to_pix24 is for 24-bit frame buffers. It will write four output bytes
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * for each bit of input bitmap. It inverts the input bits before
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * doing the output translation, for reverse video. Note that each
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * 24-bit RGB value is finally stored in a 32-bit unsigned int, with the
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * high-order byte set to zero.
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * Assuming foreground is 00000000 11111111 11111111 11111111
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * and background is 00000000 00000000 00000000 00000000
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * An input data byte of 0x53 will output the bit pattern
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * 00000000 00000000 00000000 00000000
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * 00000000 11111111 11111111 11111111
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * 00000000 00000000 00000000 00000000
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * 00000000 11111111 11111111 11111111
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * 00000000 00000000 00000000 00000000
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * 00000000 00000000 00000000 00000000
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * 00000000 11111111 11111111 11111111
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * 00000000 11111111 11111111 11111111
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China struct tem_vt_state *tem,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China destp = (pixel32_t *)tem->tvs_pix_data;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China cp = tems.ts_font.char_ptr[c];
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China bytes_wide = (tems.ts_font.width + 7) / 8;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China for (row = 0; row < tems.ts_font.height; row++) {
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China bitsleft = tems.ts_font.width;
fea9cb91bd8e12d84069b4dab1268363668b4bfflq for (i = 0; i < nbits; i++) {
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing Chinastatic text_color_t
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing Chinaansi_bg_to_solaris(struct tem_vt_state *tem, int ansi)
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing Chinastatic text_color_t
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing Chinaansi_fg_to_solaris(struct tem_vt_state *tem, int ansi)
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China * flag: TEM_ATTR_SCREEN_REVERSE or TEM_ATTR_REVERSE
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing Chinatem_safe_get_color(struct tem_vt_state *tem, text_color_t *fg,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China text_color_t *bg, uint8_t flag)
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China if (tem->tvs_flags & flag) {
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_bg_color);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_fg_color);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_fg_color);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_bg_color);
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * Clear a rectangle of screen for pixel mode.
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * arguments:
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * row: start row#
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * nrows: the number of rows to clear
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * offset_y: the offset of height in pixels to begin clear
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * col: start col#
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * ncols: the number of cols to clear
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * offset_x: the offset of width in pixels to begin clear
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * scroll_up: whether this function is called during sroll up,
fea9cb91bd8e12d84069b4dab1268363668b4bfflq * which is called only once.
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing Chinatem_safe_pix_cls_range(struct tem_vt_state *tem,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China ASSERT((MUTEX_HELD(&tems.ts_lock) && MUTEX_HELD(&tem->tvs_lock)) ||
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China called_from == CALLED_FROM_STANDALONE);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China row_add = tems.ts_c_dimension.height - 1;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China da.width = tems.ts_font.width;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China da.height = tems.ts_font.height;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_get_color(tem, &fg_color, &bg_color, TEM_ATTR_SCREEN_REVERSE);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_callback_bit2pix(tem, ' ', fg_color, bg_color);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China da.data = (uchar_t *)tem->tvs_pix_data;
fea9cb91bd8e12d84069b4dab1268363668b4bfflq for (j = 0; j < ncols; j++) {
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tems_safe_display(&da, credp, called_from);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China * virtual screen operations
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing Chinatem_safe_virtual_display(struct tem_vt_state *tem, unsigned char *string,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China unsigned char *addr;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China text_color_t *pfgcolor;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China text_color_t *pbgcolor;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China if (row < 0 || row >= tems.ts_c_dimension.height ||
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China col < 0 || col >= tems.ts_c_dimension.width ||
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China col + count > tems.ts_c_dimension.width)
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China width = tems.ts_c_dimension.width;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China addr = tem->tvs_screen_buf + (row * width + col);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China pfgcolor = tem->tvs_fg_buf + (row * width + col);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China pbgcolor = tem->tvs_bg_buf + (row * width + col);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China for (i = 0; i < count; i++) {
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China *addr++ = string[i];
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China *pfgcolor++ = fg_color;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China *pbgcolor++ = bg_color;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing Chinai_virtual_copy(unsigned char *base,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China unsigned char *from;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China unsigned char *to;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China screen_size_t chars_per_row;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China unsigned char *to_row_start;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China unsigned char *from_row_start;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China screen_size_t rows_to_move;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China int cols = tems.ts_c_dimension.width;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China chars_per_row = e_col - s_col + 1;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China rows_to_move = e_row - s_row + 1;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China to_row_start = base + ((t_row * cols) + t_col);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China from_row_start = base + ((s_row * cols) + s_col);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China if (to_row_start < from_row_start) {
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China while (rows_to_move-- > 0) {
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China to = to_row_start;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China from = from_row_start;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China to_row_start += cols;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China from_row_start += cols;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China for (cnt = chars_per_row; cnt-- > 0; )
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China *to++ = *from++;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China * Offset to the end of the region and copy backwards.
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China cnt = rows_to_move * cols + chars_per_row;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China to_row_start += cnt;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China from_row_start += cnt;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China while (rows_to_move-- > 0) {
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China to_row_start -= cols;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China from_row_start -= cols;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China to = to_row_start;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China from = from_row_start;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China for (cnt = chars_per_row; cnt-- > 0; )
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China *--to = *--from;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing Chinatem_safe_virtual_copy(struct tem_vt_state *tem,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China screen_size_t chars_per_row;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China screen_size_t rows_to_move;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China int rows = tems.ts_c_dimension.height;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China int cols = tems.ts_c_dimension.width;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China if (s_col < 0 || s_col >= cols ||
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China s_row < 0 || s_row >= rows ||
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China e_col < 0 || e_col >= cols ||
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China e_row < 0 || e_row >= rows ||
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China t_col < 0 || t_col >= cols ||
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China t_row < 0 || t_row >= rows ||
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China s_col > e_col ||
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China chars_per_row = e_col - s_col + 1;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China rows_to_move = e_row - s_row + 1;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China /* More sanity checks. */
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China if (t_row + rows_to_move > rows ||
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China t_col + chars_per_row > cols)
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China i_virtual_copy(tem->tvs_screen_buf, s_col, s_row,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China e_col, e_row, t_col, t_row);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China /* text_color_t is the same size as char */
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China i_virtual_copy((unsigned char *)tem->tvs_fg_buf,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China s_col, s_row, e_col, e_row, t_col, t_row);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China i_virtual_copy((unsigned char *)tem->tvs_bg_buf,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China s_col, s_row, e_col, e_row, t_col, t_row);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing Chinatem_safe_virtual_cls(struct tem_vt_state *tem,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China text_color_t fg_color;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China text_color_t bg_color;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_get_color(tem, &fg_color, &bg_color, TEM_ATTR_SCREEN_REVERSE);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_virtual_display(tem, tems.ts_blank_line, count, row, col,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China fg_color, bg_color);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China * only blank screen, not clear our screen buffer
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing Chinatem_safe_blank_screen(struct tem_vt_state *tem, cred_t *credp,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China ASSERT((MUTEX_HELD(&tems.ts_lock) && MUTEX_HELD(&tem->tvs_lock)) ||
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China called_from == CALLED_FROM_STANDALONE);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China if (tems.ts_display_mode == VIS_PIXEL) {
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_pix_clear_entire_screen(tem, credp, called_from);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China for (row = 0; row < tems.ts_c_dimension.height; row++) {
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_callback_cls(tem,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tems.ts_c_dimension.width,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China row, 0, credp, called_from);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China * unblank screen with associated tem from its screen buffer
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing Chinatem_safe_unblank_screen(struct tem_vt_state *tem, cred_t *credp,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China text_color_t fg_color, fg_last;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China text_color_t bg_color, bg_last;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China size_t tc_size = sizeof (text_color_t);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China int row, col, count, col_start;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China unsigned char *buf;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China ASSERT((MUTEX_HELD(&tems.ts_lock) && MUTEX_HELD(&tem->tvs_lock)) ||
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China called_from == CALLED_FROM_STANDALONE);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China if (tems.ts_display_mode == VIS_PIXEL)
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_pix_clear_entire_screen(tem, credp, called_from);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_callback_cursor(tem, VIS_HIDE_CURSOR, credp, called_from);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China width = tems.ts_c_dimension.width;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China * Display data in tvs_screen_buf to the actual framebuffer in a
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China * row by row way.
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China * When dealing with one row, output data with the same foreground
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China * and background color all together.
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China for (row = 0; row < tems.ts_c_dimension.height; row++) {
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China buf = tem->tvs_screen_buf + (row * width);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China count = col_start = 0;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China for (col = 0; col < width; col++) {
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_fg_buf[(row * width + col) * tc_size];
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem->tvs_bg_buf[(row * width + col) * tc_size];
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China fg_last = fg_color;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China bg_last = bg_color;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China if ((fg_color != fg_last) || (bg_color != bg_last)) {
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China * Call the primitive to render this data.
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_callback_display(tem,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China buf, count, row, col_start,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China fg_last, bg_last, credp, called_from);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China col_start = col;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China fg_last = fg_color;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China bg_last = bg_color;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China if (col_start == (width - 1))
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China * Call the primitive to render this data.
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China tem_safe_callback_display(tem,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China buf, count, row, col_start,
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China fg_last, bg_last, credp, called_from);