Commit Graph

19 Commits

Author SHA1 Message Date
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
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
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
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
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
6304c771dd Some refactor and style tweaks. 2018-11-07 21:38:18 +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
812e7940e2 Add a simple /proc/cpuinfo that includes some info from CPUID. 2018-11-02 10:14:21 +01:00
Andreas Kling
c70afd045e Use a freelist for GDT entries.
Tweak the kmalloc space layout a bit. Get the spawn stress test up
and running again.
2018-11-01 16:23:12 +01:00
Andreas Kling
0c5bbac86e Add an InterruptDisabler helper class and use that for kmalloc.
The naive spinlock was not nearly enough to protect kmalloc from
reentrancy problems.

I don't want to deal with coming up with a fancy lock for kmalloc
right now, so I made an InterruptDisabler thingy instead.
It does CLI and then STI iff interrupts were previously enabled.
2018-10-24 11:07:53 +02:00
Andreas Kling
fe237ee215 Lots of hacking:
- Turn Keyboard into a CharacterDevice (85,1) at /dev/keyboard.
- Implement MM::unmapRegionsForTask() and MM::unmapRegion()
- Save SS correctly on interrupt.
- Add a simple Spawn syscall for launching another process.
- Move a bunch of IO syscall debug output behind DEBUG_IO.
- Have ASSERT do a "cli" immediately when failing.
  This makes the output look proper every time.
- Implement a bunch of syscalls in LibC.
- Add a simple shell ("sh"). All it can do now is read a line
  of text from /dev/keyboard and then try launching the specified
  executable by calling spawn().

There are definitely bugs in here, but we're moving on forward.
2018-10-23 10:12:50 +02:00
Andreas Kling
a9ca75c98b Add IRQHandler class that can be subclasses to handle an IRQ.
Also move Keyboard to a class implementation using this pattern.
2018-10-22 12:58:29 +02:00
Andreas Kling
46ff281695 Turn the syscall interrupt into a trap (by switching the gate type.)
This leaves interrupts enabled while we're in the kernel, which is
precisely what we want.

This uncovered a horrendous problem with kernel tasks silently
overflowing their stacks. For now I've simply increased the stack size
but I need a more MMU-y solution for this eventually.
2018-10-19 11:31:18 +02:00
Andreas Kling
3649638259 Add Regions concept to Task. 2018-10-18 14:55:20 +02:00
Andreas Kling
f67d695254 More paging stuff.
The test userspace process now runs at linear address 0x300000 which is
mapped to a dynamically allocated page from the MemoryManager. Cool!
2018-10-18 13:05:00 +02:00
Andreas Kling
56c1f9db8e A userspace process can now GPF and the OS goes on!
This is really rickety, but it kinda sorta works for my test GPF!
2018-10-17 23:49:32 +02:00
Andreas Kling
9396108034 Import the "gerbert" kernel I worked on earlier this year.
It's a lot crappier than I remembered it. It's gonna need a lot of work.
2018-10-16 11:02:00 +02:00