Commit Graph

946 Commits

Author SHA1 Message Date
Bananymous 892e16dfb1 Kernel: Increase PS2 timeout to 300 ms, load PS2 in separate thread
PS/2 seems to hit command timeout sometimes on slow emulation so
increase the timeouts.

Also move PS/2 device initialization to a different thread because
device indentification waits for timeouts.
2025-07-02 00:17:42 +03:00
Bananymous 92e4078287 Kernel: Rewrite ThreadBlocker
This gets rid of a very old bug where kernel panics when thread is being
woken up and unblocked at the same time on different cores. This
required adding a new lock to SchedulerQueue::Node and adding a cap to
how many threads a threadblocker can simultaneously block. I don't think
I ever block more than five threads on the same ThreadBlocker so this
should be fine.
2025-07-02 00:17:42 +03:00
Bananymous fb7e9719a1 Kernel: Add fast fill method to framebuffer device
This makes `clear` much faster when running without kvm!
2025-07-02 00:17:42 +03:00
Bananymous a5b4cee298 Kernel: Load USTAR from a boot module if loading root partition fails
This allows banan-os to boot on hardware where we don't have working
storage driver or the storage driver fails (pretty common with my usb
mass storage drivers...)
2025-07-02 00:17:42 +03:00
Bananymous 17f1ac10e3 Kernel: Don't ignore modules passed with multiboot2 2025-07-02 00:17:42 +03:00
Bananymous c67198032f Kernel: Rewrite TmpFS block and inode allocation
This makes creating files and appending to then A LOT faster. Some code
I tested took 40 seconds in the previous implementation and less than a
second on the new one!

This code is really sketcy, I hope I'll never have to touch it again :)
2025-07-02 00:17:42 +03:00
Bananymous 107b092982 Kernel: Allow arbitrary sized tmpfs files
The 2 block limit started to get annoying :D
2025-07-02 00:17:42 +03:00
Bananymous bac06e45a4 Kernel: Fix TmpSymlinkInode target getting/setting 2025-07-02 00:17:42 +03:00
Bananymous c8c05f62b4 Kernel: Remove unused FileSystem::dev 2025-06-29 00:29:03 +03:00
Bananymous ebf2b16d09 Kernel: Implement chown to ext2 and tmpfs 2025-06-28 21:28:54 +03:00
Bananymous db571b4859 Kernel: Allow relockign mutex even when holding a spinlock
Only reason mutex locking is now allowed with spinlocks is to prevent
yield.

Also try_lock can be now safely used while holding a spinlock
2025-06-28 19:40:54 +03:00
Bananymous e8491b34b8 Kernel/LibC: Rework TIOC{G,S}WINSZ more linux like
Userspace can freely set terminal size, kernel just updates it when for
example new font is loaded. Also SIGWINCH is now sent by kernel instead
of userspace.
2025-06-28 19:40:54 +03:00
Bananymous 83c0ef3514 Kernel: Implement CLOCK_{PROCESS,THREAD}_CPUTIME_ID 2025-06-28 16:55:13 +03:00
Bananymous 93e5d09a63 Kernel/LibC: Implement flock 2025-06-28 16:55:13 +03:00
Bananymous 32c35a822b BuildSystem: binutils1.39->1.44, gcc12.2.0->15.1.0 2025-06-19 19:00:50 +03:00
Bananymous b668173cba Kernel: Fix pseudo terminal writability 2025-06-06 11:09:50 +03:00
Bananymous 81ff71a97f Kernel: Track the number of recursive spinlocks a thread is holding 2025-06-06 06:51:15 +03:00
Bananymous 56db0efe58 Kernel: Add missing file for race condition fixes :) 2025-06-06 04:03:37 +03:00
Bananymous eecdad50a6 Kernel: Fix most of mutex + block race conditions
All block functions now take an optional mutex parameter that is
atomically unlocked instead of having the user unlock it before hand.
This prevents a ton of race conditions everywhere in the code!
2025-06-06 03:59:22 +03:00
Bananymous bf41b448d6 Kernel: Fix TCP sending
- Fix race condition when adding packet to send buffer before other end
  has acknowledged it
