jinx: stub tcflush() in mlibc and add a WIP xf86-input-keyboard port

This commit is contained in:
Matheus
2022-10-26 00:29:04 -03:00
parent 7a13bd0b06
commit 47487e7757
4 changed files with 215 additions and 0 deletions
+35
View File
@@ -56,6 +56,41 @@ index 3474615..e034881 100644
}
char **backtrace_symbols(void *const *, int) {
diff --git mlibc-clean/options/posix/generic/termios-stubs.cpp mlibc-workdir/options/posix/generic/termios-stubs.cpp
index 3e621ad..811459e 100644
--- mlibc-clean/options/posix/generic/termios-stubs.cpp
+++ mlibc-workdir/options/posix/generic/termios-stubs.cpp
@@ -49,9 +49,15 @@ int tcflow(int fd, int action) {
return 0;
}
-int tcflush(int, int) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
+int tcflush(int fd, int queue_selector) {
+
+ MLIBC_CHECK_OR_ENOSYS(mlibc::sys_tcflush, -1);
+ if(int e = mlibc::sys_tcflush(fd, queue_selector); e) {
+ errno = e;
+ return -1;
+ }
+ return 0;
+
}
int tcgetattr(int fd, struct termios *attr) {
diff --git mlibc-clean/options/posix/include/mlibc/posix-sysdeps.hpp mlibc-workdir/options/posix/include/mlibc/posix-sysdeps.hpp
index 0917fe1..a6d975c 100644
--- mlibc-clean/options/posix/include/mlibc/posix-sysdeps.hpp
+++ mlibc-workdir/options/posix/include/mlibc/posix-sysdeps.hpp
@@ -141,6 +141,7 @@ int sys_vm_unmap(void *pointer, size_t size);
[[gnu::weak]] int sys_tcgetattr(int fd, struct termios *attr);
[[gnu::weak]] int sys_tcsetattr(int, int, const struct termios *attr);
[[gnu::weak]] int sys_tcflow(int, int);
+[[gnu::weak]] int sys_tcflush(int, int);
[[gnu::weak]] int sys_tcdrain(int);
[[gnu::weak]] int sys_pipe(int *fds, int flags);
[[gnu::weak]] int sys_socketpair(int domain, int type_and_flags, int proto, int *fds);
diff --git mlibc-workdir/sysdeps/astral/crt-x86_64/crt0.S mlibc-workdir/sysdeps/astral/crt-x86_64/crt0.S
new file mode 100644
index 0000000..0a0a4a0
@@ -0,0 +1,147 @@
diff --git xf86-input-keyboard-clean/configure.ac xf86-input-keyboard-workdir/configure.ac
index 0f71ce3..024edd3 100644
--- xf86-input-keyboard-clean/configure.ac
+++ xf86-input-keyboard-workdir/configure.ac
@@ -57,6 +57,11 @@ AC_SUBST(inputdir)
# The keyboard driver code is O/S specific
case $host_os in
+
+ astral*)
+ IS_ASTRAL="yes"
+ ;;
+
linux*)
AC_MSG_ERROR([This is not the keyboard driver you are looking for. Use evdev or libinput.])
;;
@@ -95,6 +100,7 @@ case $host_os in
esac
AC_SUBST([OS_FLAGS])
+AM_CONDITIONAL(ASTRAL, [test "x$IS_ASTRAL" = xyes])
AM_CONDITIONAL(BSD, [test "x$IS_BSD" = xyes])
AM_CONDITIONAL(SOLARIS, [test "x$IS_SOLARIS" = xyes])
AM_CONDITIONAL(HURD, [test "x$IS_HURD" = xyes])
diff --git xf86-input-keyboard-workdir/src/.astral_kbd.c.swp xf86-input-keyboard-workdir/src/.astral_kbd.c.swp
new file mode 100644
index 0000000..fd1ca48
Binary files /dev/null and xf86-input-keyboard-workdir/src/.astral_kbd.c.swp differ
diff --git xf86-input-keyboard-clean/src/Makefile.am xf86-input-keyboard-workdir/src/Makefile.am
index 52f5f4d..95b684d 100644
--- xf86-input-keyboard-clean/src/Makefile.am
+++ xf86-input-keyboard-workdir/src/Makefile.am
@@ -26,10 +26,15 @@ kbd_drv_la_SOURCES = kbd.c xf86OSKbd.h xf86Keymap.h atKeynames.h
kbd_drv_la_LIBADD = $(XORG_LIBS)
kbd_drv_ladir = @inputdir@
+ASTRAL_SRCS = astral_kbd.c
BSD_SRCS = bsd_KbdMap.c bsd_kbd.c bsd_kbd.h at_scancode.c
HURD_SRCS = hurd_kbd.c at_scancode.c
SOLARIS_SRCS = sun_kbd.c sun_kbd.h sun_kbdMap.c
+if ASTRAL
+kbd_drv_la_SOURCES += $(ASTRAL_SRCS)
+endif
+
if BSD
kbd_drv_la_SOURCES += $(BSD_SRCS)
endif
@@ -42,4 +47,4 @@ if HURD
kbd_drv_la_SOURCES += $(HURD_SRCS)
endif
-EXTRA_DIST = $(BSD_SRCS) $(HURD_SRCS) $(SOLARIS_SRCS)
+EXTRA_DIST = $(ASTRAL_SRCS) $(BSD_SRCS) $(HURD_SRCS) $(SOLARIS_SRCS)
diff --git xf86-input-keyboard-workdir/src/astral_kbd.c xf86-input-keyboard-workdir/src/astral_kbd.c
new file mode 100644
index 0000000..2ed6906
--- /dev/null
+++ xf86-input-keyboard-workdir/src/astral_kbd.c
@@ -0,0 +1,87 @@
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <xorg-server.h>
+#include <X11/X.h>
+
+#include "compiler.h"
+
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+
+#include "xf86Xinput.h"
+#include "xf86OSKbd.h"
+#include "atKeynames.h"
+#include "xf86Keymap.h"
+
+#include <stdio.h>
+#include <errno.h>
+
+// astral stuff
+
+#define KBPACKET_FLAGS_RELEASED 1
+#define KBPACKET_FLAGS_LEFTCTRL 2
+#define KBPACKET_FLAGS_CAPSLOCK 4
+#define KBPACKET_FLAGS_LEFTALT 8
+#define KBPACKET_FLAGS_RIGHTALT 16
+#define KBPACKET_FLAGS_LEFTSHIFT 32
+#define KBPACKET_FLAGS_RIGHTCTRL 64
+#define KBPACKET_FLAGS_RIGHTSHIFT 128
+
+typedef struct {
+ char ascii;
+ uintmax_t keycode;
+ int flags;
+} kbpacket_t;
+
+
+// interface
+
+static int nop(){
+ return Success;
+}
+
+static int getleds(InputInfoPtr pInfo){return 0;}
+
+static int init(InputInfoPtr, int){return Success;}
+
+static Bool openkeyboard(InputInfoPtr info){
+ info->fd = open("/dev/keyboard", O_RDONLY, 0);
+ if(info->fd == -1)
+ FatalError("Failed to open /dev/keyboard (%s)\n",strerror(errno));
+ return TRUE;
+}
+
+static void kbdread(InputInfoPtr info){
+ KbdDevPtr kbd = (KbdDevPtr) info->private;
+ kbpacket_t packet;
+
+ while(read(info->fd, &packet, sizeof(kbpacket_t)))
+ kbd->PostEvent(info, packet.keycode, packet.flags & KBPACKET_FLAGS_RELEASED ? FALSE : TRUE);
+
+}
+static void getmap(InputInfoPtr info, KeySymsPtr syms, CARD8 *map){
+
+}
+
+Bool xf86OSKbdPreInit(InputInfoPtr info){
+
+ KbdDevPtr kbd = info->private;
+
+ kbd->KbdInit = init;
+ kbd->KbdOn = nop;
+ kbd->KbdOff = nop;
+ kbd->Bell = nop;
+ kbd->SetLeds = nop;
+ kbd->GetLeds = getleds;
+ kbd->KbdGetMapping = getmap;
+ kbd->RemapScanCode = NULL;
+ kbd->OpenKeyboard = openkeyboard;
+ info->read_input = kbdread;
+
+ kbd->private = NULL;
+
+ return TRUE;
+}
+24
View File
@@ -0,0 +1,24 @@
name=xf86-input-keyboard
revision=1
from_source=xf86-input-keyboard
imagedeps="gcc"
hostdeps="gcc-cross binutils-cross pkgconfig automake autoconf util-macros libtool"
deps="mlibc xorg-server"
configure() {
SYSROOT=${sysroot_dir} ${source_dir}/configure --prefix=${prefix} --host=x86_64-astral --disable-static
}
build() {
make -j${parallelism}
}
install() {
make DESTDIR=${dest_dir} install
}
+9
View File
@@ -0,0 +1,9 @@
name=xf86-input-keyboard
version=2.0.0
source_method=tarball
tarball_url="https://xorg.freedesktop.org/archive/individual/driver/xf86-input-keyboard-${version}.tar.gz"
tarball_sha512=2243d6b93315c0fdd97e57f62f86fcb26117a512817bfee0a5af76f686d5f8a5c8ea7b3f4e543e2d8ffc8d52129b6b575b9dc2a59e42fa8b23d8ba223544715a
hostdeps="autoconf automake libtool pkgconfig util-macros"
regenerate() {
autoreconf -fvi
}