*BSD News Article 95438


Return to BSD News archive

Path: euryale.cc.adfa.oz.au!newshost.carno.net.au!harbinger.cc.monash.edu.au!munnari.OZ.AU!news.ecn.uoknor.edu!news.ysu.edu!news.radio.cz!news.apfel.de!cpk-news-hub1.bbnplanet.com!news.bbnplanet.com!newsfeed.internetmci.com!in3.uu.net!202.232.2.100!np1.iij.ad.jp!wnoc-tyo-news!news.nc.u-tokyo.ac.jp!train.ad.jp!iroha.utsunomiya-u.ac.jp!nikko.utsunomiya-u.ac.jp!yokota
From: yokota@zodiac.mech.utsunomiya-u.ac.jp. (Kazutaka YOKOTA)
Newsgroups: comp.unix.bsd.freebsd.misc
Subject: Re: Help , no Boot from Boot.flp in vers 2.2.1
Date: 15 May 1997 23:47:05 GMT
Organization: Utsunomiya University, Utsunomiya, Japan
Lines: 562
Message-ID: <5lg79p$212$1@nikko.utsunomiya-u.ac.jp>
References: <5kqkn2$90k@bambam.soi.city.ac.uk>
	<5ks7gg$4q@ui-gate.utell.co.uk>
	<3374C090.41C67EA6@akdam.demon.co.uk>
NNTP-Posting-Host: zodiac.mech.utsunomiya-u.ac.jp
X-Newsreader: mnews [version 1.19PL2] 1996-01/26(Fri)
Xref: euryale.cc.adfa.oz.au comp.unix.bsd.freebsd.misc:40986

In article <3374C090.41C67EA6@akdam.demon.co.uk> for comp.unix.bsd.freebsd.misc
Tarkan Akdam wrote:

bambi>>I've been experimenting since my original post,, And this is what I have 
bambi>>discovered.  
bambi>>
bambi>>I try a boot.flp image from ftp.cdrom.com  , This booted up the machine
bambi>>but when sysinstall was started the keyboard was all over the place and
bambi>>seem
bambi>>locked up.
bambi>>
bambi>>So, I ftp'd the boot.flp from the 3.0-SNAP directory, know this worked,
bambi>>brilliant , so I installed/upgraded my machine to 2.2.1-RELEASE status,
bambi>>
bambi>>When I booted the machine up, It would boot ok but the keyboard would
bambi>>be locked.
bambi>>
bambi>>So I ended up booting up using my original 2.1.6 kernel and everything
bambi>>was ok, I thought I better compile my self a 2.2.1 kernel,
bambi>>So I tried that compiled ok and then I try'd booting up with it
bambi>>same problem the keyboard was locked up, great!!!!!!
bambi>>Ok back again I tried compiling another kernel this time using PCVT
bambi>>console
bambi>>and not the SYSCONS driver!!!
bambi>>
bambi>>I booted it up and it worked.
bambi>>
bambi>>From what I can see something has been broken in the syscons driver
bambi>>has anyone got any ideas, I'm happy I've got the use of my machine back
bambi>>but I dont like PCVT and would like my SYSCONS back?????

I cannot think of the exact cause of your problem. I need some more
details on your system: motherboard, CPU, keyboard, video card, PS/2
mouse (if any)...

Anyway, here is diff between the syscons driver in 2.2.1-RELEASE and
the latest one for RELENG_2_2. It fixes several problems found after
2.2.1 was released.

Apply the patch to /sys/i386/isa/syscons.c and rebuild the kernel.

Hope this will solve your problem.

Kazu

Index: syscons.c
===================================================================
RCS file: /home/ncvs/src/sys/i386/isa/syscons.c,v
retrieving revision 1.182.2.15
retrieving revision 1.182.2.18
diff -u -r1.182.2.15 -r1.182.2.18
--- syscons.c	1997/03/09 06:32:28	1.182.2.15
+++ syscons.c	1997/05/11 06:09:02	1.182.2.18
@@ -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.182.2.15 1997/03/09 06:32:28 yokota Exp $
+ *  $Id: syscons.c,v 1.182.2.18 1997/05/11 06:09:02 yokota Exp $
  */
 
 #include "sc.h"
