Commit graph

61946 commits

Author SHA1 Message Date
Andreas Kling 05565bad58 Make IO helpers inline and use immediate-encoded ports when possible. 2018-11-02 10:14:26 +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 90ddbca127 Free physical pages allocated for a process's page directory on exit.
Also use a ProcessPagingScope instead of region aliasing to implement
create-process ELF loading.
2018-11-01 23:08:10 +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 9da4864a9a Oops, fix null termination bug in getpwent(). 2018-11-01 16:22:28 +01:00
Andreas Kling 3a901ae36d Way tighter locking in process creation.
We no longer disable interrupts around the whole affair.
Since MM manages per-process data structures, this works quite smoothly now.
Only procfs had to be tweaked with an InterruptDisabler.
2018-11-01 14:41:49 +01:00
Andreas Kling 52607aa086 Allow processes to go into a BeingInspected state (used by procfs.)
This ensures that the process won't get scheduled, and so inspecting
it is safe and easy without blocking interrupts.
2018-11-01 14:21:02 +01:00
Andreas Kling dfaa2b6b02 Convert VirtualConsole to the new coding style.
I'm still playing around with finding a style that I like.
This is starting to feel pleasing to the eye. I guess this is how long
it took me to break free from the habit of my previous Qt/WK coding style.
2018-11-01 14:11:22 +01:00
Andreas Kling fd03776443 Add a /proc/PID/fds text files that lists all the fds open in a process. 2018-11-01 14:00:28 +01:00
Andreas Kling 065f0aee35 Preallocate the maximum number of FileHandle pointers (fds) in every process.
This could even use a more specific data structure since it doesn't need the
grow/shrink capabilities of a vector.
2018-11-01 13:39:28 +01:00
Andreas Kling fce81d376c Move Region and Subregion out of Process and make them free classes. 2018-11-01 13:21:02 +01:00
Andreas Kling 3e532ac7b6 Process now maps regions immediately when they are allocated.
This avoids having to do a separate MM.mapRegionsForTask() pass.

Also, more Task => Process renaming that I apparently hadn't saved yet.
2018-11-01 13:15:46 +01:00
Andreas Kling 4e60551aec Rename Task to Process. 2018-11-01 13:10:12 +01:00
Andreas Kling 8525cdd6a2 Fix crash when process spawn fails. 2018-11-01 12:55:06 +01:00
Andreas Kling c178d7a9e3 Remove some unused MM functions.
These were just Q&D hacks I used while bringing up the paging code.
2018-11-01 12:51:54 +01:00
Andreas Kling 0f70b9105f Implement address validation by querying the task's page directory.
This is way better than walking the region lists. I suppose we could
even let the hardware trigger a page fault and handle that. That'll
be the next step in the evolution here I guess.
2018-11-01 12:45:51 +01:00
Andreas Kling f76fcd1e62 Do a bit less work in every context switch. 2018-11-01 11:57:36 +01:00
Andreas Kling 5891691640 Fix /proc/PID/stack in the new per-process page directory world.
I added an RAII helper called OtherTaskPagingScope. While present,
it switches the kernel over to using another task's page directory.
This is perfect for e.g walking the stack in /proc/PID/stack.
2018-11-01 11:44:21 +01:00
Andreas Kling c45f166c63 More work on per-process page directories. It basically works now!
I spent some time stuck on a problem where processes would clobber each
other's stacks. Took me a moment to figure out that their stacks
were allocated in the sub-4MB linear address range which is shared
between all processes. Oops!
2018-11-01 11:36:25 +01:00
Andreas Kling 1da0a7c949 Give each task its own page directory.
This isn't finished but I'll commit as I go. We need to get to where context
switching only needs to change CR3 and everything's ready to go.

My basic idea is:
- The first 4 kB is off-limits. This catches null dereferences.
- Up to the 4 MB mark is identity-mapped and kernel-only.
- The rest is available to everyone!

While the first 4 MB is only available to the kernel, it's still mapped in
every process, for convenience when entering the kernel.
2018-11-01 09:01:51 +01:00
Andreas Kling cddd2f37e9 Have sh print out which signal terminated a child process. 2018-11-01 01:11:00 +01:00
Andreas Kling a685809e75 Waiters should be notified when a waitee is killed.
Ran into a horrendous bug where VirtualConsole would overrun its buffer
and scribble right into some other object if we were interrupted while
processing a character. Slapped an InterruptDisabler onto onChar for now.

