1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-18 10:35:55 +00:00

Sync with sys/i386/isa/syscons.c and syscons.h revisions 1.254 and

1.37, respectively.
This commit is contained in:
KATO Takenori 1998-02-13 09:31:35 +00:00
parent 80e35f1859
commit b0fc6ff1dd
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=33317
2 changed files with 106 additions and 73 deletions

View File

@ -25,7 +25,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $Id: syscons.c,v 1.75 1998/02/10 02:51:32 kato Exp $
* $Id: syscons.c,v 1.76 1998/02/12 08:16:34 kato Exp $
*/
#include "sc.h"
@ -57,6 +57,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>
@ -101,8 +102,6 @@
#define SC_MAX_HISTORY_SIZE (SC_HISTORY_SIZE * MAXCONS)
#endif
#define SC_MOUSE_CHAR (0x03)
#if !defined(SC_MOUSE_CHAR)
#define SC_MOUSE_CHAR (0xd0)
#endif
@ -131,7 +130,6 @@ typedef struct old_mouse_info {
} old_mouse_info_t;
/* 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 = {
@ -192,6 +190,7 @@ static long scrn_time_stamp;
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
@ -290,6 +289,7 @@ static void sccnupdate(scr_stat *scp);
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 scrn_update(scr_stat *scp, int show_cursor);
@ -297,7 +297,7 @@ 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);
@ -399,7 +399,7 @@ at2pc98(unsigned int attr)
/*
* 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;
@ -413,6 +413,12 @@ draw_cursor_image(scr_stat *scp)
#else
ptr = Crtat + (scp->cursor_pos - scp->scr_buf);
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;
@ -438,8 +444,7 @@ draw_cursor_image(scr_stat *scp)
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))){
@ -458,24 +463,19 @@ draw_cursor_image(scr_stat *scp)
#endif
}
static inline void
static void
remove_cursor_image(scr_stat *scp)
{
#ifndef PC98
/*
u_short cursor_image, *ptr;
ptr = Crtat + (scp->cursor_oldpos - scp->scr_buf);
cursor_image = scp->cursor_saveunder;
*ptr = cursor_image;
SOS */
*(Crtat + (scp->cursor_oldpos - scp->scr_buf)) = scp->cursor_saveunder;
if (vesa_mode)
sc_bcopy(scp->scr_buf, scp->cursor_pos - scp->scr_buf,
scp->cursor_pos - scp->scr_buf, 0);
else
*(Crtat + (scp->cursor_oldpos - scp->scr_buf)) = scp->cursor_saveunder;
#endif
}
static inline void
static void
move_crsr(scr_stat *scp, int x, int y)
{
if (x < 0)
@ -543,7 +543,12 @@ scvidprobe(int unit, int flags)
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;
@ -559,45 +564,43 @@ scvidprobe(int unit, int flags)
}
*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) {
/* 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);
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);
/* 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);
@ -890,6 +893,9 @@ scattach(struct isa_device *dev)
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:
@ -2249,11 +2255,11 @@ scioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p)
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);
@ -2261,7 +2267,7 @@ scioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p)
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);
@ -2517,18 +2523,17 @@ scrn_update(scr_stat *scp, int show_cursor)
{
/* 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);
#ifdef PC98
sc_bcopy(scp->atr_buf + scp->start, Atrat + scp->start,
(1 + scp->end - scp->start) * sizeof(u_short));
generic_bcopy(scp->atr_buf + scp->start, Atrat + scp->start,
(1 + scp->end - scp->start) * sizeof(u_short));
#endif
}
/* we are not to show the cursor and the mouse pointer... */
if (!show_cursor) {
scp->end = 0;
scp->start = scp->xsize*scp->ysize;
scp->start = scp->xsize*scp->ysize - 1;
return;
}
@ -2584,7 +2589,7 @@ scrn_update(scr_stat *scp, int show_cursor)
draw_cutmarking(scp);
scp->end = 0;
scp->start = scp->xsize*scp->ysize;
scp->start = scp->xsize*scp->ysize - 1;
}
int
@ -2727,6 +2732,9 @@ exchange_scr(void)
update_leds(new_scp->status);
delayed_next_scr = FALSE;
mark_all(new_scp);
if (vesa_mode == 0x102) {
bzero(Crtat, 800*600/8);
}
}
static void
@ -4001,8 +4009,9 @@ scinit(void)
}
#endif
/* 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 = console[0]->mouse_oldpos
= sc_buffer;
@ -5486,7 +5495,7 @@ set_destructive_cursor(scr_stat *scp)
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);
#endif
}
@ -5791,8 +5800,7 @@ draw_mouse_image(scr_stat *scp)
while (!(inb(crtc_addr+6) & 0x08)) /* idle */ ;
#endif
set_font_mode(buf);
sc_bcopy(scp->mouse_cursor, (char *)pa_to_va(address) + SC_MOUSE_CHAR * 32,
128);
generic_bcopy(scp->mouse_cursor, (char *)pa_to_va(address) + SC_MOUSE_CHAR * 32, 128);
set_normal_mode(buf);
*(crt_pos) = (*(scp->mouse_pos) & 0xff00) | SC_MOUSE_CHAR;
*(crt_pos+scp->xsize) =
@ -6000,6 +6008,31 @@ blink_screen(void *arg)
}
}
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;
int i,j;
for (i = from ; i <= to ; i++) {
for (j = 0 ; j < 16; j++) {
d = (u_char *)Crtat;
d += 10 + 6*16*100;
d += (i%80);
d += 16*100*(i/80);
d += 100*j;
if (mark)
*d++ = 255^font_16[(p[i]&0xff)*16+j];
else
*d++ = font_16[(p[i]&0xff)*16+j];
}
}
}
}
#ifdef SC_SPLASH_SCREEN
static void
toggle_splash_screen(scr_stat *scp)

View File

@ -25,7 +25,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $Id: syscons.h,v 1.20 1997/11/25 09:51:46 kato Exp $
* $Id: syscons.h,v 1.21 1998/01/12 15:34:18 kato Exp $
*/
#ifndef _PC98_PC98_SYSCONS_H_
@ -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 */