Commit Graph

437 Commits

Author SHA1 Message Date
Bananymous 4189a1c729 LibC: Make _init and _fini weak symbols
These seem to be missing sometimes when making shared executables
2024-09-11 14:39:07 +03:00
Bananymous a07cbabcb3 LibC: Define function sizes for setjmp and longjmp
dynamic linking was complaining about these not existing
2024-09-10 16:21:20 +03:00
Bananymous 19d16620a6 DynamicLoader: Don't do file backed mapping for filesz == 0 2024-09-05 14:50:05 +03:00
Bananymous e8bcebfb8e DynamicLoader: Use file backed mmap when possible 2024-09-05 13:59:39 +03:00
Bananymous 6affef76b1 test-shared: Add more shared tests 2024-09-05 12:59:48 +03:00
Bananymous 32ba4d07e2 Userspace: Remove unnecessary mov instruction from crt0 2024-09-05 12:59:05 +03:00
Bananymous ddaaf89c87 BuildSystem: Make default libc a shared library 2024-09-05 12:58:35 +03:00
Bananymous 9aed8dbe6b Toolchain: Build crtbeginS.o crtendS.o and shared libgcc 2024-09-05 12:58:21 +03:00
Bananymous aa7e92b275 Userspace: Write a dynamic loader
This allows running executing dynamically linked executables!
2024-09-05 12:58:21 +03:00
Bananymous f30947336a BuildSystem: Cleanup cmake files 2024-09-05 12:52:25 +03:00
Bananymous 0bb44d7b75 LibC: Fix errno to work with shared libraries 2024-09-04 21:16:04 +03:00
Bananymous 35743cc8e6 LibC: Compile both static and shared version of LibC
libc target is now set as an alias for libc-static
2024-09-02 21:28:02 +03:00
Bananymous 5f92807fdd userspace: Allow building without SSE
I had added changes that had broken compilation without sse support
2024-09-02 21:25:00 +03:00
Bananymous 700c3444f5 LibELF: Add more values and macros for interpreting fields 2024-09-02 20:40:38 +03:00
Bananymous 2ae2ede0b2 LibELF: Add value definitions for DT_ 2024-08-30 15:35:01 +03:00
Bananymous 8da2f12ba6 Kernel: Only load program headers of interpreter if its present
I was loading program headers of both executable and interpreter but
that is incorrect. The interpreter will itself load the program headers
of the executable.
2024-08-28 21:19:37 +03:00
Bananymous 50ab391133 test-globals: print something when calling main
This shows that constructors and destructors are called in correct order
2024-08-28 17:09:07 +03:00
Bananymous 991647bc8f Userspace: Add shared library test
I will use this while testing my dynamic loader
2024-08-28 17:08:37 +03:00
Bananymous 57300687ff LibC: Cleanup and fix missing LibC headers 2024-08-28 17:07:58 +03:00
Bananymous d559339f5f LibC: Compile shared libc as well as static 2024-08-28 17:07:15 +03:00
Bananymous 2bf65ef512 Kernel: Invoke ELF interpreter instead if it is specified 2024-08-28 17:06:32 +03:00
Bananymous 5121d0d934 Kernel: Allow loading PIEs
This is initial work towards implementing dynamic loader and shared
library support.
2024-08-27 17:32:22 +03:00
Bananymous 2c520391eb Kernel/LibC: Add support for init_array and fini_array 2024-08-27 00:47:03 +03:00
Bananymous 991ae4383a Kernel/LibC: Implement fchmod 2024-08-25 15:07:42 +03:00
Bananymous bec3e8654f Shell: Implement escaping quotes in quoted strings 2024-08-24 17:13:50 +03:00
Bananymous 500f774b7f LibC: Add a lot of stub implementations for different libc functions
some ports want to link against these, but they are not ever called
based on simple testing

