ddvk / remarkable2-framebuffer

remarkable2 framebuffer reversing
MIT License
276 stars 22 forks source link

Make the client shim a no-op on reMarkable 1 #47

Closed matteodelabre closed 3 years ago

matteodelabre commented 3 years ago

This PR is intended to make it safe to load the librm2fb_client library even when running on reMarkable 1. This is so that Toltec can ship all the binaries that need to access the framebuffer with a dynamic dependency on librm2fb_client, and eliminate the need to set the LD_PRELOAD environment variable when starting those binaries.

In the library constructor, the /sys/devices/soc0/machine file is read to determine whether we’re running on rM1 or rM2, and set the ON_RM2 flag accordingly. When this flag is off, the wrapped system calls directly forward their arguments to the standard library.

I also cleaned up some parts of the existing code, in particular:

Test plan:

OPENED SHARED MEM: /dev/shm/swtfb.01 at 72c2e000, errno: 0
Update fn address: 0x2c050c
Create th address: 0x2c2798
Wait for th address: 0x2c1fd4
shutdown address: 0x2c273c
REPLACING THE IMAGE with shared memory
create threads called
wait clear func called

Also checked that the display worked correctly and that the touchscreen was not inverted.

matteodelabre commented 3 years ago

Thanks for the review!

Moved most file globals to block-level static variables.

what is this referring to?

There were some globals like qImageCtor, FIRST_ALLOC, touchArgs, … that were defined with file visibility although they were only used in one specific function. I moved each of those definitions inside the relevant function.

raisjn commented 3 years ago

let's give this thorough testing in the toltec upgrade