Commit Graph

267 Commits

Author SHA1 Message Date
Andreas Kling
a788e85c09 Refactor TTY signal generation a bit.
We now respect the VINTR and VQUIT control characters in the termios.
2018-11-16 20:18:58 +01:00
Andreas Kling
4e2c2b9748 Minor TTY tweak. 2018-11-16 18:12:22 +01:00
Andreas Kling
d2046e79cf Add a DoubleBuffer thingy to allow TTY read/write to be interleaved.
I feel like this concept might be useful in more places. It's very naive
right now and uses dynamically growing buffers. It should really use static
size buffers and never kmalloc().
2018-11-16 17:57:00 +01:00
Andreas Kling
52d1822c3c Add templated helpers for read/write validation, and one for strings, too. 2018-11-16 16:26:20 +01:00
Andreas Kling
8a286b9244 Improve syscall address validation a bit. 2018-11-16 16:10:59 +01:00
Andreas Kling
084287ca45 Reimplement tcsetattr/tcgetattr as ioctls. 2018-11-16 15:41:48 +01:00
Andreas Kling
c99f8af66d Add ioctl() and reimplement tcsetpgrp/tcsetpgrp as ioctls. 2018-11-16 13:13:50 +01:00
Andreas Kling
2529925fe9 Some more renaming:
FileSystem -> FS
SyntheticFileSystem -> SynthFS
ProcFileSystem -> ProcFS
Ext2FileSystem -> Ext2FS
Ext2Inode -> Ext2FSInode
2018-11-15 17:13:10 +01:00
Andreas Kling
8fa2d7104a More VFS cleanup. 2018-11-15 16:04:25 +01:00
Andreas Kling
396a32835b A pass of style/naming cleanup in VFS. 2018-11-15 15:10:30 +01:00
Andreas Kling
457a5df7d5 Rename:
VirtualFileSystem -> VFS
VirtualFileSystem::Node -> Vnode
2018-11-15 14:43:10 +01:00
Andreas Kling
c735c56e4c More work on CoreInode. 2018-11-13 23:44:54 +01:00
Andreas Kling
26852a8363 Add metadata to CoreInode. 2018-11-13 13:32:16 +01:00
Andreas Kling
10c470e95f Make page_in_from_vnode 2x faster.
...by adding a new class called Ext2Inode that inherits CoreInode.
The idea is that a vnode will wrap a CoreInode rather than InodeIdentifier.
Each CoreInode subclass can keep whatever caches they like.

Right now, Ext2Inode caches the list of block indices since it can be very
expensive to retrieve.
2018-11-13 13:02:39 +01:00
Andreas Kling
97c799576a Add close-on-exec flag for file descriptors.
I was surprised to find that dup()'ed fds don't share the close-on-exec flag.
That means it has to be stored separately from the FileDescriptor object.
2018-11-13 01:36:31 +01:00
Andreas Kling
19b9401487 Reduce kmalloc() traffic in directory iteration.
Pass the file name in a stack-allocated buffer instead of using an AK::String
when iterating directories. This dramatically reduces the amount of cycles
spent traversing the filesystem.
2018-11-13 00:17:30 +01:00
Andreas Kling
5e8e554f94 Add a braindead 10x speedup to kmalloc().
Skip over entirely full buckets when scanning for a big-enough memory slot.
This means I can postpone writing a better kmalloc() for a while longer! :^)
2018-11-12 15:29:46 +01:00
Andreas Kling
dea474dfd5 Make loading /bin/bash ~250x faster.
The ELF loader was doing huge amounts of unnecessary work.
Got rid of the "export symbols" and relocation passes since we don't need them.
They were useful things when bringing up the ELF loading code.

Also added a simple TSC-based Stopwatch RAII thingy to help debug performance issues.
2018-11-12 13:45:15 +01:00
Andreas Kling
1cf20a2fe2 Some minor termios debugging output. 2018-11-12 12:27:28 +01:00
Andreas Kling
f1404aa948 Add primitive FIFO and hook it up to sys$pipe().
It's now possible to do this in bash:

cat kernel.map | fgrep List

