i2c-hid: the touchpad crash was a printf format, not the driver

The PSOGM on the ASUS TUF A15 was a page fault in cprintf, from probe(),
in the touchpad driver's own success message. cprintf had no field widths:
"%04x" printed literally and consumed no argument, so the "%s" after it
was handed the product ID as a string pointer. "%lx" misprinted the same
way -- "0x4275838976x" for 0xFEDC2000 -- on the line before.

The driver's formats are fixed, and cprintf now steps over flags and
widths and takes l/ll/z as 64-bit, so a directive it does not render can
no longer shift every argument after it. Until now any %ld or %lu printed
the number followed by a stray letter.

The touchpad on/off entry in the boot menu has served its purpose and is
gone; the verbose step trace stays.

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 00:28:23 +02:00
commit 5ea03c4cf5
5 changed files with 43 additions and 45 deletions

View file

@ -118,9 +118,6 @@ static int VERBOSE_BOOT;
// this particular moment.
static int DEBUG_BOOT;
// SCHBOOT_OFF_FLAGS: drivers turned off at the boot menu.
static int OFF_FLAGS;
static void
serial_putc(char c)
{
@ -1542,22 +1539,20 @@ boot_menu(EFI_GRAPHICS_OUTPUT_PROTOCOL *gop)
// how to make it not refuse. An ISO built for anybody else has no way
// to turn a network debugger on, because the code that would set the
// flag is not in it.
const char *items[7];
int nitems = 6;
const char *items[6];
int nitems = 5;
items[0] = "Boot SchOS";
items[1] = "Boot SchOS (verbose)";
items[2] = resbuf;
items[3] = (OFF_FLAGS & SCHBOOT_OFF_I2C_HID) ? "Touchpad driver: off"
: "Touchpad driver: on";
items[4] = "System Information";
items[5] = "Reboot to firmware";
items[3] = "System Information";
items[4] = "Reboot to firmware";
#ifdef SCHOS_DEBUG
items[6] = DEBUG_BOOT ? "Remote debugging: on (schdbgd, port 4444)"
items[5] = DEBUG_BOOT ? "Remote debugging: on (schdbgd, port 4444)"
: "Remote debugging: off";
nitems = 7;
nitems = 6;
#endif
const char *hint = nitems == 7 ? "W/S or 1-7 to choose, Enter to select"
: "W/S or 1-6 to choose, Enter to select";
const char *hint = nitems == 6 ? "W/S or 1-6 to choose, Enter to select"
: "W/S or 1-5 to choose, Enter to select";
ui_menu("Boot Manager", items, nitems, selected, hint);
@ -1594,15 +1589,14 @@ boot_menu(EFI_GRAPHICS_OUTPUT_PROTOCOL *gop)
if (selected == 0) return 0;
if (selected == 1) return 1;
if (selected == 2) { res_choose(gop); continue; }
if (selected == 3) { OFF_FLAGS ^= SCHBOOT_OFF_I2C_HID; echoed = -1; continue; }
if (selected == 4) { sys_info(gop); continue; }
if (selected == 3) { sys_info(gop); continue; }
#ifdef SCHOS_DEBUG
// A toggle rather than an action: picking it changes what the
// entry says and leaves you in the menu, so the state you booted
// with is the state you can see before you boot.
if (selected == 6) { DEBUG_BOOT = !DEBUG_BOOT; echoed = -1; continue; }
if (selected == 5) { DEBUG_BOOT = !DEBUG_BOOT; echoed = -1; continue; }
#endif
if (selected == 5) {
if (selected == 4) {
ui_clear();
ui_text_centered((int)ui_height() / 2, "Halted -- reset to reach firmware setup",
0xB9BEC7u);
@ -2342,7 +2336,6 @@ EfiMain(EFI_HANDLE image, EFI_SYSTEM_TABLE *systab)
*(UINT32 *)SCHBOOT_EFI_FLAG = SCHBOOT_EFI_MAGIC;
*(UINT8 *)SCHBOOT_VERBOSE_FLAG = (UINT8)VERBOSE_BOOT;
*(UINT8 *)SCHBOOT_DEBUG_FLAG = (UINT8)DEBUG_BOOT;
*(UINT8 *)SCHBOOT_OFF_FLAGS = (UINT8)OFF_FLAGS;
// The page tables mboot_entry would have built. entry64low's first act is
// a movabs to 0xffff8000...., so the high half must be mapped before the