This patch adds stubs for
- openlog
- syslog
- getrusage
- mlock
- mprotect
- getpeername
- shutdown
- tzset
- mktime
2024-08-22 15:10:41 +03:00
Bananymous ca8832c0e1 LibC: Implement getaddrinfo and freeaddrinfo, add stub for getnameinfo 2024-08-22 15:10:41 +03:00
Bananymous 1cbba113fd LibC: Add and cleanup some networking structures and definitions 2024-08-22 15:10:41 +03:00
Bananymous 45b4b33a3d LibC: Add definitions for some integer sizes to limits.h 2024-08-22 15:10:41 +03:00
Bananymous c453a8e2dc LibC: Implement poll() using select 2024-08-22 15:10:41 +03:00
Bananymous 72f3fe0b12 LibC: Add empty files sys/param.h and sys/file.h
For some reason some ports include these files even when they detect
that they are not available
2024-08-22 14:47:59 +03:00
Bananymous 46b34817d2 snake: Remove random goto statements when regenerating apple's position 2024-08-16 17:36:37 +03:00
Bananymous 723e458bd7 Kernel/Terminal: Update terminal color themes and fix TTY bright/dark 2024-08-12 21:15:55 +03:00
Bananymous 25a47f0df3 LibC: Implement ungetc()
I didn't really test this, but I think this implementation does what it
needs to :)
2024-08-12 19:14:55 +03:00
Bananymous 1bd7b86e60 Terminal: Implement cursor blinking
This looks much nicer than the old static cursor
2024-08-12 14:24:17 +03:00
Bananymous 18e7cf2069 Terminal: Add cursor rendering
Cursor is now shown at the current position. It can be hidden (or shown)
with the ansi `\033[?25h` or `\033[?25l`
2024-08-12 00:50:06 +03:00
Bananymous 60b4d90608 LibGUI: Add Window::get_pixel()
This is fine as its not reading from video memory
2024-08-12 00:49:35 +03:00
Bananymous 5197000124 LibC: Fix qsort for types bigger than 64 bytes 2024-08-11 18:00:05 +03:00
Bananymous 9e79ef2a91 Terminal: Use pseudo terminal instead of pipes
Terminal can now send signals from keyboard (ctrl+c) to programs running
in the terminal!
2024-08-11 01:02:59 +03:00
Bananymous a5a097fa4a Kernel/LibC: Add initial pseudo terminal support
This patch implements posix_openpt() and ptsname()

grantpt() and unlockpt() are left in LibC as stubs, as posix_openpt
currently does all of the needed work.
2024-08-11 01:02:59 +03:00
Bananymous ad645f31d0 Kernel/LibC: Add setsid() 2024-08-11 00:58:12 +03:00
Bananymous f08d429851 Terminal: Add utf8 parsing for input
This patch adds possibility to render multibyte utf8 codepoints!
2024-08-11 00:54:51 +03:00
Bananymous a12bfe4639 LibC: Don't crash when calling tcflush() 2024-08-09 17:03:21 +03:00
Bananymous 6cda639869 LibC: Add stubs for tmpfile, mktemp and fchmod 2024-08-09 17:02:49 +03:00
Bananymous 2797fe116f LibC: Add stubs for some functions in {dlfcn,ftw,utime,wchar}.h 2024-08-09 17:01:41 +03:00
Bananymous e768cd53fb LibC: Add definition for SIGWINCH
This is actually not yet sent, but programs can install signal handlers
for it!
2024-08-09 17:00:13 +03:00
Bananymous 83e2ad40d6 LibC: Implement gai_strerror and add stubs for {get,free}addrinfo 2024-08-09 16:59:49 +03:00
Bananymous 7ebd0699e3 LibC: Add _PC* definitions to unistd.h
These are not used for anything yet
2024-08-09 16:58:58 +03:00
Bananymous 46b1d4d194 LibC: Remove cxx abi stuff from libc
These will cause multiple definitions when linking with libstdc++
2024-08-09 16:58:11 +03:00
Bananymous f60e265397 LibC: Add ldexp to math.cpp 2024-08-09 16:57:16 +03:00
Bananymous 2e642327ea LibC: Implement localeconv() 2024-08-09 16:56:48 +03:00
Bananymous a87ce41030 LibC: rename fd_set internal variable
binutils seems to need access to the internal type and uses this name
for lookup.
2024-08-09 16:55:52 +03:00
Bananymous 0c8cae4cc3 LibC: Move ioctl to <sys/ioctl.h>
Some ports seem to be assuming that ioctl exists there and not in
stropts.h
2024-08-09 16:54:30 +03:00
Bananymous 1c67b5e812 Kernel: Fix wait syscall to report status of exited children 2024-08-09 16:52:35 +03:00
Bananymous 6fedf06150 LibC: Implement {sig,_,}{longjmp,setjmp} 2024-08-09 15:58:56 +03:00
Bananymous 91d513a672 2000th COMMIT: userspace: Implement basic fetch program bananfetch
This patch adds a obligatory fetch program to banan-os!

