Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 16 Jan 1995 01:26:09 -0500
From:      Wankle Rotary Engine <wpaul@skynet.ctr.columbia.edu>
To:        freebsd-hackers@FreeBSD.org
Subject:   serial consoles and keyboard probes
Message-ID:  <199501160626.BAA03730@skynet.ctr.columbia.edu>

next in thread | raw e-mail | index | archive | help

Greetings:

At one point I suggested making it possible to allow people to install
FreeBSD on a system with only a dumb terminal on a serial port as a
console. Today, I finally took a look at the serialboot code and I
think I've found a way to make this idea work. However, I've encountered
one snag which I'm hoping some of you guys can help me with. First, a
bit on what I have managed to do.

The problem with the existing COMCONSOLE setup is that the only way
to use a serial port as a console is to make a custom kernel with the
COMCONSOLE option enabled and install a special boot block. Essentially
this means you can have it one way or the other: you can't use just
one kernel and boot block to do both.

Unfortunately, using one kernel and boot block to do both is exactly
what's required. So, to that end, I've made the following hacks:

- Merged biosboot and serialboot -- the keyboard i/o routines and the
  serial port i/o routines are contained in the same boot block: putchar()
  writes to both the serial port and the standard graphics display, and
  getchar() can be told to read either from the serial port of the
  PC's keyboard.

- Modified the bootblock's gets() function to check for keystrokes on both
  the keyboard and the serial port. Whichever you type with first gets
  precedence (more on this in a bit).

- Added another boot flag ('-h') and coresponding definition to
  <sys/reboot.h>. The definition is RB_SERIAL (0x1000). The -h
  stands for 'Hardwired terminal.' With the -h flag, you can force
  the kernel to boot in 'serial console' mode even if you're typing
  from the PC's keyboard. The -h switch is really somewhat redundant,
  but since all the other RB_ flags have switches associated with
  them I thought I'd be consistent.

- Modified /sys/i386/isa/sio.c to do away with the COMCONSOLE option
  entirely. The kernel will give COM1 priority as a console device if
  the RB_SERIAL flag is set in the boothowto word instead.

- /sys/i386/boot/serialboot now contains just a Makefile which
  differs from the biosboot Makefile only in that it specifies a special
  compile-time option: -DFORCE_SERIAL. This can be used to create a
  boot block that gives precedence to the serial port over the keyboard,
  instead of the other way around.

This last bit is the part that I could use some help with. The way I
have things working now, the following things happen:

- The boot block prints its usual banner message and prompt to both the
  VGA display and the serial port.

- It then waits for the user to press a key on either the serial port or
  the keyboard. Whichever one generates a character first gets precedence;
  a flag is set if input comes from the serial port.

- If the 'serial' flag is set, the RB_SERIAL bit in the 'howto' word is
  set, and this is then passed to the kernel.

- If the kernel sees that the RB_SERIAL bit is set, COM1 is given priority
  as a console, and it becomes the console device. If the RB_SERIAL flag
  isn't set, the VGA display is used as the console as usual.

The only problem with this is autobooting: with the default boot block I
have now, the 'serial' flag is cleared by default, which means the VGA
display is assumed to be the console device. If the user types nothing
and the timeout expires, the system will boot in 'VGA console' mode. The
ony way to have it boot in 'serial console' mode by default is to change
the boot block. I consider this to be a less than optimal solution.

Sun workstations get around this problem by checking for the presence
of a keyboard. If you unplug the keyboard, the system will use serial
port A as the console (I believe you can specify a different port, but
A is the factory default). With PCs, things are a little different: if
you just unplug the keyboard, the system won't boot: you have to go
into the CMOS configuration menu and set the keyboard to 'not installed'
in order to bypass the keyboard probe. (This is how my system works
at least; I'm pretty sure this is true of most PC/AT BIOSes.)

What I need to know is this:

- Is there a way to read the 'keyboard installed/not installed' flag
  from the CMOS configuration, or is there some probe routine in the
  BIOS that would allow you to reliably detect the presence or absence
  of the keyboard?

This would provide an ideal mechanism for chosing the default console
device: if the user unplugs the keyboard, then the serial port is assumed
to be the console device (the 'serial' flag is set by default instead
of cleared) and autobooting would work as expected. This in turn would
make it possible to support using either the VGA display or a serial port
as a console without requiring any code changes, which is what I'm after.
(If I can't get 2.1 installed on my office system using just a dumb
terminal, I'll be very upset. :)

So, anyone have any ideas? I'm hoping to save myself a trip to Columbia's
engineering library.

-Bill

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~T~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-Bill Paul            (212) 854-6020 | System Manager
Work:         wpaul@ctr.columbia.edu | Center for Telecommunications Research
Home:  wpaul@skynet.ctr.columbia.edu | Columbia University, New York City
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The Møøse Illuminati: ignore it and be confused, or join it and be confusing!
~~~~~~~~ FreeBSD 2.1.0-Development #0: Fri Jan 13 22:04:07 EST 1995 ~~~~~~~~~



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199501160626.BAA03730>