Hercules text mode not restored exiting from X11

Hercules text mode not restored exiting from X11

Post by Alan Robins » Tue, 15 Jun 1993 07:53:13

I am running X11 on a system with a Hercules Monochrome Graphics card.
Unfortunately when exiting X text mode is not restored resulting in a blank
screen. I have to reboot to get the proper mode. I recall seeing something
on this a couple of months back but I wasn't running X11 at that time and
didn't save it. Does anyone know how to solve this problem. BTW I am running
Xfree386 mono from the Feb SLS release.


The Cellar BBS - (215) 539-3043


Hercules text mode not restored exiting from X11

Post by Gerhard Kirch » Wed, 16 Jun 1993 20:42:33

I came across the following patch some months ago
(I don't know if it patches cleanly into todays kernels)


---------- begin forwarded message ---------
Newsgroups: comp.os.linux,comp.windows.x.i386unix
Status: OR

Xref: email comp.os.linux:29932 comp.windows.x.i386unix:778
Newsgroups: comp.os.linux,comp.windows.x.i386unix
Path: email!news.univie.ac.at!paladin.american.edu!howland.reston.ans.net!usc!rpi!batcomputer!munnari.oz.au!bruce.cs.monash.edu.au!monu6!vaxc.cc.monash.edu.au!apm233m

Subject: A fix for Linux XFree86 hga problems

Lines: 85

Organization: Computer Centre, Monash University, Australia
Date: Tue, 2 Mar 1993 13:13:40 GMT


Here is a small patch to the kernel to fix the problems which Hercules
card owners have with XFree86 1.2.  With the patch installed, vt
switching works as advertised and the console is returned to text mode
upon exit from XFree86.

To install the patch, put it in a file (eg "patches"), cd to
where you have put the Linux source (usually /usr/src) and do
"patch < patches". Re-compile the kernel, install the Image, and

Remember that XFree grabs the first vt which is not in use for itself,
therefore to switch back to XFree from another vt you need to switch
to that vt, not the one where you started XFree. On many systems this
will probably be vt #5, in which case Alt-F5 gets you back to XFree.
On my system, I have logins on 6 vts so I have to do Alt-F7.

I have mailed this patch to Linus, so if he approves it may appear in
the next release of the kernel.

Good luck!


------------------- >8  Patches start here  8< -------------------------------
*** linux/kernel/chr_drv/console.c.old  Sun Feb 28 18:13:08 1993
--- linux/kernel/chr_drv/console.c      Tue Mar  2 20:39:32 1993
*** 1356,1361 ****
--- 1380,1422 ----

  static void set_scrmem(int currcons)
+ #define HERCULES
+ #ifdef HERCULES
+   /* This works with XFree86 1.2.
+      It is not clear that this is the best place for the code.
+      It could be extended and made more generally useful if we could
+      determine the actual video mode. It appears that this should be
+      possible on a genuine Hercules card, but I haven't been able to
+      read from any of the required registers on my clone card.
+      This code will not be of much benefit with existing non-X Hercules
+      graphics programs, which are probably not as smart as XFree86 1.2
+      about vt changes. However, new programs which follow the techniques
+      of XFree86 would allow the use of vt changes.
+      */
+       /* This code should work with Hercules and MDA cards. */
+       if (video_type == VIDEO_TYPE_MDA)
+         {
+           if (vcmode == KD_TEXT)
+             {
+               /* Ensure that the card is in text mode. */
+               int     i;
+               static char herc_txt_tbl[12] = {
+                 0x61,0x50,0x52,0x0f,0x19,6,0x19,0x19,2,0x0d,0x0b,0x0c };
+               outb_p(0, 0x3bf);  /* Back to power-on defaults */
+               outb_p(0, 0x3b8);  /* Blank the screen, select page 0, etc */
+               for ( i = 0 ; i < 12 ; i++ )
+                 {
+                   outb_p(i, 0x3b4);
+                   outb_p(herc_txt_tbl[i], 0x3b5);
+                 }
+             }
+ #define BLINKER_ON 0x20
+ #define SCREEN_ON  8
+           /* Make sure that the hardware is not blanked */
+           outb_p(BLINKER_ON | SCREEN_ON, 0x3b8);
+         }
+ #endif HERCULES
        video_mem_start = video_mem_base;
        video_mem_end = video_mem_term;
        origin  = video_mem_start;
------------------- >8  Patches end here  8< -------------------------------
Bill Metzenthen
Mathematics Department
Monash University


1. XF86 2.0 Mono/Hercules does not restore text mode on exit

I've built XF_Mono server with HGC (Hercules) support and it seems to
work while in graphic (i.e. X11) mode. Unfortunately it does NOT switch
back to text mode when exiting X11 (or switching to virtual console).
The screen remains hopelessly blank. The OS I'm using is Linux, pl.14.

Any ideas?

Michal Szymanski


  Al. Ujazdowskie 4                   Voice:    48-22-294011 ext 23
  00-478 Warszawa, POLAND             FAX:      48-22-294967

2. Looking for XServer ...

3. XFree86-1.3 (Hercules): text mode not restored after exit???

4. Linux Counter Update (4151 users registered

5. Text mode doesn't restore properly when exiting X.

6. Minolta Dimage Scan Dual II USB with vuescan

7. How to restore text mode after exiting X??

8. vi for DOS??

9. XF86-4 fails to restore text mode at exit

10. --- text mode restore on X windows exit ??? ---

11. X11 locks up on exit or swithcing to text mode

12. Text screen is not restored after exiting from X-windows

13. X11 mach32 server screws up text video on exit from X11