This program (`bananfetch`) fetches some basic information about the
operating system and the hardware its running on!
2024-08-09 15:58:56 +03:00
Bananymous 44f0ec601f Kernel: Expose /proc/meminfo and fix /proc/<pid>/meminfo
Thread was unconditionally calling <stack>->size() without validating
that the stack actually exists
2024-08-09 15:58:56 +03:00
Bananymous 2a659a9d03 BuildSystem: Fix enable sse definition
__enable_sse was never actually defined for any targets. This also adds
__arch definition for libc (so `utsname` works).
2024-08-09 15:52:42 +03:00
Bananymous 3b23458ecc LibC: Start work on locales
This patch adds 2 locales, POSIX locale and UTF8 locale.

functions `mbstowcs()` and `strcoll()` use locales to do convertions and
comparison respectively.
2024-08-09 15:52:42 +03:00
Bananymous 7afdfb150f LibC: Rewrite sigprocmask in terms of pthread_sigmask
Also don't fail SYS_SIGPROCMASK if how is invalid and set is NULL.
2024-08-07 17:01:35 +03:00
Bananymous fe94d6cf89 LibC: Implement dummy rename() so vim can save files
vim calls rename when saving a file. This patch adds dummy
implementation that only works for regular files and does a copy instead
of proper rename.
2024-08-05 20:16:05 +03:00
Bananymous 4d96ae56ac LibC: Add stubs for ungetc(), tcflush() and symlink() 2024-08-05 01:48:24 +03:00
Bananymous adadb10b15 LibC: Fix strsignal() and implement psignal() 2024-08-05 00:59:03 +03:00
Bananymous a749b9806e LibC: Add definition for h_errno
Nothing uses this yet, but linking will succeed
2024-08-05 00:58:06 +03:00
Bananymous 615d9d4abe LibC: Add INADDR_LOOPBACK
Some port was using this. Loopback addresses are not supported, but they
will be 127.0.0.1.
2024-08-05 00:56:42 +03:00
Bananymous aa03274093 LibC: Remove O_DIRECTORY from opendir()
opendir() did not work on symlinks after with this flag...
2024-08-05 00:55:03 +03:00
Bananymous e7a06979ec LibC: Implement usleep()
This is not a POSIX function, but some ports seem to be using it either
way
2024-08-05 00:54:17 +03:00
Bananymous 3651306f57 LibC: Implement strto{u,i}max() 2024-08-05 00:53:27 +03:00
Bananymous 5dce4e6aea LibC: Implement strftime()
I did not test this at all, this might very well be broken
2024-08-05 00:49:44 +03:00
Bananymous 1d9041f2aa LibC: make opendir() fail if path is not a directory 2024-08-01 22:57:46 +03:00
Bananymous a578527012 Kernel/LibC: Implement ioctl(TIOCGWINSZ)
This allows ncurses to get the window size!
2024-08-01 22:56:26 +03:00
Bananymous a33b63d066 Kernel/LibC: Implement alarm() and setitimer()
This makes vim able to start!
2024-08-01 21:09:56 +03:00
Bananymous 6de350ce9d Kernel/LibC: Cleanup, fix and implement a lot of signal code
This patch implements sigsets and some of their usages
2024-08-01 17:01:18 +03:00
Bananymous 401b460d75 LibC: Implement setbuf() and setvbuf() 2024-08-01 01:30:00 +03:00
Bananymous c440204fa5 LibC: Implement dummy strcoll() 2024-07-31 23:58:10 +03:00
Bananymous adf50dffd8 LibC: Implement uname() 2024-07-31 23:54:26 +03:00
Bananymous 20d38ed28c LibC/Shell: Implement gethostname() and shell uses it for hostname 2024-07-31 23:53:55 +03:00
Bananymous edc30cd71d LibC: Compile without exceptions
This allows libc to not require __gxx_personality_v0. I can maybe add
C++ back to libc... :D I don't know why I did not research earlier what
this symbols was used for
2024-07-31 23:33:41 +03:00
Bananymous 10ce03a1e7 LibC: Implement ctime() and asctime() 2024-07-31 23:26:10 +03:00
Bananymous 5fca5c774a LibC: Implement umask() 2024-07-31 23:26:10 +03:00
Bananymous fc6c39e670 LibC: Implement gettimeofday() 2024-07-31 23:26:06 +03:00
Bananymous e52dac3b25 LibC: Implement tmpnam()
This implementation is not really spec compliant as rand() does not
guarantee TMP_MAX different outputs + seeding
2024-07-30 12:02:30 +03:00
Bananymous 62db9a8ef3 LibC: Implement C++ static guards 2024-07-30 12:02:05 +03:00
Bananymous f0be4f86a6 LibC/Kernel: Implement access 2024-07-30 11:51:07 +03:00
Bananymous e5bb843059 LibC/Kernel: Implement ttyname 2024-07-30 11:41:18 +03:00
Bananymous ca774dfeb5 LibC: Implement setlocale() for C locale 2024-07-30 11:33:02 +03:00
Bananymous 681d8327f5 LibC/Kernel: Cleanup termios code
This is still not correct, but much better than it used to be
2024-07-30 11:10:43 +03:00
Bananymous e00efca170 Userspace: Pprogram template and loadfont mark install as optional 2024-07-21 17:41:40 +03:00
Bananymous 3ab1214012 LibC: Fix _toupper and _tolower definitions
They were using C++ global namespace, which of course does not exist for
C targets.
2024-07-18 01:10:51 +03:00
Bananymous 61f0043cd8 resolver: Fix infinite debug printing loop, if client disconnects 2024-07-16 15:05:07 +03:00
Bananymous 5b8fdbc82d LibC: Don't expose math.h in stdlib.h 2024-07-16 12:47:38 +03:00
Bananymous a5cb4057f9 Kernel: Implement unified input files for device hot-plugging support
/dev/keyboard and /dev/mouse can be read for events from any attached
keyboard or mouse respectively. This makes device hot-plugging support
pretty much automatic for TTY, GUI, and whatever takes input.
2024-07-15 22:11:15 +03:00
Bananymous 442ea8a692 BAN: Remove Optional emplace constructor
This was kind breaking some initializations. Emplacing is still possible
through Optional::emplace
2024-07-14 01:53:50 +03:00
Bananymous a97a574718 Kernel: Rewrite the whole input system
PS/2 code is now kind of messed up, but it works. Keyboards and mice are
now an abstract class that is automatically exposed to userspace. This
will make adding USB input much nicer.
2024-07-14 01:53:50 +03:00
Bananymous 8ddab05ed3 BuildSystem: Cleanup userspace directory layout
userspace programs are now in userspace/programs
userspace tests are now in userspace/tests

