Commit Graph

201 Commits

Author SHA1 Message Date
Bananymous 97ea4986af Kernel/LibC: implement proper getpgid and setpgid 2023-08-22 14:53:12 +03:00
Bananymous 42b90ae76c Kernel/LibC: Add {get,set}pgrp() 2023-08-22 11:36:33 +03:00
Bananymous b10168eb1c LibC: make printf buffer only 128 bytes
Only reason for it to be big is if you want super large zero padding
for your number. This will eventually be handled without the buffer.
2023-08-18 16:49:27 +03:00
Bananymous dc7391dc89 BuildSystem: only apply stack usage warning to libc 2023-08-17 20:49:52 +03:00
Bananymous dcd8374b89 LibC: add fileno() and fdopen()
fdopen() doesn't currently care about mode and will have same mode
as the underlying file descriptor.
2023-08-17 12:03:59 +03:00
Bananymous 8e4216215e Kernel/LibC: add dup() syscall and function 2023-08-17 12:03:29 +03:00
Bananymous 9a63d3b2da LibC: printf handles nan and inf 2023-08-16 10:49:34 +03:00
Bananymous bf02330db9 LibC: math.h defines is*() macros and uses builtins for values 2023-08-16 10:41:55 +03:00
Bananymous d34c0a5abe LibC: cleanup fstatat 2023-08-11 12:25:15 +03:00
Bananymous 165a379c73 LibC: Fix S_IF* macros and add macros for access/type masks 2023-08-11 10:30:50 +03:00
Bananymous c67a7cec5b LibC: fix typo 2023-08-02 22:10:12 +03:00
Bananymous 13852e865c LibC: sys/wait.h now has proper exit status macros
We use the same format as basically every implementation
2023-08-01 10:32:04 +03:00
Bananymous 679d47131d BuildSystem: Edit build flags regarding sse and warnings 2023-07-31 22:31:17 +03:00
Bananymous 8ec6d4c9fc LibC: we don't parse syscall arguments in unistd
We just call Kernel::syscall() with 5 arguments from the variadic function.