This is very cool! :^)
2018-11-12 01:28:46 +01:00
Andreas Kling
18e3ddf605 Add a naive /bin/fgrep for testing pipes. 2018-11-11 20:42:41 +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
f394e3486a Stub out a bunch more functions to get closer to that sweet bash build. 2018-11-11 10:38:33 +01:00
Andreas Kling
7cc4caee4f Add ispunct() to LibC + some minor cleanups. 2018-11-11 00:44:04 +01:00
Andreas Kling
3b2f172d48 A bunch of compat work (mostly stubs but some real implementations, too.)
Another pass at getting bash-1.14.7 to build. Not that many symbols remain.
2018-11-11 00:20:53 +01:00
Andreas Kling
6a0a2c9ab4 Some improvements to signals.
- Add sigprocmask() and sigpending().
- Forked children inherit signal dispositions and masks.
- Exec clears signal dispositions and masks.
2018-11-10 23:30:41 +01:00
Andreas Kling
c97a5862ce Remove MM::allocate_physical_pages() since it wasn't used.
Everyone was allocating one page at a time with allocate_physical_page().
2018-11-10 22:14:41 +01:00
Andreas Kling
36b3dc6c32 Add /proc/PID/cwd, a symlink to the process's current directory. 2018-11-10 18:16:21 +01:00
Andreas Kling
a768c2b919 Rename ProcessInspectionScope to ProcessInspectionHandle.
It might be useful to pass these things around.
2018-11-10 16:50:42 +01:00
Andreas Kling
2ac5e14c08 Merge VGA into VirtualConsole. 2018-11-10 16:26:18 +01:00
Andreas Kling
b8264e7d47 Merge Disk namespace into the IDEDiskDevice class. 2018-11-10 15:15:31 +01:00
Andreas Kling
cba05ce75e Before sys$write returns, check for pending unmasked signals.
If there is one, put the process into a new BlockedSignal state which makes
the next scheduler iteration dispatch the signal.
2018-11-10 02:43:33 +01:00
Andreas Kling
8605711f4b Make /bin/clear work again.
After I made stdio buffered, we were dropping anything unflushed on exit.
Since /bin/clear just prints out some escape sequences without a newline,
the entire buffer was being discarded.

Also add VirtualConsole::clear() that handles clearing of background VC's.
2018-11-10 00:56:10 +01:00
Andreas Kling
3e3de67f02 Use the VGA start address for fast VirtualConsole scrolling.
Instead of memcpy'ing the entire screen every time we press enter at the
bottom, use the VGA start address register to make a "view" onto the
underlying memory that moves downward as we scroll.

Eventually we run out of memory and have to reset to the start of the
buffer. That's when we memcpy everything. It would be cool if there was
some way to get the hardware to act like a ring buffer with automatic
wrapping here but I don't know how to do that.
2018-11-09 21:18:03 +01:00
Andreas Kling
8a865c11ec Pre-size the ksyms vector for speedier loading.
Also show loading progress on the screen because it looks neat.
2018-11-09 20:40:39 +01:00
Andreas Kling
de38e63d3e Run QEMU with the possibility to attach gdb. 2018-11-09 18:35:32 +01:00
Andreas Kling
985074c790 Okay, now *actually* plug the leaks in exec().
I didn't even put the { } properly around everything that would leak.
Let's make sure this works correctly by splitting out the work into a
helper called do_exec().
2018-11-09 18:00:50 +01:00
Andreas Kling
e0ca6bb97e Add /proc/vnodes, listing basic info about all open vnodes. 2018-11-09 17:46:55 +01:00
Andreas Kling
ebf308d413 Make kernel build with clang.
It's a bit faster than g++ and seems to generate perfectly fine code.
The kernel is also roughly 10% smaller(!)
2018-11-09 12:22:31 +01:00
Andreas Kling
8249c086c3 Get rid of redundant sys$spawn now that we have fork+exec. 2018-11-09 10:22:27 +01:00
Andreas Kling
e9cdb6bb9b Fix all current build warnings in LibC. 2018-11-09 10:09:46 +01:00
Andreas Kling
47b7eeda44 Fix all current build warnings in the kernel. 2018-11-09 10:03:21 +01:00
Andreas Kling
e71cb1c56b Fix some paging related bugs exposed by the spawn stress test.
- Process::exec() needs to restore the original paging scope when called
  on a non-current process.
- Add missing InterruptDisabler guards around g_processes access.
- Only flush the TLB when modifying the active page tables.
2018-11-09 01:25:31 +01:00
Andreas Kling
7b96218389 Fix VMO leak in Process::exec().
Gotta make sure things get cleaned up before we yield-teleport in exec().
Also VMOs and regions are now viewable through /proc/mm and /proc/regions.
2018-11-08 22:25:29 +01:00
Andreas Kling
cd1e7419f0 Teach Process::exec() about the magic of file-backed VMO's.
This is really sweet! :^) The four instances of /bin/sh spawned at
startup now share their read-only text pages.

There are problems and limitations here, and plenty of room for
improvement. But it kinda works.
2018-11-08 21:20:09 +01:00
Andreas Kling
992769c9d4 Make Process::for_each...() functions inline and allocation-free.
AK::Function is very handy, but costs us an 8-byte allocation.
Let's not have kmalloc() calls in the scheduler hot path.
2018-11-08 16:09:05 +01:00
Andreas Kling
3b2dcd5929 Add a VMO pointer to VNode.
This way, if anyone tries to map an already mapped file, we share the VMO.
2018-11-08 15:39:26 +01:00
Andreas Kling
862f108cb5 Refactor the virtual memory object model a bit:
Process now has a number of Regions.
Each Region is backed by a VMObject.
A VMObject can be file-backed or anonymous. These can be shared.
2018-11-08 14:42:16 +01:00
Andreas Kling
3c8064a787 Support basic mmap'ing of a file!
All right, we can now mmap() a file and it gets magically paged in from fs
in response to an NP page fault. This is really cool :^)

I need to refactor this to support sharing of read-only file-backed pages,
but it's cool to just have something working.
2018-11-08 12:59:16 +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