Demand paging, the RTL8168H, links that come up late, and Ctrl+Alt+F1..F12

- Anonymous memory can be reserved without being backed: large mappings,
  MAP_NORESERVE and PROT_NONE are recorded and each page appears, zeroed,
  on first touch -- from trap() for the program, from uva2ka() for the
  kernel on its behalf. WebKit reserves 4 GB at start and touches a sliver;
  backing it all failed with ENOMEM and Epiphany aborted.
- r8169: the 8168G generation and later (the laptop's 8168H, XID 541) are
  taken from the firmware's out-of-band mode, get their PLL powered, the
  receive gate opened, and their PHY reached through the OCP window. The
  PHY's power-down bit is cleared; the old code kept it while restarting
  autonegotiation. Untested on the hardware so far.
- The network thread follows each device's link into lwIP. The link was
  read once at attach, 0.02 s into boot; real autonegotiation takes
  seconds, so on hardware the interface stayed down for good.
- Twelve terminals, switched with Ctrl+Alt+F1..F12 by default: the keys X
  uses, so the console and the desktop agree. AltGr+F-key is gone from
  the defaults (chvt -c altgr+F brings it back).
- SO_PASSCRED on Unix sockets, with SCM_CREDENTIALS delivered by recvmsg.
  WebKit sets it on its IPC sockets and aborted when refused.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01S1giNvrHTrPMPw7V6x1kQ4
This commit is contained in:
Nexoniarz 2026-10-25 11:27:48 +01:00
commit 54b25708c3
24 changed files with 4166 additions and 68 deletions

View file

@ -9,19 +9,40 @@
// The chord, settable at run time through VT_SETCHORD.
//
// AltGr+F1..F6 by default. Every other candidate is taken by the host, by
// applications, or by the keyboard layout -- see include/dev/kbd.h -- and AltGr
// with a function key is taken by none of the three: a Polish layout wants
// AltGr+*letter*, which still reaches the shell untouched, and no window
// manager binds AltGr with an F-key.
// Ctrl+Alt+F1..F12 by default, the same keys X switches with. It used to be
// AltGr+F-key, chosen because nothing else claimed it -- but under X the
// server owns the keyboard and only Ctrl+Alt+F-key works, so the console and
// the desktop answered different keys for the same thing.
//
// AltGr+minus and AltGr+equals step to the previous and next terminal on the
// same modifiers, for when you have two and do not care which number they are.
// Ctrl+Alt+minus and Ctrl+Alt+equals step to the previous and next terminal,
// for when you have two and do not care which number they are.
//
// Zero modifiers disables all of it; `chvt N` still works.
uint vt_chord_mods = RALT;
// Zero modifiers disables the chord; `chvt N` still works.
uint vt_chord_mods = CTL | ALT;
uint vt_chord_base = SCAN_F1;
// Which terminal an F-key scancode names: F1..F10 are 0x3B..0x44 and F11 and
// F12 sit apart, at 0x57 and 0x58. -1 for anything else.
static int
fkey_index(uint data)
{
if (data >= SCAN_F1 && data < SCAN_F1 + 10) return (int)(data - SCAN_F1);
if (data == 0x57) return 10;
if (data == 0x58) return 11;
return -1;
}
// The terminal a chord key names, from `base`: the F-keys by fkey_index, any
// other base as a run of ten consecutive scancodes -- a digit row is 1..9, 0,
// and the minus and equals after it are already the previous and next keys.
static int
chord_index(uint data, uint base)
{
int i = base == SCAN_F1 ? fkey_index(data)
: (data >= base && data < base + 10 ? (int)(data - base) : -1);
return i < NVT ? i : -1;
}
// Which scancodes are modifiers, and which are locks. Hardware facts rather
// than layout ones -- every layout agrees that 0x2A is a Shift key -- so they
// stay here while the character tables live in keymap.c.
@ -146,21 +167,20 @@ kbdgetc(void)
// modifiers named, and nothing else held.
if (vt_chord_mods != 0 &&
(shift & (CTL | SHIFT | ALT | RALT)) == vt_chord_mods) {
if (data >= vt_chord_base && data < vt_chord_base + NVT)
return KBD_VT_SWITCH + (data - vt_chord_base);
int i = chord_index(data, vt_chord_base);
if (i >= 0)
return KBD_VT_SWITCH + i;
if (data == SCAN_MINUS) return KBD_VT_PREV;
if (data == SCAN_EQUALS) return KBD_VT_NEXT;
}
// And Linux's own: Alt+F1..F6 and Ctrl+Alt+F1..F6, whatever the chord is set
// to. These are what anyone who has used Linux presses, on a real machine,
// and nothing reached them: SchOS answered only AltGr+F-keys, which no one
// thinks to try. Under X the terminal is in VT_PROCESS, console_vt_hotkey()
// lets the keys through, and X switches with them itself -- as on Linux.
if (data >= SCAN_F1 && data < SCAN_F1 + NVT &&
// And Linux's own: Alt+F-key and Ctrl+Alt+F-key, whatever the chord is set
// to. Under X the terminal is in VT_PROCESS, console_vt_hotkey() lets the
// keys through, and X switches with them itself -- as on Linux.
if (chord_index(data, SCAN_F1) >= 0 &&
((shift & (CTL | SHIFT | ALT | RALT)) == ALT ||
(shift & (CTL | SHIFT | ALT | RALT)) == (CTL | ALT)))
return KBD_VT_SWITCH + (data - SCAN_F1);
return KBD_VT_SWITCH + chord_index(data, SCAN_F1);
cp = keymap_lookup(data, shift);
if (cp == 0)