This makes listing userspace projects much cleaner. Libraries were
already separated to their own directory, so other programs should also.
2024-07-03 09:18:02 +03:00
Bananymous 5dc441c4af Kernel/userspace: Implement KD_LOADFONT and loadfont program 2024-07-03 09:02:49 +03:00
Bananymous d58a569660 WindowServer: Limit msync to 60 Hz and only sync necessary pages
This speeds up GUI a lot. I can now run GUI on real hardware at almost
60 Hz.
2024-06-29 19:00:58 +03:00
Bananymous 0c645ba867 LibGUI: Window now uses double buffering
This allows data in shared memory object be always up to date. With this
change window server can update lazily, and not necessarily on all
invalidate calls
2024-06-27 00:39:59 +03:00
Bananymous f538dd5276 test-tcp: Fix printing of "connection reset" when tcp connection closed 2024-06-27 00:39:22 +03:00
Bananymous 66905fcc08 http-server: Make http-server actually usable
http-server now implements basic static content from a specified
directory.
2024-06-25 19:36:10 +03:00
Bananymous af4b138094 Kernel/LibC: Implement realpath
realpath is implemented as a syscall. This is not really required but it
was the easiest way to get it working as there is already path
canonicalization at kernel level.
2024-06-25 19:32:40 +03:00
Bananymous 95681a7a05 LibImage: Cleanup bicubic calculations 2024-06-25 11:04:03 +03:00
Bananymous 67dfe0bcf3 BAN: Allow String::formatted to fail 2024-06-25 11:04:03 +03:00
Bananymous 61aa1ea11f sudo: Fix installation permissions
I had accudentally removed SETUID bit from sudo. This required to
elevate the permissions.
2024-06-24 15:00:08 +03:00
Bananymous 20aa7c79d1 BuildSystem: Fix crt file installation
crt files should be installed always before userpace programs are
linked.
2024-06-22 17:30:00 +03:00
Bananymous 22548a3f4a BuildSystem: Fix crt file installation
crt files for userspace are now a dependency of libc, which means that
everytime libc gets installed, crt files will also install.

