Commit graph

143 commits

Author SHA1 Message Date
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
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
d5ec18027e Protect the first 4 KB of memory.
This makes null pointers crashy, tremendously useful :^)
2018-10-21 21:59:11 +02:00
Andreas Kling
dd6706a1a1 Fix null deref in contextSwitch(). 2018-10-21 21:57:43 +02:00
Andreas Kling
2f99ff801e Move post-boot kernel stack pointer to 0x4000. 2018-10-21 21:51:12 +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
2d1d01661b Add a way to initialize VFS globals.
This is needed since the kernel loader doesn't even zero out bss,
much less call any static constructors.
2018-10-19 11:20:49 +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
6ab0649ad6 ksprintf() should null-terminate strings. 2018-10-18 15:24:07 +02:00
Andreas Kling
c149d2a8f0 Build ELFLoader into Kernel. 2018-10-18 15:03:10 +02:00
Andreas Kling
3649638259 Add Regions concept to Task. 2018-10-18 14:55:20 +02:00
Andreas Kling
5b10846bed Add a simple ELF binary called _test.o to the test fs. 2018-10-18 13:16:30 +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
e86cadc7af Add an fd field to FileHandle in Kernel builds. 2018-10-18 10:27:07 +02:00
Andreas Kling
9d5de91cf3 Actually destroy tasks after they crash. 2018-10-18 00:26:30 +02:00
Andreas Kling
1a801e5737 Hang if we GPF in ring 0. 2018-10-18 00:13:06 +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
286e27ef40 Allow running in QEMU with "./run q"
The kernel doesn't run in QEMU right now and I don't know why.
2018-10-17 16:58:35 +02:00
Andreas Kling
8ff394f83f Fix a dumb in buffer_putch. 2018-10-17 16:56:47 +02:00
Andreas Kling
9aa88fe186 Add a PIC::getISR() helper. 2018-10-17 16:54:49 +02:00
Andreas Kling
e0f31d38a2 Add -fno-pic -fno-pie to build flags. 2018-10-17 16:49:30 +02:00
Andreas Kling
f82b25d4f9 Fix some minor build warnings. 2018-10-17 16:48:43 +02:00
Andreas Kling
347e202f7f Add size_t and ssize_t to kernel builds. 2018-10-17 16:47:19 +02:00
Andreas Kling
7580ac576f Make VFS host build work again. 2018-10-17 12:23:19 +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
d2425495ca VirtualFileSystem class builds inside Kernel. 2018-10-17 11:40:58 +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
Andreas Kling
12e515735b Add a simple IDEDiskDevice class that implements DiskDevice from VFS. 2018-10-16 14:17:43 +02:00
Andreas Kling
8293a0ff36 Rework DiskDevice's read() and write() to be non-virtual wrappers.
This way subclasses only have to implement readBlock() and writeBlock().
read() and write() require that the offset and length are both divisible
by the blockSize().
2018-10-16 14:13:32 +02:00
Andreas Kling
cafb5b2ad6 Fixup small.fs again. 2018-10-16 14:00:44 +02:00
Andreas Kling
5d465582a3 Start fixing up AK to work inside the kernel. 2018-10-16 13:59:28 +02:00
Andreas Kling
1203c327c7 Merge some features from gerbert into OwnPtr and RetainPtr. 2018-10-16 12:21:06 +02:00
Andreas Kling
fd708a4cb1 Reduce dependence on STL. 2018-10-16 12:11:27 +02:00