Skip to contentSkip to conversation

tty canonical mode: nicer erase behaviour

PATCH In review [email protected] 4 participants 6 messages Sep 23, 2001 – Sep 24, 2001

lore
Share & tools
lore
#0 lore raw
Quoted 3 lines · Alan Cox

Your xterm is not following Linux policy - this is a solved problem in Linuxspace. Debian bit the bullet a few years ago and did the neccessary deed to make all their terminal emulators and console match.

So Linux policy is to support only terminals that generate ^? for backspace? I thought Unix-like systems were supposed to be usable from a great variety of text terminals. Debian's policy works when your universe consists solely of Linux machines configured to Debian specifications, where your terminals are just the Linux console, xterm and screen, but it fails to handle glass ttys, or xterms running on other systems.

I recall the reaction when someone proposed changing zsh's line editor (ZLE) to treat backspace and delete characters differently. Just among the developers we have users of a wide variety of terminals, and the proposed change would have broken the line editor for many of us. As it is, ZLE just works, with no extra effort, on any text terminal, and we get no complaints.

Quoted 3 lines

Original telnet has
IAC sequences to send a "delete" regardless of keymapping policies that are not known at end points.

Yes, it was a nice model, a pity it fell out of use. Telnet defined a Network Virtual Terminal, that was intended to be a common terminal type to be emulated on all Telnet sessions, which would have eliminated the need for the server to know what terminal type was being used on the client end. Of course, the NVT was a product of its time: no cursor addressing, no display attributes, and on the input side only a single erase key. The closest equivalent to this model that is currently in use is the de facto almost-universal capability to emulate a VT100.

These days telnet connections (and rsh and ssh) are used more as dumb pipes to talk to the user's actual terminal. We can't change that, and the result is that Unix systems have to handle whatever terminal type the user is using.

-zefram

#1 lore raw
Quoted 3 lines

proposed change would have broken the line editor for many of us. As it is, ZLE just works, with no extra effort, on any text terminal, and we get no complaints.

And bash treats the two delete keys differently - something a similarly religious group believe to be the right thing to do

Quoted 3 lines

pipes to talk to the user's actual terminal. We can't change that, and the result is that Unix systems have to handle whatever terminal type the user is using.

Which is why they have termcap, terminfo, and x keyboard maps. The kernel is not there to cover up for usermode programmers inability to get things right. It has enough to do covering up for the hardware folk

Alan

#2 lore raw
Quoted 3 lines · Alan Cox

Which is why they have termcap, terminfo, and x keyboard maps. The kernel is not there to cover up for usermode programmers inability to get things right.

Aha, I believe I now see a substantive difference of opinion. You argue that the tty line discipline depends on being configured for the terminal by usermode code, and that it should remain so, whereas I am proposing that it adopt a strategy with some additional logic so that it doesn't require usermode configuration. Please correct me if this is not a fair representation of your position. I'm now going to switch from correcting inaccurate statements to an attempt to persuade you on this underlying disagreement.

Most of the tty's control characters are perfectly simple user choices. The user can sensibly choose to use ^R or ^L to invoke the REPRINT function, or indeed not to have any such control character, and such choices can be executed by a very simple invocation of stty. This kind of choice is not affected by what terminal the user is using, because the ^R or whatever keystroke is just the same on any terminal. This kind of choice extends to the ERASE character, provided that the user is picking something like the traditional #. But uniquely among the tty control characters, the most commonly desired setting for ERASE is not a particular character, but rather "whatever my backspace key sends".

Theoretically, a user could set up the ERASE key to whatever their backspace key sends by doing "stty erase $(echotc kd)". In practice this doesn't work nearly as well as it should -- it relies on having echotc, and on the terminfo database being sufficiently complete and accurate for the current terminal, which is made particularly difficult by things like the xterm variations previously mentioned. It is true that this is principally a usermode problem, and indeed I would like to see the usermode improvements that would make this a viable solution.

