boot2/loader: serial port handling

From: Xin Li <delphij_at_delphij.net>
Date: Fri, 12 Oct 2012 16:30:11 -0700
Hi,

We have some rather hacky quick hack at $WORK that addresses a problem
we have found with boot2/loader and wants to share it and see if we can
have more neat solution.

Here is the problem: the current boot2 and loader have various places
where it considers serial port to exist.  When the port is not there,
the code would hang because it tests whether the hardware's -READY bit,
basically something like:

	do {
	} while (inpb(state register) & READY_BIT);

This unfortunately would enter an infinite loop when the device is not
present -- all in operations would get all bits set.

To reproduce this, one can compile boot2/loader with non-existent port
and the system will hang at very early stage of boot.

---

Because boot2 is size constrained we can not use very sophisticated
detection logic there, what I did is to use something like:

	outb(line control register, word)
	if (inb(line control register) != word)
		Disable the serial port read/write

For loader I'm not sure if we should use better detection logic.  By the
way, it seems that the system may force using the default console in
loader regardless if the detection logic said no, if it decides that's
the only usable one.

So what would be the right way to solve these issue?

Cheers,
-- 
Xin LI <delphij_at_delphij.net>    https://www.delphij.net/
FreeBSD - The Power to Serve!           Live free or die

Received on Fri Oct 12 2012 - 21:30:26 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:40:31 UTC