Skip to content

Commit c3f5944

Browse files
bootstrap::xf86-input-mouse
Signed-off-by: Andy-Python-Programmer <[email protected]>
1 parent 5043ca5 commit c3f5944

File tree

7 files changed

+449
-52
lines changed

7 files changed

+449
-52
lines changed

bootstrap/xorg.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -659,6 +659,47 @@ packages:
659659
environ:
660660
DESTDIR: '@THIS_COLLECT_DIR@'
661661

662+
- name: xf86-input-mouse
663+
source:
664+
subdir: 'bundled'
665+
git: 'https://gitlab.freedesktop.org/xorg/driver/xf86-input-mouse.git'
666+
tag: 'xf86-input-mouse-1.9.4'
667+
version: '1.9.4'
668+
tools_required:
669+
- host-autoconf-v2.69
670+
- host-automake-v1.16
671+
- host-libtool
672+
- host-pkg-config
673+
- host-xorg-macros
674+
regenerate:
675+
- args: ['./autogen.sh']
676+
environ:
677+
NOCONFIGURE: 'yes'
678+
tools_required:
679+
- host-gcc
680+
- host-autoconf-v2.69
681+
- host-automake-v1.16
682+
- host-pkg-config
683+
pkgs_required:
684+
- mlibc
685+
- xorg-server
686+
- xorg-util-macros
687+
- libx11
688+
configure:
689+
- args:
690+
- '@THIS_SOURCE_DIR@/configure'
691+
- '--host=x86_64-aero'
692+
- '--prefix=/usr'
693+
- '--sysconfdir=/etc'
694+
- '--localstatedir=/var'
695+
- '--disable-static'
696+
- '--with-sysroot=@SYSROOT_DIR@' # Set libtool's lt_sysroot.
697+
build:
698+
- args: ['make', '-j@PARALLELISM@']
699+
- args: ['make', 'install-strip']
700+
environ:
701+
DESTDIR: '@THIS_COLLECT_DIR@'
702+
662703
# `libxfont` provides the core of the legacy X11 font system, handling the index
663704
# files
664705
- name: libxfont2

patches/mlibc/mlibc.patch

Lines changed: 36 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
1-
From 9f270baad38e7f90bd7c67780ae8f78d66c00de5 Mon Sep 17 00:00:00 2001
1+
From 9591f4a8fe0242eafb16c5816455f1d763b19b77 Mon Sep 17 00:00:00 2001
22
From: Andy-Python-Programmer <[email protected]>
3-
Date: Sun, 18 Dec 2022 14:31:45 +1100
3+
Date: Wed, 1 Feb 2023 16:53:35 +1100
44
Subject: [PATCH] <xxx>
55

66
---
7-
.gitignore | 2 +
8-
options/ansi/generic/stdlib-stubs.cpp | 185 +++++++++++++++++++++++-
9-
options/glibc/generic/execinfo.cpp | 5 +-
10-
options/posix/generic/dlfcn-stubs.cpp | 1 +
11-
options/posix/generic/termios-stubs.cpp | 5 +-
12-
options/rtdl/generic/linker.cpp | 2 +-
13-
sysdeps/aero/generic/aero.cpp | 71 +++++----
14-
sysdeps/aero/generic/filesystem.cpp | 35 ++++-
15-
sysdeps/aero/generic/sockets.cpp | 87 ++++++++++-
16-
sysdeps/aero/generic/time.cpp | 24 +++
17-
sysdeps/aero/include/aero/syscall.h | 9 ++
18-
sysdeps/aero/meson.build | 1 +
19-
12 files changed, 381 insertions(+), 46 deletions(-)
7+
.gitignore | 2 +
8+
options/ansi/generic/stdlib-stubs.cpp | 185 ++++++++++++++++++++++++--
9+
options/glibc/generic/execinfo.cpp | 5 +-
10+
options/posix/generic/dlfcn-stubs.cpp | 1 +
11+
options/rtdl/generic/linker.cpp | 2 +-
12+
sysdeps/aero/generic/aero.cpp | 69 ++++++----
13+
sysdeps/aero/generic/filesystem.cpp | 35 ++++-
14+
sysdeps/aero/generic/sockets.cpp | 87 +++++++++++-
15+
sysdeps/aero/generic/time.cpp | 24 ++++
16+
sysdeps/aero/include/aero/syscall.h | 9 ++
17+
sysdeps/aero/meson.build | 1 +
18+
11 files changed, 374 insertions(+), 46 deletions(-)
2019
create mode 100644 sysdeps/aero/generic/time.cpp
2120

