Commit Graph

3390 Commits

Author SHA1 Message Date
Bananymous 83e5cb81e8 ports: Cleanup projects using cmake
There is no need to use $BANAN_CMAKE because our own toolchain directory
is added to path.
2026-01-10 19:32:48 +02:00
Bananymous 7a49a0d986 BuildSystem: Install meson as part of the toolchain
Debian based distros have meson 0.6x in their repositories. These cause
some obscure error messages when building meson based ports.
2026-01-10 19:32:48 +02:00
Bananymous 78cd054d59 BuildSystem: Write my own disk image perm updater
If user's bash does not have bultin stat, updating image perms was
terribly slow. This patch adds a simple c program that does the job
without exec overhead
2026-01-10 17:57:21 +02:00
Bananymous d33a8eac9c ports/mesa: Download prebuilt llvm instead of building it
compiling llvm takes too long :D
2026-01-10 16:40:12 +02:00
Bananymous 9355ab1656 ports: Add cairo port
This is needed by harfbuzz
2026-01-10 16:21:12 +02:00
Bananymous 1f87bfbf2e ports/SuperTuxKart: Don't disable configure :D 2026-01-10 16:00:24 +02:00
Bananymous e06429da87 ports: Add SuperTuxKart port 2026-01-10 13:35:07 +02:00
Bananymous 26058763df ports: Add harfbuzz port 2026-01-10 13:32:20 +02:00
Bananymous 1f03d23dae Kernel: Fix load balancing
My code to find least loaded processor used processor index instead of
processor id to index the array. Most of the time this lead to wrong
processor returned as the least loaded, leaving some processors
basically idle.
2026-01-10 01:46:08 +02:00
Bananymous 2eea074473 Kernel: Remove unnecessary page table loads
loading a page table is slow as it invalidates the whole tlb
2026-01-10 01:13:48 +02:00
Bananymous ed82a18e2a Kernel: Fix deadlock in ext2 filesystem
If multiple threads were waiting for more block buffers without anyone
releasing them, they ended up in a deadlock.

Now we store 6 blocks for 8 threads. If a thread already has a block
buffer, it will not have to wait for a new one. Only if there are more
than 8 threads using blocks, will it block until there are free slots
for a thread available.
2026-01-10 00:30:30 +02:00
Bananymous 2961a49dc7 Kernel: Optimize futexes
Add support for processor local futexes. These work the exact same way
as global ones, but only lock a process specific lock and use a process
specific hash map.

Also reduce the time futex lock is held. There was no need to hold the
global lock while validating addresses in the process' address space.
2026-01-09 22:27:59 +02:00
Bananymous 5c9151d3e9 LibC: Add stubs for {init,set}state
Some port wanted these as it detected we had {,s}random
2026-01-09 22:08:32 +02:00
Bananymous 90deb9fb43 BAN: Make debug output thread safe
Now file lock is only acquired once per message, not once per character
2026-01-09 20:30:35 +02:00
Bananymous 12489a4c6b Kernel: Fix 32 bit target compile and runtime
Apparently I have to reload stack in the fork trampoline. Not sure why
or why not on x86_64. Also sse builtins did not compile
2026-01-09 17:06:57 +02:00
Bananymous 74f70ae4bd Kernel/LibC: Use builtin functions over inline asm
Getting flags and saving/restoring sse state and reading TSC can be done
using compiler builtins
2026-01-09 15:39:19 +02:00
Bananymous a9ceab0415 Kernel: Use syscall/sysret for syscalls in x86_64 2026-01-09 15:18:58 +02:00
Bananymous 94bd74d0bb BuildSystem: Update qemu script
Default to intel-hda instead of ac97 for audio

If we are accelerating with kvm, use host cpu and disable migratable to
allow invariant TSC
2026-01-08 17:16:20 +02:00
Bananymous b2d8199480 ports/openal-soft: Add SDL2 as a dependency 2026-01-08 17:13:59 +02:00
Bananymous e60f3711f8 ports: Update openssl 3.3.1->3.6.0 2026-01-08 17:13:59 +02:00
Bananymous 6ec9e4f7b8 ports: Update freetype 2.13.3->2.14.1 2026-01-08 17:13:59 +02:00
Bananymous 9eb3834ae5 Kernel: Add syscall-less clock_gettime
If the processor has invariant TSC it can be used to measure time. We
keep track of the last nanosecond and TSC values and offset them based
on the current TSC. This allows getting current time in userspace.

The implementation maps a single RO page to every processes' address
space. The page contains the TSC info which gets updated every 100 ms.
If the processor does not have invariant TSC, this page will not
indicate the capability for TSC based timing.

There was the problem about how does a processor know which cpu it is
running without doing syscall. TSC counters may or may not be
synchronized between cores, so we need a separate TSC info for each
processor. I ended up adding sequence of bytes 0..255 at the start of
the shared page. When a scheduler gets a new thread, it updates the
threads gs/fs segment to point to the byte corresponding to the current
cpu.

This TSC based timing is also used in kernel. With 64 bit HPET this
probably does not bring much of a benefit, but on PIT or 32 bit HPET
this removes the need to aquire a spinlock to get the current time.

This change does force the userspace to not use gs/fs themselves and
they are both now reserved. Other one is used for TLS (this can be
technically used if user does not call libc code) and the other for
the current processor index (cannot be used as kernel unconditionally
resets it after each load balance).

