Commit Graph

26 Commits

Author SHA1 Message Date
7a097f16ea apps: add a new example app which does all kinds of stdio misbehaving >.< 2022-10-11 17:31:06 +02:00
6c51477197 libc: Implement ferror() and feof() 2022-10-11 16:57:08 +02:00
d25e8a43db build system: strip apps 2022-10-10 21:24:21 +02:00
93f6be9319 libc: Implement the start of a FILE* API (the standard, portable C way of doing file stuff) 2022-10-10 21:08:57 +02:00
9e0bd39964 libc: Implement wrappers for sys_{open,read,write}
read() and close() are in unistd.h, but open() in fnctl.h.
I thought only the definitions for O_SOMETHING were in fnctl.h, but it is as it is.
Don't know why, but let's not anger the Unix gods.

The FILE* C API is pending as well.
2022-10-10 20:45:26 +02:00
da2ede3450 Kernel, libc, userspace: Implement file descriptors
Kernel: Implement a descriptor struct which stores the opened node and read offset, and give each task 8 of those.
Implement three syscalls: sys_read, sys_open and sys_close (sys_write still writes to the console instead of using a fd, for now)
Implement three new errors: ENOENT, EBADF and EMFILE.

libc: Implement the new errors, and the new syscalls in syscall().
Also fix _RETURN_WITH_ERRNO() to set errno correctly, which was making strerror() return null, thus crashing perror().

userspace: make init demonstrate the new file API.
2022-10-10 20:21:39 +02:00
49c7900407 Add %m to userspace printf
%m as a format specifier is a nonstandard glibc extension, but I like it so I'm implementing it.
What it does is print the value of strerror(errno), without consuming any arguments to printf().
2022-10-08 18:44:14 +02:00
40099feb80 Apps: Use the new %p in printf() 2022-10-08 18:11:41 +02:00
f83a6ace51 Kernel, libc: Add support for providing a status code to exit()
The exit() libc function already accepted an integer, but didn't pass it on to the kernel since we had no mechanism for it to do that.
Now, the kernel stores a task's exit status to display it later (and in the future, return it to userspace via wait()/waitpid())
2022-10-08 17:56:40 +02:00
e76d903642 apps: make memeater use perror 2022-10-08 12:42:46 +02:00
21e8ea1486 apps: make memeater use strerror() 2022-10-08 12:29:19 +02:00
71e15e94af Kernel, libc and userspace: Add basic errno support.
Kernel: Add an errno.h header with definitions for each header,
and return those, negated, from syscalls when there is an error.
mmap() returns an invalid address with errno encoded, instead of
returning a negated errno; this address is encoded as ffffffffffffffEE
where EE is errno in hex.

libc: make syscall() return -1 and set errno on error, instead of
returning the raw return value of the system call. Also, add mmap()
and munmap() wrappers in sys/mman.h :).

userspace: make the memeater program show the value of errno
when allocating memory fails.

Things to improve: add perror() and strerror() to make the errno
experience even better! >.<
2022-10-08 12:06:09 +02:00
5d8b825659 Add a few example apps/demos in C, and make the kernel choose a random one to demonstrate every boot 2022-10-03 21:24:38 +02:00
34aa953dbc Add printf() and puts(), quite primitive, looks like hex printing isn't there yet... 2022-10-03 19:00:10 +02:00
dae2ff8d50 Add mmap and munmap syscalls, and thus, add malloc and free to libc!! (yet again, thanks to the wonderful liballoc) 2022-10-02 20:45:04 +02:00
1ecd24f5d6 Kernel: Add SSE support (enable SSE on boot and save context (user tasks only) on task switch) 2022-10-02 18:53:54 +02:00
d2f9e17c86 Use __luna_abort in init 2022-10-02 18:16:27 +02:00
ae95a528f2 Make function stubs in libc loudly abort instead of silently failing 2022-10-02 18:10:53 +02:00
8e6741ebd6 Rename SYS_version to SYS_getversion 2022-10-02 17:25:56 +02:00
6bacded5cf Update build system 2022-10-02 17:01:30 +02:00
f8a72f15c8 Adjust build system to be more flexible and to work with the new toolchain 2022-10-02 12:44:32 +02:00
c7f46f96ff Use the new syscalls in init 2022-10-01 17:32:50 +02:00
96f53922c9 Write a (kindof) proper init, at least with the capabilities we have right now 2022-10-01 15:54:42 +02:00
cde850258d Don't assume we are located at /bin/init 2022-10-01 13:16:59 +02:00
1c4383dea4 Add an apps/ folder and build-system to build userspace apps which can now be loaded from the initrd 2022-10-01 12:17:16 +02:00
867d312177 Let's try to start parsing ELFs! 2022-09-30 17:43:14 +02:00