This provokes an interesting question though.. if a process is killed
while its in kernel space, how the heck do we release any locks it held?
I'm sure there are many different solutions to this problem, but I'll
have to think about it.
2018-11-01 01:05:59 +01:00
Andreas Kling 9a086b2d35 Add a kmalloc_eternal() for things that will never be destroyed. 2018-10-31 23:19:15 +01:00
Andreas Kling d980ddc745 Fix busted display of tty names in /proc/summary. 2018-10-31 22:43:49 +01:00
Andreas Kling a8f36f72a8 printfing a number or string bigger than the field width should not crash. 2018-10-31 22:40:10 +01:00
Andreas Kling c7d5ce6b5a Add a /bin/tty command that prints the current tty.
Also fix ttyname() syscall to include "/dev/" in the name.
2018-10-31 21:46:05 +01:00
Andreas Kling 4605b549d6 perror() should send output to stderr. 2018-10-31 21:37:09 +01:00
Andreas Kling 8f6998c902 Add SpinLock to IDE disk access.
This forces serialization of accesses. This driver needs to be redesigned.
2018-10-31 21:33:27 +01:00
Andreas Kling dec5683e9c Snazz up the kprintf() output a bit by giving it its own color. 2018-10-31 20:14:23 +01:00
Andreas Kling 9886b27d9c Add getpwent() family of functions to LibC.
Also add a little /etc/passwd database. There's just me in there.
2018-10-31 19:54:25 +01:00
Andreas Kling 819ce91395 Enough compatibility work to make figlet build and run!
I ran out of steam writing library routines and imported two
BSD-licensed libc routines: sscanf() and getopt().

I will most likely rewrite them sooner or later. For now
I just wanted to see figlet running.
2018-10-31 17:52:59 +01:00
Andreas Kling 69c7a59e6f Fix wrong allocation size used in opendir(). 2018-10-31 17:25:24 +01:00
Andreas Kling 2fdc7c2c60 Use ALWAYS_INLINE for ctype inlines. 2018-10-31 15:53:11 +01:00
Andreas Kling 71c9b09e8c Fix ls build. 2018-10-31 15:52:24 +01:00
Andreas Kling 9160fd0d47 More LibC portability work while trying to get figlet building. 2018-10-31 10:14:56 +01:00
Andreas Kling bb90c8ecab A bunch of LibC boilerplate stuff added while trying to get figlet to build. 2018-10-31 02:09:11 +01:00
Andreas Kling 511ed4c4de Snazz up the sh prompt a bit. Add the current tty to it. 2018-10-31 01:21:56 +01:00
Andreas Kling 3218f00099 Implement basic sys$kill() and add a /bin/kill
All it can do right now is send SIGKILL which just murders the target task.
2018-10-31 01:06:57 +01:00
Andreas Kling 7be30a2fa8 Fuck it, add a 4th virtual console. :^) 2018-10-31 00:27:34 +01:00
Andreas Kling 4dec23b487 Add assertion that RTC year is >= 2018. 2018-10-31 00:27:28 +01:00
Andreas Kling 555c10a1f8 Minor cleanup. 2018-10-31 00:26:22 +01:00
Andreas Kling 72e75c52e3 Pass the register dump to syscall_entry() via an argument.
I'm not sure why this was using a global, but it was very racy and made
processes walk over each other when multiple processes were doing
syscalls simultaneously.
2018-10-31 00:23:46 +01:00
Andreas Kling b4f3bc078f Minor VGA cleanup. 2018-10-30 23:49:06 +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 00c21d1590 Add sys$ttyname_r and ttyname_r() + ttyname().
And print a greeting when sh starts up so we know which TTY we're on.
2018-10-30 22:03:02 +01:00
Andreas Kling 7a85384e47 sh should read from fd 0 (stdin) instead of /dev/keyboard. 2018-10-30 16:17:34 +01:00
Andreas Kling 1b81813a66 Fix crashy bug where we'd try to deactivate VC -1 on boot. 2018-10-30 16:16:20 +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 bd2b5327d0 Basic support the backspace key.
This doesn't mean we get any line editing just yet. But the keyboard device
now recognizes the backspace key, and the console device knows what to do
with the backspace characters.
2018-10-30 11:55:58 +01:00