Files
Baptiste MOINE a71ccdf682 Take a dropped payload, and stop drowning the console
Double-clicking the emulator printed a usage line to a console nobody sees
and exited. It now opens a window that accepts a dropped .bin, with O for the
system file dialog - GetOpenFileName on Windows, zenity or kdialog on Linux,
since there is no such thing there without dragging in a toolkit. The window
draws a dashed frame and an upload glyph from rectangles and one filled
triangle; no text, because a font would have to be vendored for a screen that
lives a few seconds and the instruction is on the title bar already. It is
created and destroyed before the emulator's own display comes up, so it
cannot interfere with the framebuffer window. A headless or toolkit-less
machine falls back to the old usage message, and dragging a payload onto the
executable still skips all of it - that arrives as argv[1].

Dropping a payload was then unusably slow, and the reason had nothing to do
with the picker. A full hwtest sweep printed 52,452 lines, of which about
51,900 were per-register-access traces: 29,673 [gpio], 16,707 [mmio], 5,430
[sdmmc]. Redirected to a file that is merely wasteful, which is why it went
unnoticed - every scripted run here redirects. On a Windows console it is
not: each line goes through conhost one write at a time. Those traces now
need --trace or RCM_EMU_TRACE=1, which drops default output to 578 lines -
the payload's own UART plus the handful of [emu], [display], [pcie] and
[audio] lines worth seeing. The flag brings all 48,354 back when a
register-level question needs answering.

Also adds RCM_EMU_PICK, which runs the picker's window lifecycle and returns
a path as if it had been dropped, so that path can be tested by a script
instead of only by a human dragging a file.
2026-08-20 10:29:28 +02:00

19 lines
919 B
C

#pragma once
#include <cstdio>
// Per-access register tracing. Off unless asked for, because it is enormous:
// a full hwtest sweep emits ~52,000 lines, ~51,000 of which are [gpio],
// [mmio] and [sdmmc] traces. Piped to a file that is merely wasteful, but on
// a Windows console every line goes through conhost one write at a time and
// the emulator slows to a crawl - which is exactly what a user sees when
// they double-click the executable instead of running it from a script.
//
// Enable with --trace on the command line or RCM_EMU_TRACE=1.
extern bool emu_trace_enabled;
#define TRACE(...) \
do { \
if (emu_trace_enabled) \
printf(__VA_ARGS__); \
} while (0)