Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 08 Sep 1996 00:40:14 -0700
From:      Arve Ronning <arver@sn.no>
To:        sos@FreeBSD.org
Cc:        Arve.Ronning@alcatel.no, j@uriah.heep.sax.de, freebsd-hackers@FreeBSD.org, durham@w2xo.pgh.pa.us
Subject:   Re: Support for fixed-scan monitors
Message-ID:  <3232785E.118D@sn.no>
References:  <199609071545.RAA12747@DeepCore.dk>

next in thread | previous in thread | raw e-mail | index | archive | help
Hi Søren, thanx for the prompte response.
sos@FreeBSD.org wrote:
> 
> In reply to Arve Ronning who wrote:
> >
> > What this is all meant to achieve is :
> > 1) if PREFER_MDA is *not* defined, the code is unchanged.
> > 2) if PREFER_MDA is defined and only MDA present, MDA is used.
> > 3) if PREFER_MDA is defined and both MDA and VGA present, MDA is used.
> > 4) if PREFER_MDA is defined and only VGA is present, VGA is used.
> >
> > So, in effect PREFER_MDA does what it says : PREFER MDA over VGA, while the
> > original code does PREFER VGA over MDA.

I will try to defend my views as best I can, but please understand : I'm in no
way an expert of UN*X, drivers, C, or AS. I'm just a fairly ordinary user and
fan of FreeBSD who feels you guys are doing a fine job and who would enjoy
contributing some useful functionality :-).

Without going into too much detail, I think it would be appropriate to explain
the motive behind my patches. I was given this 19" single-scan monitor which
I couldn't use because it burnt out (literally, I tried:) if it was subjected
to the default VGA scan signals. So, in short, I added a MDA/hercules and a
matching monitor, and patched FreeBSD to boot on the MDA. I now had the nice
virtual console functionality on the MDA and could do all work there if I wanted.
I also had the option of using X on the 19"er which was really the point here.
> 
> Hmm I have some old patches lying around for syscons, so that it can
> used both a mda & a vga simultaniously if both are present, priority
> could easily be changed.

Installing MDA *and* VGA in a FreeBSD box is done (I think) for either of two 
reasons :
1)to get two character based (and X?) monitor screens to work on
or
2)because the VGA single-scan monitor can't work with the (current)
  character based drivers

Your old patches would presumably work for 1). However, for 2) some patching
in the boot blocks *would* be required if you want to see the '>>FreeBSD...Boot:'
prompt and use some boot option (like -c).
(I wouldn't want this to be a 'my patches are better than yours' thing though :-).

> If I remember right you can set the PC to boot into whichever you
> want by setting the BIOS to either monochrome og vga. Syscons could
> then take over the device that the BIOS used as default. As I see
> it there is no need to muck with the bootblocks....

With MDA *and* VGA present...Hmm...
Some BIOSes may be able to do that, but the ones I've tried have failed either
by silently resetting the primary to VGA or by not initializing the MDA correctly
on the next power-on boot (I thought my MDA monitor had departed for good, but it
was the silly BIOS. Neither VGA nor MDA worked until I set the BIOS back to VGA,
then *presto* they both worked :). So, for this to be portable between BIOSes,
we'd better do what BIOS should ideally have done for us:).

> 
> > Would you be interested in looking at the patches and give me your opinion ?
> > Do you think there would be any interest in including this in -current ? (or
> > any other version for that matter:).
> 
> Lets have a look at it, I'm mostly for the "dual video card" support, than
> for some specific hacks to the bootblocks & drivers...
> I dont think we need "Yet another kernel option", we have plenty of
> that allready.
> I agree. However my hacks aren't so specific. One of the main goals was to keep
the old functionality and at the same time add something useful. The only reason
for having the PREFER_MDA option is to enable a *fallback* to the old code.
Hopefully my hacks would work on *all* FreeBSD boxes, with (MDA only) or (MDA and VGA)
or (VGA only). However, I use the word _Hopefully_ because you never know with
PC hardware :(.

Maybe a combination would be good, your "dual video card" support in syscons and my
hack in start.S.

> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
> Søren Schmidt               (sos@FreeBSD.org)               FreeBSD Core Team
>                 Even more code to hack -- will it ever end
> ..I'm afraid it won't unless you make it :-). But **please** don't :-).

Regards,     - Arve

Anyway, here are my hacks, patches and cludges :

/sys/i386/isa/syscons.c :
------------------------------------------------------------------------
*** syscons.c.ori       Thu Jun 27 23:39:55 1996
--- syscons.c   Tue Sep  3 22:38:19 1996
***************
*** 1968,1973 ****
--- 1968,1986 ----
       * to CGA_BUF offset. ONLY add the difference since locore.s adds
       * in the remapped offset at the "right" time
       */
+ #ifdef PREFER_MDA
+     cp = Crtat;
+     was = *cp;
+     *cp = (u_short) 0xA55A;
+     if (*cp == 0xA55A) {
+         *cp = was;
+         crtc_addr = MONO_BASE;
+     }
+     else {
+         crtc_addr = COLOR_BASE;
+         Crtat = Crtat + (CGA_BUF-MONO_BUF)/sizeof(u_short);
+     }
+ #else
      was = *cp;
      *cp = (u_short) 0xA55A;
      if (*cp != 0xA55A)
***************
*** 1977,1982 ****
--- 1990,1996 ----
        crtc_addr = COLOR_BASE;
        Crtat = Crtat + (CGA_BUF-MONO_BUF)/sizeof(u_short);
      }