This fixes the problem when building libc
2024-06-21 17:10:58 +03:00
Bananymous 9e1b5cbaab BuildSystem: Cleanup CMake code to allow libc only installation
There was no way to just install libc which is required for stdlibc++
2024-06-21 01:45:14 +03:00
Bananymous 1488ec5a03 Userspace: Implement the most basic http server
This server just responds with static http "hello world" to every
incoming request
2024-06-20 13:29:01 +03:00
Bananymous ad6d95ba52 BuildSystem: Rework the whole cmake build system
Now files are installed using the install() command instead of manually
copying files to their destinations. This allows automatic recompilation
of headers that did not work previously
2024-06-19 09:40:03 +03:00
Bananymous 318ce5dec8 All: Fix a lot of compiler warnings from header files
While reworking build system, header files started to report warnings.
2024-06-18 23:02:10 +03:00
Bananymous c69919738b BuildSystem: Move all userpace libraries under the userspace directory
As the number of libraries is increasing, root directory starts to
expand. This adds better organization for libraries
2024-06-18 13:14:35 +03:00
Bananymous aaf7a249c6 image: Add nicer error message if image could not be parsed 2024-06-17 22:58:59 +03:00
Bananymous dd64e2060e WindowServer: Add support for background images
WindowServer now looks in _$HOME/.config/WindowServer.conf_ for a
configuration file that can specify a background image.

Also add default background image /usr/share/images/sample.ppm to the
base sysroot provided in the git repo.
2024-06-16 00:28:09 +03:00
Bananymous 157e05f57c image: Implement --scale argument to scale image to framebuffer
Also fix bug where red and blue channels were flipped
2024-06-15 17:24:01 +03:00
Bananymous 672ce40618 LibImage: Move userspace image parsing to its own library
The image utility now uses this tool instead of parsing images on its
own.
2024-06-14 11:05:54 +03:00
Bananymous a9b0bfa740 LibC: Make ino_t always 64 bit 2024-06-14 00:18:21 +03:00
Bananymous 843a6851c4 Userspace: Start work on a terminal emulator
Terminal is still missing some ANSI codes, cursor and pseudo terminal
support.

