Commit Graph

42 Commits

Author SHA1 Message Date
Andreas Kling
43604bf71a LibC+Shell: Make system() actually work.
system() will now fork off a child process and execute the command via
/bin/sh -c. There are probably some things to fix here, but it's a start.
2019-05-13 04:52:55 +02:00
Andreas Kling
4291e96991 LibC: Implement a simple freelist-based malloc() with size classes.
It's not thread-safe yet, and there is lots of room for improvement.
Still it's a lot faster than the first-fit bitmap-based one it replaces.
2019-05-02 02:35:29 +02:00
Andreas Kling
98a0e10319 LibC: Log all malloc() calls if LIBC_LOG_MALLOC is set.
This makes it easier to quickly determine if a userspace process is getting
bogged down in memory allocation.
2019-04-30 01:22:18 +02:00
Andreas Kling
95ddca8a52 LibC: Make the malloc()/free() scrubbing runtime optional (default on.)
Memory returned by malloc() is normally memset with 0x85.
Memory passed to free() is normally memset with 0x82.

These behaviors can now be disabled by setting one or both of
LIBC_NOSCRUB_MALLOC and LIBC_NOSCRUB_FREE in your environment. :^)
2019-04-27 21:19:56 +02:00
Andreas Kling
0c898e3c2c Put assertions behind a DEBUG flag to make it easy to build without them. 2019-04-23 21:52:02 +02:00
Andreas Kling
58240fdb33 Do a pass of compiler warning fixes.
This is really making me question not using 64-bit integers more.
2019-04-23 13:00:53 +02:00
Andreas Kling
34087a9f90 LibC: Bring the C library close enough to newlib to trick GCC.
Now we can build GCC with --with-newlib, which hopefully cuts down on weird
toolchain build issues.
2019-04-17 23:16:16 +02:00
Andreas Kling
e145344767 LibC: Remove the validate_mallocation() stuff since Binutils hates it. 2019-03-27 05:02:02 +01:00
Andreas Kling
baab9f4402 LibC: Implement atexit() and strtoul(). 2019-03-27 01:55:39 +01:00
Andreas Kling
93a6681388 LibC: malloc() should use mmap() directly for allocations >= PAGE_SIZE.
This is a solid speedup on PNG loading, and basically everything else.
Once again I find a way to defer writing a better allocator for now. :^)
2019-03-21 13:29:20 +01:00
Andreas Kling
b7ad35d040 Terminal: Enough compat work for Lynx to actually load web pages. 2019-03-14 18:33:21 +01:00
Andreas Kling
2c3cf22bc9 LibC: A whole bunch of compat work towards porting Lynx. 2019-03-14 15:18:15 +01:00
Andreas Kling
e421c10735 More compat work towards porting vim.
It now builds and runs in the small-featureset configuration. :^)
2019-02-27 00:02:01 +01:00
Andreas Kling
a356746d04 Compat work towards porting vim. 2019-02-26 15:57:59 +01:00
Andreas Kling
cccc8d8aeb More compat work.
Move syscall to int 0x82 since using int 0x80 was kinda prone to fork bombs
when building things on Linux. :^)
2019-02-26 12:57:02 +01:00
Andreas Kling
93c0dfd1d7 LibC: A bunch of compat work towards porting GCC. 2019-02-24 15:20:07 +01:00
Andreas Kling
a7a456002e LibC: Enough compat work to make binutils-2.32 build and run. 2019-02-23 17:24:50 +01:00
Andreas Kling
0730b3c15f Add ability to switch video modes from the system menu.
I had to change PhysicalPage around a bit for this. Physical pages can now
be instantiated for any arbitrary physical address without worrying that
such pages end up in the kernel page allocator when released.

