Commit graph

381 commits

Author SHA1 Message Date
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 4914f3b837 Build LibC and Userland with clang as well. 2018-11-09 14:29:00 +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 7b3b5f745f Move <utsname.h> to <sys/utsname.h> for correctness. 2018-11-09 10:24:41 +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 3e0a0dd7ed Fix all current build warnings in the userland. 2018-11-09 10:19:33 +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 abdf24cb73 Fix deadlock in synthfs read implementation.
Not cool disabling interrupts and then calling out to arbitrary code.
2018-11-08 16:07:45 +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
Andreas Kling 41a751c90c Minor tweak to /bin/kill. 2018-11-08 02:07:08 +01:00
Andreas Kling 71a2942a0a Make it run in QEMU.
Looks like the problem was the weirdly-sized floppy image file.
I guess QEMU was inferring the floppy disk geometry from the image size.
2018-11-08 02:03:19 +01:00
Andreas Kling da3857b0c2 Add some simple write buffering to LibC's stdio.
Plumb it all the way to the VirtualConsole. Also fix /bin/cat to write()
the whole chunks we get from read() directly to stdout.
2018-11-08 01:23:47 +01:00
Andreas Kling e287f8ef3a The colonel task already had a halt loop.
Also don't reap() current in the scheduler, just wait until it's not current.
2018-11-08 00:30:35 +01:00
Andreas Kling ac1d12465f Move timer tick handling into Scheduler. 2018-11-08 00:26:04 +01:00
Andreas Kling 27fded7002 Unbreak signal delivery to userspace again.
My my, this code is quite fickle.
2018-11-08 00:08:50 +01:00
Andreas Kling 1dbc340da8 Get rid of the undertaker and have waitpid() be the reaper.
For dead orphans, the scheduler calls reap().
2018-11-07 23:59:49 +01:00
Andreas Kling f792349853 Unbreak sys$sigreturn() after colonel process changes. 2018-11-07 23:21:32 +01:00
Andreas Kling 43f40a3050 Finally unbreak the colonel process and make it the true idle process. 2018-11-07 23:14:56 +01:00
Andreas Kling 440029c9d1 Reduce number of passes in the scheduler by 2. 2018-11-07 22:24:20 +01:00
Andreas Kling 39d2fcbbee Move the scheduler code to its own class.
This is very mechanical.
2018-11-07 22:15:02 +01:00
Andreas Kling 6304c771dd Some refactor and style tweaks. 2018-11-07 21:38:18 +01:00
Andreas Kling 03a8357e84 Implement sending signals to blocked-in-kernel processes.
This is dirty but pretty cool! If we have a pending, unmasked signal for
a process that's blocked inside the kernel, we set up alternate stacks
for that process and unblock it to execute the signal handler.

A slightly different return trampoline is used here: since we need to
get back into the kernel, a dedicated syscall is used (sys$sigreturn.)

This restores the TSS contents of the process to the state it was in
while we were originally blocking in the kernel.

NOTE: There's currently only one "kernel resume TSS" so signal nesting
definitely won't work.
2018-11-07 21:19:47 +01:00
Andreas Kling c8b308910e Signals to processes in userspace now work again.
Ugh, how am I going to dispatch signals to processes in the kernel?
2018-11-07 19:03:44 +01:00
Andreas Kling dd887e158b Add a /proc/PID/regs that shows register state from the process's TSS. 2018-11-07 18:40:29 +01:00
Andreas Kling 678882e020 Rework process states to make a bit more sense.
Processes are either alive (with many substates), dead or forgiven.
A dead process is forgiven when the parent waitpid()s on it.
Dead orphans are also forgiven.

There's a lot of work to be done around this.
2018-11-07 18:34:37 +01:00
Andreas Kling 71bffa9864 Fix whiny build. 2018-11-07 16:38:45 +01:00
Andreas Kling 61a84193d7 Fix some broken stuff in VFS test environment.
It's still lagging behind the metal environment but here's some work towards
fixing it at least.
2018-11-07 15:51:39 +01:00
Andreas Kling 981a3ae4b3 Make VFS test environment build again. 2018-11-07 12:05:51 +01:00
Andreas Kling 83172e6a4b Rename FileHandle to FileDescriptor. 2018-11-07 11:37:54 +01:00
Andreas Kling e088121b3a Fix sys$sigaction() to return the old action metadata if requested. 2018-11-07 10:48:44 +01:00
Andreas Kling 0b3e927597 Oops, waitpid() was not passing the options parameter to the kernel. 2018-11-07 10:46:48 +01:00
Andreas Kling d7a41579e5 Miscellaneous compat work while seeing if GNU coreutils would build. 2018-11-07 10:23:16 +01:00
Andreas Kling a7f1d892a9 Add some basic setgroups(), getgroups() and initgroups().
Also teach /bin/id to print the user's supplemental groups.
2018-11-07 01:38:51 +01:00
Andreas Kling d3bd3791cb Minor fixes in getgrent() and getpwent() function families. 2018-11-07 00:33:10 +01:00
Andreas Kling 8135952832 Add a Chomp feature to String construction that removes a trailing newline.
This will be useful in many situations.
2018-11-07 00:19:35 +01:00
Andreas Kling 90bab5ea71 Add getgrent() family of functions. 2018-11-06 22:27:51 +01:00
Andreas Kling e5e0bffd76 Add getwd(). 2018-11-06 15:59:57 +01:00
Andreas Kling 7c3746592b Add strsignal() and improve sharing signal numbers between LibC and kernel. 2018-11-06 15:45:16 +01:00