Commit Graph

158 Commits

Author SHA1 Message Date
d3130884b6 Kernel: Hack TTY to work as debug console
debug printing takes the debug lock, but TTY uses mutex for its lock
2026-06-25 01:41:41 +03:00
a19e6938eb Kernel: Remove TTY keyboard thread
This was really hacky as it had no idea when the keyboard had events
and the blocking was just one millisecond sleeps :D

Now keyboard device checks if current tty is receiving input and if so
it forwards the events to the TTY.
2026-05-20 04:17:03 +03:00
1dc26d3c06 Kernel: Cleanup inode stat updating
Inode now handles stat upates itself and calls sync function to make
updates visible on the underlying filesystem
2026-05-19 13:00:05 +03:00
6e95519acc Kernel: Make TTY write lock a mutex instead of a spinlock
The mutex could not be locked while processing ANSI DGR in VTTY
2026-05-17 00:29:20 +03:00
16967cd9c0 Kernel: Replace is_* with kind field
Replaced the is_* virtual functions with a kind field instead
2026-05-15 21:23:12 +03:00
647d6a273d Kernel: Changed stat values from func to be field
- Removed virtual functions for all of the stat stuff.
This did however introduce some issues, mainly with /proc
becoming out of sync if you changed your ID. I propose we
do the linux thing and just have a stat update function
which is optional, but allows dynamic updates of stat fields
for cases such as those in uid/gid in /proc.
- Simplified the API, although still kind of annoying
it is a bit simpler.
- Moved some of the FS structure from having the FS inode inside
the in memory inode to a Serialise <-> Deserialise model where
Inodes are deserialised from disk into in memory ones and then
back into on disk ones when it comes time for syncing.
This makes it semantically better in my opinion, as it explicitly
separates disk and non-disk functionality.
2026-05-15 20:49:04 +03:00
05c9f0640c Kernel/LibC: Replace terminal syscalls with ioctls
isatty, tc{get,set}attr, tc{get,set}pgrp are now implemented as ioctls
instead of separate syscalls
2026-05-15 17:03:33 +03:00
9f4271f6d8 Kernel: Remove the big inode lock
This moves locking to the inodes themselves which allows reducing lock
times significantly. Main inodes (ext2 and tmpfs) still do contain a
single big mutex that gets locked during operations but now we have the
architecture to optimize these.
2026-05-09 23:28:00 +03:00
b74812d669 Kernel: Remove unnused features from VirtualRange
On-demand paging has not been used ever since I made userspace stack be
a normal MemoryRegion.
2026-04-21 19:58:09 +03:00
eeef945c25 Kernel: Make tty use the new byte ring buffer 2026-02-28 14:53:15 +02:00
6a924db68c Kernel: Implement FIONREAD for tty and pty 2025-11-24 18:15:10 +02:00
db7ffcf9d5 Kernel/Terminal: Add support for bracketed paste mode
This gets rid of annoying warnings when running some programs like bash
2025-11-18 05:40:36 +02:00
34bdcb12e5 Kernel: Fix termios and enter key handling
Enter key now produces expected \r which gets converted to \n by default
by the ICRNL input flag.

Also input flags are now handled always, not just when ICANON is set.
I don't know why I though ICANON should disable input handling
2025-08-19 16:23:30 +03:00
ef6ee78fd1 Kernel/LibC: Implement chroot 2025-08-11 14:07:37 +03:00
6084aae603 Kernel: Add guard pages to kernel and userspace stacks 2025-07-02 23:12:36 +03:00
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
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
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
3283359ac8 Kernel: Cleanup ANSI DSR 2025-06-19 19:05:49 +03:00
9c86e5e54d Kernel: Add ANSI SGR 39 and 49
Also debug log unimplemented ANSI SRGs, this makes finding missing
commonly used ANSI SGR codes more easy
2025-06-18 20:34:55 +03:00
b668173cba Kernel: Fix pseudo terminal writability 2025-06-06 11:09:50 +03:00
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
73090ecb37 Kernel: TTY set EPOLLOUT 2025-06-05 22:04:51 +03:00
cfeabc4580 Kernel/Terminal: Fix ANSI SGR 8 bit color parsing 2025-06-05 20:43:57 +03:00
f79db874bf Kernel: Fix ANSI CSI 1J
I was accidentally clearing the whole screen when I needed to clear from
cursor to the end of the screen
2025-06-05 02:38:57 +03:00
8de19aff3c Kernel/Terminal: Fix 24 bit ANSI SGR color parsing 2025-06-05 02:38:07 +03:00
4c0b7d44b4 Kernel: Enable ECHOE and ECHOK, support VKILL, fix VEOF 2025-06-02 16:26:53 +03:00
fb466b5af7 Kernel: use termios c_cc values instead of hardcoded characters 2025-06-02 15:54:11 +03:00
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
692ba43182 Kernel: Fix spinlock bugs found by the new spinlock security 2025-06-01 13:48:03 +03:00
0e0d7016b3 Kernel: Rename has_hangup -> has_hungup 2025-05-17 12:39:23 +03:00
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
a7bd4acd46 Kernel: Remove static variables from virtual tty 2025-05-13 10:16:21 +03:00
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
418678466c Kernel: Fix text mode palette
ANSI and text mode color indices are not in the same order
2025-04-23 23:07:47 +03:00
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
a8edb8870e Kernel: Add support for 8bit and 24bit ANSI SGR 2025-04-23 22:03:53 +03:00
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
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
20e17a28cf Kernel: Fix \b handling
Don't clear the character, only move cursor backwards
2025-04-23 06:33:11 +03:00
28bf2d6374 Kernel/Terminal: Add support for ANSI DSR 2025-04-23 06:14:56 +03:00
8a00b53050 Kernel/Terminal: Fix ANSI SGR m for multiple values 2025-04-23 05:29:22 +03:00
85505b0482 Kernel: Fix ANSI SGR color invert 2025-04-18 17:31:46 +03:00
9258c73484 Kernel: Optimize VTTY cursor rendering
cursor is now only updated once after all consecutive `putchar`s are
handled.
2025-04-18 03:55:56 +03:00
6858546ce9 Kernel: Fix rendering bugs with framebuffer cursor 2025-04-18 03:54:17 +03:00
7c6966a9c4 Kernel: Add support for text mode terminal
This probably won't be used at all but it was so simple and made me do
really nice refactorings so i decided to add it :)
2025-04-18 02:45:06 +03:00
40d1d20cd6 Kernel: Move cursor handling from TTY -> TerminalDriver 2025-04-18 02:43:41 +03:00
c0942d78cb Kernel: Fix TTY ANSI ? handling 2025-04-18 02:42:49 +03:00
cef8779bf7 Kernel: Improve error handling when setting TTY font 2025-04-18 02:42:24 +03:00
554b13ac50 Kernel: Restructure terminal initialization
This is still very ugly and will be rewritten in the future :D
2025-04-18 01:19:59 +03:00