- Allow sending multiple packets before receiving ACK for previous ones
2025-06-04 22:21:35 +03:00
Bananymous fb466b5af7 Kernel: use termios c_cc values instead of hardcoded characters 2025-06-02 15:54:11 +03:00
Bananymous 7a645b8555 Kernel: Add SMP message StackTrace
This event is sent when user presses ctrl+{F1-F12} and it will dump the
corresponding processor's stack trace. This is really helpful for
detecting deadlocks in the system
2025-06-02 11:39:18 +03:00
Bananymous 9883fb7bf6 Kernel: Rewrite epoll notifying system
This removes the need to lock epoll's mutex when notifying epoll. This
prevents a ton of deadlocks when epoll is notified from an interrupt
handler or otherwise with interrupts disabled
2025-06-02 11:39:18 +03:00
Bananymous 31bcad2535 LibC: Implement truncate 2025-06-01 13:48:03 +03:00
Bananymous b75970958e Kernel/LibC: Implement unlinkat 2025-06-01 13:48:03 +03:00
Bananymous 91756c057e LibC: Add all of the missing POSIX definitions in unistd.h and limits.h 2025-06-01 13:48:03 +03:00
Bananymous 56fdf6002c Kernel/LibC: Implement pthread_kill 2025-06-01 13:48:03 +03:00
Bananymous b1065fa01d Kernel/LibC: Add ppoll syscall and fix poll
poll is now using its own syscall instead of wrapping aroung pselect.
This adds less overhead on top of poll and adds support for POLLHUP
2025-06-01 13:48:03 +03:00
Bananymous 8ff9c030bf Kernel: Add better termios support
I'm not sure if this is correct but at least it's better than before :)
2025-06-01 13:48:03 +03:00
Bananymous 9b875fb930 Kernel: Make epoll work with different fds pointing to same inode 2025-06-01 13:48:03 +03:00
Bananymous 6542a037df Kernel: Make spinlocks more safe
Kernel now makes sure thread is not holding any spinlocks when it tries
to lock a mutex or yield. Spinlocks are supposed to be only used for
short times without the possibility of yielding
2025-06-01 13:48:03 +03:00
Bananymous 9f4b451501 Kernel: Fix epoll deadlock
If epoll_wait and epoll_notify were called at the same time, there was a
possible deadlock when epoll was confirming the event from the inode
2025-06-01 13:48:03 +03:00
Bananymous 1bd454b8fd Kernel/LibC: Implement utime* family functions
This patch adds *working*
 - utime
 - utimes
 - utimensat
 - futimens
2025-06-01 13:48:03 +03:00
Bananymous 4d4fb3b6ec Kernel: Cleanup and fix pipe
pipe now sends SIGPIPE and returns EPIPE when writing and no readers are
open
2025-05-29 01:02:22 +03:00
Bananymous 89c9bfd052 Kernel/LibC: Implement `socketpair` for UNIX sockets 2025-05-28 03:10:01 +03:00
Bananymous 12b93567f7 Kernel/LibC: Implement `getpeername` 2025-05-28 03:10:01 +03:00
Bananymous 44b762f916 Kernel/LibC: Implement pwrite and make pread non-locking 2025-05-28 03:10:01 +03:00
Bananymous 0e0d7016b3 Kernel: Rename has_hangup -> has_hungup 2025-05-17 12:39:23 +03:00
Bananymous 553c76ab0f Kernel: Add locking to inode's epoll list
This was prone to crashing :)
2025-05-17 12:36:36 +03:00
Bananymous 1bcd1edbf5 Kernel/LibC: Implement basic epoll
This implementation is on top of inodes instead of fds as linux does it.
If I start finding ports/software that relies on epoll allowing
duplicate inodes, I will do what linux does.

I'm probably missing multiple epoll_notify's which may cause hangs but
the system seems to work fine :dd:
2025-05-13 10:18:05 +03:00
Bananymous 143a00626b Kernel: Fix fork cmdline copying and copy environ 2025-05-13 10:16:21 +03:00
Bananymous 0eb981f51c Kernel: Fix Random.h includes 2025-05-13 10:16:21 +03:00
Bananymous a7bd4acd46 Kernel: Remove static variables from virtual tty 2025-05-13 10:16:21 +03:00
Bananymous 8e0a56b49a Kernel: Implement loopback network interface 2025-05-13 10:16:21 +03:00
Bananymous 9ff9d679e9 Kernel: Fix text mode cursor
Apparently text mode renders cursor in the *foreground* color. My
current clear function used the same color for foreground and background
making the cursor effectively invisible.

Also cursor hiding is now done by moving the cursor off bounds (0, height)
some website I read said this to be valid even on VGA compatible cards
without disable bit.

http://www.osdever.net/FreeVGA/vga/textcur.htm
2025-04-25 02:31:33 +03:00
Bananymous 9f4cb5c4dd Kernel: Make pseudo terminals not overwrite old data
If pseudo terminal buffer was filled, old implementation would overwrite
old data. This is bad if producer is capable of producing more data than
consumer can handle.
2025-04-23 22:03:53 +03:00
Bananymous a8edb8870e Kernel: Add support for 8bit and 24bit ANSI SGR 2025-04-23 22:03:53 +03:00
Bananymous dabc3c6cc4 Kernel: Don't wrap cursor immediatly at cols()
This prevents unwanted scrolling when writing to bottom right cell
2025-04-23 22:03:53 +03:00
Bananymous cc7c1ad30d Kernel: Add per terminal palette for TerminalDriver
This allows better color approximation on text mode and in future will
allow user to possibly change the palette
2025-04-23 18:44:37 +03:00
Bananymous f8e3ae0525 Kernel: Fix deadlock caused by multithreading
This allows multiple threads to concurrently call the most common
blocking syscalls:
- read
- write
- accept
- connect
- sendto
- recv
- pselect

This prevents a dead lock when for example process is waiting on a pipe,
but unable to write to it since process is locked.

This is the beginning of starting to remove processes own lock from
syscall and locking only necessary parts.
2025-04-22 04:51:53 +03:00