Commit Graph

65 Commits

Author SHA1 Message Date
Andreas Kling
a182ea8c60 Kernel: After creating our GDT, make sure CS refers to the right descriptor.
This will allow us to boot from e.g GRUB which will have a different looking
GDT in effect before we start moving things around.
2019-05-17 18:52:29 +02:00
Andreas Kling
e8ae2c952e Kernel: Put GDT and IDT in BSS rather than runtime-allocating them. 2019-05-17 18:25:50 +02:00
Andreas Kling
e0ff07bb57 Kernel: Make sure we load DS/ES/FS/GS/SS immediately after making the GDT. 2019-05-17 18:23:08 +02:00
Andreas Kling
923e587283 Kernel: GDTR and IDTR limits should be table size - 1. 2019-05-17 18:17:53 +02:00
Andreas Kling
4e88872c8e Kernel: Always dump_backtrace() on process crash. 2019-05-16 19:49:48 +02:00
Andreas Kling
2f4e7edee5 Kernel: Simplify dump_backtrace() API for clients.
It makes no sense that clients had to worry about whether or not KSyms
were loaded.
2019-05-16 13:41:16 +02:00
Andreas Kling
89df887e1f Kernel: Dump backtrace on user process page fault. 2019-04-28 22:05:13 +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
a58d7fd8bb Kernel: Get rid of Kernel/types.h, separate LinearAddress/PhysicalAddress. 2019-04-06 14:29:29 +02:00
Andreas Kling
b9738fa8ac Kernel: Move VM-related files into Kernel/VM/.
Also break MemoryManager.{cpp,h} into one file per class.
2019-04-03 15:13:07 +02:00
Andreas Kling
e9f2cc3595 Kernel: Save/restore the SSE context on context switch. 2019-03-27 15:27:45 +01:00
Andreas Kling
750d79dcaf Kernel: Initialize the CPU to allow SSE on startup.
I still need to add support for SSE to the context switching code, but now
at least one process can use it.
2019-03-27 13:40:00 +01:00
Andreas Kling
e7c1caa2b5 Kernel: Don't hang the system on unrecoverable page fault.
I needed this while debugging threads and now they basically work pretty
well so we can remove this. :^)
2019-03-24 02:11:07 +01:00
Andreas Kling
e561ab1b0b Kernel+LibC: Add a simple create_thread() syscall.
It takes two parameters, a function pointer for the entry function,
and a void* argument to be passed to that function on the new thread.
2019-03-23 22:59:08 +01:00
Andreas Kling
60d25f0f4a Kernel: Introduce threads, and refactor everything in support of it.
The scheduler now operates on threads, rather than on processes.
Each process has a main thread, and can have any number of additional
threads. The process exits when the main thread exits.

This patch doesn't actually spawn any additional threads, it merely
does all the plumbing needed to make it possible. :^)
2019-03-23 22:03:17 +01:00
Andreas Kling
5dd79736c5 Kernel: Remove the one client of Vector-with-custom-allocator.
This was a silly experiment. If I want to save space here, I can do it in
one of many other ways.
2019-03-16 13:19:58 +01:00
Andreas Kling
e53cef02d5 Kernel: Dump kernel stack trace on assertion failure. 2019-03-06 14:05:41 +01:00
Andreas Kling
91031346e5 Kernel: More signal handling improvements.
Finally fixed the weird flaky crashing when resizing Terminal windows.
It was because we were dispatching a signal to "current" from the scheduler.
Yet another thing I dislike about even having a "current" process while
we're in the scheduler. Not sure yet how to fix this.