However, this usermode approach, of using terminfo, seems out of character with the tty canonical mode code. In every other aspect, it is terminal-independent. For output, the only control characters it uses are ^G, ^M, ^J and ^H, which behave the same way on pretty much any terminal. (Actually, because of this policy of using only terminal-independent control characters, backspacing past a line wrap doesn't display correctly on most terminals.) For input, with the default control character settings, the only special keys used are Return and Backspace.

When handling the Return key, under default settings, the tty line discipline accepts both ^M and ^J as indicating the end of the line. (Actually, internally it translates ^M to ^J.) This allows for some variation in terminal behaviour and in translations that might occur before the input gets to the tty. The internal translation can be turned off or modified, but the particular characters that can be accepted are hardcoded, and the default behaviour is to accept both.

What I propose is that this manner of handling the Return key -- accepting both possible characters that can result from the key, without requiring usermode configuration to tell it which one to use -- be extended to the Backspace key when used for its normal function. (Obviously the mechanism is a little different, since the ERASE character is more configurable than the end-of-line character.) By doing this, the tty line discipline code would become fully terminal-independent under its default settings, which seems a worthwhile goal for a program that is so nearly there already.

I accept that we have here an issue about which reasonable people can disagree, and so if the disagreement now persists then I don't intend to pursue it much further in this forum.

-zefram

#3 lore raw

PATCH 1/1 Enable SSE on K7's with old/broken BIOS's.

In reply to Alan Cox

Linus, Alan..

Please consider applying the attached patch to the mainstream kernel(s). It enables SSE support on Athlon4/MP/XP (later model) Athlon's if the BIOS does not. This is done by zero-ing bit 15 of the Athlon's HWCR. The patch has been tested for a few days by me and a few other people with AthlonMP's and Athlon4's, with no negative reports.

It's a very simple patch, please consider applying.

john.c

Signature · 40 lines
John Clemens          http://www.deater.net/john
[email protected]     ICQ: 7175925, IM: PianoManO8
      "I Hate Quotes" -- Samuel L. Clemens

diff -u --recursive linux-orig/arch/i386/kernel/setup.c linux/arch/i386/kernel/setup.c
--- linux-orig/arch/i386/kernel/setup.c	Wed Sep 19 22:49:11 2001
+++ linux/arch/i386/kernel/setup.c	Fri Sep 21 01:23:22 2001
@@ -1272,6 +1272,21 @@

 		case 6:	/* An Athlon/Duron. We can trust the BIOS probably */
 			mcheck_init(c);
+
+	                /* Bit 15 of Athlon specific MSR 15, needs to be 0
+			 * to enable SSE on Palomino/Morgan CPU's.
+			 * If the BIOS didn't enable it already, enable it
+			 * here.
+			 */
+			if (c->x86_model == 6 || c->x86_model == 7) {
+				if (!test_bit(X86_FEATURE_XMM, &c->x86_capability)) {
+					printk(KERN_INFO "Enabling K7/SSE support, since BIOS did not\n");
+				        rdmsr(MSR_K7_HWCR, l, h);
+				        l &= ~0x00008000;
+					wrmsr(MSR_K7_HWCR, l, h);
+					set_bit(X86_FEATURE_XMM, &c->x86_capability);
+				}
+			}
 			break;
 	}

diff -u --recursive linux-orig/include/asm-i386/msr.h linux/include/asm-i386/msr.h
--- linux-orig/include/asm-i386/msr.h	Wed Sep 19 22:49:27 2001
+++ linux/include/asm-i386/msr.h	Wed Sep 19 22:57:32 2001
@@ -81,6 +81,7 @@

 #define MSR_K7_EVNTSEL0			0xC0010000
 #define MSR_K7_PERFCTR0			0xC0010004
+#define MSR_K7_HWCR			0xC0010015

 /* Centaur-Hauls/IDT defined MSRs. */
 #define MSR_IDT_FCR1			0x107
#4 lore raw

Re: [PATCH] Enable SSE on K7's with old/broken BIOS's.

Quoted 4 lines

It enables SSE support on Athlon4/MP/XP (later model) Athlon's if the BIOS does not. This is done by zero-ing bit 15 of the Athlon's HWCR. The patch has been tested for a few days by me and a few other people with AthlonMP's and Athlon4's, with no negative reports.

Please submit it via Dave Jones <[email protected]>. He is the keeper of most of the setup code and also has Athlon bios info and contacts with AMD for stuff

#5 lore raw
In reply to [email protected]
Quoted 7 lines · On Sun, 23 Sep 2001 [email protected] wrote:
Quoted 3 lines · Alan Cox

Your xterm is not following Linux policy - this is a solved problem in Linuxspace. Debian bit the bullet a few years ago and did the neccessary deed to make all their terminal emulators and console match.

So Linux policy is to support only terminals that generate ^? for backspace?

No.

Linux supports everything. Try doing a "man stty".

But the default behaviour is ^?, which makes emacs happy, and also happens to be the default mode for most real vt100 terminals out there.

If you have a terminal that really really wants ^H, just do

stty erase ^H

and Linux will happily believe you.

Linus