Date: Sat, 8 Jan 2000 12:37:11 -0500 (EST) From: kbyanc@posi.net To: FreeBSD-gnats-submit@freebsd.org Subject: kern/15996: patch to add sysctl variable to control SC_MOUSE_CHAR at run-time Message-ID: <200001081737.MAA00451@home.posi.net>
next in thread | raw e-mail | index | archive | help
>Number: 15996
>Category: kern
>Synopsis: patch adds hw.syscons.sc_mouse_char sysctl variable
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: change-request
>Submitter-Id: current-users
>Arrival-Date: Sat Jan 8 10:10:01 PST 2000
>Closed-Date:
>Last-Modified:
>Originator: Kelly Yancey
>Release: FreeBSD 3.4-STABLE i386
>Organization:
>Environment:
>Description:
As discussed in message thread on -hackers (see message ID
20000106212404.A30244@dcse.fee.vutbr.cz):
"Nearly everyone who wants to set up their national
locale needs to recompile the kernel, since some
important characters are hidden under mouse cursor."
This is because syscons needs to munge 4 character font
definitions to create the illusion of a graphical mouse cursor in
text mode.
The attached patch remedies this situation by creating a new
sysctl variable hw.syscons.sc_mouse_char which can be used to
redefine the base character used for creating the mouse pointer
image at run-time. It defaults to the setting of SC_MOUSE_CHAR
which can be used to define a preference at compile-time (courtesy
Kazu).
It should be noted that on most, if not all, VGA adapters are
hardwired to copy the 0th bit of into the 9th bit of character
fonts in the range 0xc0-0xdf, but for all other characters it just
leaves them blank. If you move the base character for the mouse
pointer out of this range, you will see gaps in the pointer (or
for an even weirder effect, have the mouse character range cross
the boundary between 9th-bit copied and non-copied character
definitions).
However, this is only the case in some video modes (the most
notable being all 80-character wide text modes, i.e. the default
80x25). 90-character wide text modes that are available in
-current's syscons do not perform 9th bit copying (hence how they
reclaim pixels to use for the extra 10 columns).
Finally, for a psycadelic experience, you can set the
hw.syscons.sc_mouse_char to a value like 32 to overwrite the space
character with the mouse image. Move the mouse around and free
your mind. :)
Bug reports, bug reports, how can it be
so many bug reports for FreeBSD
Not typos or glitches, there's more there it seems,
like ports, docs, and man pages by hackers like me.
-Kelly
>How-To-Repeat:
>Fix:
--- sys/dev/syscons/syscons.c.orig Fri Jan 7 21:31:44 2000
+++ sys/dev/syscons/syscons.c Sat Jan 8 11:56:05 2000
@@ -48,6 +48,7 @@
#include <sys/conf.h>
#include <sys/proc.h>
#include <sys/signalvar.h>
+#include <sys/sysctl.h>
#include <sys/tty.h>
#include <sys/kernel.h>
#include <sys/malloc.h>
@@ -239,6 +240,7 @@
#define SC_CONSOLE 255
vm_offset_t Crtat;
static const int nsccons = MAXCONS+2;
+static int sc_mouse_char = SC_MOUSE_CHAR;
#define WRAPHIST(scp, pointer, offset)\
((scp)->history + ((((pointer) - (scp)->history) + (scp)->history_size \
@@ -337,6 +339,39 @@
static void remove_cutmarking(scr_stat *scp);
static void do_bell(scr_stat *scp, int pitch, int duration);
static timeout_t blink_screen;
+static void reload_current_font(scr_stat *scp);
+
+static int
+sysctl_sc_mouse_char SYSCTL_HANDLER_ARGS
+{
+ int error;
+
+ error = sysctl_handle_int(oidp, &sc_mouse_char, 0, req);
+ if (!error && req->newptr) {
+ /* Limit range to ensure mouse pointer characters exist in font */
+ if(sc_mouse_char < 0) sc_mouse_char = 0;
+ if(sc_mouse_char > 256 - 4) sc_mouse_char = 256 - 4;
+
+ /*
+ * The base character for drawing the mouse pointer has changed.
+ * Clear the pointer, restore the original font, and then redraw
+ * the pointer mangling characters at the new location.
+ */
+ remove_mouse_image(cur_console);
+
+ /* Reload fonts to demangle character defs used by mouse cursor. */
+ reload_current_font(cur_console);
+
+ if (cur_console->status & MOUSE_VISIBLE)
+ draw_mouse_image(cur_console);
+ }
+ return (error);
+}
+
+SYSCTL_NODE(_hw, OID_AUTO, syscons, CTLFLAG_RW, 0, "Syscons driver mgmt");
+SYSCTL_PROC(_hw_syscons, OID_AUTO, sc_mouse_char, CTLTYPE_INT|CTLFLAG_RW,
+ 0, 0, sysctl_sc_mouse_char, "I",
+ "First character of four character range used to draw mouse cursor");
#define CDEV_MAJOR 12
@@ -4096,27 +4131,7 @@
Crtat = scp->adp->va_window;
if (!(scp->status & GRAPHICS_MODE)) {
- /* load appropriate font */
- if (!(scp->status & PIXEL_MODE) && ISFONTAVAIL(scp->adp->va_flags)) {
- if (scp->font_size < 14) {
- if (fonts_loaded & FONT_8)
- copy_font(scp, LOAD, 8, font_8);
- } else if (scp->font_size >= 16) {
- if (fonts_loaded & FONT_16)
- copy_font(scp, LOAD, 16, font_16);
- } else {
- if (fonts_loaded & FONT_14)
- copy_font(scp, LOAD, 14, font_14);
- }
- /*
- * FONT KLUDGE:
- * This is an interim kludge to display correct font.
- * Always use the font page #0 on the video plane 2.
- * Somehow we cannot show the font in other font pages on
- * some video cards... XXX
- */
- (*vidsw[scp->ad]->show_font)(scp->adp, 0);
- }
+ reload_current_font(scp);
mark_all(scp);
}
@@ -4217,13 +4232,13 @@
}
if (scp->status & MOUSE_VISIBLE) {
- if ((scp->cursor_saveunder & 0xff) == SC_MOUSE_CHAR)
+ if ((scp->cursor_saveunder & 0xff) == sc_mouse_char)
bcopy(&scp->mouse_cursor[0], cursor, scp->font_size);
- else if ((scp->cursor_saveunder & 0xff) == SC_MOUSE_CHAR + 1)
+ else if ((scp->cursor_saveunder & 0xff) == sc_mouse_char + 1)
bcopy(&scp->mouse_cursor[32], cursor, scp->font_size);
- else if ((scp->cursor_saveunder & 0xff) == SC_MOUSE_CHAR + 2)
+ else if ((scp->cursor_saveunder & 0xff) == sc_mouse_char + 2)
bcopy(&scp->mouse_cursor[64], cursor, scp->font_size);
- else if ((scp->cursor_saveunder & 0xff) == SC_MOUSE_CHAR + 3)
+ else if ((scp->cursor_saveunder & 0xff) == sc_mouse_char + 3)
bcopy(&scp->mouse_cursor[96], cursor, scp->font_size);
else
bcopy(font_buffer+((scp->cursor_saveunder & 0xff)*scp->font_size),
@@ -4551,16 +4566,16 @@
#endif
font_loading_in_progress = TRUE;
(*vidsw[scp->ad]->load_font)(scp->adp, 0, 32, scp->mouse_cursor,
- SC_MOUSE_CHAR, 4);
+ sc_mouse_char, 4);
font_loading_in_progress = FALSE;
- writew(crt_pos, (*(scp->mouse_pos) & 0xff00) | SC_MOUSE_CHAR);
+ writew(crt_pos, (*(scp->mouse_pos) & 0xff00) | sc_mouse_char);
writew(crt_pos+2*scp->xsize,
- (*(scp->mouse_pos + scp->xsize) & 0xff00) | (SC_MOUSE_CHAR + 2));
+ (*(scp->mouse_pos + scp->xsize) & 0xff00) | (sc_mouse_char + 2));
if (scp->mouse_xpos < (scp->xsize-1)*8) {
- writew(crt_pos + 2, (*(scp->mouse_pos + 1) & 0xff00) | (SC_MOUSE_CHAR + 1));
+ writew(crt_pos + 2, (*(scp->mouse_pos + 1) & 0xff00) | (sc_mouse_char + 1));
writew(crt_pos+2*scp->xsize + 2,
- (*(scp->mouse_pos + scp->xsize + 1) & 0xff00) | (SC_MOUSE_CHAR + 3));
+ (*(scp->mouse_pos + scp->xsize + 1) & 0xff00) | (sc_mouse_char + 3));
}
mark_for_update(scp, scp->mouse_pos - scp->scr_buf);
mark_for_update(scp, scp->mouse_pos + scp->xsize + 1 - scp->scr_buf);
@@ -4671,6 +4686,31 @@
scp->xsize * scp->ysize);
blink_in_progress--;
timeout(blink_screen, scp, hz / 10);
+ }
+}
+
+static void
+reload_current_font(scr_stat *scp)
+{
+ if (!(scp->status & PIXEL_MODE) && ISFONTAVAIL(scp->adp->va_flags)) {
+ if (scp->font_size < 14) {
+ if (fonts_loaded & FONT_8)
+ copy_font(scp, LOAD, 8, font_8);
+ } else if (scp->font_size >= 16) {
+ if (fonts_loaded & FONT_16)
+ copy_font(scp, LOAD, 16, font_16);
+ } else {
+ if (fonts_loaded & FONT_14)
+ copy_font(scp, LOAD, 14, font_14);
+ }
+ /*
+ * FONT KLUDGE:
+ * This is an interim kludge to display correct font.
+ * Always use the font page #0 on the video plane 2.
+ * Somehow we cannot show the font in other font pages on
+ * some video cards... XXX
+ */
+ (*vidsw[scp->ad]->show_font)(scp->adp, 0);
}
}
>Release-Note:
>Audit-Trail:
>Unformatted:
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200001081737.MAA00451>
