Commit Graph

970 Commits

Author SHA1 Message Date
Bananymous 309ec660b6 Kernel/LibC: Implement chroot 2025-08-11 03:45:38 +03:00
Bananymous af0bca74e4 Kernel/LibC: Implement {get,set,init}groups
This allows dropping /etc/group parsing from the kernel :D
2025-08-10 19:57:31 +03:00
Bananymous f41e254e35 Kernel: Fix dead lock on process exit 2025-08-10 19:57:31 +03:00
Bananymous 5b587d199e Kernel/LibC: Implement FIONREAD for tcp and udp sockets 2025-08-10 19:57:31 +03:00
Bananymous 7ad3f967db Kernel: Don't stop audio processing after each entry in AC97 2025-08-07 16:43:05 +03:00
Bananymous 72f85dce2b Kernel: Make userspace stack on-demand allocated
Also bump the hardlimit of stack size from 512 KiB->32 MiB. This still
feels quite low but is much better than before :D
2025-08-07 16:43:05 +03:00
Bananymous f5bbcc017c Kernel: Only send one smp message when reserving a range
This was causing some kernel panic because processors ran out of smp
message storage when reserving large areas.

Also most of the time there is no need to actually send the SMP message.
If process is mapping something to just its own address space, there is
no need for a TLB shootdown. Maybe this should be only limited to kernel
memory and threads across the same process. I'm not sure what the best
approach here and it is better to send too many invalidations that too
few!
2025-08-07 16:43:05 +03:00
Bananymous 647fedfa19 Kernel: Add missing multiboot.h 2025-08-05 17:12:26 +03:00
Bananymous f1369c8fd6 Kernel/LibC: Implement mprotect
There may be some race conditions with this but i think this is good
enough to start with
2025-08-05 03:09:24 +03:00
Bananymous 5940e912b3 Kernel/LibC: Implement simple futex 2025-08-05 03:09:24 +03:00
Bananymous 927fbda1e8 Kernel: Make on-demand paging thread safe 2025-08-05 03:09:24 +03:00
Bananymous cc04bd0f06 LibC/Kernel: Implement ttyname_r 2025-07-31 22:47:40 +03:00
Bananymous e72e1e4e43 LibC: Add _SC_NPROCESSORS_{CONF,ONLN) 2025-07-31 22:47:40 +03:00
Bananymous 2c65590134 Kernel: Add support for absolute position mouse 2025-07-19 18:00:39 +03:00
Bananymous 5874fd640e Kernel: Fix TmpFS for 32 bit target
There was a problem when sizeof(size_t) != sizeof(PageInfo)
2025-07-18 19:07:32 +03:00
Bananymous d5301508ec Kernel: Increase kernel thread stack size
HACK HACK HACK

This is just to make banan-os boot on one razer laptop where AML
triggers a stack overflow :)
2025-07-17 21:21:14 +03:00
Bananymous 793cca423b Kernel: Fix system timer disabling
I was actually not disabling system timer (HPET, PIT) when using lapic
timers for scheduling. This made BSB get too many timer interrupts :D
2025-07-16 20:02:04 +03:00
Bananymous 3960687f9d Kernel: Parse PCIConfig opregion address on read/write
I was testing on some hardware and _ADR does not have to exist in the
namespace when opregion is parsed :)
2025-07-16 15:34:36 +03:00
Bananymous 8a663cb94f Kernel: Implement basic AC97 driver 2025-07-15 14:17:49 +03:00
Bananymous 995dfa1455 Kernel: Fix AML PCIConfig OpRegion accesses
Apparently I'm not supposted to calculate device/function from the
offset, but parse them from the acpi namespace :)

This allows PCI PIN interrupt routing actually work
2025-07-04 13:21:02 +03:00
Bananymous 8da4f80453 Kernel: Add custom stack to double fault handler
This prevents triple faults!
2025-07-02 23:14:52 +03:00
Bananymous 6084aae603 Kernel: Add guard pages to kernel and userspace stacks 2025-07-02 23:12:36 +03:00
Bananymous 51fd7a607d Kernel: Fix IDE controller waiting
We did not correctly wait until controller is ready to receive data on
write command. Also remove possible kernel panic if controller sends
unexpected interrupts
2025-07-02 22:04:41 +03:00
Bananymous 8a0269d29e Kernel: Remove kernel processes
Kernel can just use raw threads, pretty muchs the only thing that
process provides is syscalls which kernel threads of course don't
need.

Also this makes init process have pid 1 :D
2025-07-02 01:54:03 +03:00
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