This was a necessary addition since the syscall() function
used over 2 KiB of stack space.
2023-07-31 22:24:11 +03:00
Bananymous 432c296b7b Kernel: Implement SYS_GET_PID and SYS_TCSETPGID
we don't have consept of process groups yet
2023-07-24 22:29:59 +03:00
Bananymous adb14ba373 Kernel: Userspace signal handlers are now called one at a time
I added a syscall for telling the kernel when signal execution has
finished. We should send a random hash or id to the signal trampoline
that we would include in the syscall, so validity of signal exit can
be confirmed.
2023-07-23 13:34:53 +03:00
Bananymous 7391d91317 Kernel/LibC: add SYS_SIGNAL/signal() 2023-07-21 20:08:13 +03:00
Bananymous 2149cec29f Kernel: Make signals more POSIX 2023-07-21 20:01:12 +03:00
Bananymous ad756c36fc Kernel/LibC: Add SYS_KILL/kill() 2023-07-21 19:27:38 +03:00
Bananymous dcd4d0daeb Kernel/LibC: Add bareboness signals
You can now call raise() to raise a signal. Signal handlers are
not yet supported, but the handling works :)
2023-07-21 15:45:02 +03:00
Bananymous bba09a3cd0 LibC: add getpwname() and getpwuid() 2023-07-13 12:01:16 +03:00
Bananymous 985df3532b LibC: implement endpwent(), getpwent() and setpwent() 2023-07-13 11:22:09 +03:00
Bananymous 4972284dde Kernel: open() and openat() now take mode as parameter
O_CREAT now tries to create file if O_CREAT is specified
2023-07-10 15:08:54 +03:00
Bananymous 6d93c1eb92 LibC: add NAME_MAX to limits.h
This is defined to 255 which is _XOPEN_NAME_MAX, smallest value
for XOPEN compliance
2023-07-10 11:48:11 +03:00
Bananymous 274ecbba78 LibC: limits.h now defined OPEN_MAX 2023-07-07 23:08:49 +03:00
Bananymous a549336530 Kernel/LibC: add basic dup2 2023-07-06 23:17:54 +03:00
Bananymous 4eb95c963d Kernel/LibC: Add basic pipe() syscall and command
You can now create pipes :)
2023-07-06 22:16:26 +03:00
Bananymous 22caacd2a9 LibC: add read() and write() to unistd 2023-07-06 22:15:55 +03:00
Bananymous 3c068aa0ae Kernel/LibC: add clock_gettime() for CLOCK_MONOTONIC
This gets the number of milliseconds since boot
2023-07-06 00:38:29 +03:00
Bananymous d99e704728 LibC: Fix syscall SYS_READ and SYS_WRITE arguments 2023-06-19 10:38:29 +03:00
Bananymous 0f63cfa43f Kernel/LibC: add SYS_{SET,GET}_PWD and chdir, getpwd 2023-06-12 02:02:52 +03:00
Bananymous b254ade69b Kernel: Add SYS_GET_{,E}{UID,GID} 2023-06-11 22:37:00 +03:00
Bananymous ef4ebaa969 Kernel: Add syscalls for set{,e,re}{uid,gid} 2023-06-11 22:37:00 +03:00
Bananymous 99f8133b91 LibC: gid_t and id_t are now signed types
I have no idea why I had made them unisigned
2023-06-11 22:37:00 +03:00
Bananymous 51eb44bf40 Kernel/Userspace: Add basic init process
This process parses /etc/passwd and promps login screen.
When an username is entered, it will launch that users shell
2023-06-11 22:37:00 +03:00
Bananymous 071da18fa3 LibC: add strchrnul()
this is a gnu libc extension
2023-06-11 20:18:03 +03:00
Bananymous 8be28012ee LibC: Reorder some syscalls 2023-06-11 03:29:22 +03:00
Bananymous 5aed186827 Kernel: Add SYS_OPENAT 2023-06-11 03:29:22 +03:00
Bananymous f0b22c48b2 LibC: implement close 2023-06-11 03:29:22 +03:00
Bananymous 52c4eebd77 Kernel: Implement SYS_FSTAT 2023-06-11 03:29:22 +03:00
Bananymous 24f0d26fce LibC: Implement basic dirent functionality
We don't currently support seeking
2023-06-11 03:29:22 +03:00
Bananymous 7a5d5cabad Kernel: Add syscall for reading directory entries 2023-06-11 00:18:08 +03:00
Bananymous f7de310889 LibC: add missing O_EXEC and O_SEARCH 2023-06-11 00:17:18 +03:00
Bananymous 86f58f60cb LibC: implement setenv, unsetenv, putenv 2023-06-05 22:51:02 +03:00
Bananymous 064ce568c2 Kernel: add basic support for environment variables
exec functions will search files from PATH
2023-06-05 22:51:02 +03:00
Bananymous b0e9ab0519 Kernel/LibC: pass environ pointer to process 2023-06-05 21:12:08 +03:00
Bananymous 480842a203 LibC: abort now prints 'abort()' and exits
we used to call assert in abort which then recursively called
abort again.
2023-06-05 18:23:19 +03:00
Bananymous 9d64dbd5c2 Kernel/LibC: add SYS_STAT and stat(), lstat() 2023-06-05 14:37:14 +03:00
Bananymous cbb9f47ee5 LibC: add wait and waitpid
Note that wait() doesn't work since only waiting for specified
pid is supported. wait() will just return -1 and set errno to
ECHILD.
2023-06-04 18:00:52 +03:00
Bananymous 4f84faf392 LibC: printf string persision works now 2023-06-03 15:07:02 +03:00
Bananymous 3c3c7826ef LibC: Add simple definition for realloc
The syscall just crashes the kernel currently. I will implement
this when needed
2023-06-02 17:56:13 +03:00
Bananymous 2207357b93 LibC: add __cxa_at_exit() for libc 2023-06-02 17:50:55 +03:00
Bananymous 3a69768eb0 LibC: remove select() declaration
This already comes from sys/select.h
2023-06-02 17:29:09 +03:00
Bananymous afb29ff3ec LibC: rename [[noreturn]] to __attribute__((__noreturn__))
This compiles with C compiler
2023-06-02 17:28:36 +03:00
Bananymous e6f0f891a6 LibC: stdlib.h doesn't seem to typedef wchar_t without __need_wchar_t 2023-06-02 17:27:31 +03:00
Bananymous 36e5aa4683 LibC: fix INFINITY definition typo 2023-06-02 17:27:14 +03:00
Bananymous 7738050105 LibC: fix DIR typedef for C code 2023-06-02 17:26:38 +03:00
Bananymous 4bf11ec349 LibC: complex.h undefs I before defining it 2023-06-02 17:13:09 +03:00
Bananymous d821012eed LibC: mbstate_t is empty struct 2023-06-02 17:10:29 +03:00
Bananymous 35c6edd989 LibC: fix sig_atomic_t definition 2023-06-02 17:08:43 +03:00
Bananymous cb359a05dc BuildSystem: link libraries when they change
This also fixed the need for manual linkin on firt build
2023-05-31 23:01:40 +03:00
Bananymous 0acab11620 LibC: add execl 2023-05-31 22:36:26 +03:00
Bananymous ab61b49aca Kernel: Add SYS_EXEC syscall 2023-05-31 20:57:33 +03:00
Bananymous 341f7e41e5 LibC: Fix some headers to make gcc build again 2023-05-30 01:17:45 +03:00
Bananymous 7151bb86a8 Kernel/LibC: opening standard files is done in libc 2023-05-29 20:21:19 +03:00
Bananymous 2a34391b71 LibC: open() now just returns syscall(SYS_OPEN, ...)
errno is handled in syscall()
2023-05-29 20:19:17 +03:00
Bananymous 0c316ebfb2 Kernel: Add SYS_SLEEP 2023-05-28 22:34:48 +03:00
Bananymous 6fdbe6f9c2 Kernel: Add bareboness fork() function 2023-05-28 18:08:49 +03:00
Bananymous 481c8406f3 LibC: fputs uses fputc instead of putc 2023-05-28 17:48:34 +03:00
Bananymous f79250c4d4 LibC: Rewrite all the headers.
We now have more or less posix issue 2018 conforming libc headers.

