Hello, Gentoo. On Wed, Jan 20, 2021 at 19:59:09 +0000, Alan Mackenzie wrote:
[Context: Scrolling on the Linux text console using the keys <shift><PgUp> and <shift><PgDn> has been removed from the kernel. This is not a Good Thing.] > What I have in mind now is writing a Linux driver, a small piece of code > which would piggy-back on the existing virtual terminal drivers, and > simply pass everything through to and from the main driver, filtering out > things relevant to scrolling, and processing these in my new driver. > I've spent the last few evenings reading up on drivers, and reading the > relevant source code from 4.19.97. I can understand the kernel > maintainers not being enthusiastic about the existing code. But that > dates from, I believe, the 1990s, when RAM was measured in megabytes, and > processor speeds in megahertz. Optimisation for speed and store usage > just isn't important any more. I finally got around to looking into this seriously in the last couple of weeks. The above plan turned out not to be the right thing. I've now cobbled together a working console scroll on Linux 5.4.80-gentoo-r1. In the end, I reused much of the old machinery which was still present in 4.19.97. Once I've tidied it up, I hope that the resulting patch file will apply cleanly also to later versions than 5.4.80-r1. As a matter of interest, the kernel code for the console is not the easiest in the world to deal with, having too many abstractions and too few comments. ;-( I've enhanced the mechanism so that each tty has its own scrollback buffer, rather than one buffer being shared between all tty's. The default size of these buffers is now 128kB, but can be set in make menuconfig. I'm intending to make sharing a buffer between all tty's be an option, but haven't implemented that yet. The code, as yet, is a bit scruffy (in fact, very scruffy), and I have several technical problems: (i) The scrolling doesn't work on /dev/tty1 aka the console. (ii) When, e.g., /dev/tty6 has been scrolled upwards a bit, and then <Alt><F2> pressed to go to /dev/tty2, on returning to /dev/tty6, the scrolling has been cancelled and the cursor is no longer visible. However, the scrollback buffer is still present. I think I'm fairly likely to be able to solve (ii). However, (i), the problem with /dev/tty1, has me baffled. I don't know where to start looking for the problem. If anybody with some kernel knowledge could make any suggestions, I'd be very grateful. -- Alan Mackenzie (Nuremberg, Germany).