Date: Sun, 14 Dec 1997 12:06:58 +0100 From: Poul-Henning Kamp <phk@critter.freebsd.dk> To: mobile@freebsd.org Subject: 800x600 on laptops (answer to Deng Hongwei) Message-ID: <12343.882097618@critter.freebsd.dk>
next in thread | raw e-mail | index | archive | help
(Deng, email to you bounces, see the headers at the bottom of this
email!)
In message <349308CC.FD11DC6D@sz.cei.go.cn>, Deng Hongwei writes:
>So, Would you please tell me howto get the patch and howto set VESA
>videomode 0x102 (800x600x16) before loading kernel.
the patch is included below. it's still being reviewed and mangled
by Soren Schmidt, but eventually it will be included I think.
You need to compile a font into your kernel as well, add this to your
config file:
options "STD8X16FONT"
makeoptions "STD8X16FONT"="iso-thin"
You give the option "-b" to the kernel when you boot. You can do this
automatically by
cat > /boot.config
-b
^D
Please ask if you have questions...
Poul-Henning
Index: i386/include/console.h
===================================================================
RCS file: /home/ncvs/src/sys/i386/include/console.h,v
retrieving revision 1.33
diff -u -r1.33 console.h
- --- console.h 1997/12/07 08:08:49 1.33
+++ console.h 1997/12/07 21:42:35
@@ -150,6 +150,7 @@
#define KD_EGA 4 /* enhanced graphics adapter */
#define KD_VGA 5 /* video graphics adapter */
#define KD_PC98 6 /* PC-98 display */
+#define KD_PIXEL 7 /* pixel/graphics adapter/mode */
#define KD_TEXT 0 /* set text mode restore fonts */
#define KD_TEXT0 0 /* ditto */
Index: i386/isa/syscons.c
===================================================================
RCS file: /home/ncvs/src/sys/i386/isa/syscons.c,v
retrieving revision 1.242
diff -u -r1.242 syscons.c
- --- syscons.c 1997/12/07 08:09:19 1.242
+++ syscons.c 1997/12/07 21:42:46
@@ -56,6 +56,7 @@
#include <machine/pc/display.h>
#include <machine/apm_bios.h>
#include <machine/random.h>
+#include <machine/bootinfo.h>
#include <vm/vm.h>
#include <vm/vm_param.h>
@@ -92,7 +93,7 @@
#define MODE_PARAM_SIZE 64
/* XXX use sc_bcopy where video memory is concerned */
- -#define sc_bcopy generic_bcopy
+
extern void generic_bcopy(const void *, void *, size_t);
static default_attr user_default = {
@@ -136,6 +137,7 @@
u_char scr_map[256];
u_char scr_rmap[256];
char *video_mode_ptr = NULL;
+static int vesa_mode;
int fonts_loaded = 0
#ifdef STD8X16FONT
| FONT_16
@@ -222,13 +224,14 @@
static scr_stat *get_scr_stat(dev_t dev);
static scr_stat *alloc_scp(void);
static void init_scp(scr_stat *scp);
+static void sc_bcopy(u_short *p, int from, int to, int mark);
static int get_scr_num(void);
static timeout_t scrn_timer;
static void stop_scrn_saver(void (*saver)(int));
static void clear_screen(scr_stat *scp);
static int switch_scr(scr_stat *scp, u_int next_scr);
static void exchange_scr(void);
- -static inline void move_crsr(scr_stat *scp, int x, int y);
+static void move_crsr(scr_stat *scp, int x, int y);
static void scan_esc(scr_stat *scp, u_char c);
static void draw_cursor_image(scr_stat *scp);
static void remove_cursor_image(scr_stat *scp);
@@ -293,12 +296,18 @@
/*
* These functions need to be before calls to them so they can be inlined.
*/
- -static inline void
+static void
draw_cursor_image(scr_stat *scp)
{
u_short cursor_image, *ptr = Crtat + (scp->cursor_pos - scp->scr_buf);
u_short prev_image;
+ if (vesa_mode) {
+ sc_bcopy(scp->scr_buf, scp->cursor_pos - scp->scr_buf,
+ scp->cursor_pos - scp->scr_buf, 1);
+ return;
+ }
+
/* do we have a destructive cursor ? */
if (flags & CHAR_CURSOR) {
prev_image = scp->cursor_saveunder;
@@ -324,8 +333,7 @@
cursor_image &= 0xff00;
cursor_image |= DEAD_CHAR;
}
- - }
- - else {
+ } else {
cursor_image = (*(ptr) & 0x00ff) | *(scp->cursor_pos) & 0xff00;
scp->cursor_saveunder = cursor_image;
if (!(flags & BLINK_CURSOR)||((flags & BLINK_CURSOR)&&(blinkrate & 4))){
@@ -343,13 +351,17 @@
*ptr = cursor_image;
}
- -static inline void
+static void
remove_cursor_image(scr_stat *scp)
{
- - *(Crtat + (scp->cursor_oldpos - scp->scr_buf)) = scp->cursor_saveunder;
+ if (vesa_mode)
+ sc_bcopy(scp->scr_buf, scp->cursor_oldpos - scp->scr_buf,
+ scp->cursor_oldpos - scp->scr_buf, 0);
+ else
+ *(Crtat + (scp->cursor_oldpos - scp->scr_buf)) = scp->cursor_saveunder;
}
- -static inline void
+static void
move_crsr(scr_stat *scp, int x, int y)
{
if (x < 0)
@@ -409,7 +421,12 @@
cp = (u_short *)CGA_BUF;
was = *cp;
*cp = (u_short) 0xA55A;
- - if (*cp == 0xA55A) {
+ if (bootinfo.bi_vesa == 0x102) {
+ vesa_mode = bootinfo.bi_vesa;
+ Crtat = (u_short *)pa_to_va(0xA0000);
+ crtc_type = KD_PIXEL;
+ bzero(Crtat, 800*600/8);
+ } else if (*cp == 0xA55A) {
Crtat = (u_short *)CGA_BUF;
crtc_addr = COLOR_BASE;
crtc_type = KD_CGA;
@@ -425,45 +442,43 @@
}
*cp = was;
- - /*
- - * Check rtc and BIOS date area.
- - * XXX: don't use BIOSDATA_EQUIPMENT, it is not a dead copy
- - * of RTC_EQUIPMENT. The bit 4 and 5 of the ETC_EQUIPMENT are
- - * zeros for EGA and VGA. However, the EGA/VGA BIOS will set
- - * these bits in BIOSDATA_EQUIPMENT according to the monitor
- - * type detected.
- - */
- - switch ((rtcin(RTC_EQUIPMENT) >> 4) & 3) { /* bit 4 and 5 */
- - case 0: /* EGA/VGA, or nothing */
- - crtc_type = KD_EGA;
- - /* the color adapter may be in the 40x25 mode... XXX */
- - break;
- - case 1: /* CGA 40x25 */
- - /* switch to the 80x25 mode? XXX */
- - /* FALL THROUGH */
- - case 2: /* CGA 80x25 */
- - /* `crtc_type' has already been set... */
- - /* crtc_type = KD_CGA; */
- - break;
- - case 3: /* MDA */
- - /* `crtc_type' has already been set... */
- - /* crtc_type = KD_MONO; */
- - break;
- - }
+ if (crtc_type != KD_PIXEL) {
+ /*
+ * Check rtc and BIOS date area.
+ * XXX: don't use BIOSDATA_EQUIPMENT, it is not a dead copy
+ * of RTC_EQUIPMENT. The bit 4 and 5 of the ETC_EQUIPMENT are
+ * zeros for EGA and VGA. However, the EGA/VGA BIOS will set
+ * these bits in BIOSDATA_EQUIPMENT according to the monitor
+ * type detected.
+ */
+ switch ((rtcin(RTC_EQUIPMENT) >> 4) & 3) { /* bit 4 and 5 */
+ case 0: /* EGA/VGA, or nothing */
+ crtc_type = KD_EGA;
+ /* the color adapter may be in the 40x25 mode... XXX */
+ break;
+ case 1: /* CGA 40x25 */
+ /* switch to the 80x25 mode? XXX */
+ /* FALL THROUGH */
+ case 2: /* CGA 80x25 */
+ /* `crtc_type' has already been set... */
+ /* crtc_type = KD_CGA; */
+ break;
+ case 3: /* MDA */
+ /* `crtc_type' has already been set... */
+ /* crtc_type = KD_MONO; */
+ break;
+ }
- - /* is this a VGA or higher ? */
- - outb(crtc_addr, 7);
- - if (inb(crtc_addr) == 7) {
- -
- - crtc_type = KD_VGA;
- - crtc_vga = TRUE;
- - read_vgaregs(vgaregs);
- -
- - /* Get the BIOS video mode pointer */
- - segoff = *(u_long *)pa_to_va(0x4a8);
- - pa = (((segoff & 0xffff0000) >> 12) + (segoff & 0xffff));
- - if (ISMAPPED(pa, sizeof(u_long))) {
- - segoff = *(u_long *)pa_to_va(pa);
+ /* is this a VGA or higher ? */
+ outb(crtc_addr, 7);
+ if (inb(crtc_addr) == 7) {
+
+ crtc_type = KD_VGA;
+ crtc_vga = TRUE;
+ read_vgaregs(vgaregs);
+
+ /* Get the BIOS video mode pointer */
+ segoff = *(u_long *)pa_to_va(0x4a8);
pa = (((segoff & 0xffff0000) >> 12) + (segoff & 0xffff));
if (ISMAPPED(pa, MODE_PARAM_SIZE))
video_mode_ptr = (char *)pa_to_va(pa);
@@ -728,6 +743,9 @@
case KD_CGA:
printf("CGA");
break;
+ case KD_PIXEL:
+ printf("Graphics display (VESA mode = 0x%x)", vesa_mode);
+ break;
case KD_MONO:
case KD_HERCULES:
default:
@@ -1915,11 +1933,11 @@
return ENXIO;
case PIO_FONT8x16: /* set 8x16 dot font */
- - if (!crtc_vga)
+ if (!crtc_vga && crtc_type != KD_PIXEL)
return ENXIO;
bcopy(data, font_16, 16*256);
fonts_loaded |= FONT_16;
- - if (!(cur_console->status & UNKNOWN_MODE)) {
+ if (crtc_vga && !(cur_console->status & UNKNOWN_MODE)) {
copy_font(LOAD, FONT_16, font_16);
if (flags & CHAR_CURSOR)
set_destructive_cursor(cur_console);
@@ -1927,7 +1945,7 @@
return 0;
case GIO_FONT8x16: /* get 8x16 dot font */
- - if (!crtc_vga)
+ if (!crtc_vga && crtc_type != KD_PIXEL)
return ENXIO;
if (fonts_loaded & FONT_16) {
bcopy(font_16, data, 16*256);
@@ -2046,8 +2064,7 @@
s = splclock();
if (scp == cur_console && !(scp->status & UNKNOWN_MODE)) {
if (/* timer not running && */ (scp->start <= scp->end)) {
- - sc_bcopy(scp->scr_buf + scp->start, Crtat + scp->start,
- - (1 + scp->end - scp->start) * sizeof(u_short));
+ sc_bcopy(scp->scr_buf, scp->start, scp->end, 0);
scp->start = scp->xsize * scp->ysize;
scp->end = 0;
}
@@ -2159,8 +2176,7 @@
if (scrn_blanked <= 0) {
/* update screen image */
if (scp->start <= scp->end) {
- - sc_bcopy(scp->scr_buf + scp->start, Crtat + scp->start,
- - (1 + scp->end - scp->start) * sizeof(u_short));
+ sc_bcopy(scp->scr_buf, scp->start, scp->end, 0);
}
/* update "pseudo" mouse pointer image */
@@ -2354,6 +2370,9 @@
update_leds(new_scp->status);
delayed_next_scr = FALSE;
mark_all(new_scp);
+ if (vesa_mode == 0x102) {
+ bzero(Crtat, 800*600/8);
+ }
}
static void
@@ -3104,8 +3123,9 @@
}
/* copy screen to temporary buffer */
- - sc_bcopy(Crtat, sc_buffer,
- - console[0]->xsize * console[0]->ysize * sizeof(u_short));
+ if (crtc_type != KD_PIXEL)
+ generic_bcopy(Crtat, sc_buffer,
+ console[0]->xsize * console[0]->ysize * sizeof(u_short));
console[0]->scr_buf = console[0]->mouse_pos = sc_buffer;
console[0]->cursor_pos = console[0]->cursor_oldpos = sc_buffer + hw_cursor;
@@ -4322,7 +4342,7 @@
while (!(inb(crtc_addr+6) & 0x08)) /* wait for vertical retrace */ ;
#endif
set_font_mode(buf);
- - sc_bcopy(cursor, (char *)pa_to_va(address) + DEAD_CHAR * 32, 32);
+ generic_bcopy(cursor, (char *)pa_to_va(address) + DEAD_CHAR * 32, 32);
set_normal_mode(buf);
}
@@ -4623,7 +4643,7 @@
while (!(inb(crtc_addr+6) & 0x08)) /* idle */ ;
#endif
set_font_mode(buf);
- - sc_bcopy(scp->mouse_cursor, (char *)pa_to_va(address) + 0xd0 * 32, 128);
+ generic_bcopy(scp->mouse_cursor, (char *)pa_to_va(address) + 0xd0 * 32, 128);
set_normal_mode(buf);
*(crt_pos) = (*(scp->mouse_pos)&0xff00)|0xd0;
*(crt_pos+scp->xsize) = (*(scp->mouse_pos+scp->xsize)&0xff00)|0xd2;
@@ -4750,6 +4770,33 @@
Crtat, scp->xsize * scp->ysize);
blink_in_progress--;
timeout(blink_screen, scp, hz / 10);
+ }
+}
+
+void
+sc_bcopy(u_short *p, int from, int to, int mark)
+{
+ if (!vesa_mode) {
+ generic_bcopy(p+from, Crtat+from, (to-from+1)*sizeof (u_short));
+ } else if (vesa_mode == 0x102) {
+ u_char *d, *e;
+ int i,j;
+
+ d = (u_char *)Crtat;
+ d += 10 + 6*16*100 + (from%80) + 16*100*(from/80);
+ for (i = from ; i <= to ; i++) {
+ e = d;
+ for (j = 0 ; j < 16; j++) {
+ if (mark)
+ *e = 255^font_16[(p[i]&0xff)*16+j];
+ else
+ *e = font_16[(p[i]&0xff)*16+j];
+ e+=100;
+ }
+ d++;
+ if ((i % 80) == 79)
+ d += 20 + 15*100;
+ }
}
}
Index: i386/isa/syscons.h
===================================================================
RCS file: /home/ncvs/src/sys/i386/isa/syscons.h,v
retrieving revision 1.36
diff -u -r1.36 syscons.h
- --- syscons.h 1997/11/21 11:37:07 1.36
+++ syscons.h 1997/11/22 15:11:23
@@ -48,7 +48,7 @@
}
#define mark_all(scp) {\
scp->start = 0;\
- - scp->end = scp->xsize * scp->ysize;\
+ scp->end = scp->xsize * scp->ysize - 1;\
}
/* status flags */
------- Forwarded Message
Return-Path: MAILER-DAEMON
Received: from sz.cei.gov.cn ([203.207.179.2])
by critter.freebsd.dk (8.8.7/8.8.7) with ESMTP id LAA12195
for <phk@critter.freebsd.dk>; Sun, 14 Dec 1997 11:35:38 +0100 (CET)
(envelope-from )
Received: from localhost (localhost) by sz.cei.gov.cn (8.7.5+2.6Wbeta6/3.4W CEI-LN 96090315) with internal id SAA08604; Sun, 14 Dec 1997 18:43:07 +0800 (CST)
Date: Sun, 14 Dec 1997 18:43:07 +0800 (CST)
From: Mail Delivery Subsystem <MAILER-DAEMON@sz.cei.gov.cn>
Subject: Returned mail: Local configuration error
Message-Id: <199712141043.SAA08604@sz.cei.gov.cn>
To: postmaster@sz.cei.gov.cn
To: <phk@critter.freebsd.dk>
Auto-Submitted: auto-generated (failure)
The original message was received at Sun, 14 Dec 1997 18:42:52 +0800 (CST)
from critter.freebsd.dk [195.8.129.26]
----- The following addresses have delivery notifications -----
<dhongwei@sz.cei.go.cn> (unrecoverable error)
----- Transcript of session follows -----
553 szup2.sz.cei.go.cn. config error: mail loops back to me (MX problem?)
554 <dhongwei@sz.cei.go.cn>... Local configuration error
----- Original message follows -----
Return-Path: phk@critter.freebsd.dk
Received: from critter.freebsd.dk (critter.freebsd.dk [195.8.129.26]) by sz.cei.gov.cn (8.7.5+2.6Wbeta6/3.4W CEI-LN 96090315) with ESMTP id SAA08602 for <dhongwei@sz.cei.go.cn>; Sun, 14 Dec 1997 18:42:52 +0800 (CST)
Received: from critter.freebsd.dk (localhost.cybercity.dk [127.0.0.1])
by critter.freebsd.dk (8.8.7/8.8.7) with ESMTP id LAA12175
for <dhongwei@sz.cei.go.cn>; Sun, 14 Dec 1997 11:33:40 +0100 (CET)
(envelope-from phk@critter.freebsd.dk)
To: Deng Hongwei <dhongwei@sz.cei.go.cn>
Subject: Re: Help the patch for 800x600x16 boot -current
In-reply-to: Your message of "Sun, 14 Dec 1997 06:14:36 +0800."
<349308CC.FD11DC6D@sz.cei.go.cn>
Date: Sun, 14 Dec 1997 11:33:39 +0100
Message-ID: <12173.882095619@critter.freebsd.dk>
From: Poul-Henning Kamp <phk@critter.freebsd.dk>
--
Poul-Henning Kamp FreeBSD coreteam member
phk@FreeBSD.ORG "Real hackers run -current on their laptop."
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?12343.882097618>