2221
diff --git a/.gitignore b/.gitignore
@@ -283,36 +282,32 @@ index 2e2d3f1..3ff5fef 100644
283282
constexpr bool eagerBinding = true;
284283

285284
diff --git a/sysdeps/aero/generic/aero.cpp b/sysdeps/aero/generic/aero.cpp
286-
index 29fb961..ee09678 100644
285+
index 29fb961..b5945a8 100644
287286
--- a/sysdeps/aero/generic/aero.cpp
288287
+++ b/sysdeps/aero/generic/aero.cpp
289-
@@ -62,6 +62,16 @@ static frg::vector<Slice, MemoryAllocator> create_slice(char *const arg[]) {
288+
@@ -62,29 +62,33 @@ static frg::vector<Slice, MemoryAllocator> create_slice(char *const arg[]) {
290289
}
291290

292291
namespace mlibc {
292+
-int sys_futex_tid() {
293+
- // SAFETY: gettid does not return any errors (ie. the call is always
294+
- // successful).
295+
- return syscall(SYS_GETTID);
296+
-}
297+
-
298+
-int sys_futex_wait(int *pointer, int expected, const struct timespec *time) {
299+
- auto result = syscall(SYS_FUTEX_WAIT, pointer, expected, time);
293300
+int sys_uname(struct utsname *buf) {
294301
+ auto result = syscall(SYS_UNAME, buf);
295-
+
296-
+ if (result < 0) {
297-
+ return -result;
298-
+ }
299-
+
302+
303+
if (result < 0) {
304+
return -result;
305+
}
306+
300307
+ return result;
301308
+}
302309
+
303-
int sys_futex_tid() {
304-
// SAFETY: gettid does not return any errors (ie. the call is always
305-
// successful).
306-
@@ -69,22 +79,22 @@ int sys_futex_tid() {
307-
}
308-
309-
int sys_futex_wait(int *pointer, int expected, const struct timespec *time) {
310-
- auto result = syscall(SYS_FUTEX_WAIT, pointer, expected, time);
311-
-
312-
- if (result < 0) {
313-
- return -result;
314-
- }
315-
-
310+
+int sys_futex_wait(int *pointer, int expected, const struct timespec *time) {
316311
+ // auto result = syscall(SYS_FUTEX_WAIT, pointer, expected, time);
317312
+ //
318313
+ // if (result < 0) {
@@ -338,7 +333,7 @@ index 29fb961..ee09678 100644
338333
return 0;
339334
}
340335

341-
@@ -124,7 +134,9 @@ int sys_anon_free(void *pointer, size_t size) {
336+
@@ -124,7 +128,9 @@ int sys_anon_free(void *pointer, size_t size) {
342337
}
343338

344339
void sys_libc_panic() {
@@ -349,7 +344,7 @@ index 29fb961..ee09678 100644
349344
sys_exit(1);
350345
}
351346

352-
@@ -140,8 +152,15 @@ void sys_exit(int status) {
347+
@@ -140,8 +146,15 @@ void sys_exit(int status) {
353348

354349
pid_t sys_getpid() {
355350
auto result = syscall(SYS_GETPID);
@@ -366,7 +361,7 @@ index 29fb961..ee09678 100644
366361
return result;
367362
}
368363

369-
@@ -162,11 +181,6 @@ pid_t sys_getpgid(pid_t pid, pid_t *pgid) {
364+
@@ -162,11 +175,6 @@ pid_t sys_getpgid(pid_t pid, pid_t *pgid) {
370365
return 0;
371366
}
372367

@@ -378,7 +373,7 @@ index 29fb961..ee09678 100644
378373
int sys_clock_get(int clock, time_t *secs, long *nanos) {
379374
struct timespec ts;
380375
auto result = syscall(SYS_GETTIME, clock, &ts);
381-
@@ -233,7 +247,11 @@ uid_t sys_geteuid() {
376+
@@ -233,7 +241,11 @@ uid_t sys_geteuid() {
382377
return 0;
383378
}
384379

@@ -391,7 +386,7 @@ index 29fb961..ee09678 100644
391386
int sys_seteuid(uid_t euid) UNIMPLEMENTED("sys_seteuid")
392387

393388
gid_t sys_getgid() {
394-
@@ -256,16 +274,19 @@ int sys_setegid(gid_t egid) {
389+
@@ -256,16 +268,19 @@ int sys_setegid(gid_t egid) {
395390
return 0;
396391
}
397392

@@ -647,5 +642,5 @@ index a807b37..878c216 100644
647642

648643
if not no_headers
649644
--
650-
2.38.1
645+
2.39.1
651646

Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
From 560b74fa3e234dced21e0bbf03ea444197b7da15 Mon Sep 17 00:00:00 2001
2+
From: Andy-Python-Programmer <[email protected]>
3+
Date: Sat, 4 Feb 2023 13:21:25 +1100
4+
Subject: [PATCH xf86-input-mouse] <xxx>
5+
6+
---
7+
configure.ac | 3 ++
8+
src/Makefile.am | 2 +-
9+
src/aero_mouse.c | 115 +++++++++++++++++++++++++++++++++++++++++++++++
10+
3 files changed, 119 insertions(+), 1 deletion(-)
11+
create mode 100644 src/aero_mouse.c
12+
13+
diff --git a/configure.ac b/configure.ac
14+
index 6c453cd..a3dd16d 100644
15+
--- a/configure.ac
16+
+++ b/configure.ac
17+
@@ -81,6 +81,9 @@ case $host_os in
18+
solaris*)
19+
OS_MOUSE_NAME=sun
20+
;;
21+
+ aero*)
22+
+ OS_MOUSE_NAME=aero
23+
+ ;;
24+
gnu*)
25+
OS_MOUSE_NAME=hurd
26+
;;
27+
diff --git a/src/Makefile.am b/src/Makefile.am
28+
index aad8d0e..6de4354 100644
29+
--- a/src/Makefile.am
30+
+++ b/src/Makefile.am
31+
@@ -32,7 +32,7 @@ AM_CPPFLAGS = -I$(top_srcdir)/include $(XORG_CFLAGS)
32+
33+
# We have to list all the mouse drivers here, even if we don't build them, so
34+
# they get included in distcheck.
35+
-OS_SRCS = bsd_mouse.c hurd_mouse.c lnx_mouse.c sun_mouse.c
36+
+OS_SRCS = bsd_mouse.c hurd_mouse.c lnx_mouse.c sun_mouse.c aero_mouse.c
37+
38+
@DRIVER_NAME@_drv_la_SOURCES = \
39+
mouse.c \
40+
diff --git a/src/aero_mouse.c b/src/aero_mouse.c
41+
new file mode 100644
42+
index 0000000..de18985
43+
--- /dev/null
44+
+++ b/src/aero_mouse.c
45+
@@ -0,0 +1,115 @@
46+
+#include "mouse.h"
47+
+#include <fcntl.h>
48+
+#include <stddef.h>
49+
+#include <unistd.h>
50+
+#include <stdio.h>
51+
+#include <stdint.h>
52+
+#include <sys/stat.h>
53+
+
54+
+#include "xf86_OSlib.h"
55+
+
56+
+#define MOUSE_FLAG_LB (1 << 0)
57+
+#define MOUSE_FLAG_RB (1 << 1)
58+
+#define MOUSE_FLAG_MB (1 << 2)
59+
+
60+
+#define DEVPATH "/dev/mouse0"
61+
+
62+
+struct mouse_packet {
63+
+ int16_t x;
64+
+ int16_t y;
65+
+
66+
+ uint8_t flags;
67+
+};
68+
+
69+
+static void MouseReadInput(InputInfoPtr pInfo) {
70+
+ MouseDevPtr mouse = pInfo->private;
71+
+
72+
+ struct mouse_packet packet;
73+
+
74+
+ for (;;) {
75+
+ size_t result = read(pInfo->fd, &packet, sizeof(struct mouse_packet));
76+
+
77+
+ if (result != sizeof(struct mouse_packet)) {
78+
+ break;
79+
+ }
80+
+
81+
+ int b = mouse->lastButtons;
82+
+ b &= ~0x7;
83+
+
84+
+ b |= (packet.flags & MOUSE_FLAG_RB) ? 1 : 0;
85+
+ b |= (packet.flags & MOUSE_FLAG_MB) ? 2 : 0;
86+
+ b |= (packet.flags & MOUSE_FLAG_LB) ? 4 : 0;
87+
+
88+
+ mouse->PostEvent(pInfo, b, packet.x, -packet.y, 0, 0);
89+
+ }
90+
+}
91+
+
92+
+static Bool OsMousePreInit(InputInfoPtr pInfo, const char *protocol, int flags) {
93+
+ MouseDevPtr mouse = pInfo->private;
94+
+ mouse->protocol = protocol;
95+
+
96+
+ xf86ProcessCommonOptions(pInfo, pInfo->options);
97+
+
98+
+ pInfo->fd = xf86OpenSerial(pInfo->options);
99+
+ if (pInfo->fd == -1) {
100+
+ xf86Msg(X_ERROR, "%s: cannot open %s\n", pInfo->name, DEVPATH);
101+
+ return FALSE;
102+
+ }
103+
+
104+
+ mouse->CommonOptions(pInfo);
105+
+ pInfo->read_input = MouseReadInput;
106+
+ return TRUE;
107+
+}
108+
+
109+
+static const char *internalNames[] = {
110+
+ "Aero",
111+
+ NULL
112+
+};
113+
+
114+
+static const char ** BuiltinNames(void) {
115+
+ return internalNames;
116+
+}
117+
+
118+
+static Bool CheckProtocol(const char *protocol) {
119+
+ for (int i = 0; internalNames[i]; i++) {
120+
+ if (xf86NameCmp(protocol, internalNames[i]) == 0)
121+
+ return TRUE;
122+
+ }
123+
+
124+
+ return FALSE;
125+
+}
126+
+
127+
+static const char *FindDevice(InputInfoPtr pInfo, const char *protocol, int flags) {
128+
+ struct stat st;
129+
+
130+
+ if (stat(DEVPATH, &st) == -1)
131+
+ return NULL;
132+
+
133+
+ pInfo->options = xf86AddNewOption(pInfo->options, "Device", DEVPATH);
134+
+ return DEVPATH;
135+
+}
136+
+
137+
+static const char *DefaultProtocol(void) {
138+
+ return "Aero";
139+
+}
140+
+
141+
+static int SupportedInterfaces(void) {
142+
+ return MSE_PS2;
143+
+}
144+
+
145+
+OSMouseInfoPtr OSMouseInit(int flags) {
146+
+ OSMouseInfoPtr p;
147+
+
148+
+ p = calloc(sizeof(OSMouseInfoRec), 1);
149+
+ if (p == NULL)
150+
+ return NULL;
151+
+
152+
+ p->SupportedInterfaces = SupportedInterfaces;
153+
+ p->BuiltinNames = BuiltinNames;
154+
+ p->FindDevice = FindDevice;
155+
+ p->DefaultProtocol = DefaultProtocol;
156+
+ p->CheckProtocol = CheckProtocol;
157+
+ p->PreInit = OsMousePreInit;
158+
+
159+
+ return p;
160+
+}
161+
\ No newline at end of file
162+
--
163+
2.39.1
164+

src/aero_kernel/src/drivers/keyboard.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,9 +280,9 @@ pub fn ps2_keyboard_init() {
280280

281281
let mut config = ConfigFlags::from_bits_truncate(io::inb(0x60));
282282

283-
config.remove(ConfigFlags::FIRST_DISABLED);
283+
config.remove(ConfigFlags::FIRST_DISABLED | ConfigFlags::SECOND_DISABLED);
284284
config.remove(ConfigFlags::FIRST_TRANSLATE); // Use scancode set 2
285-
config.insert(ConfigFlags::FIRST_INTERRUPT);
285+
config.insert(ConfigFlags::FIRST_INTERRUPT | ConfigFlags::SECOND_INTERRUPT);
286286

287287
io::outb(0x64, 0x60); // command: write config
288288
io::outb(0x60, config.bits());
@@ -295,6 +295,8 @@ pub fn ps2_keyboard_init() {
295295

296296
apic::io_apic_setup_legacy_irq(1, keyboard_vector, 1);
297297

298+
super::mouse::ps2_mouse_init();
299+
298300
// TODO: Move this into /dev/input instead
299301
// TODO: Add support for multiple keyboards
300302
register_keyboard_listener(KEYBOARD.as_ref().clone());

src/aero_kernel/src/drivers/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ pub mod keyboard;
2828
#[cfg(target_arch = "x86_64")]
2929
pub mod lai;
3030
// FIXME: aarch64 port
31+
pub mod mouse;
3132
#[cfg(target_arch = "x86_64")]
3233
pub mod pci;
3334
pub mod pty;

0 commit comments

Comments
 (0)