+ #endif /* PREFER_MDA */

      /* extract cursor location */
      outb(crtc_addr, 14);
---------------------------------------------------------------------

/sys/i386/boot/biosboot/Makefile :
----------------------------------------------------------------------
*** Makefile.ori        Mon Jul  1 18:35:36 1996
--- Makefile    Sat Sep  7 00:27:50 1996
***************
*** 12,17 ****
--- 12,20 ----
  CFLAGS+=      -DBOOTSEG=${BOOTSEG} -DBOOTSTACK=${BOOTSTACK}
  CFLAGS+=      -I${.CURDIR} -I${.CURDIR}/../..

+ # prefer MDA over VGA when both are present
+ CFLAGS+=      -DPREFER_MDA
+
  # force usage of serial console instead of keyboard probing
  #CFLAGS+=     -DFORCE_COMCONSOLE

-----------------------------------------------------------------------  

/sys/i386/boot/biosboot/start.S :

*** start.S.ori Sat Sep 30 12:49:28 1995
--- start.S     Sat Sep  7 18:41:23 1996
***************
*** 25,30 ****
--- 25,32 ----
   *
   *    from: Mach, Revision 2.2  92/04/04  11:36:29  rpd
   *    $Id: start.S,v 1.5.8.1 1995/09/30 11:49:28 davidg Exp $
+  *
+  *    Modified 96.01.07, Arve
   */

  /*
***************
*** 60,65 ****
--- 62,68 ----
  PARTSZ=               16      /* each partition table entry is 16 bytes */
  BSDPART=      0xA5    /* value of boot_ind, means bootable partition */
  BOOTABLE=     0x80    /* value of boot_ind, means bootable partition */
+ MDA_SEG=      0xB000  /* MDA regen segment */

        .text

***************
*** 72,77 ****
--- 75,166 ----
        ljmp $0x7c0, $start

  start:
+
+ #ifdef        PREFER_MDA
+       /*
+        * First set up the stack and save %ebx, %ecx and %edx
+        */
+       data32
+       mov     $BOOTSEG, %eax
+       mov     %ax, %ss
+       data32
+       mov     $BOOTSTACK, %esp
+       data32
+       push    %ebx
+       data32
+       push    %ecx
+       data32
+       push    %edx
+       /*
+        * Probe for MDA
+        */
+       data32
+       mov     $MDA_SEG, %eax
+       mov     %ax, %ds
+       data32
+       mov     $0xABCD5AA5, %ecx
+       data32
+       mov     $0x0, %ebx
+       addr32
+       movl    %ecx, %ds:(%ebx)
+       addr32
+       cmpl    %ecx, %ds:(%ebx)
+       data32
+       jne     no_mda
+       /*
+        * MDA is present. Do nothing if it was initialized by BIOS
+        */
+       xor     %eax, %eax
+       mov     %ax, %es
+       data32
+       mov     $0x410, %ebx
+       addr32
+       movb    %es:(%ebx), %al
+       andb    $0x30, %al
+       cmpb    $0x30, %al
+       je      already_mda     /* MDA initialized by BIOS ? */
+                               /* No ! */
+       /*
+        * MDA is present, send message to the BIOS screen (which will
+        * probably be the VGA if present) just to keep the user informed
+        * in case (s)he installed the MDA but forgot to connect the
+        * monochrome monitor.
+        */
+       mov     %cs, %ax
+       mov     %ax, %ds
+       data32
+       mov     $mda, %esi
+       data32
+       call    message
+       /*
+        * Now, talk the BIOS into using the MDA
+        */
+       xor     %eax, %eax
+       addr32
+       orb     $0x30, %es:(%ebx)
+       movb    $0x07, %al
+       int     $0x10                   /* Set video mode 7 */
+       movb    $0x02, %ah
+       xor     %edx, %edx
+       movb    %dl, %bh
+       int     $0x10                   /* Set cursor position 0,0 */
+       movb    $0x01, %ah
+       data32
+       mov     $0x0B0C, %ecx
+       int     $0x10                   /* Set cursor shape */
+ no_mda:
+ already_mda:
+       /*
+        * Clean up
+        */
+       data32
+       pop     %edx
+       data32
+       pop     %ecx
+       data32
+       pop     %ebx
+ #endif        PREFER_MDA
+
        /* set up %ds */
        mov     %cs, %ax
        mov     %ax, %ds
***************
*** 278,283 ****
--- 367,375 ----
  six:  String          "6\r\n\0"
  seven:        String          "7\r\n\0"
  #endif        DEBUG
+ #ifdef        PREFER_MDA
+ mda:  String          "boot1: Console on MDA\r\n\0"
+ #endif
  eread:        String          "Read error\r\n\0"
  enoboot: String               "No bootable partition\r\n\0"
  endofcode:
------------------------------------------------------------------




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3232785E.118D>