Commit graph

181 commits

Author SHA1 Message Date
Andreas Kling 16f318408d ELFLoader should fail with an error message for unresolved symbols. 2018-10-25 10:02:04 +02:00
Andreas Kling ec1d16b307 Add a "pwd" utility to userland.
It's implemented as a separate process. How cute is that.
Tasks now have a current working directory. Spawned tasks inherit their
parent task's working directory.
Currently everyone just uses "/" as there's no way to chdir().
2018-10-24 14:28:22 +02:00
Andreas Kling eb4074bb9d Put more logspam behind EXT2_DEBUG. 2018-10-24 13:38:53 +02:00
Andreas Kling 5f36a5f22e Add an lstat() syscall and use it to make "ls" nicer. 2018-10-24 13:19:36 +02: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
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 9a296d63f3 Add simplified mmap() and munmap() syscalls. 2018-10-24 09:48:41 +02:00
Andreas Kling a5caf7ca99 Make the kmalloc global stats variable volatile.
I know I'm praying for cargo here, but this does fix a weird issue
where logging the sum_alloc and sum_free globals wouldn't display
symmetric values all the time.
2018-10-24 01:04:06 +02:00
Andreas Kling 82dae8fc90 Add a kmalloc lock. This definitely reduces flakiness. 2018-10-24 00:51:19 +02:00
Andreas Kling 8e27cf2428 Cleanup. 2018-10-24 00:51:09 +02:00
Andreas Kling 57136ad87e synthfs: generated files should have size=0.
This way we don't need to generate the file just to see how big it would get.
2018-10-24 00:50:23 +02:00
Andreas Kling b40c851fce Unbreak crashy user process test. 2018-10-24 00:35:07 +02:00
Andreas Kling 3253a23b91 Add a simplified waitpid() so that sh can wait on spawned commands. 2018-10-24 00:20:34 +02:00
Andreas Kling 018da1be11 Generalize the SpinLock and move it to AK.
Add a separate lock to protect the VFS. I think this might be a good idea.
I'm not sure it's a good approach though. I'll fiddle with it as I go along.