Let the signal handler's kernel stack be a kmalloc() allocation for now.
Once we can do allocation of consecutive physical pages in the supervisor
memory region, we can use that for all types of kernel stacks.
2019-03-05 12:52:35 +01:00
Andreas Kling
809ffa56d7 Kernel: Reduce code duplication in exception handlers. 2019-02-20 12:28:41 +01:00
Andreas Kling
b704d3d295 LibGUI: Add a GToolBar class that can be populated with GActions.
The same action can be added to both a menu and a toolbar.
Use this to put a toolbar into FileManager. This is pretty neat. :^)
2019-02-20 02:39:46 +01:00
Andreas Kling
022f7790db Use modern C++ attributes instead of __attribute__ voodoo.
This is quite nice, although I wish [[gnu::always_inline]] implied inline.
Also "gnu::" is kind of a wart, but whatcha gonna do.
2019-02-15 12:30:48 +01:00
Andreas Kling
9860e55047 Kernel: Put page fault logspam behind PAGE_FAULT_DEBUG. 2019-02-10 11:37:59 +01:00
Andreas Kling
ca16d9d98e Kernel: Invalidate file-backed VMO's when inodes are written.
The current strategy is simply to nuke all physical pages and force
reload them from disk. This is obviously not optimal and should eventually
be optimized. It should be fairly straightforward.
2019-02-05 08:17:46 +01:00
Andreas Kling
ffab6897aa Big, possibly complete sweep of naming changes. 2019-01-31 17:31:23 +01:00
Andreas Kling
2a7af0eacf Kernel: Don't try to dump invalid code memory in page fault handler. 2019-01-30 20:18:50 +01:00
Andreas Kling
dfdca9d2a7 Kernel: Implement lazy FPU state restore. 2019-01-25 07:52:44 +01:00
Andreas Kling
0db72786cf Snazz up the windows with some title bar gradients. :^) 2019-01-25 05:02:32 +01:00
Andreas Kling
e28de4ad5e Kernel: Dump registers and code on ring0 page fault. 2019-01-25 00:32:50 +01:00
Andreas Kling
b75ee4aacb Coding style fixes in AK. 2019-01-19 22:53:05 +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
b0e3f73375 Start refactoring the windowing system to use an event loop.
Userspace programs can now open /dev/gui_events and read a stream of GUI_Event
structs one at a time.

I was stuck on a stupid problem where we'd reenter Scheduler::yield() due to
having one of the has_data_available_for_reading() implementations using locks.
2019-01-14 14:42:49 +01:00
Andreas Kling
becc2c7fa5 Make GraphicsBitmaps be Region-backed when running in the kernel.
This is a lot better than having them in kmalloc memory. I'm gonna need
a way to keep track of which process owns which bitmap eventually,
maybe through some sort of resource keying system. We'll see.
2019-01-13 00:29:32 +01:00
Andreas Kling
3f3535213b Fix some issues uncovered by the spawn stress test. 2018-12-26 22:02:24 +01:00
Andreas Kling
ec1c487dcd Yet another pass of style fixes. 2018-12-21 02:10:45 +01:00
Andreas Kling
f6e27c2abe More coding style changes. 2018-12-03 00:39:25 +01:00
Andreas Kling
9d05f6b7a7 Make bash-2.05b build with minimal changes.
This is really neat. :^)
2018-11-17 00:14:07 +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
47b7eeda44 Fix all current build warnings in the kernel. 2018-11-09 10:03:21 +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
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
6304c771dd Some refactor and style tweaks. 2018-11-07 21:38:18 +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
9e62eb4856 Only COW on fault if the physical page has retain_count > 1.
This makes COW pages lazily-but-transparently revert back to read/write.
2018-11-05 14:11:21 +01:00
Andreas Kling
2d045d2a64 Implement COW pages! :^)
sys$fork() now clones all writable regions with per-page COW bits.
The pages are then mapped read-only and we handle a PF by COWing the pages.

This is quite delightful. Obviously there's lots of work to do still,
and it needs better data structures, but the general concept works.
2018-11-05 13:48:07 +01:00
Andreas Kling
e85c22fe58 Tidy up the page fault code a bit in preparation. 2018-11-05 10:29:19 +01:00
Andreas Kling
72cdc62155 Replace zones with individually tracked physical pages.
It's just a simple struct { ref_count, paddr }.
This will allow me to implement lazy zeroing and COW pages.
2018-11-05 10:23:00 +01:00
Andreas Kling
8b4b684d6d Move assertion failures out-of-line to reduce binary bloat. 2018-11-04 13:12:58 +01:00
Andreas Kling
812e7940e2 Add a simple /proc/cpuinfo that includes some info from CPUID. 2018-11-02 10:14:21 +01:00