Commit Graph

53 Commits

Author SHA1 Message Date
Andreas Kling
7be30a2fa8 Fuck it, add a 4th virtual console. :^) 2018-10-31 00:27:34 +01:00
Andreas Kling
b833aa4162 Fix bug where Console::the() was initialized too late.
Yet another problem due to lack of BSS zeroing in the kernel loader...
2018-10-30 23:02:06 +01:00
Andreas Kling
7a7956a595 Virtual consoles kinda work!
We now make three VirtualConsoles at boot: tty0, tty1, and tty2.
We launch an instance of /bin/sh in each one.
You switch between them with Alt+1/2/3

How very very cool :^)
2018-10-30 15:33:37 +01:00
Andreas Kling
68739dc43e Start working on virtual consoles/TTYs.
This is a mess right now, but I'd rather commit as I go.
2018-10-30 13:59:29 +01:00
Andreas Kling
e6284a8774 Fix broken SpinLock.
The SpinLock was all backwards and didn't actually work. Fixing it exposed
how wrong most of the locking here is.

I need to come up with a better granularity here.
2018-10-29 22:04:26 +01:00
Andreas Kling
bea106fdb2 Fix up VFS::resolveSymbolicLink() to use a base inode instead of a base path.
Also more VFS error plumbing.
2018-10-28 14:25:51 +01:00
Andreas Kling
dd3244137e Add basic support for ANSI color escape sequences. 2018-10-28 00:56:19 +02:00
Andreas Kling
de2fb183cc Rename "kernel map" concept to just "ksyms" 2018-10-27 15:02:39 +02:00
Andreas Kling
5cfeeede7c Remove the obsolete "Userspace" stuff. 2018-10-27 00:41:23 +02:00
Andreas Kling
2716a9e2d7 Greatly improve /proc/PID/stack by tracing the ebp frame chain.
I also added a generator cache to FileHandle. This way, multiple
reads to a generated file (i.e in a synthfs) can transparently
handle multiple calls to read() without the contents changing
between calls.

The cache is discarded at EOF (or when the FileHandle is destroyed.)
2018-10-27 00:14:24 +02:00
Andreas Kling
c928b06218 Add a very hackish /proc/PID/stack.
It walks the stack and identifies anything that looks like a kernel symbol.
This could be a lot more sophisticated.
2018-10-26 22:33:15 +02:00
Andreas Kling
a32b3a3ddf Implement /proc/PID/vm.
Refactored SyntheticFileSystem to maintain an arbitrary directory structure.
ProcFileSystem creates a directory entry in /proc for each new process.
2018-10-26 17:44:19 +02:00
Andreas Kling
6312c3f253 Fix mixup between /dev/null and /dev/zero device registration. 2018-10-26 11:25:46 +02:00
Andreas Kling
dc6f57f19c Add gettimeofday() syscall and LibC wrappers gettimeofday() and time().
This only has second accuracy right now, I'll work out subseconds later.
2018-10-25 17:36:18 +02:00
Andreas Kling
c6f2890d8e Implement a basic way for read() to block.
FileHandle gets a hasDataAvailableForRead() getter.
If this returns true in sys$read(), the task will block(BlockedRead) + yield.
The fd blocked on is stored in Task::m_fdBlockedOnRead.
The scheduler then looks at the state of that fd during the unblock phase.

This makes "sh" restful. :^)

There's still some problem with the kernel not surviving the colonel task
getting scheduled. I need to figure that out and fix it.
2018-10-25 13:09:56 +02:00
Andreas Kling
571dc8234f Make the stage2 init task sleep dreamily when finished.
Something is off about scheduling, I don't think the kernel is handing
out all the available time to processes that are available to run.
2018-10-25 12:40:17 +02:00
Andreas Kling
260b14e505 Implement errno in LibC.
This also meant I had to implement BSS (SHT_NOBITS) sections in ELFLoader.
I also added an strerror() so we can print out what the errors are.
2018-10-25 12:06:50 +02:00
Andreas Kling
434b6a8688 Unify the Task constructors.
There's now Task::create() and Task::createKernelTask().
2018-10-25 11:17:47 +02:00
Andreas Kling
de7c54545a Remove age-old IPC stuff that wasn't working anyway.
I'll make a fresh start with IPC code when I get there.
2018-10-25 10:39:39 +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
8e27cf2428 Cleanup. 2018-10-24 00:51:09 +02:00
Andreas Kling
b40c851fce Unbreak crashy user process test. 2018-10-24 00:35:07 +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
d90d125dfe Add an undertaker task that is responsible for destroying dead tasks. 2018-10-23 15:43:05 +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
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
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
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
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
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
fc88368582 Have Console::write() directly call vga_putch. 2018-10-21 22:44:26 +02:00
Andreas Kling
a70bfb87d5 Add a Console device and start refactoring screen output. 2018-10-21 21:59:43 +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
97e0d75bcb ELFLoader works inside the kernel!
We load /_hello.o which just prints out a simple message.
It executes inside the kernel itself, so no fancy userspace process
or anything, but this is still so cool!
2018-10-18 15:46:08 +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
89851a9ded Use FileHandle from VFS. 2018-10-18 10:28:09 +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
77299cf54d Add basic paging. Only identity maps the bottom 4MB as a start. 2018-10-17 23:13:55 +02:00
Andreas Kling
39fa1eb2c2 Print the contents of motd.txt on boot. 2018-10-17 12:07:39 +02:00
Andreas Kling
705832f387 List the root directory after mounting /.
So cool that it works! It's spewing out a bunch of terminal escape sequences
that the OS console obviously doesn't support, but we'll get there too.
2018-10-17 11:47:14 +02:00
Andreas Kling
b05ed591ab VFS mounts an ext2fs root! :^) 2018-10-17 11:44:06 +02:00
Andreas Kling
9171521752 Integrate ext2 from VFS into Kernel. 2018-10-17 10:57:23 +02:00
Andreas Kling
aec8ab0a60 Add the basic character devices to kernel. 2018-10-16 14:33:16 +02:00