From 6eaea5ca33cfaeea7a7fc9434e082ce1a9e0c6c5 Mon Sep 17 00:00:00 2001 From: Malte Voos Date: Wed, 3 Apr 2024 18:12:50 +0200 Subject: init --- fakefbdev/SharedBuffer.h | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 fakefbdev/SharedBuffer.h (limited to 'fakefbdev/SharedBuffer.h') diff --git a/fakefbdev/SharedBuffer.h b/fakefbdev/SharedBuffer.h new file mode 100644 index 0000000..8c96668 --- /dev/null +++ b/fakefbdev/SharedBuffer.h @@ -0,0 +1,38 @@ +#pragma once + +#include + +constexpr int fb_width = 1404; +constexpr int fb_height = 1872; +constexpr int fb_pixel_size = sizeof(uint16_t); + +// this is the number of bytes that xochitl mmaps() from the framebuffer. +// MIGHT CHANGE BETWEEN XOCHITL VERSIONS! +// the below value was extracted from xochitl 3.10.2.2063. +// +// to figure out this value, decompile xochitl using ghidra and +// - search for the string "Error writing variable information" +// - this string should be used in a call to perror() which is contained +// in the if-part of a branch +// - look for the corresponding else-branch: the first statement should be +// a call to mmap() with the below size. +// (of course, these instruction might become outdated if remarkable folks +// rewrite this part of xochitl :/) +constexpr int fb_size = 0x17bd800; + +constexpr auto default_fb_name = "/rm2fb.01"; + +// TODO: use unistdpp +struct SharedFB { + int fd = -1; + uint16_t* mem = nullptr; + + SharedFB(const char* path); + ~SharedFB(); + + SharedFB(const SharedFB& other) = delete; + SharedFB& operator=(const SharedFB& other) = delete; + + SharedFB(SharedFB&& other) noexcept; + SharedFB& operator=(SharedFB&& other) noexcept; +}; -- cgit 1.4.1