I was looking at how many times timer's current time was polled
(userspace and kernel combined). When idling in window manager, it was
around 8k times/s. When running doom it peaked at over 1 million times
per second when loading and settled at ~30k times/s.
2026-01-08 17:13:59 +02:00
Bananymous ee57cf3e9a Kernel: Expose usb device's device descriptor
This is used by the joystick detection code but i forgot to commit this
:D
2026-01-08 13:46:11 +02:00
Bananymous fea5d1d82b BAN: Fix wrong include in heap 2026-01-07 22:12:20 +02:00
Bananymous c84a30d4dd ports/SDL2: Update to new joystick interface 2026-01-07 19:07:42 +02:00
Bananymous 24d91eee90 Kernel/LibInput: Rework Joystick handling
Joystick axis and buttons are now named to standard values, this allows
interfacing multiple different controllers (only DS3 is supported)

Add ioctl calls for userspace to set joystick player leds and rumble

Only use DS3 code paths when we detect that the attached device is
actually an DS3 controller

update test-joystick program to the new interface and add support to
control rumble and player leds
2026-01-07 19:01:07 +02:00
Bananymous a5318448f5 userspace: Add audioctl utility to configure audio server 2026-01-06 22:26:11 +02:00
Bananymous b7c40eeb57 AudioServer: Handle multiple audio devices with multiple pins
This makes audio server configurable during runtime!
2026-01-06 22:26:11 +02:00
Bananymous e7c9be1875 AudioServer: Increase send buffer size and hardcode volume to 20% 2026-01-06 22:26:11 +02:00
Bananymous 8f1b314802 Kernel: Add ioctls to select audio device's output pin 2026-01-06 22:26:11 +02:00
Bananymous da6794c8ce Kernel: Implement HD audio driver
This is very basic and does not support a lot of stuff (like changing
the output pin :D)
2026-01-06 22:26:10 +02:00
Bananymous e926beba5a test-mouse: Fix mouse fd cleanup
I was creating a local variable shadowing the global one. This prevented
cleanup to close it. (this is not really necessary as the program dies
anyway)
2026-01-06 21:58:56 +02:00
Bananymous 3ad053cf6d image: Add option to change resize algoritm
Also benchmark timing is now done cpu clock, not monotonic one
2026-01-06 21:58:56 +02:00
Bananymous bc11469a0b mkdir: Fix mkdir error handling 2026-01-06 21:58:56 +02:00
Bananymous a00695bdac LibC: Add stubs that I have locally
I'm not sure if these are used by anything but I would assume so as I
have added them :D

functions added:
- getprotobyname
- open_memstream
- munlock
- lockf
- nice
- crypt
- getsid
- wcstoul
2026-01-06 21:58:56 +02:00
Bananymous 89959b800c LibC: Implement random and srandom 2026-01-06 21:58:56 +02:00
Bananymous 3e19c3b62e LibC: Fix timeradd and timersub overflow/underflow 2026-01-06 21:58:56 +02:00
Bananymous d970debb4d LibC: Define MAXPATHLEN in sys/param.h
This file is not POSIX, but some software seems to rely on it
2026-01-06 21:58:56 +02:00
Bananymous d0ba52073f LibC: Add stubs for shm_* functions 2026-01-06 21:58:56 +02:00
Bananymous 943e3b6f51 LibC: Define IN_CLASS* macros
These are not POSIX but some software seems to rely on them
2026-01-06 21:58:56 +02:00
Bananymous 25d43682aa LibC: Bump FOPEN_MAX 16->64 2026-01-06 21:58:56 +02:00
Bananymous ad16de59f8 Kernel: Implement basic F_{GET,SET}LK{,W}
At the moment these lock the whole file which is not what is supposed to
happen. Some port was trying to use these and this seems to work for
that. This may cause deadlocks but that should be easy enough to find
the reason because of the debug warnings
2026-01-06 21:58:56 +02:00
Bananymous 8634bbb792 Kernel: Don't save/restore sse or reschedule on spurious interrupts
I think these should be just fully ignored :D
2026-01-06 21:58:56 +02:00
Bananymous 60ec5d30fd init: Start Clipboard server on startup
I had forgotten to commit this when I added the clipboard server :D
2026-01-06 21:58:56 +02:00
Bananymous 7667fe6ca5 LibC: Implement sem_timedwait 2026-01-06 21:58:56 +02:00
Bananymous 4b5a8196c3 Kernel: Fix bitmap byte index calculation in PMM
No idea how I had not crashed here earlier, but running on real hw with
a bit initrd ended up crashing :D
2026-01-04 01:16:43 +02:00
Bananymous 706c0816dd Kernel: Move smp_initialized flag after schedulers are initialized
Before this real hardware failed to boot with smp enabled. Allocating
the idle thread does a page mapping which ends up broadcasting TLB
shootdown to other processes. This ends up failing somewhere halting the
processors never allowing them to initialize their scheduler
2026-01-03 23:39:07 +02:00
Bananymous a8aa89362d ports/SDL2: Add support for game controllers
SuperTux and tuxracer now work with controller support!
2026-01-03 20:42:42 +02:00
Bananymous 7964698ae5 userspace: Add simple joystick test app 2026-01-03 20:42:42 +02:00
Bananymous 65664b0d65 Kernel: Add support for DualShock 3 controllers
This driver accepts any HID joystick devices but button and axis
mappings will only work on a PS3 controller
2026-01-03 20:07:08 +02:00