Most of the pieces were already in place, I just glued everything together.
2019-02-17 13:12:59 +01:00
Andreas Kling
3b42db0b4c LibC: Fix busted realloc() implementation. 2019-02-15 22:36:59 +01:00
Andreas Kling
736e852525 LibC: Implement enough missing stuff to get bash-5.0 running. :^) 2019-02-08 02:38:21 +01:00
Andreas Kling
ddb13ae6d8 LibC: Add some integer functionality needed for NASM. 2019-02-05 13:38:32 +01:00
Andreas Kling
c2adfd0e2d LibC: Implement various things to get GNU bc building and running.
Looks like that's all we needed, and bc now runs. :^)
2019-02-03 04:32:31 +01:00
Andreas Kling
76f53b40f4 LibC: Add some things needed to build GNU bc.
This patch adds vprintf(), sig_atomic_t, random() and strdup().
bc doesn't build yet, but it will.
2019-02-01 16:03:21 +01:00
Andreas Kling
cfa197f821 LibC: Let malloc(0) return nullptr. 2019-01-23 07:32:16 +01:00
Andreas Kling
69a3aecf6b LibC: Add vsnprintf(), snprintf(), execvp() and abs(). 2019-01-23 06:35:34 +01:00
Andreas Kling
2f74c2f430 Add basic PTY support.
For now, there are four hard-coded PTYs: /dev/pt{m,s}[0123]
Use this in the Terminal to open a pty pair and spawn a shell.
2019-01-15 06:30:19 +01:00
Andreas Kling
0c5ecd303c Share GraphicsBitmaps between the windowing server and the client process.
This is pretty cool. :^)

GraphicsBitmaps are now mapped into both the server and the client address
space (usually at different addresses but that doesn't matter.)

Added a GUI syscall for getting a window's backing store, and another one
for invalidating a window so that the server redraws it.
2019-01-14 15:25:34 +01:00
Andreas Kling
e7cc08226f Implement basic support for times().
The kernel now bills processes for time spent in kernelspace and userspace
separately. The accounting is forwarded to the parent process in reap().

This makes the "time" builtin in bash work.
2018-12-03 01:14:19 +01:00
Andreas Kling
e88f306d07 Make /proc/PID/vm more readable.
And move the unreadable detail-heavy mess to /proc/PID/vmo.
2018-11-19 01:49:19 +01:00
Andreas Kling
526dcafd57 Some improvements to LibC malloc(). 2018-11-19 01:40:19 +01:00
Andreas Kling
85649077cd Adapt kmalloc() for userspace.
A slightly more useful malloc() for userspace. The max allocation limit
is still 128 kB, but at least now free() is able to recycle memory.
2018-11-19 00:53:02 +01:00
Andreas Kling
303577df16 Various stubs while trying to get an old coreutils to build. 2018-11-17 15:56:09 +01:00
Andreas Kling
2cf477a151 Add fcntl() F_DUPFD which is slightly different from dup2(). 2018-11-16 22:14:40 +01:00
Andreas Kling
d5d45d1088 Rage hacking to get bash to run. It finally runs. So cool! :^) 2018-11-11 15:38:07 +01:00
Andreas Kling
9b70808ab5 Add really cheap atol() since sizeof(int) == sizeof(long) here anyway. 2018-11-11 10:40:50 +01:00
Andreas Kling
e9cdb6bb9b Fix all current build warnings in LibC. 2018-11-09 10:09:46 +01:00
Andreas Kling
fdbd9f1e27 Start working on memory-mapped files.
First of all, change sys$mmap to take a struct SC_mmap_params since our
sycsall calling convention can't handle more than 3 arguments.

This exposed a bug in Syscall::invoke() needing to use clobber lists.
It was a bit confusing to debug. :^)
2018-11-08 11:40:58 +01:00
Andreas Kling
3024167cbd Change syscall naming scheme. 2018-11-06 13:33:54 +01:00
Andreas Kling
819ce91395 Enough compatibility work to make figlet build and run!
I ran out of steam writing library routines and imported two
BSD-licensed libc routines: sscanf() and getopt().

I will most likely rewrite them sooner or later. For now
I just wanted to see figlet running.
2018-10-31 17:52:59 +01:00
Andreas Kling
1d5afbdffc Add sys$set_mmap_name and use it from LibC's malloc.
It's nice to be able to identify mmap's in /proc/PID/vm.
2018-10-28 09:57:22 +01:00
Andreas Kling
e904f193c1 Canonicalize the path used by sh.
With a bunch of LibC work to support the feature. LibC now initializes
AK::StringImpl by default. It's now fine to use AK in LibC/Userland! :^)
2018-10-28 09:36:21 +01:00
Andreas Kling
bca4b71bfa Lots of hacking to make a very simple "ls" utility.
I added a dead-simple malloc that only allows allocations < 4096 bytes.
It just forwards the request to mmap() every time.

I also added simplified versions of opendir() and readdir().
2018-10-24 12:50:07 +02:00