It's really fun to figure out all these things on my own.
2018-10-23 23:34:05 +02:00
Andreas Kling e4bfcd2346 Add "times scheduled" field to /proc/summary 2018-10-23 15:59:38 +02:00
Andreas Kling 44045b258c Teach MM to flush individual TLB entries only. 2018-10-23 15:53:11 +02:00
Andreas Kling 3676214a62 Remove remains of the old "panel" task.
...and grow the console by 1 row! :^)
2018-10-23 15:47:03 +02:00
Andreas Kling d90d125dfe Add an undertaker task that is responsible for destroying dead tasks. 2018-10-23 15:43:05 +02:00
Andreas Kling 1c1d0f5362 ExecSpace should free its own allocations on destruction.
If hookableAlloc was used, we don't free anything. That's the client's
responsibility.
2018-10-23 15:31:23 +02:00
Andreas Kling ccd15e0590 Various things:
- putch syscall now directly calls Console::putChar().
- /proc/summary includes some info about kmalloc stats.
- Syscall entry is guarded by a simple spinlock.
- Unmap regions for crashed tasks.
2018-10-23 15:19:02 +02:00
Andreas Kling c80a1f39ce Minor userland tweaks. 2018-10-23 13:57:17 +02:00
Andreas Kling 71ed63c91d Assume commands are binaries in /bin for now. 2018-10-23 13:05:50 +02:00
Andreas Kling d133a2845f Add missing TLB flushes. 2018-10-23 13:03:11 +02:00
Andreas Kling 77821da42f Also send console output to port 0xe9 (bochs console.)
This is very handy for debugging.
2018-10-23 13:02:38 +02:00
Andreas Kling 63e253bac9 Generate a basic /proc/summary file with some info about all tasks. 2018-10-23 12:44:46 +02:00
Andreas Kling ed2422d7af Start adding a basic /proc filesystem and a "ps" utility. 2018-10-23 12:04:03 +02:00
Andreas Kling 98f76f0153 Flush the TLB after modifying page tables.
This is a very inefficient naive implementation, but it gets us going.
Mapping tasks in and out of a shared address space now totally works.
2018-10-23 11:03:56 +02:00
Andreas Kling 56ed448424 Move ELFLoader debug output behind flags.
The logging spam was out of control.
2018-10-23 11:03:26 +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 72514c8b97 Don't use doubles in RandomDevice.
...since Computron doesn't have FPU support yet, I'm gonna avoid using it
here in Serenity for now.
2018-10-23 00:35:11 +02:00
Andreas Kling c8b7173aa8 Add a CircularQueue template class to AK. 2018-10-22 22:46:02 +02:00
Andreas Kling b824f15619 Launching an arbitrary ELF executable from disk works! :^)
This is so cool! It's a bit messy now with two Task constructors,
but eventually they should fold into a single constructor somehow.
2018-10-22 15:43:02 +02:00
Andreas Kling befeabd8fe Okay, with some mucking around, there is now a /bin/id and it runs!
It statically links against everything in LibC that it needs.
This will work just fine for a long time to come!
2018-10-22 14:41:54 +02:00
Andreas Kling 38a621c721 Link "id" against the LibC.
We can now produce what should essentially be a runnable Serenity executable.
2018-10-22 14:13:17 +02:00
Andreas Kling 63764b3a65 Import very modest Userland. 2018-10-22 14:06:22 +02:00
Andreas Kling 4cbf079a17 Start work on a standard C library. I'm calling it... LibC. 2018-10-22 13:57:25 +02:00
Andreas Kling 85bcf2ed0f Add getgid() and getpid() syscalls. Prep for LibC. 2018-10-22 13:55:11 +02:00
Andreas Kling bae59609e3 Move kprintf to its own file. It has nothing to do with VGA anymore. 2018-10-22 13:20:35 +02:00
Andreas Kling 702d308e67 Oops, StringImpl's "the empty string" global was not always initialized.
These "oops forgot to initialize" bugs are getting annoying...
2018-10-22 13:10:08 +02:00
Andreas Kling c5e55f4737 Use UD2 instead of CLI;HLT for CRASH().
This way the kernel prints out a nice register dump so we can find
out where we crashed.
2018-10-22 13:07:06 +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 8f941561b4 Add ALWAYS_INLINE macro. 2018-10-22 12:55:59 +02:00
Andreas Kling ba185e3eba Zero out VirtualFileSystem::s_the in initializeGlobals().
This catches attempts to access the vfs before it's been constructed.
2018-10-22 12:54:19 +02:00
Andreas Kling e4afa2a041 Tweak _test.o to use the putch() syscall.
It's still running in kernel space. Once I make it possible for ELFLoader
to set up a ring 3 task, we'll really be cooking!
2018-10-22 11:53:59 +02:00
Andreas Kling 3a3c57357c Add a sys$exit and make init_stage2 call it when finished. 2018-10-22 11:43:55 +02:00
Andreas Kling 79ffdb7205 A lot of hacking:
- More work on funneling console output through Console.
- init() now breaks off into a separate task ASAP.
- ..this leaves the "colonel" task as a simple hlt idle loop.
- Mask all IRQs on startup (except IRQ2 for slave passthru)
- Fix underallocation bug in Task::allocateRegion().
- Remember how many times each Task has been scheduled.

The panel and scheduling banner are disabled until I get things
working nicely in the (brave) new Console world.
2018-10-22 11:15:16 +02:00
Andreas Kling df4fdd6f1e printf format fixups in ELFLoader. 2018-10-22 00:29:35 +02:00
Andreas Kling 09fc9c0698 Make Console::m_rows/m_columns const for now. 2018-10-21 23:48:50 +02:00
Andreas Kling e38f40a83c Add an InlineLinkedList::containsSlow(T*) helper. 2018-10-21 23:48:27 +02:00
Andreas Kling a89bebfda4 printf -> kprintf 2018-10-21 23:48:13 +02:00