This was a really time consuming and boring operation but it had to
be done.

Now we get to actually start implementing libc :)
2023-05-26 22:31:21 +03:00
Bananymous 9e0abbc2f0 Kernel: Add bareboness possibility to set termios 2023-05-26 22:31:21 +03:00
Bananymous 4a4a3bf184 Kernel/LibC: move file offset back to kernel
This makes keeping track of offsets easier and more proper
2023-05-26 22:31:21 +03:00
Bananymous d82c6c2337 LibC: fix bugs with printf 2023-05-15 22:47:08 +03:00
Bananymous 1a0fdc5a44 LibC: printf now prints 0 as integer 2023-05-11 18:20:37 +03:00
Bananymous 53f4b5a9da LibC: add function declarations to sys/stat.h 2023-05-11 15:11:33 +03:00
Bananymous 1d4a6c3a42 LibC: add function declarations to dirent.h 2023-05-11 01:42:52 +03:00
Bananymous 40083e4aa1 LibC: add definitions to math.h 2023-05-11 01:40:42 +03:00
Bananymous bd929bff07 LibC: add defines in stdio.h 2023-05-11 01:39:16 +03:00
Bananymous cd4a0530fa LibC: add function declarations to unistd.h 2023-05-11 00:34:03 +03:00
Bananymous 273fdd2235 LibC: add function declarations to string.h 2023-05-11 00:34:03 +03:00
Bananymous b20f2e8d31 LibC: add function declarations to math.h 2023-05-11 00:34:03 +03:00
Bananymous e756cde2b1 LibC: define all errnos and strerror{name,desk}_np 2023-05-11 00:34:03 +03:00
Bananymous de18d3e64d LibC: add function declarations to time.h 2023-05-11 00:34:03 +03:00
Bananymous 441999ba9f LibC: add more types to sys/types.h 2023-05-11 00:33:53 +03:00
Bananymous dd046b1ace LibC: Add dummy signal.h 2023-05-10 23:20:27 +03:00
Bananymous 926aa238ab LibC: add toupper, tolower in ctype.h 2023-05-10 23:13:56 +03:00
Bananymous 01fa521a03 LibC: Add dummy setjmp.h 2023-05-10 23:00:53 +03:00
Bananymous f31da19266 LibC: Add dummy locale.h 2023-05-10 22:58:07 +03:00
Bananymous 48edc38817 LibC: implement printf conversions e, E, f, F 2023-05-10 22:36:03 +03:00
Bananymous ac12132ac0 LibC: add math.h with floorl 2023-05-10 22:35:42 +03:00
Bananymous 67005a80be LibC: add working f modifier to printf
This is implementation will write out of bounds if the conversion
takes more than 1024 characters (either super large number or very
big percision).

Also we dont handle NaN and infinity cases
2023-05-10 15:43:42 +03:00
Bananymous f43bfcb398 LibC: add better error string support 2023-05-10 02:22:31 +03:00
Bananymous d5ce4c9d2c LibC: add probably functional *printf
I wrote a general printf function that takes an putc function
pointer. We can use this to implement all the printf family
functions. I haven't done thorough testing with this, but it seems
to be functional for the most part
2023-05-10 02:00:28 +03:00
Bananymous 1cf7ef3de6 Kernel: Remove offset from OpenFileDescriptor
This is now handled on the libc side. There might be reasons to
have it in kernel side, but for simplicity's sake I'm moving it
to libc for now :)
2023-05-09 20:31:22 +03:00
Bananymous 5248a3fe48 LibC: Fix bug in *printf 2023-05-09 20:30:12 +03:00
Bananymous c2ad76fe4f BAN: Error uses 64 bit error codes 2023-05-07 02:09:52 +03:00
Bananymous 10d9b72da1 LibC: syscall() now returns -1 on error and updates errno 2023-05-07 01:51:39 +03:00
Bananymous 2fe9af7165 Kernel/LibC: add free function for FixedWidthAllocator
I have to rework the syscall API and allocators in process. For
now this works well enough :)
2023-05-07 01:21:50 +03:00
Bananymous ff5bcd4416 Kernel: Add basic fixed width allocator for userspace
We have to move process stacks to the general heap and maybe map
kernel to higher half.
2023-05-06 19:58:08 +03:00
Bananymous 5bfcf6783e LibC: add proper stdlib.h header
Function declarations taken from the posix specifications
2023-04-27 15:14:03 +03:00