Shell's builtin start-gui now launches a Terminal instead of test
windows.
2024-06-03 18:04:33 +03:00
Bananymous 234051d6bc Shell: Optimize drawing characters at the end of a command 2024-06-03 18:03:19 +03:00
Bananymous 981c0eb8bc Shell: Only set terminal properties if STDIN is a TTY 2024-06-03 18:02:49 +03:00
Bananymous 6346d1b6c7 Shell: Add builtin command for starting window server and test windows 2024-06-02 17:27:40 +03:00
Bananymous 05ee242b80 WindowServer: Add window title to title bar and send close events 2024-06-02 17:27:09 +03:00
Bananymous ae3ae6fd0e WindowServer: Fix partial invalidation over cursor 2024-05-31 03:20:21 +03:00
Bananymous 011a5f57e1 WindowServer: Add title bars and clean up code 2024-05-31 03:02:58 +03:00
Bananymous c2b6ba0d5a Userspace: Start work on GUI and WindowServer
Current implementation can create custom windows and each window has
its own framebuffer. When window wants to write its framebuffer to the
screen it will send a message to the WindowServer using unix sockets.
2024-05-29 16:00:54 +03:00
Bananymous 8bc6c2eb20 Kernel: Move KeyEvent/MouseEvent from kernel to LibInput 2024-05-28 23:30:08 +03:00
Bananymous cc2cc2849e Whoami: Rewrite whoami using getlogin 2024-05-23 15:44:21 +03:00
Bananymous 06f4b0b29a BAN: Make String and StringView header only
This allows linking with libc without having to link ban
2024-05-23 15:43:26 +03:00
Bananymous 967f9a9174 Shell: Ignore tab as that just fucks up formatting 2024-05-07 14:16:17 +03:00
Bananymous 414f0f6cd9 Userspace: Don't link with libc
This fixes bug where sometimes cmake does not find libc from sysroot

LibC is linked per program in its own CMakeLists.txt
2024-04-03 14:46:18 +03:00
Bananymous 5dbe51a52e Userspace: Update printf formats to compile on 32 bit 2024-03-26 03:03:33 +02:00
Bananymous 7f5c850744 Userspace: Add us keymap and make it default 2024-03-19 12:30:57 +02:00
Bananymous b979023b9d Shell: Add test cases for stroul and strod in builtin `test-strtox` 2024-02-16 15:35:02 +02:00
Bananymous c469d9b3ff Shell: Add builtin test for strtol `test-strtol` 2024-02-14 22:38:16 +02:00
Bananymous 1f467580ee Userspace: Add test for popen 2024-02-14 17:23:26 +02:00
Bananymous 7eb5d220fd Userspace: Implement getopt for testing libc getopt() 2024-02-14 15:01:27 +02:00
Bananymous 420a7b60ca resolver: use select for client communication 2024-02-12 23:47:39 +02:00
Bananymous ccde8148a7 Userspace: Implement basic udp test program 2024-02-12 04:45:42 +02:00
Bananymous b9bbf42538 Userspace: Implement basic test program for tcp connection 2024-02-12 04:45:42 +02:00
Bananymous f117027175 resolver: dump errors to debug output 2024-02-08 18:34:15 +02:00
Bananymous 5a939cf252 Userspace: Add simple test for unix domain sockets 2024-02-08 13:18:54 +02:00
Bananymous 065ee9004c Userspace: Add DNS cache to resolver
Also the format of resolver reply is now just sockaddr_storage with
family set and address in the storage field.
2024-02-08 12:06:30 +02:00
Bananymous 2424f38a62 Userspace: Implement super simple DNS resolver in userspace
You connect to this service using unix domain sockets and send the
asked domain name. It will respond with ip address or 'unavailable'

There is no DNS cache implemented so all calls ask the nameserver.
2024-02-08 03:14:00 +02:00
Bananymous 40e341b0ee BAN: Remove unstable hash map and set
These can now be implemented safely with new linked list api
2024-02-06 17:35:15 +02:00
Bananymous f804e87f7d Kernel: Implement basic gateway for network interfaces 2024-02-05 18:18:56 +02:00
Bananymous b2291ce162 Kernel/BAN: Fix network strucute endianness 2024-02-05 18:18:56 +02:00
Bananymous 89805fb092 dhcp-client: Use dprintln for debug printing 2024-02-05 01:24:45 +02:00
Bananymous 692cec8458 Kernel/Userspace/LibC: Implement basic dprintln for userspace 2024-02-05 01:24:09 +02:00
Bananymous 79897e77dc dhcp-client: Remove packet send test :D 2024-02-03 18:04:31 +02:00
Bananymous 2138eeb87f Userspace: Implement super simple DHCP client 2024-02-03 02:41:06 +02:00
Bananymous 7cb71ec6fb test-sort: Test more algorithms and cleanup output format 2024-02-01 15:22:28 +02:00