@@ -79,8 +79,9 @@
 #define COLD 0
 #define WARM 1
 
-/* this may break on older VGA's but is useful on real 32 bit systems */
-#define bcopyw  bcopy
+/* 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 = {
     (FG_LIGHTGREY | BG_BLACK) << 8,
@@ -127,6 +128,7 @@
 	char		font_14[256*14];
 	char		font_16[256*16];
 	char        	palette[256*3];
+static  char		vgaregs[64];
 static	char 		*cut_buffer;
 static  u_short 	mouse_and_mask[16] = {
 				0xc000, 0xe000, 0xf000, 0xf800,
@@ -201,6 +203,9 @@
 static void set_keyboard(int command, int data);
 static void update_leds(int which);
 static void set_vgaregs(char *modetable);
+static void read_vgaregs(char *buf);
+static int comp_vgaregs(u_char *buf1, u_char *buf2);
+static void dump_vgaregs(u_char *buf);
 static void set_font_mode(void);
 static void set_normal_mode(void);
 static void set_destructive_cursor(scr_stat *scp);
@@ -332,14 +337,10 @@
     c |= KBD_OVERRIDE_KBD_LOCK;
 #endif
 
-    /*
-     * enable the keyboard port, but disable the keyboard intr. 
-     * the aux port (mouse port) is disabled too.
-     */
+    /* enable the keyboard port, but disable the keyboard intr. */
     if (!set_controller_command_byte(sc_kbdc,
-            KBD_KBD_CONTROL_BITS | KBD_AUX_CONTROL_BITS,
-            KBD_ENABLE_KBD_PORT | KBD_DISABLE_KBD_INT
-                | KBD_DISABLE_AUX_PORT | KBD_DISABLE_AUX_INT)) {
+            KBD_KBD_CONTROL_BITS, 
+            KBD_ENABLE_KBD_PORT | KBD_DISABLE_KBD_INT)) {
 	/* CONTROLLER ERROR 
 	 * there is very little we can do...
 	 */
@@ -411,8 +412,8 @@
     }
     /* enable the keyboard port and intr. */
     if (!set_controller_command_byte(sc_kbdc, 
-            KBD_KBD_CONTROL_BITS | KBD_AUX_CONTROL_BITS | KBD_OVERRIDE_KBD_LOCK,
-	    (c & (KBD_AUX_CONTROL_BITS | KBD_OVERRIDE_KBD_LOCK))
+            KBD_KBD_CONTROL_BITS | KBD_TRANSLATION | KBD_OVERRIDE_KBD_LOCK,
+	    (c & (KBD_TRANSLATION | KBD_OVERRIDE_KBD_LOCK))
 	        | KBD_ENABLE_KBD_PORT | KBD_ENABLE_KBD_INT)) {
 	/* CONTROLLER ERROR 
 	 * This is serious; we are left with the disabled keyboard intr. 
@@ -468,7 +469,7 @@
 				     M_DEVBUF, M_NOWAIT);
 
     /* copy temporary buffer to final buffer */
-    bcopyw(sc_buffer, scp->scr_buf, scp->xsize * scp->ysize * sizeof(u_short));
+    bcopy(sc_buffer, scp->scr_buf, scp->xsize * scp->ysize * sizeof(u_short));
 
     scp->cursor_pos = scp->cursor_oldpos =
 	scp->scr_buf + scp->xpos + scp->ypos * scp->xsize;
@@ -494,6 +495,19 @@
 
     update_leds(scp->status);
 
+    if (bootverbose) {
+        printf("sc%d: BIOS video mode:%d\n", 
+	    dev->id_unit, *(u_char *)pa_to_va(0x449));
+        printf("sc%d: VGA registers upon power-up\n", dev->id_unit);
+        dump_vgaregs(vgaregs);
+        printf("sc%d: video mode:%d\n", dev->id_unit, scp->mode);
+        if (video_mode_ptr != NULL) {
+            printf("sc%d: VGA registers for mode:%d\n", 
+		dev->id_unit, scp->mode);
+            dump_vgaregs(video_mode_ptr + (64*scp->mode));
+        }
+    }
+
     printf("sc%d: ", dev->id_unit);
     if (crtc_vga)
 	if (crtc_addr == MONO_BASE)
@@ -1472,7 +1486,7 @@
     s = splclock();
     if (scp == cur_console && !(scp->status & UNKNOWN_MODE)) {
 	if (/* timer not running && */ (scp->start <= scp->end)) {
-	    bcopyw(scp->scr_buf + scp->start, Crtat + scp->start,
+	    sc_bcopy(scp->scr_buf + scp->start, Crtat + scp->start,
 		   (1 + scp->end - scp->start) * sizeof(u_short));
 	    scp->start = scp->xsize * scp->ysize;
 	    scp->end = 0;
@@ -1564,7 +1578,7 @@
     if (!scrn_blanked) {
 	/* update screen image */
 	if (scp->start <= scp->end) {
-	    bcopyw(scp->scr_buf + scp->start, Crtat + scp->start,
+	    sc_bcopy(scp->scr_buf + scp->start, Crtat + scp->start,
 		   (1 + scp->end - scp->start) * sizeof(u_short));
 	}
 
@@ -1753,7 +1767,7 @@
 	    if (scp->ypos > 0)
 		move_crsr(scp, scp->xpos, scp->ypos - 1);
 	    else {
-		bcopyw(scp->scr_buf, scp->scr_buf + scp->xsize,
+		bcopy(scp->scr_buf, scp->scr_buf + scp->xsize,
 		       (scp->ysize - 1) * scp->xsize * sizeof(u_short));
 		fillw(scp->term.cur_color | scr_map[0x20],
 		      scp->scr_buf, scp->xsize);
@@ -1906,7 +1920,7 @@
 	    src = scp->scr_buf + scp->ypos * scp->xsize;
 	    dst = src + n * scp->xsize;
 	    count = scp->ysize - (scp->ypos + n);
-	    bcopyw(src, dst, count * scp->xsize * sizeof(u_short));
+	    bcopy(src, dst, count * scp->xsize * sizeof(u_short));
 	    fillw(scp->term.cur_color | scr_map[0x20], src,
 		  n * scp->xsize);
 	    mark_for_update(scp, scp->ypos * scp->xsize);
@@ -1920,7 +1934,7 @@
 	    dst = scp->scr_buf + scp->ypos * scp->xsize;
 	    src = dst + n * scp->xsize;
 	    count = scp->ysize - (scp->ypos + n);
-	    bcopyw(src, dst, count * scp->xsize * sizeof(u_short));
+	    bcopy(src, dst, count * scp->xsize * sizeof(u_short));
 	    src = dst + count * scp->xsize;
 	    fillw(scp->term.cur_color | scr_map[0x20], src,
 		  n * scp->xsize);
@@ -1935,7 +1949,7 @@
 	    dst = scp->cursor_pos;
 	    src = dst + n;
 	    count = scp->xsize - (scp->xpos + n);
-	    bcopyw(src, dst, count * sizeof(u_short));
+	    bcopy(src, dst, count * sizeof(u_short));
 	    src = dst + count;
 	    fillw(scp->term.cur_color | scr_map[0x20], src, n);
 	    mark_for_update(scp, scp->cursor_pos - scp->scr_buf);
@@ -1949,7 +1963,7 @@
 	    src = scp->cursor_pos;
 	    dst = src + n;
 	    count = scp->xsize - (scp->xpos + n);
-	    bcopyw(src, dst, count * sizeof(u_short));
+	    bcopy(src, dst, count * sizeof(u_short));
 	    fillw(scp->term.cur_color | scr_map[0x20], src, n);
 	    mark_for_update(scp, scp->cursor_pos - scp->scr_buf);
 	    mark_for_update(scp, scp->cursor_pos - scp->scr_buf + n + count);
@@ -1959,7 +1973,7 @@
 	    n = scp->term.param[0]; if (n < 1)  n = 1;
 	    if (n > scp->ysize)
 		n = scp->ysize;
-	    bcopyw(scp->scr_buf + (scp->xsize * n),
+	    bcopy(scp->scr_buf + (scp->xsize * n),
 		   scp->scr_buf,
 		   scp->xsize * (scp->ysize - n) * sizeof(u_short));
 	    fillw(scp->term.cur_color | scr_map[0x20],
@@ -1972,7 +1986,7 @@
 	    n = scp->term.param[0]; if (n < 1)  n = 1;
 	    if (n > scp->ysize)
 		n = scp->ysize;
-	    bcopyw(scp->scr_buf,
+	    bcopy(scp->scr_buf,
 		  scp->scr_buf + (scp->xsize * n),
 		  scp->xsize * (scp->ysize - n) *
 		  sizeof(u_short));
@@ -2342,14 +2356,14 @@
     if (scp->cursor_pos >= scp->scr_buf + scp->ysize * scp->xsize) {
 	remove_cutmarking(scp);
 	if (scp->history) {
-	    bcopyw(scp->scr_buf, scp->history_head,
+	    bcopy(scp->scr_buf, scp->history_head,
 		   scp->xsize * sizeof(u_short));
 	    scp->history_head += scp->xsize;
 	    if (scp->history_head + scp->xsize >
 		scp->history + scp->history_size)
 		scp->history_head = scp->history;
 	}
-	bcopyw(scp->scr_buf + scp->xsize, scp->scr_buf,
+	bcopy(scp->scr_buf + scp->xsize, scp->scr_buf,
 	       scp->xsize * (scp->ysize - 1) * sizeof(u_short));
 	fillw(scp->term.cur_color | scr_map[0x20],
 	      scp->scr_buf + scp->xsize * (scp->ysize - 1),
@@ -2431,6 +2445,7 @@
 	u_long  segoff;
 
 	crtc_vga = TRUE;
+	read_vgaregs(vgaregs);
 
 	/* Get the BIOS video mode pointer */
 	segoff = *(u_long *)pa_to_va(0x4a8);
@@ -2447,8 +2462,14 @@
     init_scp(console[0]);
     cur_console = console[0];
 
+    /* discard the video mode table if we are not familiar with it... */
+    if (video_mode_ptr) {
+        if (comp_vgaregs(vgaregs, video_mode_ptr + 64*console[0]->mode)) 
+            video_mode_ptr = NULL;
+    }
+
     /* copy screen to temporary buffer */
-    bcopyw(Crtat, sc_buffer,
+    sc_bcopy(Crtat, sc_buffer,
 	   console[0]->xsize * console[0]->ysize * sizeof(u_short));
 
     console[0]->scr_buf = console[0]->mouse_pos = sc_buffer;
@@ -2577,7 +2598,7 @@
     int i;
 
     for (i=0; i<scp->ysize; i++)
-	bcopyw(scp->history + (((scp->history_pos - scp->history) +
+	bcopy(scp->history + (((scp->history_pos - scp->history) +
 	       scp->history_size-((i+1)*scp->xsize))%scp->history_size),
 	       scp->scr_buf + (scp->xsize * (scp->ysize-1 - i)),
 	       scp->xsize * sizeof(u_short));
@@ -2759,7 +2780,7 @@
 
 	    /* copy screen into top of history buffer */
 	    for (i=0; i<cur_console->ysize; i++) {
-		bcopyw(cur_console->scr_buf + (cur_console->xsize * i),
+		bcopy(cur_console->scr_buf + (cur_console->xsize * i),
 		       cur_console->history_head,
 		       cur_console->xsize * sizeof(u_short));
 		cur_console->history_head += cur_console->xsize;
@@ -2941,7 +2962,7 @@
 			    u_short *ptr = cur_console->history_save;
 
 			    for (i=0; i<cur_console->ysize; i++) {
-				bcopyw(ptr,
+				bcopy(ptr,
 				       cur_console->scr_buf +
 				       (cur_console->xsize*i),
 				       cur_console->xsize * sizeof(u_short));
@@ -3110,11 +3131,12 @@
 
     /* disable the keyboard and mouse interrupt */
     s = spltty();
+#if 0
     c = get_controller_command_byte(sc_kbdc);
     if ((c == -1) 
 	|| !set_controller_command_byte(sc_kbdc, 
             kbdc_get_device_mask(sc_kbdc),
-            KBD_ENABLE_KBD_PORT | KBD_DISABLE_KBD_INT
+            KBD_DISABLE_KBD_PORT | KBD_DISABLE_KBD_INT
                 | KBD_DISABLE_AUX_PORT | KBD_DISABLE_AUX_INT)) {
 	/* CONTROLLER ERROR */
         kbdc_lock(sc_kbdc, FALSE);
@@ -3129,15 +3151,21 @@
      * by the lock flag set via `kbdc_lock()'
      */
     splx(s);
+#endif
 
-    send_kbd_command_and_data(sc_kbdc, command, data);
+    if (send_kbd_command_and_data(sc_kbdc, command, data) != KBD_ACK)
+        send_kbd_command(sc_kbdc, KBDC_ENABLE_KBD);
 
+#if 0
     /* restore the interrupts */
     if (!set_controller_command_byte(sc_kbdc,
             kbdc_get_device_mask(sc_kbdc),
 	    c & (KBD_KBD_CONTROL_BITS | KBD_AUX_CONTROL_BITS))) { 
 	/* CONTROLLER ERROR */
     }
+#else
+    splx(s);
+#endif
     kbdc_lock(sc_kbdc, FALSE);
 }
 
@@ -3169,22 +3197,22 @@
     /* setup video hardware for the given mode */
     switch (scp->mode) {
     case M_VGA_M80x60:
-	bcopyw(video_mode_ptr+(64*M_VGA_M80x25), &special_modetable, 64);
+	bcopy(video_mode_ptr+(64*M_VGA_M80x25), &special_modetable, 64);
 	goto special_80x60;
 
     case M_VGA_C80x60:
-	bcopyw(video_mode_ptr+(64*M_VGA_C80x25), &special_modetable, 64);
+	bcopy(video_mode_ptr+(64*M_VGA_C80x25), &special_modetable, 64);
 special_80x60:
 	special_modetable[2]  = 0x08;
 	special_modetable[19] = 0x47;
 	goto special_480l;
 
     case M_VGA_M80x30:
-	bcopyw(video_mode_ptr+(64*M_VGA_M80x25), &special_modetable, 64);
+	bcopy(video_mode_ptr+(64*M_VGA_M80x25), &special_modetable, 64);
 	goto special_80x30;
 
     case M_VGA_C80x30:
-	bcopyw(video_mode_ptr+(64*M_VGA_C80x25), &special_modetable, 64);
+	bcopy(video_mode_ptr+(64*M_VGA_C80x25), &special_modetable, 64);
 special_80x30:
 	special_modetable[19] = 0x4f;
 special_480l:
@@ -3199,21 +3227,21 @@
 	goto setup_mode;
 
     case M_ENH_B80x43:
-	bcopyw(video_mode_ptr+(64*M_ENH_B80x25), &special_modetable, 64);
+	bcopy(video_mode_ptr+(64*M_ENH_B80x25), &special_modetable, 64);
 	goto special_80x43;
 
     case M_ENH_C80x43:
-	bcopyw(video_mode_ptr+(64*M_ENH_C80x25), &special_modetable, 64);
+	bcopy(video_mode_ptr+(64*M_ENH_C80x25), &special_modetable, 64);
 special_80x43:
 	special_modetable[28] = 87;
 	goto special_80x50;
 
     case M_VGA_M80x50:
-	bcopyw(video_mode_ptr+(64*M_VGA_M80x25), &special_modetable, 64);
+	bcopy(video_mode_ptr+(64*M_VGA_M80x25), &special_modetable, 64);
 	goto special_80x50;
 
     case M_VGA_C80x50:
-	bcopyw(video_mode_ptr+(64*M_VGA_C80x25), &special_modetable, 64);
+	bcopy(video_mode_ptr+(64*M_VGA_C80x25), &special_modetable, 64);
 special_80x50:
 	special_modetable[2] = 8;
 	special_modetable[19] = 7;
@@ -3316,6 +3344,86 @@
 }
 
 static void
+read_vgaregs(char *buf)
+{
+    int i, j;
+    int s;
+
+    bzero(buf, 64);
+
+    s = splhigh();
+
+    outb(TSIDX, 0x00); outb(TSREG, 0x01);   	/* stop sequencer */
+    outb(TSIDX, 0x07); outb(TSREG, 0x00);   	/* unlock registers */
+    for (i=0, j=5; i<4; i++) {           
+	outb(TSIDX, i+1);
+	buf[j++] = inb(TSREG);
+    }
+    buf[9] = inb(MISC + 10);      		/* dot-clock */
+    outb(TSIDX, 0x00); outb(TSREG, 0x03);   	/* start sequencer */
+
+    for (i=0, j=10; i<25; i++) {       		/* crtc */
+	outb(crtc_addr, i);
+	buf[j++] = inb(crtc_addr+1);
+    }
+    for (i=0, j=35; i<20; i++) {          	/* attribute ctrl */
+        inb(crtc_addr+6);           		/* reset flip-flop */
+	outb(ATC, i);
+	buf[j++] = inb(ATC + 1);
+    }
+    for (i=0, j=55; i<9; i++) {           	/* graph data ctrl */
+	outb(GDCIDX, i);
+	buf[j++] = inb(GDCREG);
+    }
+    inb(crtc_addr+6);           		/* reset flip-flop */
+    outb(ATC, 0x20);            		/* enable palette */
+
+    buf[0] = *(char *)pa_to_va(0x44a);		/* COLS */
+    buf[1] = *(char *)pa_to_va(0x484);		/* ROWS */
+    buf[2] = *(char *)pa_to_va(0x485);		/* POINTS */
+    buf[3] = *(char *)pa_to_va(0x44c);
+    buf[4] = *(char *)pa_to_va(0x44d);
+
+    splx(s);
+}
+
+static int 
+comp_vgaregs(u_char *buf1, u_char *buf2)
+{
+    int i;
+
+    for(i = 0; i < 20; ++i) {
+	if (*buf1++ != *buf2++)
+	    return 1;
+    }
+    buf1 += 2;  /* skip the cursor shape */
+    buf2 += 2;
+    for(i = 22; i < 24; ++i) {
+	if (*buf1++ != *buf2++)
+	    return 1;
+    }
+    buf1 += 2;  /* skip the cursor position */
+    buf2 += 2;
+    for(i = 26; i < 64; ++i) {
+	if (*buf1++ != *buf2++)
+	    return 1;
+    }
+    return 0;
+}
+
+static void
+dump_vgaregs(u_char *buf)
+{
+    int i;
+
+    for(i = 0; i < 64;) {
+	printf("%02x ", buf[i]);
+	if ((++i % 16) == 0)
+	    printf("\n");
+    }
+}
+
+static void
 set_font_mode()
 {
     int s = splhigh();
@@ -3387,6 +3495,9 @@
 	modetable = video_mode_ptr + (64*M_VGA_C80x25);
     }
 
+    if (video_mode_ptr == NULL)
+	modetable = vgaregs;
+
     /* setup vga for normal operation mode again */
     inb(crtc_addr+6);           		/* reset flip-flop */
     outb(ATC, 0x10); outb(ATC, modetable[0x10+35]);
@@ -3481,19 +3592,19 @@
 
     if (scp->status & MOUSE_VISIBLE) {
 	if ((scp->cursor_saveunder & 0xff) == 0xd0)
-    	    bcopyw(&scp->mouse_cursor[0], cursor, scp->font_size);
+    	    bcopy(&scp->mouse_cursor[0], cursor, scp->font_size);
 	else if ((scp->cursor_saveunder & 0xff) == 0xd1)
-    	    bcopyw(&scp->mouse_cursor[32], cursor, scp->font_size);
+    	    bcopy(&scp->mouse_cursor[32], cursor, scp->font_size);
 	else if ((scp->cursor_saveunder & 0xff) == 0xd2)
-    	    bcopyw(&scp->mouse_cursor[64], cursor, scp->font_size);
+    	    bcopy(&scp->mouse_cursor[64], cursor, scp->font_size);
 	else if ((scp->cursor_saveunder & 0xff) == 0xd3)
-    	    bcopyw(&scp->mouse_cursor[96], cursor, scp->font_size);
+    	    bcopy(&scp->mouse_cursor[96], cursor, scp->font_size);
 	else
-	    bcopyw(font_buffer+((scp->cursor_saveunder & 0xff)*scp->font_size),
+	    bcopy(font_buffer+((scp->cursor_saveunder & 0xff)*scp->font_size),
  	       	   cursor, scp->font_size);
     }
     else
-    	bcopyw(font_buffer + ((scp->cursor_saveunder & 0xff) * scp->font_size),
+    	bcopy(font_buffer + ((scp->cursor_saveunder & 0xff) * scp->font_size),
  	       cursor, scp->font_size);
     for (i=0; i<32; i++)
 	if ((i >= scp->cursor_start && i <= scp->cursor_end) ||
@@ -3503,7 +3614,7 @@
     while (!(inb(crtc_addr+6) & 0x08)) /* wait for vertical retrace */ ;
 #endif
     set_font_mode();
-    bcopy(cursor, (char *)pa_to_va(address) + DEAD_CHAR * 32, 32);
+    sc_bcopy(cursor, (char *)pa_to_va(address) + DEAD_CHAR * 32, 32);
     set_normal_mode();
 }
 
@@ -3630,13 +3741,13 @@
     yoffset = scp->mouse_ypos % font_size;
 
     /* prepare mousepointer char's bitmaps */
-    bcopyw(font_buffer + ((*(scp->mouse_pos) & 0xff) * font_size),
+    bcopy(font_buffer + ((*(scp->mouse_pos) & 0xff) * font_size),
 	   &scp->mouse_cursor[0], font_size);
-    bcopyw(font_buffer + ((*(scp->mouse_pos+1) & 0xff) * font_size),
+    bcopy(font_buffer + ((*(scp->mouse_pos+1) & 0xff) * font_size),
 	   &scp->mouse_cursor[32], font_size);
-    bcopyw(font_buffer + ((*(scp->mouse_pos+scp->xsize) & 0xff) * font_size),
+    bcopy(font_buffer + ((*(scp->mouse_pos+scp->xsize) & 0xff) * font_size),
 	   &scp->mouse_cursor[64], font_size);
-    bcopyw(font_buffer + ((*(scp->mouse_pos+scp->xsize+1) & 0xff) * font_size),
+    bcopy(font_buffer + ((*(scp->mouse_pos+scp->xsize+1) & 0xff) * font_size),
 	   &scp->mouse_cursor[96], font_size);
     for (i=0; i<font_size; i++) {
 	buffer[i] = scp->mouse_cursor[i]<<8 | scp->mouse_cursor[i+32];
@@ -3663,7 +3774,7 @@
     while (!(inb(crtc_addr+6) & 0x08)) /* idle */ ;
 #endif
     set_font_mode();
-    bcopy(scp->mouse_cursor, (char *)pa_to_va(address) + 0xd0 * 32, 128);
+    sc_bcopy(scp->mouse_cursor, (char *)pa_to_va(address) + 0xd0 * 32, 128);
     set_normal_mode();
     *(crt_pos) = (*(scp->mouse_pos)&0xff00)|0xd0;
     *(crt_pos+scp->xsize) = (*(scp->mouse_pos+scp->xsize)&0xff00)|0xd2;
@@ -3798,8 +3909,12 @@
 {
     static int toggle = 0;
     static u_char save_mode;
-    int s = splhigh();
+    int s;
+
+    if (video_mode_ptr == NULL)
+	return;
 
+    s = splhigh();
     if (toggle) {
 	scp->mode = save_mode;
 	scp->status &= ~UNKNOWN_MODE;